| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php defined('BX_DOL') or die('hack attempt');
- /**
- * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
- * CC-BY License - http://creativecommons.org/licenses/by/3.0/
- *
- * @defgroup Posts Posts
- * @ingroup TridentModules
- *
- * @{
- */
- class BxPostsSearchResult extends BxBaseModTextSearchResult
- {
- function __construct($sMode = '', $aParams = array())
- {
- parent::__construct($sMode, $aParams);
- $this->aCurrent = array(
- 'name' => 'bx_posts',
- 'module_name' => 'bx_posts',
- 'object_metatags' => 'bx_posts',
- 'title' => _t('_bx_posts_page_title_browse'),
- 'table' => 'bx_posts_posts',
- 'ownFields' => array('id', 'title', 'text', 'thumb', 'author', 'added'),
- 'searchFields' => array('title', 'text'),
- 'restriction' => array(
- 'author' => array('value' => '', 'field' => 'author', 'operator' => '='),
- 'status' => array('value' => 'active', 'field' => 'status', 'operator' => '='),
- ),
- 'paginate' => array('perPage' => getParam('bx_posts_per_page_browse'), 'start' => 0),
- 'sorting' => 'last',
- 'rss' => array(
- 'title' => '',
- 'link' => '',
- 'image' => '',
- 'profile' => 0,
- 'fields' => array (
- 'Guid' => 'link',
- 'Link' => 'link',
- 'Title' => 'title',
- 'DateTimeUTS' => 'added',
- 'Desc' => 'text',
- ),
- ),
- 'ident' => 'id',
- );
- $this->sFilterName = 'bx_posts_filter';
- $this->oModule = $this->getMain();
- $oProfileAuthor = null;
- $CNF = &$this->oModule->_oConfig->CNF;
- switch ($sMode) {
- case 'author':
- $oProfileAuthor = BxDolProfile::getInstance((int)$aParams['author']);
- if (!$oProfileAuthor) {
- $this->isError = true;
- break;
- }
- $this->aCurrent['restriction']['author']['value'] = $oProfileAuthor->id();
- $this->sBrowseUrl = 'page.php?i=' . $CNF['URI_AUTHOR_ENTRIES'] . '&profile_id={profile_id}';
- $this->aCurrent['title'] = _t('_bx_posts_page_title_browse_by_author');
- $this->aCurrent['rss']['link'] = 'modules/?r=posts/rss/' . $sMode . '/' . $oProfileAuthor->id();
- break;
- case 'public':
- $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_HOME']);
- $this->aCurrent['title'] = _t('_bx_posts_page_title_browse_recent');
- $this->aCurrent['rss']['link'] = 'modules/?r=posts/rss/' . $sMode;
- break;
- case 'popular':
- $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_POPULAR']);
- $this->aCurrent['title'] = _t('_bx_posts_page_title_browse_popular');
- $this->aCurrent['rss']['link'] = 'modules/?r=posts/rss/' . $sMode;
- $this->aCurrent['sorting'] = 'popular';
- break;
- case '': // search results
- $this->sBrowseUrl = BX_DOL_SEARCH_KEYWORD_PAGE;
- $this->aCurrent['title'] = _t('_bx_posts');
- $this->aCurrent['paginate']['perPage'] = 3;
- unset($this->aCurrent['rss']);
- break;
- default:
- $sMode = '';
- $this->isError = true;
- }
- $this->processReplaceableMarkers($oProfileAuthor);
- $this->addConditionsForPrivateContent($CNF, $oProfileAuthor);
- }
- function getAlterOrder()
- {
- $aSql = array();
- switch ($this->aCurrent['sorting']) {
- case 'last':
- $aSql['order'] = ' ORDER BY `bx_posts_posts`.`added` DESC';
- break;
- case 'popular':
- $aSql['order'] = ' ORDER BY `bx_posts_posts`.`views` DESC';
- break;
- }
- return $aSql;
- }
- }
- /** @} */
|