BxTasksSearchResult.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 Tasks Tasks
  6. * @ingroup UnaModules
  7. *
  8. * @{
  9. */
  10. class BxTasksSearchResult extends BxBaseModTextSearchResult
  11. {
  12. function __construct($sMode = '', $aParams = array())
  13. {
  14. parent::__construct($sMode, $aParams);
  15. $this->aCurrent = array(
  16. 'name' => 'bx_tasks',
  17. 'module_name' => 'bx_tasks',
  18. 'object_metatags' => 'bx_tasks',
  19. 'title' => _t('_bx_tasks_page_title_browse'),
  20. 'table' => 'bx_tasks_tasks',
  21. 'ownFields' => array('id', 'title', 'text', 'thumb', 'author', 'added'),
  22. 'searchFields' => array(),
  23. 'restriction' => array(
  24. 'author' => array('value' => '', 'field' => 'author', 'operator' => '='),
  25. 'featured' => array('value' => '', 'field' => 'featured', '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_tasks_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_tasks_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. case 'favorite':
  63. if(!$this->_updateCurrentForFavorite($sMode, $aParams, $oProfileAuthor))
  64. $this->isError = true;
  65. break;
  66. case 'public':
  67. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_HOME']);
  68. $this->aCurrent['title'] = _t('_bx_tasks_page_title_browse_recent');
  69. $this->aCurrent['rss']['link'] = 'modules/?r=tasks/rss/' . $sMode;
  70. break;
  71. case 'featured':
  72. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_HOME']);
  73. $this->aCurrent['title'] = _t('_bx_tasks_page_title_browse_featured');
  74. $this->aCurrent['restriction']['featured']['value'] = '0';
  75. $this->aCurrent['rss']['link'] = 'modules/?r=tasks/rss/' . $sMode;
  76. $this->aCurrent['sorting'] = 'featured';
  77. break;
  78. case 'popular':
  79. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_TOP']);
  80. $this->aCurrent['title'] = _t('_bx_tasks_page_title_browse_popular');
  81. $this->aCurrent['rss']['link'] = 'modules/?r=tasks/rss/' . $sMode;
  82. $this->aCurrent['sorting'] = 'popular';
  83. break;
  84. case 'top':
  85. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_POPULAR']);
  86. $this->aCurrent['title'] = _t('_bx_tasks_page_title_browse_top');
  87. $this->aCurrent['rss']['link'] = 'modules/?r=tasks/rss/' . $sMode;
  88. $this->aCurrent['sorting'] = 'top';
  89. break;
  90. case 'updated':
  91. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_UPDATED']);
  92. $this->aCurrent['title'] = _t('_bx_tasks_page_title_browse_updated');
  93. $this->aCurrent['rss']['link'] = 'modules/?r=tasks/rss/' . $sMode;
  94. $this->aCurrent['sorting'] = 'updated';
  95. break;
  96. case '': // search results
  97. $this->sBrowseUrl = BX_DOL_SEARCH_KEYWORD_PAGE;
  98. $this->aCurrent['title'] = _t('_bx_tasks');
  99. unset($this->aCurrent['paginate']['perPage'], $this->aCurrent['rss']);
  100. break;
  101. default:
  102. $sMode = '';
  103. $this->isError = true;
  104. }
  105. $this->processReplaceableMarkers($oProfileAuthor);
  106. $this->addConditionsForPrivateContent($CNF, $oProfileAuthor);
  107. }
  108. }
  109. /** @} */