| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933 |
- <?php
- // TODO: decide later what to do with text* classes and module, it looks like they will stay and text modules will be still based on it, but some refactoring is needed
- /***************************************************************************
- * Dolphin Smart Community Builder
- * -------------------
- * begin : Mon Mar 23 2006
- * copyright : (C) 2007 BoonEx Group
- * website : http://www.boonex.com
- * This file is part of Dolphin - Smart Community Builder
- *
- * Dolphin is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the
- * License, or any later version.
- *
- * Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License along with Dolphin,
- * see license.txt file; if not, write to marketing@boonex.com
- ***************************************************************************/
- bx_import('BxDolViews');
- bx_import('BxDolAlerts');
- bx_import('BxDolModule');
- bx_import('BxDolPaginate');
- //bx_import('BxDolCategories');
- bx_import('BxDolRssFactory');
- //bx_import('BxDolSubscription');
- //bx_import('BxTemplTagsModule');
- //bx_import('BxTemplCategoriesModule');
- require_once(BX_DIRECTORY_PATH_PLUGINS . 'Services_JSON.php');
- class BxDolTextModule extends BxDolModule {
- var $_oTextData;
- var $_oPrivacy;
- function BxDolTextModule($aModule) {
- parent::BxDolModule($aModule);
- $this->_oConfig->init($this->_oDb);
- $this->_oTemplate->init($this);
- $sClassPrefix = $this->_oConfig->getClassPrefix();
- $sClassName = $sClassPrefix . 'Privacy';
- $this->_oPrivacy = class_exists($sClassName) ? new $sClassName($this) : null;
- $sClassName = $sClassPrefix . 'Data';
- $this->_oTextData = class_exists($sClassName) ? new $sClassName($this) : null;
- }
- function getBlockView($sUri)
- {
- $aEntry = $this->_oDb->getEntries(array('sample_type' => 'uri', 'uri' => $sUri));
- if(empty($aEntry) || !is_array($aEntry))
- $this->_oTemplate->displayPageNotFound();
- $sModuleUri = $this->_oConfig->getUri();
- $oView = new BxDolViews($this->_oConfig->getViewsSystemName(), $aEntry['id']);
- $oView->makeView();
- $this->_oTemplate->setPageTitle($aEntry['caption']);
- $GLOBALS['oTopMenu']->setCustomSubHeader($aEntry['caption']);
- $GLOBALS['oTopMenu']->setCustomBreadcrumbs(array(
- _t('_' . $sModuleUri . '_top_menu_item') => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'index/',
- $aEntry['caption'] => '')
- );
- return $this->_oTemplate->displayList(array(
- 'sample_type' => 'view',
- 'viewer_type' => $this->_oTextData->getViewerType(),
- 'uri' => $aEntry['uri']
- ));
- }
- function getBlockComment($sUri)
- {
- $aEntry = $this->_oDb->getEntries(array('sample_type' => 'uri', 'uri' => $sUri));
- if(!$this->_oConfig->isCommentsEnabled() || !$this->_isCommentsAllowed($aEntry))
- return '';
- $sModuleUri = $this->_oConfig->getUri();
- if($aEntry['status'] != BX_TD_STATUS_ACTIVE)
- return MsgBox(_t('_' . $sModuleUri . '_msg_no_results'));
- $this->_oTemplate->addCss(array('cmts.css'));
- $oComments = $this->_createObjectCmts($aEntry['id']);
- return $oComments->getCommentsFirst('comment');
- }
- function getBlockVote($sUri)
- {
- $aEntry = $this->_oDb->getEntries(array('sample_type' => 'uri', 'uri' => $sUri));
- if(!$this->_oConfig->isVotesEnabled() || !$this->_isVotesAllowed($aEntry))
- return '';
- $sModuleUri = $this->_oConfig->getUri();
- if($aEntry['status'] != BX_TD_STATUS_ACTIVE)
- return MsgBox(_t('_' . $sModuleUri . '_msg_no_results'));
- $oVotes = $this->_createObjectVoting($aEntry['id']);
- return $oVotes->getBigVoting();
- }
- function getBlockAction($sUri)
- {
- $aEntry = $this->_oDb->getEntries(array('sample_type' => 'uri', 'uri' => $sUri));
- $sModuleUri = $this->_oConfig->getUri();
- $sModuleBaseUri = $this->_oConfig->getBaseUri();
- if($aEntry['status'] != BX_TD_STATUS_ACTIVE)
- return MsgBox(_t('_' . $sModuleUri . '_msg_no_results'));
- $sModuleUri = $this->_oConfig->getUri();
- $oSubscription = new BxDolSubscription();
- $aButton = $oSubscription->getButton($this->getUserId(), $this->_oConfig->getSubscriptionsSystemName(), '', $aEntry['id']);
- $aReplacement['sbs_' . $sModuleUri . '_title'] = $aButton['title'];
- $aReplacement['sbs_' . $sModuleUri . '_script'] = $aButton['script'];
- $aReplacement['del_' . $sModuleUri . '_title'] = '';
- if($this->_isDeleteAllowed()) {
- $this->_oTemplate->addJsTranslation(array('_' . $sModuleUri . '_msg_success_delete', '_' . $sModuleUri . '_msg_failed_delete'));
- $aReplacement['del_' . $sModuleUri . '_title'] = _t('_' . $sModuleUri . '_actions_delete');
- $aReplacement['del_' . $sModuleUri . '_script'] = $this->_oConfig->getJsObject() . '.deleteEntry(' . $aEntry['id'] . ')';
- }
- $aReplacement['share_' . $sModuleUri . '_title'] = '';
- if($this->_isShareAllowed($aEntry)) {
- $aReplacement['share_' . $sModuleUri . '_title'] = _t('_Share');
- $aReplacement['share_' . $sModuleUri . '_script'] = "showPopupAnyHtml('" . $sModuleBaseUri . "share_popup/" . $aEntry['id'] . "')";
- }
- return $oSubscription->getData() . $GLOBALS['oFunctions']->genObjectsActions($aReplacement, $this->_oConfig->getActionsViewSystemName());
- }
- function getBlockSocialSharing($sUri)
- {
- $aEntry = $this->_oDb->getEntries(array('sample_type' => 'uri', 'uri' => $sUri));
- if(!$aEntry || $aEntry['status'] != BX_TD_STATUS_ACTIVE)
- return '';
- $sUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $aEntry['uri'];
- $sTitle = $aEntry['caption'];
- bx_import('BxTemplSocialSharing');
- $s = BxTemplSocialSharing::getInstance()->getCode($sUrl, $sTitle);
- return array($s, array(), array(), false);
- }
- function getCalendar($iYear = 0, $iMonth = 0)
- {
- $sClassName = $this->_oConfig->getClassPrefix() . 'Calendar';
- return new $sClassName($iYear, $iMonth, $this->_oDb, $this->_oConfig);
- }
- function getSearchResult() {
- $sClassName = $this->_oConfig->getClassPrefix() . 'SearchResult';
- return new $sClassName($this);
- }
- function getSearchContent($aRestrictions, $sUri, $iPage = 1, $iPerPage = 0) {
- $iPerPage = !empty($iPerPage) ? $iPerPage : $this->_oConfig->getPerPage();
- $sClassName = $this->_oConfig->getClassPrefix() . 'SearchResult';
- $oSearchResult = new $sClassName($this);
- foreach($aRestrictions as $sKey => $mixedValue)
- if(is_array($mixedValue))
- $oSearchResult->aCurrent['restriction'][$sKey] = $mixedValue;
- else if(is_string($mixedValue))
- $oSearchResult->aCurrent['restriction'][$sKey]['value'] = $mixedValue;
- $oSearchResult->aCurrent['paginate']['forcePage'] = $iPage;
- $oSearchResult->aCurrent['paginate']['perPage'] = $iPerPage;
- $sCode = $oSearchResult->displayResultBlock();
- if(!empty($sCode)) {
- $oPaginate = new BxDolPaginate(array(
- 'page_url' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . $sUri . '{page}/{per_page}',
- 'count' => $oSearchResult->aCurrent['paginate']['totalNum'],
- 'per_page' => $iPerPage,
- 'page' => $iPage,
- 'per_page_changer' => true,
- 'page_reloader' => false,
- 'on_change_page' => '',
- 'on_change_per_page' => '',
- ));
- $sCode .= $oPaginate->getPaginate();
- }
- return $sCode;
- }
- function getCategoryContent($sCategory, $iPage = 1, $iPerPage = 0) {
- $sCategory = uri2title(process_db_input($sCategory, BX_TAGS_STRIP));
- $iPage = (int)$iPage;
- $iPerPage = (int)$iPerPage;
- $sCategoryDisplay = $GLOBALS['MySQL']->unescape($sCategory);
- return array(
- $sCategoryDisplay,
- $this->getSearchContent(array('category' => $sCategory), 'category/' . title2uri($sCategoryDisplay) . '/', $iPage, $iPerPage)
- );
- }
- function getTagContent($sTag = '', $iPage = 1, $iPerPage = 0) {
- $sTag = uri2title(process_db_input($sTag, BX_TAGS_STRIP));
- $iPage = (int)$iPage;
- $iPerPage = (int)$iPerPage;
- $sTagDisplay = $GLOBALS['MySQL']->unescape($sTag);
- return array(
- $sTagDisplay,
- $this->getSearchContent(array('tag' => $sTag), 'tag/' . title2uri($sTagDisplay) . '/', $iPage, $iPerPage)
- );
- }
- function getCalendarContent($iYear, $iMonth, $iDay, $iPage, $iPerPage) {
- $iYear = (int)$iYear;
- $iMonth = (int)$iMonth;
- $iDay = (int)$iDay;
- $iPage = (int)$iPage;
- $iPerPage = (int)$iPerPage;
- return $this->getSearchContent(
- array(
- 'calendar-min' => array('value' => "UNIX_TIMESTAMP('" . $iYear . "-" . $iMonth . "-" . $iDay . " 00:00:00')", 'field' => 'when', 'operator' => '>=', 'no_quote_value' => true),
- 'calendar-max' => array('value' => "UNIX_TIMESTAMP('" . $iYear . "-" . $iMonth . "-" . $iDay . " 23:59:59')", 'field' => 'when', 'operator' => '<=', 'no_quote_value' => true),
- ),
- 'calendar/' . $iYear . '/' . $iMonth . '/' . $iDay . '/',
- $iPage,
- $iPerPage
- );
- }
- /**
- * Admin Settings Methods
- */
- function getSettingsForm($mixedResult) {
- $sUri = $this->_oConfig->getUri();
- $iId = (int)$this->_oDb->getOne("SELECT `ID` FROM `sys_options_cats` WHERE `name`='" . ucwords(str_replace('_', ' ', $sUri)) . "'");
- if(empty($iId))
- return MsgBox('_' . $sUri . '_msg_no_results');
- $oSettings = new BxDolAdminSettings($iId, BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'admin');
- $sResult = $oSettings->getForm();
- if($mixedResult !== true && !empty($mixedResult))
- $sResult = $mixedResult . $sResult;
- return $sResult;
- }
- function setSettings($aData) {
- $sUri = $this->_oConfig->getUri();
- $iId = (int)$this->_oDb->getOne("SELECT `ID` FROM `sys_options_cats` WHERE `name`='" . ucwords(str_replace('_', ' ', $sUri)) . "'");
- if(empty($iId))
- return MsgBox(_t('_' . $sUri . '_msg_no_results'));
- $oSettings = new BxDolAdminSettings($iId);
- return $oSettings->saveChanges($_POST);
- }
- /**
- * Service methods
- */
- function servicePostBlock() {
- $aVariables = array(
- 'include_css' => $this->_oTemplate->addCss(array('post.css'), true),
- 'post_form' => $this->_oTextData->getPostForm()
- );
- return $this->_oTemplate->parseHtmlByName('post.html', $aVariables);
- }
- function serviceEditBlock($mixed) {
- if(is_string($mixed))
- $aEntry = $this->_oDb->getEntries(array('sample_type' => 'uri', 'uri' => $mixed));
- else if(is_int($mixed))
- $aEntry = $this->_oDb->getEntries(array('sample_type' => 'id', 'id' => $mixed));
- $aVariables = array(
- 'include_css' => $this->_oTemplate->addCss(array('post.css'), true),
- 'post_form' => $this->_oTextData->getEditForm($aEntry)
- );
- return $this->_oTemplate->parseHtmlByName('post.html', $aVariables);
- }
- function serviceAdminBlock($iStart = 0, $iPerPage = 0, $sFilterValue = '') {
- if(empty($iPerPage))
- $iPerPage = $this->_oConfig->getPerPage();
- return $this->_oTemplate->displayAdminBlock(array(
- 'sample_type' => 'admin',
- 'viewer_type' => $this->_oTextData->getViewerType(),
- 'start' => $iStart,
- 'count' => $iPerPage,
- 'admin_panel' => true,
- 'filter_value' => $sFilterValue,
- 'search_result_object' => $this->getSearchResult()
- ));
- }
- function serviceArchiveBlockIndex($iStart = 0, $iPerPage = 0, $bShowEmpty = true) {
- if(empty($iPerPage))
- $iPerPage = $this->_oConfig->getIndexNumber();
- return $this->serviceArchiveBlock($iStart, $iPerPage, $bShowEmpty);
- }
- function serviceArchiveBlockMember($iStart = 0, $iPerPage = 0, $bShowEmpty = true) {
- if(empty($iPerPage))
- $iPerPage = $this->_oConfig->getMemberNumber();
- return $this->serviceArchiveBlock($iStart, $iPerPage, $bShowEmpty);
- }
- function serviceArchiveBlock($iStart = 0, $iPerPage = 0, $bShowEmpty = true) {
- if(empty($iPerPage))
- $iPerPage = $this->_oConfig->getPerPage();
- return $this->_oTemplate->displayBlock(array(
- 'sample_type' => 'archive',
- 'viewer_type' => $this->_oTextData->getViewerType(),
- 'start' => $iStart,
- 'count' => $iPerPage,
- 'show_empty' => $bShowEmpty
- ));
- }
- function serviceFeaturedBlockIndex($iStart = 0, $iPerPage = 0, $bShowEmpty = true) {
- if(empty($iPerPage))
- $iPerPage = $this->_oConfig->getIndexNumber();
- return $this->serviceFeaturedBlock($iStart, $iPerPage, $bShowEmpty);
- }
- function serviceFeaturedBlockMember($iStart = 0, $iPerPage = 0, $bShowEmpty = true) {
- if(empty($iPerPage))
- $iPerPage = $this->_oConfig->getMemberNumber();
- return $this->serviceFeaturedBlock($iStart, $iPerPage, $bShowEmpty);
- }
- function serviceFeaturedBlock($iStart = 0, $iPerPage = 0, $bShowEmpty = true) {
- if(empty($iPerPage))
- $iPerPage = $this->_oConfig->getPerPage();
- return $this->_oTemplate->displayBlock(array(
- 'sample_type' => 'featured',
- 'viewer_type' => $this->_oTextData->getViewerType(),
- 'start' => $iStart,
- 'count' => $iPerPage,
- 'show_empty' => $bShowEmpty
- ));
- }
- function serviceTopRatedBlock($iStart = 0, $iPerPage = 0) {
- if(empty($iPerPage))
- $iPerPage = $this->_oConfig->getPerPage();
- return $this->_oTemplate->displayBlock(array(
- 'sample_type' => 'top_rated',
- 'viewer_type' => $this->_oTextData->getViewerType(),
- 'start' => $iStart,
- 'count' => $iPerPage
- ));
- }
- function serviceCategoriesBlock($iBlockId) {
- $sUri = $this->_oConfig->getUri();
- $oCategories = new BxTemplCategoriesModule(array('type' => $this->_oConfig->getCategoriesSystemName()), _t('_categ_users'), BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'category');
- return $oCategories->getBlockCode_Common($iBlockId, true);
- }
- function serviceTagsBlock($iBlockId) {
- $sUri = $this->_oConfig->getUri();
- $oTags = new BxTemplTagsModule(array('type' => $this->_oConfig->getTagsSystemName(), 'orderby' => 'popular'), _t('_' . $sUri . '_bcaption_all_tags'), BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'tags');
- $aResult = $oTags->getBlockCode_All($iBlockId);
- return $aResult[0];
- }
- function serviceGetCalendarBlock($iBlockID, $aParams = array()) {
- $isMiniMode = isset($aParams['mini_mode']) && $aParams['mini_mode'] === true;
- $sDynamicUrl = isset($aParams['dynamic_url']) ? $aParams['dynamic_url'] : BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'index/';
- $aDateParams = array();
- $sDate = bx_get('date');
- if($sDate) {
- $aDateParams = explode('/', $sDate);
- }
- $oCalendar = $this->_createObjectCalendar((int)$aDateParams[0], (int)$aDateParams[1]);
- $oCalendar->setBlockId($iBlockID);
- $oCalendar->setDynamicUrl($sDynamicUrl);
- return $oCalendar->display($isMiniMode);
- }
- function servicePopularBlock($iStart = 0, $iPerPage = 0) {
- if(empty($iPerPage))
- $iPerPage = $this->_oConfig->getPerPage();
- return $this->_oTemplate->displayBlock(array(
- 'sample_type' => 'popular',
- 'viewer_type' => $this->_oTextData->getViewerType(),
- 'start' => $iStart,
- 'count' => $iPerPage
- ));
- }
- function serviceGetSubscriptionParams($sUnit, $sAction, $iObjectId) {
- $sUnit = str_replace('bx_', '', $sUnit);
- if(empty($sAction))
- $sAction = 'main';
- $aItem = $this->_oDb->getEntries(array('sample_type' => 'id', 'id' => $iObjectId));
- return array(
- 'template' => array(
- 'Subscription' => _t('_' . $sUnit . '_sbs_' . $sAction, $aItem['caption']),
- 'ViewLink' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $aItem['uri']
- )
- );
- }
- /**
- * Action methods
- */
- function actionRss($iLength = 0) {
- $iLength = $iLength != 0 ? $iLength : (int)$this->_oConfig->getRssLength();
- $aEntries = $this->_oDb->getEntries(array(
- 'sample_type' => 'archive',
- 'viewer_type' => $this->_oTextData->getViewerType(),
- 'start' => 0,
- 'count' => $iLength
- ));
- $aRssData = array();
- $sRssViewUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/';
- foreach($aEntries as $aEntry) {
- if(empty($aEntry['caption'])) continue;
- $aRssData[$aEntry['id']] = array(
- 'UnitID' => $aEntry['id'],
- 'OwnerID' => $aEntry['id'],
- 'UnitTitle' => $aEntry['caption'],
- 'UnitLink' => $sRssViewUrl . $aEntry['uri'],
- 'UnitDesc' => $aEntry['content'],
- 'UnitDateTimeUTS' => $aEntry['when_uts'],
- 'UnitIcon' => ''
- );
- }
- $oRss = new BxDolRssFactory();
- return $oRss->GenRssByData($aRssData, _t('_news_rss_caption'), $this->_oConfig->getBaseUri() . 'act_rss/');
- }
- function actiongetEntries($sSampleType = 'all', $iStart = 0, $iPerPage = 0) {
- check_logged();
- if(empty($iPerPage))
- $iPerPage = $this->_oConfig->getPerPage();
- return $this->_oTemplate->displayList(array(
- 'sample_type' => $sSampleType,
- 'sample_params' => isset($_POST['params']) ? unserialize(urldecode($_POST['params'])) : '',
- 'viewer_type' => $this->_oTextData->getViewerType(),
- 'start' => $iStart,
- 'count' => $iPerPage,
- 'filter_value' => isset($_POST['filter_value']) ? process_db_input($_POST['filter_value'], BX_TAGS_STRIP) : ''
- ));
- }
- function actionMarkFeatured() {
- $iId = (int)$_POST['id'];
- return !empty($iId) ? $this->_actFeatured($iId) : false;
- }
- function actionPublish() {
- $iId = (int)$_POST['id'];
- return !empty($iId) ? $this->_actPublish($iId) : false;
- }
- function actionDelete() {
- $iId = (int)$_POST['id'];
- return !empty($iId) ? $this->_actDelete($iId) : false;
- }
- function actionSharePopup($iEntry) {
- header('Content-type:text/html;charset=utf-8');
- $sUri = $this->_oConfig->getUri();
- $aEntry = $this->_oDb->getEntries(array('sample_type' => 'id', 'id' => (int)$iEntry));
- if(!$aEntry) {
- echo MsgBox(_t('_' . $sUri . '_msg_no_results'));
- exit;
- }
- $sEntryUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $aEntry['EntryUri'];
- require_once (BX_DIRECTORY_PATH_INC . "shared_sites.inc.php");
- echo getSitesHtml($sEntryUrl);
- exit;
- }
- function actionArchive($iStart = 0, $iPerPage = 0) {
- $sUri = $this->_oConfig->getUri();
- $aParams = array(
- 'title' => array(
- 'page' => _t('_' . $sUri . '_pcaption_archive'),
- 'block' => _t('_' . $sUri . '_bcaption_archive')
- ),
- 'content' => array(
- 'page_main_code' => $this->serviceArchiveBlock((int)$iStart, (int)$iPerPage)
- )
- );
- $this->_oTemplate->getPageCode($aParams);
- }
- function actionPopular() {
- $sUri = $this->_oConfig->getUri();
- $aParams = array(
- 'title' => array(
- 'page' => _t('_' . $sUri . '_pcaption_popular'),
- 'block' => _t('_' . $sUri . '_bcaption_popular')
- ),
- 'content' => array(
- 'page_main_code' => $this->servicePopularBlock()
- )
- );
- $this->_oTemplate->getPageCode($aParams);
- }
- function actionTop() {
- $sUri = $this->_oConfig->getUri();
- $aParams = array(
- 'title' => array(
- 'page' => _t('_' . $sUri . '_pcaption_top_rated'),
- 'block' => _t('_' . $sUri . '_bcaption_top_rated')
- ),
- 'content' => array(
- 'page_main_code' => $this->serviceTopRatedBlock()
- )
- );
- $this->_oTemplate->getPageCode($aParams);
- }
- function actionCalendar($iYear = 0, $iMonth = 0, $iDay = 0, $iStart = 1, $iPerPage = 0) {
- $sUri = $this->_oConfig->getUri();
- $iArgs = func_num_args();
- if($iArgs == 1 && is_string($iYear))
- $iArgs = 0;
- $sContent = '';
- switch($iArgs) {
- case 0:
- case 2:
- $oCalendar = $this->getCalendar((int)$iYear, (int)$iMonth);
- $sContent = $oCalendar->display();
- break;
- case 3:
- case 5:
- $sContent = $this->getCalendarContent((int)$iYear, (int)$iMonth, (int)$iDay, (int)$iStart, (int)$iPerPage);
- $sContent = strlen($sContent) > 0 ? $sContent : _t('_' . $sUri . '_msg_no_results');
- break;
- }
- $sBlockTitle = !$iDay
- ? _t('_' . $sUri . '_bcaption_calendar')
- : _t('_' . $sUri . '_bcaption_calendar_browse') . ': ' . getLocaleDate(
- strtotime("{$iYear}-{$iMonth}-{$iDay}"), BX_DOL_LOCALE_DATE_SHORT);
- $sPageTitle = !$iDay
- ? _t('_' . $sUri . '_pcaption_calendar')
- : $sBlockTitle;
- $aParams = array(
- 'title' => array(
- 'page' => $sPageTitle,
- 'block' => $sBlockTitle,
- ),
- 'content' => array(
- 'page_main_code' => $sContent
- )
- );
- $this->_oTemplate->getPageCode($aParams);
- }
- function actionCategories() {
- $sUri = $this->_oConfig->getUri();
- $oCategories = new BxTemplCategoriesModule(array('type' => $this->_oConfig->getCategoriesSystemName()), _t('_categ_users'), BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'categories');
- $aParams = array(
- 'index' => 1,
- 'css' => array('view.css'),
- 'title' => array(
- 'page' => _t('_' . $sUri . '_pcaption_categories')
- ),
- 'content' => array(
- 'page_main_code' => $oCategories->getCode()
- )
- );
- $this->_oTemplate->getPageCode($aParams);
- }
- function actionCategory($sCategory = '', $iPage = 1, $iPerPage = 0) {
- $sUri = $this->_oConfig->getUri();
- $sBaseUri = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri();
- $sContent = MsgBox(_t('_' . $sUri . '_msg_no_results'));
- if(!empty($sCategory))
- list($sCategoryDisplay, $sContent) = $this->getCategoryContent($sCategory, $iPage, $iPerPage);
- $aParams = array(
- 'css' => array('view.css'),
- 'title' => array(
- 'page' => _t('_' . $sUri . '_pcaption_category', $sCategoryDisplay),
- 'block' => _t('_' . $sUri . '_bcaption_category', $sCategoryDisplay)
- ),
- 'breadcrumb' => array(
- _t('_' . $sUri . '_top_menu_item') => $sBaseUri . 'home/',
- _t('_' . $sUri . '_categories_top_menu_sitem') => $sBaseUri . 'categories/',
- $sCategoryDisplay => ''
- ),
- 'content' => array(
- 'page_main_code' => $sContent
- )
- );
- $this->_oTemplate->getPageCode($aParams);
- }
- function actionTags() {
- $sUri = $this->_oConfig->getUri();
- $oTags = new BxTemplTagsModule(array('type' => $this->_oConfig->getTagsSystemName(), 'orderby' => 'popular'), _t('_' . $sUri . '_bcaption_all_tags'), BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'tags');
- $aParams = array(
- 'index' => 1,
- 'css' => array('view.css'),
- 'title' => array(
- 'page' => _t('_' . $sUri . '_pcaption_tags')
- ),
- 'content' => array(
- 'page_main_code' => $oTags->getCode()
- )
- );
- $this->_oTemplate->getPageCode($aParams);
- }
- function actionTag($sTag = '', $iPage = 1, $iPerPage = 0) {
- $sUri = $this->_oConfig->getUri();
- $sBaseUri = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri();
- $sContent = MsgBox(_t('_' . $sUri . '_msg_no_results'));
- if(!empty($sTag))
- list($sTagDisplay, $sContent) = $this->getTagContent($sTag, $iPage, $iPerPage);
- $aParams = array(
- 'css' => array('view.css'),
- 'title' => array(
- 'page' => _t('_' . $sUri . '_pcaption_tag', $sTagDisplay),
- 'block' => _t('_' . $sUri . '_bcaption_tag', $sTagDisplay)
- ),
- 'breadcrumb' => array(
- _t('_' . $sUri . '_top_menu_item') => $sBaseUri . 'home/',
- _t('_' . $sUri . '_tags_top_menu_sitem') => $sBaseUri . 'tags/',
- $sTagDisplay => ''
- ),
- 'content' => array(
- 'page_main_code' => $sContent
- )
- );
- $this->_oTemplate->getPageCode($aParams);
- }
- function actionFeatured() {
- $sUri = $this->_oConfig->getUri();
- $aParams = array(
- 'title' => array(
- 'page' => _t('_' . $sUri . '_pcaption_featured'),
- 'block' => _t('_' . $sUri . '_bcaption_featured')
- ),
- 'content' => array(
- 'page_main_code' => $this->serviceFeaturedBlock()
- )
- );
- $this->_oTemplate->getPageCode($aParams);
- }
- function actionHome() {
- $this->actionIndex();
- }
- function actionIndex() {
- $sUri = $this->_oConfig->getUri();
- $oPage = bx_instance($this->_oConfig->getClassPrefix() . 'PageMain', array($this), $this->_aModule);
- $aParams = array(
- 'index' => 1,
- 'css' => array('view.css', 'cmts.css'),
- 'title' => array(
- 'page' => _t('_' . $sUri . '_pcaption_home')
- ),
- 'content' => array(
- 'page_main_code' => $oPage->getCode()
- )
- );
- $this->_oTemplate->getPageCode($aParams);
- }
- function actionView($sName) {
- $sUri = $this->_oConfig->getUri();
- $oPage = bx_instance($this->_oConfig->getClassPrefix() . 'PageView', array($sName, $this), $this->_aModule);
- $aParams = array(
- 'index' => 1,
- 'js' => array('main.js'),
- 'css' => array('view.css', 'cmts.css'),
- 'content' => array(
- 'page_main_code' => $this->_oTemplate->getViewJs(true) . $oPage->getCode()
- )
- );
- $this->_oTemplate->getPageCode($aParams);
- }
- function actionAdmin($sName = '') {
- $GLOBALS['iAdminPage'] = 1;
- require_once(BX_DIRECTORY_PATH_INC . 'admin_design.inc.php');
- $sUri = $this->_oConfig->getUri();
- check_logged();
- if(!@isAdmin()) {
- send_headers_page_changed();
- login_form("", 1);
- exit;
- }
- //--- Process actions ---//
- $mixedResultSettings = '';
- if(isset($_POST['save']) && isset($_POST['cat'])) {
- $mixedResultSettings = $this->setSettings($_POST);
- }
- if(isset($_POST[$sUri . '-publish']))
- $this->_actPublish($_POST[$sUri . '-ids'], true);
- else if(isset($_POST[$sUri . '-unpublish']))
- $this->_actPublish($_POST[$sUri . '-ids'], false);
- else if(isset($_POST[$sUri . '-featured']))
- $this->_actFeatured($_POST[$sUri . '-ids'], true);
- else if(isset($_POST[$sUri . '-unfeatured']))
- $this->_actFeatured($_POST[$sUri . '-ids'], false);
- else if(isset($_POST[$sUri . '-delete']))
- $this->_actDelete($_POST[$sUri . '-ids']);
- //--- Process actions ---//
- //--- Get New/Edit form ---//
- $sPostForm = '';
- if(!empty($sName))
- $sPostForm = $this->serviceEditBlock(process_db_input($sName, BX_TAGS_STRIP));
- else if(isset($_POST['id']))
- $sPostForm = $this->serviceEditBlock((int)$_POST['id']);
- else
- $sPostForm = $this->servicePostBlock();
- //--- Get New/Edit form ---//
- $sFilterValue = '';
- if(isset($_GET[$sUri . '-filter']))
- $sFilterValue = process_db_input($_GET[$sUri . '-filter'], BX_TAGS_STRIP);
- $sContent = DesignBoxAdmin(_t('_' . $sUri . '_bcaption_settings'), $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => $this->getSettingsForm($mixedResultSettings))));
- $sContent .= DesignBoxAdmin(_t('_' . $sUri . '_bcaption_post'), $sPostForm);
- $sContent .= DesignBoxAdmin(_t('_' . $sUri . '_bcaption_all'), $this->serviceAdminBlock(0, 0, $sFilterValue));
- $aParams = array(
- 'title' => array(
- 'page' => _t('_' . $sUri . '_pcaption_admin')
- ),
- 'content' => array(
- 'page_main_code' => $sContent
- )
- );
- $this->_oTemplate->getPageCodeAdmin($aParams);
- }
- /**
- * View list of latest entries for mobile app
- */
- function actionMobileLatestEntries($iPage = 1) {
- $sUri = $this->_oConfig->getUri();
- $iPerPage = 10;
- $iPage = (int)$iPage;
- if ($iPage < 1)
- $iPage = 1;
- bx_import('BxDolMobileTemplate');
- $oMobileTemplate = new BxDolMobileTemplate($this->_oConfig, $this->_oDb);
- $oMobileTemplate->pageStart();
- $sCaption = _t('_' . $sUri . '_bcaption_latest');
- $aParams = array(
- 'sample_type' => 'archive',
- 'sample_params' => '',
- 'viewer_type' => $this->_oTextData->getViewerType(),
- 'start' => ($iPage - 1) * $iPerPage,
- 'count' => $iPerPage,
- 'filter_value' => '',
- );
- $iTotalCount = $this->_oDb->getCount($aParams);
- $aEntries = $iTotalCount ? $this->_oDb->getEntries($aParams) : array();
- if (empty($aEntries)) {
- $oMobileTemplate->displayNoData($sCaption);
- return;
- }
- foreach ($aEntries as $aEntry) {
- $aVars = array (
- 'content' => '<h2>' . $aEntry['caption'] . '</h2>' . getLocaleDate($aEntry['when_uts'], BX_DOL_LOCALE_DATE),
- 'url' => bx_js_string(BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'mobile_entry/' . $aEntry['id']),
- );
- echo $oMobileTemplate->parseHtmlByName('mobile_row.html', $aVars);
- }
- bx_import('BxDolPaginate');
- $oPaginate = new BxDolPaginate(array(
- 'page_url' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'mobile_latest_entries/{page}',
- 'count' => $iTotalCount,
- 'per_page' => $iPerPage,
- 'page' => $iPage,
- ));
- echo $oPaginate->getMobilePaginate();
- $oMobileTemplate->pageCode($sCaption, false);
- }
- /**
- * Entry view page for mobile app
- */
- function actionMobileEntry($iId) {
- bx_import('BxDolMobileTemplate');
- $oMobileTemplate = new BxDolMobileTemplate($this->_oConfig, $this->_oDb);
- $oMobileTemplate->pageStart();
- $aParams = array(
- 'sample_type' => 'id',
- 'id' => (int)$iId,
- );
- $aEntry = $this->_oDb->getEntries($aParams);
- if (empty($aEntry)) {
- $oMobileTemplate->displayPageNotFound();
- return;
- }
- echo '<h1>' . $aEntry['caption'] . '</h1>';
- echo getLocaleDate($aEntry['when_uts'], BX_DOL_LOCALE_DATE);
- echo $aEntry['content'];
- $oMobileTemplate->pageCode($aEntry['caption']);
- }
- /**
- * Common methods
- */
- function _actFeatured($aIds, $bPositive = true) {
- if(!isAdmin())
- return false;
- if(is_int($aIds) || is_string($aIds))
- $aIds = array((int)$aIds);
- $bResult = $this->_oDb->updateEntry($aIds, array('featured' => ($bPositive ? 1 : 0)));
- if($bResult)
- foreach($aIds as $iId) {
- //--- Entry -> Featured for Alerts Engine ---//
- bx_import('BxDolAlerts');
- $oAlert = new BxDolAlerts($this->_oConfig->getAlertsSystemName(), 'featured', $iId, BxDolTextData::getAuthorId());
- $oAlert->alert();
- //--- Entry -> Featured for Alerts Engine ---//
- }
- return $bResult;
- }
- function _actPublish($aIds, $bPositive = true) {
- if(!isAdmin())
- return false;
- if(is_int($aIds) || is_string($aIds))
- $aIds = array((int)$aIds);
- $bResult = $this->_oDb->updateEntry($aIds, array('status' => ($bPositive ? BX_TD_STATUS_ACTIVE : BX_TD_STATUS_INACTIVE)));
- if($bResult)
- foreach($aIds as $iId) {
- //--- Entry -> Publish/Unpublish for Alerts Engine ---//
- $oAlert = new BxDolAlerts($this->_oConfig->getAlertsSystemName(), ($bPositive ? 'publish' : 'unpublish'), $iId, BxDolTextData::getAuthorId());
- $oAlert->alert();
- //--- Entry -> Publish/Unpublish for Alerts Engine ---//
- //--- Reparse Global Tags ---//
- $oTags = new BxDolTags();
- $oTags->reparseObjTags($this->_oConfig->getTagsSystemName(), $iId);
- //--- Reparse Global Tags ---//
- //--- Reparse Global Categories ---//
- $oCategories = new BxDolCategories();
- $oCategories->reparseObjTags($this->_oConfig->getCategoriesSystemName(), $iId);
- //--- Reparse Global Categories ---//
- }
- return $bResult;
- }
- function _actDelete($aIds) {
- if(!$this->_isDeleteAllowed(true))
- return false;
- if(is_int($aIds) || is_string($aIds))
- $aIds = array((int)$aIds);
- $bResult = $this->_oDb->deleteEntries($aIds);
- if($bResult) {
- $oTags = new BxDolTags();
- $oCategories = new BxDolCategories();
- $oSubscription = new BxDolSubscription();
- foreach($aIds as $iId) {
- //--- Entry -> Delete for Alerts Engine ---//
- $oAlert = new BxDolAlerts($this->_oConfig->getAlertsSystemName(), 'delete', $iId, BxDolTextData::getAuthorId());
- $oAlert->alert();
- //--- Entry -> Delete for Alerts Engine ---//
- //--- Reparse Global Tags ---//
- $oTags->reparseObjTags($this->_oConfig->getTagsSystemName(), $iId);
- //--- Reparse Global Tags ---//
- //--- Reparse Global Categories ---//
- $oCategories->reparseObjTags($this->_oConfig->getCategoriesSystemName(), $iId);
- //--- Reparse Global Categories ---//
- //--- Remove all subscriptions ---//
- $oSubscription->unsubscribe(array('type' => 'object_id', 'unit' => $this->_oConfig->getSubscriptionsSystemName(), 'object_id' => $iId));
- //--- Remove all subscriptions ---//
- }
- }
- return $bResult;
- }
- function _isCommentsAllowed(&$aEntry) {
- return true;
- }
- function _isVotesAllowed(&$aEntry) {
- return true;
- }
- function _isShareAllowed(&$aEntry) {
- return true;
- }
- }
- ?>
|