BxResourcesSearchResult.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. * @defgroup Resources Resources
  6. * @ingroup UnaModules
  7. *
  8. * @{
  9. */
  10. class BxResourcesSearchResult extends BxBaseModTextSearchResult
  11. {
  12. function __construct($sMode = '', $aParams = [])
  13. {
  14. parent::__construct($sMode, $aParams);
  15. $this->aCurrent = array(
  16. 'name' => 'bx_resources',
  17. 'module_name' => 'bx_resources',
  18. 'object_metatags' => 'bx_resources',
  19. 'title' => _t('_bx_resources_page_title_browse'),
  20. 'table' => 'bx_resources_entries',
  21. 'ownFields' => array('id', 'link', 'title', 'text', 'thumb', 'author', 'added'),
  22. 'searchFields' => array(),
  23. 'restriction' => array(
  24. 'author' => array('value' => '', 'field' => 'author', 'operator' => '='),
  25. 'cat' => array('value' => '', 'field' => 'cat', 'operator' => '='),
  26. 'status' => array('value' => 'active', 'field' => 'status', 'operator' => '='),
  27. 'statusAdmin' => array('value' => 'active', 'field' => 'status_admin', 'operator' => '='),
  28. ),
  29. 'paginate' => array('perPage' => getParam('bx_resources_per_page_browse'), 'start' => 0),
  30. 'sorting' => 'last',
  31. 'rss' => array(
  32. 'title' => '',
  33. 'link' => '',
  34. 'image' => '',
  35. 'profile' => 0,
  36. 'fields' => array (
  37. 'Guid' => 'link',
  38. 'Link' => 'link',
  39. 'Title' => 'title',
  40. 'DateTimeUTS' => 'added',
  41. 'Desc' => 'text',
  42. 'Image' => 'thumb'
  43. ),
  44. ),
  45. 'ident' => 'id',
  46. );
  47. $this->sFilterName = 'bx_resources_filter';
  48. $this->oModule = $this->getMain();
  49. $CNF = &$this->oModule->_oConfig->CNF;
  50. $sSearchFields = getParam($CNF['PARAM_SEARCHABLE_FIELDS']);
  51. $this->aCurrent['searchFields'] = !empty($sSearchFields) ? explode(',', $sSearchFields) : '';
  52. $oProfileAuthor = null;
  53. switch ($sMode) {
  54. case 'author':
  55. if(!$this->_updateCurrentForAuthor($sMode, $aParams, $oProfileAuthor))
  56. $this->isError = true;
  57. break;
  58. case 'context':
  59. if(!$this->_updateCurrentForContext($sMode, $aParams, $oProfileAuthor)) {
  60. $this->isError = true;
  61. break;
  62. }
  63. if(($sCategory = $aParams['category'] ?? false))
  64. $this->aCurrent['restriction']['cat']['value'] = $sCategory;
  65. break;
  66. case '': // search results
  67. $this->sBrowseUrl = BX_DOL_SEARCH_KEYWORD_PAGE;
  68. $this->aCurrent['title'] = _t('_bx_resources');
  69. unset($this->aCurrent['paginate']['perPage'], $this->aCurrent['rss']);
  70. break;
  71. default:
  72. $sMode = '';
  73. $this->isError = true;
  74. }
  75. $this->processReplaceableMarkers($oProfileAuthor);
  76. $this->addConditionsForPrivateContent($CNF, $oProfileAuthor);
  77. }
  78. }
  79. /** @} */