| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- <?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 Notes Notes
- * @ingroup DolphinModules
- *
- * @{
- */
- bx_import('BxTemplSearchResult');
- class BxNotesSearchResult extends BxTemplSearchResult {
- var $aCurrent = array(
- 'name' => 'bx_notes',
- 'title' => '_bx_notes_page_title_browse',
- 'table' => 'bx_notes_posts',
- 'ownFields' => array('id', 'title', 'text', 'summary', 'thumb', 'author', 'added'),
- 'searchFields' => array('title', 'text'),
- 'restriction' => array(
- 'author' => array('value' => '', 'field' => 'author', 'operator' => '='),
- ),
- 'paginate' => array('perPage' => 8, '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'
- );
- function __construct($sMode = '', $aParams) {
- $oProfileAuthor = null;
- $oModuleMain = $this->getMain();
- switch ($sMode) {
- case 'search':
- if ($sValue)
- $this->aCurrent['restriction']['keyword'] = array('value' => $sValue,'field' => '','operator' => 'against');
- $this->sBrowseUrl = "search/?q=" . $sValue;
- $this->aCurrent['title'] = _t('_bx_notes_page_title_search_results', $sValue);
- unset($this->aCurrent['rss']);
- break;
- case 'author':
- bx_import('BxDolProfile');
- $oProfileAuthor = BxDolProfile::getInstance((int)$aParams['author']);
- if (!$oProfileAuthor) {
- $this->isError = true;
- break;
- }
- $this->aCurrent['restriction']['author']['value'] = $oProfileAuthor->id();
- $this->sBrowseUrl = 'page.php?i=notes-author&profile_id={profile_id}';
- $this->aCurrent['title'] = _t('_bx_notes_page_title_browse_by_author');
- break;
-
- case 'public':
- case '':
- $this->sBrowseUrl = 'page.php?i=notes-home';
- $this->aCurrent['title'] = _t('_bx_notes_page_title_browse_recent');
- break;
- default:
- $this->isError = true;
- }
- // add replacable markers and replace them
- if ($oProfileAuthor) {
- $this->addMarkers($oProfileAuthor->getInfo()); // profile info is replacable
- $this->addMarkers(array('profile_id' => $oProfileAuthor->id())); // profile id is replacable
- $this->addMarkers(array('display_name' => $oProfileAuthor->getDisplayName())); // profile display name is replacable
- }
- $this->sBrowseUrl = $this->_replaceMarkers($this->sBrowseUrl);
- $this->aCurrent['title'] = $this->_replaceMarkers($this->aCurrent['title']);
- // add conditions for private content
- bx_import('BxDolPrivacy');
- $oPrivacy = BxDolPrivacy::getObjectInstance(BxNotesConfig::$OBJECT_PRIVACY_VIEW);
- $a = $oPrivacy ? $oPrivacy->getContentPublicAsCondition($oProfileAuthor ? $oProfileAuthor->id() : 0) : array();
- if (isset($a['restriction']))
- $this->aCurrent['restriction'] = array_merge($this->aCurrent['restriction'], $a['restriction']);
- if (isset($a['join']))
- $this->aCurrent['join'] = array_merge($this->aCurrent['join'], $a['join']);
- $this->setProcessPrivateContent(false);
- // set rss links if required
- if (isset($this->aCurrent['rss']))
- $this->aCurrent['rss']['link'] = BX_DOL_URL_ROOT . $this->sBrowseUrl;
- if (bx_get('rss'))
- $this->aCurrent['paginate']['perPage'] = 10;//$oModuleMain->_oDb->getParam('bx_groups_max_rss_num');
- $this->sFilterName = 'bx_notes_filter';
- // $this->aCurrent['paginate']['perPage'] = $oModuleMain->_oDb->getParam('bx_groups_perpage_browse'); // TODO:
- parent::__construct();
- }
- function displayResultBlock () {
- $s = parent::displayResultBlock ();
- $s = '<div class="bx-notes-wrapper">' . $s . '</div>';
- return $s;
- }
- function getAlterOrder() {
- if ($this->aCurrent['sorting'] == 'last') {
- $aSql = array();
- $aSql['order'] = " ORDER BY `bx_notes_posts`.`added` DESC";
- return $aSql;
- }
- return array();
- }
- function getMain() {
- return BxDolModule::getInstance($this->aCurrent['name']);
- }
- function getRssUnitLink (&$a) {
- bx_import('BxDolPermalinks');
- return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=view-note&id=' . $a['id']);
- }
- function _getPseud () {
- return array(
- 'id' => 'id',
- 'title' => 'title',
- 'text' => 'text',
- 'added' => 'added',
- 'author' => 'author',
- 'photo' => 'photo',
- );
- }
- }
- /** @} */
|