BxPostsSearchResult.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 Posts Posts
  7. * @ingroup TridentModules
  8. *
  9. * @{
  10. */
  11. class BxPostsSearchResult extends BxBaseModTextSearchResult
  12. {
  13. function __construct($sMode = '', $aParams = array())
  14. {
  15. parent::__construct($sMode, $aParams);
  16. $this->aCurrent = array(
  17. 'name' => 'bx_posts',
  18. 'object_metatags' => 'bx_posts',
  19. 'title' => _t('_bx_posts_page_title_browse'),
  20. 'table' => 'bx_posts_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. 'status' => array('value' => 'active', 'field' => 'status', 'operator' => '='),
  26. ),
  27. 'paginate' => array('perPage' => getParam('bx_posts_per_page_browse'), 'start' => 0),
  28. 'sorting' => 'last',
  29. 'rss' => array(
  30. 'title' => '',
  31. 'link' => '',
  32. 'image' => '',
  33. 'profile' => 0,
  34. 'fields' => array (
  35. 'Guid' => 'link',
  36. 'Link' => 'link',
  37. 'Title' => 'title',
  38. 'DateTimeUTS' => 'added',
  39. 'Desc' => 'text',
  40. ),
  41. ),
  42. 'ident' => 'id',
  43. );
  44. $this->sFilterName = 'bx_posts_filter';
  45. $this->oModule = $this->getMain();
  46. $oProfileAuthor = null;
  47. $CNF = &$this->oModule->_oConfig->CNF;
  48. switch ($sMode) {
  49. case 'author':
  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_posts_page_title_browse_by_author');
  58. $this->aCurrent['rss']['link'] = 'modules/?r=posts/rss/' . $sMode . '/' . $oProfileAuthor->id();
  59. break;
  60. case 'public':
  61. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_HOME']);
  62. $this->aCurrent['title'] = _t('_bx_posts_page_title_browse_recent');
  63. $this->aCurrent['rss']['link'] = 'modules/?r=posts/rss/' . $sMode;
  64. break;
  65. case 'popular':
  66. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_POPULAR']);
  67. $this->aCurrent['title'] = _t('_bx_posts_page_title_browse_popular');
  68. $this->aCurrent['rss']['link'] = 'modules/?r=posts/rss/' . $sMode;
  69. $this->aCurrent['sorting'] = 'popular';
  70. break;
  71. case '': // search results
  72. $this->sBrowseUrl = BX_DOL_SEARCH_KEYWORD_PAGE;
  73. $this->aCurrent['title'] = _t('_bx_posts');
  74. $this->aCurrent['paginate']['perPage'] = 3;
  75. unset($this->aCurrent['rss']);
  76. break;
  77. default:
  78. $sMode = '';
  79. $this->isError = true;
  80. }
  81. $this->processReplaceableMarkers($oProfileAuthor);
  82. $this->addConditionsForPrivateContent($CNF, $oProfileAuthor);
  83. }
  84. function getAlterOrder()
  85. {
  86. $aSql = array();
  87. switch ($this->aCurrent['sorting']) {
  88. case 'last':
  89. $aSql['order'] = ' ORDER BY `bx_posts_posts`.`added` DESC';
  90. break;
  91. case 'popular':
  92. $aSql['order'] = ' ORDER BY `bx_posts_posts`.`views` DESC';
  93. break;
  94. }
  95. return $aSql;
  96. }
  97. }
  98. /** @} */