BxBaseModGeneralSearchResult.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 BaseGeneral Base classes for modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. define('BX_SYS_PER_PAGE_BROWSE_SHOWCASE', 32);
  12. class BxBaseModGeneralSearchResult extends BxTemplSearchResult
  13. {
  14. protected $oModule;
  15. protected $bShowcaseView = false;
  16. function __construct($sMode = '', $aParams = array())
  17. {
  18. parent::__construct();
  19. }
  20. function getMain()
  21. {
  22. return BxDolModule::getInstance($this->aCurrent['module_name']);
  23. }
  24. function getRssUnitLink (&$a)
  25. {
  26. $CNF = &$this->oModule->_oConfig->CNF;
  27. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $a[$CNF['FIELD_ID']]);
  28. }
  29. function getRssPageUrl ()
  30. {
  31. if (false === parent::getRssPageUrl())
  32. return false;
  33. $oPermalinks = BxDolPermalinks::getInstance();
  34. return BX_DOL_URL_ROOT . $oPermalinks->permalink($this->aCurrent['rss']['link']);
  35. }
  36. function rss ()
  37. {
  38. if (!isset($this->aCurrent['rss']))
  39. return '';
  40. $this->aCurrent['paginate']['perPage'] = empty($this->oModule->_oConfig->CNF['PARAM_NUM_RSS']) ? 10 : getParam($this->oModule->_oConfig->CNF['PARAM_NUM_RSS']);
  41. return parent::rss();
  42. }
  43. /**
  44. * Add conditions for private content
  45. */
  46. protected function addConditionsForPrivateContent($CNF, $oProfile, $aCustomGroup = array())
  47. {
  48. if(empty($CNF['OBJECT_PRIVACY_VIEW']))
  49. return;
  50. $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
  51. if(!$oPrivacy)
  52. return;
  53. $aCondition = $oPrivacy->getContentPublicAsCondition($oProfile ? $oProfile->id() : 0, $aCustomGroup);
  54. if(empty($aCondition) || !is_array($aCondition))
  55. return;
  56. if(isset($aCondition['restriction']))
  57. $this->aCurrent['restriction'] = array_merge($this->aCurrent['restriction'], $aCondition['restriction']);
  58. if(isset($aCondition['join']))
  59. $this->aCurrent['join'] = array_merge($this->aCurrent['join'], $aCondition['join']);
  60. $this->setProcessPrivateContent(false);
  61. }
  62. function showPagination($bAdmin = false, $bChangePage = true, $bPageReload = true)
  63. {
  64. if ($this->bShowcaseView){
  65. return '';
  66. }
  67. else{
  68. $sTmp = parent::showPagination ($bAdmin, $bChangePage, $bPageReload);
  69. if ($sTmp != '')
  70. return '<div class="bx-def-margin-top">' . parent::showPagination ($bAdmin, $bChangePage, $bPageReload) . '</div>';
  71. else
  72. return '';
  73. }
  74. }
  75. function displayResultBlock ()
  76. {
  77. if ($this->bShowcaseView){
  78. $this->addContainerClass(array('bx-def-margin-sec-lefttopright-neg', 'bx-base-unit-showcase-wrapper'));
  79. $CNF = &$this->oModule->_oConfig->CNF;
  80. $iPerPageInShowCase = isset($CNF['PARAM_PER_PAGE_BROWSE_SHOWCASE']) ? getParam($CNF['PARAM_PER_PAGE_BROWSE_SHOWCASE']) : BX_SYS_PER_PAGE_BROWSE_SHOWCASE;
  81. $this->aCurrent['paginate']['perPage'] = empty($iPerPageInShowCase) ? BX_SYS_PER_PAGE_BROWSE_SHOWCASE : $iPerPageInShowCase;
  82. $this->oModule->_oTemplate->addCss(array(BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'flickity/|flickity.css'));
  83. $this->oModule->_oTemplate->addJs(array('flickity/flickity.pkgd.min.js','modules/base/general/js/|showcase.js'));
  84. }
  85. return parent::displayResultBlock ();
  86. }
  87. }
  88. /** @} */