BxNotesSearchResult.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup Notes Notes
  7. * @ingroup DolphinModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxBaseModTextSearchResult');
  12. class BxNotesSearchResult extends BxBaseModTextSearchResult
  13. {
  14. function __construct($sMode = '', $aParams = array())
  15. {
  16. parent::__construct($sMode, $aParams);
  17. $this->aCurrent = array(
  18. 'name' => 'bx_notes',
  19. 'title' => _t('_bx_notes_page_title_browse'),
  20. 'table' => 'bx_notes_posts',
  21. 'ownFields' => array('id', 'title', 'text', 'thumb', 'author', 'added'),
  22. 'searchFields' => array('title', 'text'),
  23. 'restriction' => array(
  24. 'author' => array('value' => '', 'field' => 'author', 'operator' => '='),
  25. ),
  26. 'paginate' => array('perPage' => getParam('bx_notes_per_page_browse'), 'start' => 0),
  27. 'sorting' => 'last',
  28. 'rss' => array(
  29. 'title' => '',
  30. 'link' => '',
  31. 'image' => '',
  32. 'profile' => 0,
  33. 'fields' => array (
  34. 'Guid' => 'link',
  35. 'Link' => 'link',
  36. 'Title' => 'title',
  37. 'DateTimeUTS' => 'added',
  38. 'Desc' => 'text',
  39. ),
  40. ),
  41. 'ident' => 'id',
  42. );
  43. $this->sFilterName = 'bx_notes_filter';
  44. $this->oModule = $this->getMain();
  45. $oProfileAuthor = null;
  46. $CNF = &$this->oModule->_oConfig->CNF;
  47. switch ($sMode) {
  48. case 'author':
  49. bx_import('BxDolProfile');
  50. $oProfileAuthor = BxDolProfile::getInstance((int)$aParams['author']);
  51. if (!$oProfileAuthor) {
  52. $this->isError = true;
  53. break;
  54. }
  55. $this->aCurrent['restriction']['author']['value'] = $oProfileAuthor->id();
  56. $this->sBrowseUrl = 'page.php?i=' . $CNF['URI_AUTHOR_ENTRIES'] . '&profile_id={profile_id}';
  57. $this->aCurrent['title'] = _t('_bx_notes_page_title_browse_by_author');
  58. $this->aCurrent['rss']['link'] = 'modules/?r=notes/rss/' . $sMode . '/' . $oProfileAuthor->id();
  59. break;
  60. case 'public':
  61. bx_import('BxDolPermalinks');
  62. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_HOME']);
  63. $this->aCurrent['title'] = _t('_bx_notes_page_title_browse_recent');
  64. $this->aCurrent['rss']['link'] = 'modules/?r=notes/rss/' . $sMode;
  65. break;
  66. case '': // search results
  67. $this->sBrowseUrl = BX_DOL_SEARCH_KEYWORD_PAGE;
  68. $this->aCurrent['title'] = _t('_bx_notes');
  69. $this->aCurrent['paginate']['perPage'] = 3;
  70. unset($this->aCurrent['rss']);
  71. break;
  72. default:
  73. $sMode = '';
  74. $this->isError = true;
  75. }
  76. // add replaceable markers and replace them
  77. if ($oProfileAuthor) {
  78. $this->addMarkers($oProfileAuthor->getInfo()); // profile info is replacable
  79. $this->addMarkers(array('profile_id' => $oProfileAuthor->id())); // profile id is replacable
  80. $this->addMarkers(array('display_name' => $oProfileAuthor->getDisplayName())); // profile display name is replacable
  81. }
  82. $this->sBrowseUrl = $this->_replaceMarkers($this->sBrowseUrl);
  83. $this->aCurrent['title'] = $this->_replaceMarkers($this->aCurrent['title']);
  84. // add conditions for private content
  85. bx_import('BxDolPrivacy');
  86. $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
  87. $a = $oPrivacy ? $oPrivacy->getContentPublicAsCondition($oProfileAuthor ? $oProfileAuthor->id() : 0) : array();
  88. if (isset($a['restriction']))
  89. $this->aCurrent['restriction'] = array_merge($this->aCurrent['restriction'], $a['restriction']);
  90. if (isset($a['join']))
  91. $this->aCurrent['join'] = array_merge($this->aCurrent['join'], $a['join']);
  92. $this->setProcessPrivateContent(false);
  93. }
  94. function displayResultBlock ()
  95. {
  96. $s = parent::displayResultBlock ();
  97. $s = '<div class="bx-notes-wrapper ' . ('unit_gallery.html' == $this->sUnitTemplate ? 'bx-def-margin-neg bx-clearfix' : '') . '">' . $s . '</div>';
  98. return $s;
  99. }
  100. function getAlterOrder()
  101. {
  102. if ($this->aCurrent['sorting'] == 'last') {
  103. $aSql = array();
  104. $aSql['order'] = " ORDER BY `bx_notes_posts`.`added` DESC";
  105. return $aSql;
  106. }
  107. return array();
  108. }
  109. }
  110. /** @} */