BxPollsSearchResult.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 Polls Polls
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxPollsSearchResult extends BxBaseModTextSearchResult
  12. {
  13. protected $sUnitViewDefault = 'extended';
  14. function __construct($sMode = '', $aParams = array())
  15. {
  16. parent::__construct($sMode, $aParams);
  17. $this->aCurrent = array(
  18. 'name' => 'bx_polls',
  19. 'module_name' => 'bx_polls',
  20. 'object_metatags' => 'bx_polls',
  21. 'title' => _t('_bx_polls_page_title_browse'),
  22. 'table' => 'bx_polls_entries',
  23. 'ownFields' => array('id', 'text', 'thumb', 'author', 'anonymous', 'hidden_results', 'comments', 'added'),
  24. 'searchFields' => array(),
  25. 'restriction' => array(
  26. 'author' => array('value' => '', 'field' => 'author', 'operator' => '='),
  27. 'featured' => array('value' => '', 'field' => 'featured', 'operator' => '<>'),
  28. 'status' => array('value' => 'active', 'field' => 'status', 'operator' => '='),
  29. 'statusAdmin' => array('value' => 'active', 'field' => 'status_admin', 'operator' => '='),
  30. ),
  31. 'paginate' => array('perPage' => getParam('bx_polls_per_page_browse'), 'start' => 0),
  32. 'sorting' => 'last',
  33. 'rss' => array(
  34. 'title' => '',
  35. 'link' => '',
  36. 'image' => '',
  37. 'profile' => 0,
  38. 'fields' => array (
  39. 'Guid' => 'link',
  40. 'Link' => 'link',
  41. 'Title' => 'text',
  42. 'DateTimeUTS' => 'added',
  43. 'Desc' => '',
  44. 'Image' => 'thumb'
  45. ),
  46. ),
  47. 'ident' => 'id',
  48. );
  49. $this->sFilterName = 'bx_polls_filter';
  50. $this->oModule = $this->getMain();
  51. $CNF = &$this->oModule->_oConfig->CNF;
  52. $sSearchFields = getParam($CNF['PARAM_SEARCHABLE_FIELDS']);
  53. $this->aCurrent['searchFields'] = !empty($sSearchFields) ? explode(',', $sSearchFields) : '';
  54. $oProfileAuthor = null;
  55. switch ($sMode) {
  56. case 'author':
  57. if(!$this->_updateCurrentForAuthor($sMode, $aParams, $oProfileAuthor))
  58. $this->isError = true;
  59. break;
  60. case 'context':
  61. if(!$this->_updateCurrentForContext($sMode, $aParams, $oProfileAuthor))
  62. $this->isError = true;
  63. break;
  64. case 'favorite':
  65. if(!$this->_updateCurrentForFavorite($sMode, $aParams, $oProfileAuthor))
  66. $this->isError = true;
  67. break;
  68. case 'public':
  69. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_HOME']);
  70. $this->aCurrent['title'] = _t('_bx_polls_page_title_browse_recent');
  71. $this->aCurrent['rss']['link'] = 'modules/?r=polls/rss/' . $sMode;
  72. break;
  73. case 'featured':
  74. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_HOME']);
  75. $this->aCurrent['title'] = _t('_bx_polls_page_title_browse_featured');
  76. $this->aCurrent['restriction']['featured']['value'] = '0';
  77. $this->aCurrent['rss']['link'] = 'modules/?r=polls/rss/' . $sMode;
  78. $this->aCurrent['sorting'] = 'featured';
  79. break;
  80. case 'popular':
  81. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_POPULAR']);
  82. $this->aCurrent['title'] = _t('_bx_polls_page_title_browse_popular');
  83. $this->aCurrent['rss']['link'] = 'modules/?r=polls/rss/' . $sMode;
  84. $this->aCurrent['sorting'] = 'popular';
  85. break;
  86. case 'top':
  87. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_TOP']);
  88. $this->aCurrent['title'] = _t('_bx_polls_page_title_browse_top');
  89. $this->aCurrent['rss']['link'] = 'modules/?r=posts/rss/' . $sMode;
  90. $this->aCurrent['sorting'] = 'top';
  91. break;
  92. case 'updated':
  93. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_UPDATED']);
  94. $this->aCurrent['title'] = _t('_bx_polls_page_title_browse_updated');
  95. $this->aCurrent['rss']['link'] = 'modules/?r=polls/rss/' . $sMode;
  96. $this->aCurrent['sorting'] = 'updated';
  97. break;
  98. case '': // search results
  99. $this->sBrowseUrl = BX_DOL_SEARCH_KEYWORD_PAGE;
  100. $this->aCurrent['title'] = _t('_bx_polls');
  101. unset($this->aCurrent['paginate']['perPage'], $this->aCurrent['rss']);
  102. break;
  103. default:
  104. $sMode = '';
  105. $this->isError = true;
  106. }
  107. $this->processReplaceableMarkers($oProfileAuthor);
  108. $this->addConditionsForPrivateContent($CNF, $oProfileAuthor);
  109. $this->addCustomConditions($CNF, $oProfileAuthor, $sMode, $aParams);
  110. }
  111. function displaySearchUnit ($aData)
  112. {
  113. if(empty($aData['salt']))
  114. $aData['salt'] = $this->oModule->_oConfig->getSalt();
  115. return parent::displaySearchUnit($aData);
  116. }
  117. function addCustomParts ()
  118. {
  119. $this->oModule->_oTemplate->addJs(array('entry.js'));
  120. $this->oModule->_oTemplate->addCss(array('entry.css'));
  121. return $this->oModule->_oTemplate->getJsCode('entry');
  122. }
  123. }
  124. /** @} */