BxPostsSearchResult.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. 'module_name' => 'bx_posts',
  19. 'object_metatags' => 'bx_posts',
  20. 'title' => _t('_bx_posts_page_title_browse'),
  21. 'table' => 'bx_posts_posts',
  22. 'ownFields' => array('id', 'title', 'text', 'thumb', 'author', 'added'),
  23. 'searchFields' => array('title', 'text'),
  24. 'restriction' => array(
  25. 'author' => array('value' => '', 'field' => 'author', 'operator' => '='),
  26. 'status' => array('value' => 'active', 'field' => 'status', 'operator' => '='),
  27. ),
  28. 'paginate' => array('perPage' => getParam('bx_posts_per_page_browse'), 'start' => 0),
  29. 'sorting' => 'last',
  30. 'rss' => array(
  31. 'title' => '',
  32. 'link' => '',
  33. 'image' => '',
  34. 'profile' => 0,
  35. 'fields' => array (
  36. 'Guid' => 'link',
  37. 'Link' => 'link',
  38. 'Title' => 'title',
  39. 'DateTimeUTS' => 'added',
  40. 'Desc' => 'text',
  41. ),
  42. ),
  43. 'ident' => 'id',
  44. );
  45. $this->sFilterName = 'bx_posts_filter';
  46. $this->oModule = $this->getMain();
  47. $oProfileAuthor = null;
  48. $CNF = &$this->oModule->_oConfig->CNF;
  49. switch ($sMode) {
  50. case 'author':
  51. $oProfileAuthor = BxDolProfile::getInstance((int)$aParams['author']);
  52. if (!$oProfileAuthor) {
  53. $this->isError = true;
  54. break;
  55. }
  56. $this->aCurrent['restriction']['author']['value'] = $oProfileAuthor->id();
  57. $this->sBrowseUrl = 'page.php?i=' . $CNF['URI_AUTHOR_ENTRIES'] . '&profile_id={profile_id}';
  58. $this->aCurrent['title'] = _t('_bx_posts_page_title_browse_by_author');
  59. $this->aCurrent['rss']['link'] = 'modules/?r=posts/rss/' . $sMode . '/' . $oProfileAuthor->id();
  60. break;
  61. case 'public':
  62. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_HOME']);
  63. $this->aCurrent['title'] = _t('_bx_posts_page_title_browse_recent');
  64. $this->aCurrent['rss']['link'] = 'modules/?r=posts/rss/' . $sMode;
  65. break;
  66. case 'popular':
  67. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_POPULAR']);
  68. $this->aCurrent['title'] = _t('_bx_posts_page_title_browse_popular');
  69. $this->aCurrent['rss']['link'] = 'modules/?r=posts/rss/' . $sMode;
  70. $this->aCurrent['sorting'] = 'popular';
  71. break;
  72. case 'updated':
  73. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_UPDATED']);
  74. $this->aCurrent['title'] = _t('_bx_posts_page_title_browse_updated');
  75. $this->aCurrent['rss']['link'] = 'modules/?r=posts/rss/' . $sMode;
  76. $this->aCurrent['sorting'] = 'updated';
  77. break;
  78. case '': // search results
  79. $this->sBrowseUrl = BX_DOL_SEARCH_KEYWORD_PAGE;
  80. $this->aCurrent['title'] = _t('_bx_posts');
  81. $this->aCurrent['paginate']['perPage'] = 3;
  82. unset($this->aCurrent['rss']);
  83. break;
  84. default:
  85. $sMode = '';
  86. $this->isError = true;
  87. }
  88. $this->processReplaceableMarkers($oProfileAuthor);
  89. $this->addConditionsForPrivateContent($CNF, $oProfileAuthor);
  90. }
  91. function getAlterOrder()
  92. {
  93. $aSql = array();
  94. switch ($this->aCurrent['sorting']) {
  95. case 'last':
  96. $aSql['order'] = ' ORDER BY `bx_posts_posts`.`added` DESC';
  97. break;
  98. case 'updated':
  99. $aSql['order'] = ' ORDER BY `bx_posts_posts`.`changed` DESC';
  100. break;
  101. case 'popular':
  102. $aSql['order'] = ' ORDER BY `bx_posts_posts`.`views` DESC';
  103. break;
  104. }
  105. return $aSql;
  106. }
  107. }
  108. /** @} */