BxVideosSearchResult.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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 Videos Videos
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxVideosSearchResult extends BxBaseModTextSearchResult
  12. {
  13. function __construct($sMode = '', $aParams = array())
  14. {
  15. parent::__construct($sMode, $aParams);
  16. $this->aCurrent = array(
  17. 'name' => 'bx_videos',
  18. 'module_name' => 'bx_videos',
  19. 'object_metatags' => 'bx_videos',
  20. 'title' => _t('_bx_videos_page_title_browse'),
  21. 'table' => 'bx_videos_entries',
  22. 'ownFields' => array('id', 'title', 'text', 'duration', 'thumb', 'poster', 'video', 'author', 'added', 'views', 'video_source', 'video_embed_data'),
  23. 'searchFields' => array(),
  24. 'restriction' => array(
  25. 'author' => array('value' => '', 'field' => 'author', 'operator' => '='),
  26. 'featured' => array('value' => '', 'field' => 'featured', 'operator' => '<>'),
  27. 'status' => array('value' => 'active', 'field' => 'status', 'operator' => '='),
  28. 'statusAdmin' => array('value' => 'active', 'field' => 'status_admin', 'operator' => '='),
  29. ),
  30. 'paginate' => array('perPage' => getParam('bx_videos_per_page_browse'), 'start' => 0),
  31. 'sorting' => 'last',
  32. 'rss' => array(
  33. 'title' => '',
  34. 'link' => '',
  35. 'image' => '',
  36. 'profile' => 0,
  37. 'fields' => array (
  38. 'Guid' => 'link',
  39. 'Link' => 'link',
  40. 'Title' => 'title',
  41. 'DateTimeUTS' => 'added',
  42. 'Desc' => 'text',
  43. 'Image' => 'thumb'
  44. ),
  45. ),
  46. 'ident' => 'id',
  47. );
  48. $this->sFilterName = 'bx_videos_filter';
  49. $this->oModule = $this->getMain();
  50. $CNF = &$this->oModule->_oConfig->CNF;
  51. $sSearchFields = getParam($CNF['PARAM_SEARCHABLE_FIELDS']);
  52. $this->aCurrent['searchFields'] = !empty($sSearchFields) ? explode(',', $sSearchFields) : '';
  53. $oProfileAuthor = null;
  54. switch ($sMode) {
  55. case 'author':
  56. if(!$this->_updateCurrentForAuthor($sMode, $aParams, $oProfileAuthor))
  57. $this->isError = true;
  58. break;
  59. case 'context':
  60. if(!$this->_updateCurrentForContext($sMode, $aParams, $oProfileAuthor))
  61. $this->isError = true;
  62. break;
  63. case 'followed_contexts':
  64. if(!$this->_updateCurrentForFollowedContexts($sMode, $aParams, $oProfileAuthor))
  65. $this->isError = true;
  66. break;
  67. case 'favorite':
  68. if(!$this->_updateCurrentForFavorite($sMode, $aParams, $oProfileAuthor))
  69. $this->isError = true;
  70. break;
  71. case 'public':
  72. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_HOME']);
  73. $this->aCurrent['title'] = _t('_bx_videos_page_title_browse_recent');
  74. $this->aCurrent['rss']['link'] = 'modules/?r=videos/rss/' . $sMode;
  75. break;
  76. case 'featured':
  77. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_HOME']);
  78. $this->aCurrent['title'] = _t('_bx_videos_page_title_browse_featured');
  79. $this->aCurrent['restriction']['featured']['value'] = '0';
  80. $this->aCurrent['rss']['link'] = 'modules/?r=videos/rss/' . $sMode;
  81. $this->aCurrent['sorting'] = 'featured';
  82. break;
  83. case 'popular':
  84. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_POPULAR']);
  85. $this->aCurrent['title'] = _t('_bx_videos_page_title_browse_popular');
  86. $this->aCurrent['rss']['link'] = 'modules/?r=videos/rss/' . $sMode;
  87. $this->aCurrent['sorting'] = 'popular';
  88. break;
  89. case 'top':
  90. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_TOP']);
  91. $this->aCurrent['title'] = _t('_bx_videos_page_title_browse_top');
  92. $this->aCurrent['rss']['link'] = 'modules/?r=videos/rss/' . $sMode;
  93. $this->aCurrent['sorting'] = 'top';
  94. break;
  95. case 'updated':
  96. $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_UPDATED']);
  97. $this->aCurrent['title'] = _t('_bx_videos_page_title_browse_updated');
  98. $this->aCurrent['rss']['link'] = 'modules/?r=videos/rss/' . $sMode;
  99. $this->aCurrent['sorting'] = 'updated';
  100. break;
  101. case '': // search results
  102. $this->checkRestrictionsForContext($sMode, $aParams, $oProfileAuthor);
  103. $this->sBrowseUrl = BX_DOL_SEARCH_KEYWORD_PAGE;
  104. $this->aCurrent['title'] = _t('_bx_videos');
  105. unset($this->aCurrent['paginate']['perPage'], $this->aCurrent['rss']);
  106. break;
  107. default:
  108. $sMode = '';
  109. $this->isError = true;
  110. }
  111. $this->processReplaceableMarkers($oProfileAuthor);
  112. $this->addConditionsForPrivateContent($CNF, $oProfileAuthor);
  113. $this->addCustomConditions($CNF, $oProfileAuthor, $sMode, $aParams);
  114. }
  115. }
  116. /** @} */