BxStoriesSearchResult.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup Stories Stories
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxStoriesSearchResult extends BxBaseModTextSearchResult
  12. {
  13. public function __construct($sMode = '', $aParams = [])
  14. {
  15. $this->aUnitViews = ['extended' => 'unit.html', 'gallery' => 'unit_gallery.html'];
  16. if(empty($aParams['unit_view'])) {
  17. if(!is_array($aParams))
  18. $aParams = [];
  19. $aParams['unit_view'] = 'extended';
  20. }
  21. parent::__construct($sMode, $aParams);
  22. $this->aCurrent = array(
  23. 'name' => 'bx_stories',
  24. 'module_name' => 'bx_stories',
  25. 'object_metatags' => 'bx_stories',
  26. 'title' => _t('_bx_stories_page_title_browse'),
  27. 'table' => 'bx_stories_entries',
  28. 'ownFields' => array('id', 'title', 'text', 'thumb', 'author', 'added'),
  29. 'searchFields' => array(),
  30. 'restriction' => array(
  31. 'author' => array('value' => '', 'field' => 'author', 'operator' => '='),
  32. 'expired' => array('value' => time(), 'field' => 'expired', 'operator' => '>'),
  33. 'status' => array('value' => 'active', 'field' => 'status', 'operator' => '='),
  34. 'statusAdmin' => array('value' => 'active', 'field' => 'status_admin', 'operator' => '='),
  35. ),
  36. 'paginate' => array('perPage' => getParam('bx_stories_per_page_browse'), 'start' => 0),
  37. 'sorting' => 'last',
  38. 'rss' => array(
  39. 'title' => '',
  40. 'link' => '',
  41. 'image' => '',
  42. 'profile' => 0,
  43. 'fields' => array (
  44. 'Guid' => 'link',
  45. 'Link' => 'link',
  46. 'Title' => 'title',
  47. 'DateTimeUTS' => 'added',
  48. 'Desc' => 'text',
  49. 'Image' => 'thumb'
  50. ),
  51. ),
  52. 'ident' => 'id',
  53. );
  54. $this->sFilterName = 'bx_stories_filter';
  55. $this->oModule = $this->getMain();
  56. $CNF = &$this->oModule->_oConfig->CNF;
  57. $sSearchFields = getParam($CNF['PARAM_SEARCHABLE_FIELDS']);
  58. $this->aCurrent['searchFields'] = !empty($sSearchFields) ? explode(',', $sSearchFields) : '';
  59. $oProfileAuthor = null;
  60. switch ($sMode) {
  61. case 'author':
  62. $this->aCurrent['restriction']['expired'] = '';
  63. if(!$this->_updateCurrentForAuthor($sMode, $aParams, $oProfileAuthor))
  64. $this->isError = true;
  65. break;
  66. case 'context':
  67. if(!$this->_updateCurrentForContext($sMode, $aParams, $oProfileAuthor))
  68. $this->isError = true;
  69. break;
  70. case 'public':
  71. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_HOME']);
  72. $this->aCurrent['title'] = _t('_bx_stories_page_title_browse_recent');
  73. $this->aCurrent['rss']['link'] = 'modules/?r=stories/rss/' . $sMode;
  74. break;
  75. case 'popular':
  76. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_POPULAR']);
  77. $this->aCurrent['title'] = _t('_bx_stories_page_title_browse_popular');
  78. $this->aCurrent['rss']['link'] = 'modules/?r=stories/rss/' . $sMode;
  79. $this->aCurrent['sorting'] = 'popular';
  80. break;
  81. case 'top':
  82. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_TOP']);
  83. $this->aCurrent['title'] = _t('_bx_stories_page_title_browse_top');
  84. $this->aCurrent['rss']['link'] = 'modules/?r=stories/rss/' . $sMode;
  85. $this->aCurrent['sorting'] = 'top';
  86. break;
  87. case 'updated':
  88. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_UPDATED']);
  89. $this->aCurrent['title'] = _t('_bx_stories_page_title_browse_updated');
  90. $this->aCurrent['rss']['link'] = 'modules/?r=stories/rss/' . $sMode;
  91. $this->aCurrent['sorting'] = 'updated';
  92. break;
  93. case '': // search results
  94. $this->sBrowseUrl = BX_DOL_SEARCH_KEYWORD_PAGE;
  95. $this->aCurrent['title'] = _t('_bx_stories');
  96. unset($this->aCurrent['paginate']['perPage'], $this->aCurrent['rss']);
  97. break;
  98. default:
  99. $sMode = '';
  100. $this->isError = true;
  101. }
  102. $this->processReplaceableMarkers($oProfileAuthor);
  103. $this->addConditionsForPrivateContent($CNF, $oProfileAuthor);
  104. $this->addCustomConditions($CNF, $oProfileAuthor, $sMode, $aParams);
  105. }
  106. function displayResultBlock ()
  107. {
  108. $s = parent::displayResultBlock ();
  109. $s = '<div class="bx-stories-wrapper">' . $s . '</div>';
  110. return $this->oModule->_oTemplate->getJsCode('main') . $s;
  111. }
  112. function getDesignBoxMenu ()
  113. {
  114. return BxBaseModGeneralSearchResult::getDesignBoxMenu ();
  115. }
  116. }
  117. /** @} */