BxPostsSearchResult.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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(),
  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. $this->aCurrent['searchFields'] = explode(',', getParam($this->oModule->_oConfig->CNF['PARAM_SEARCHABLE_FIELDS']));
  48. $oProfileAuthor = null;
  49. $CNF = &$this->oModule->_oConfig->CNF;
  50. switch ($sMode) {
  51. case 'author':
  52. $this->_updateCurrentForAuthor($sMode, $aParams, $oProfileAuthor);
  53. break;
  54. case 'favorite':
  55. $this->_updateCurrentForFavorite($sMode, $aParams, $oProfileAuthor);
  56. break;
  57. case 'public':
  58. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_HOME']);
  59. $this->aCurrent['title'] = _t('_bx_posts_page_title_browse_recent');
  60. $this->aCurrent['rss']['link'] = 'modules/?r=posts/rss/' . $sMode;
  61. break;
  62. case 'popular':
  63. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_POPULAR']);
  64. $this->aCurrent['title'] = _t('_bx_posts_page_title_browse_popular');
  65. $this->aCurrent['rss']['link'] = 'modules/?r=posts/rss/' . $sMode;
  66. $this->aCurrent['sorting'] = 'popular';
  67. break;
  68. case 'updated':
  69. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_UPDATED']);
  70. $this->aCurrent['title'] = _t('_bx_posts_page_title_browse_updated');
  71. $this->aCurrent['rss']['link'] = 'modules/?r=posts/rss/' . $sMode;
  72. $this->aCurrent['sorting'] = 'updated';
  73. break;
  74. case '': // search results
  75. $this->sBrowseUrl = BX_DOL_SEARCH_KEYWORD_PAGE;
  76. $this->aCurrent['title'] = _t('_bx_posts');
  77. $this->aCurrent['paginate']['perPage'] = 3;
  78. unset($this->aCurrent['rss']);
  79. break;
  80. default:
  81. $sMode = '';
  82. $this->isError = true;
  83. }
  84. $this->processReplaceableMarkers($oProfileAuthor);
  85. $this->addConditionsForPrivateContent($CNF, $oProfileAuthor);
  86. }
  87. function getAlterOrder()
  88. {
  89. $aSql = array();
  90. switch ($this->aCurrent['sorting']) {
  91. case 'last':
  92. $aSql['order'] = ' ORDER BY `bx_posts_posts`.`added` DESC';
  93. break;
  94. case 'updated':
  95. $aSql['order'] = ' ORDER BY `bx_posts_posts`.`changed` DESC';
  96. break;
  97. case 'popular':
  98. $aSql['order'] = ' ORDER BY `bx_posts_posts`.`views` DESC';
  99. break;
  100. }
  101. return $aSql;
  102. }
  103. }
  104. /** @} */