BxMarketSearchResult.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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 Market Market
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxMarketSearchResult extends BxBaseModTextSearchResult
  12. {
  13. function __construct($sMode = '', $aParams = array())
  14. {
  15. parent::__construct($sMode, $aParams);
  16. $this->aCurrent = array(
  17. 'name' => 'bx_market',
  18. 'module_name' => 'bx_market',
  19. 'object_metatags' => 'bx_market',
  20. 'title' => _t('_bx_market_page_title_browse'),
  21. 'table' => 'bx_market_products',
  22. 'ownFields' => array('id', 'title', 'text', 'price_single', 'price_recurring', 'duration_recurring', 'thumb', 'cover', 'author', 'added'),
  23. 'searchFields' => array(),
  24. 'restriction' => array(
  25. 'author' => array('value' => '', 'field' => 'author', 'operator' => '='),
  26. 'featured' => array('value' => '', 'field' => 'featured', 'operator' => '<>'),
  27. 'except' => array('value' => '', 'field' => 'id', 'operator' => 'not in'),
  28. 'status' => array('value' => 'active', 'field' => 'status', 'operator' => '='),
  29. 'statusAdmin' => array('value' => 'active', 'field' => 'status_admin', 'operator' => '='),
  30. ),
  31. 'paginate' => array('perPage' => getParam('bx_market_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' => 'title',
  42. 'DateTimeUTS' => 'added',
  43. 'Desc' => 'text',
  44. 'Image' => 'thumb'
  45. ),
  46. ),
  47. 'ident' => 'id',
  48. );
  49. $this->sFilterName = 'bx_market_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_LATEST']);
  70. $this->aCurrent['title'] = _t('_bx_market_page_title_browse_latest');
  71. $this->aCurrent['rss']['link'] = 'modules/?r=market/rss/' . $sMode;
  72. break;
  73. case 'featured':
  74. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_FEATURED']);
  75. $this->aCurrent['title'] = _t('_bx_market_page_title_browse_featured');
  76. $this->aCurrent['restriction']['featured']['value'] = '0';
  77. $this->aCurrent['rss']['link'] = 'modules/?r=market/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_market_page_title_browse_popular');
  83. $this->aCurrent['rss']['link'] = 'modules/?r=market/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_market_page_title_browse_top');
  89. $this->aCurrent['rss']['link'] = 'modules/?r=market/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_market_page_title_browse_updated');
  95. $this->aCurrent['rss']['link'] = 'modules/?r=market/rss/' . $sMode;
  96. $this->aCurrent['sorting'] = 'updated';
  97. break;
  98. case '': // search results
  99. $this->sBrowseUrl = BX_DOL_SEARCH_KEYWORD_PAGE;
  100. unset($this->aCurrent['paginate']['perPage'], $this->aCurrent['rss']);
  101. break;
  102. default:
  103. $sMode = '';
  104. $this->isError = true;
  105. }
  106. $this->processReplaceableMarkers($oProfileAuthor);
  107. $this->addConditionsForPrivateContent($CNF, $oProfileAuthor);
  108. $this->addCustomConditions($CNF, $oProfileAuthor, $sMode, $aParams);
  109. }
  110. public function setMetaType($s)
  111. {
  112. $this->_sMetaType = $s;
  113. if(!empty($this->_sMetaType) && $this->_sMetaType == 'keyword')
  114. $this->aCurrent['title'] = _t('_bx_market_page_title_browse_keyword', bx_process_pass(bx_get('keyword')));
  115. }
  116. public function setCategoryObject($s)
  117. {
  118. $this->_sCategoryObject = $s;
  119. if(!empty($this->_sCategoryObject) && $o = BxDolCategory::getObjectInstance($this->_sCategoryObject))
  120. $this->aCurrent['title'] = _t('_bx_market_page_title_browse_category', $o->getCategoryTitle((int)bx_get('keyword')));
  121. }
  122. function displayResultBlock ()
  123. {
  124. return BxDolPayments::getInstance()->getCartJs() . parent::displayResultBlock();
  125. }
  126. }
  127. /** @} */