BxTimelineSearchResult.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 Timeline Timeline
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxTimelineSearchResult extends BxBaseModNotificationsSearchResult
  12. {
  13. function __construct($sMode = '', $aParams = array())
  14. {
  15. parent::__construct($sMode, $aParams);
  16. $this->aCurrent = array(
  17. 'name' => 'bx_timeline',
  18. 'module_name' => 'bx_timeline',
  19. 'title' => _t('_bx_timeline_page_title_browse'),
  20. 'table' => 'bx_timeline_events',
  21. 'ownFields' => array('id', 'owner_id', 'type', 'action', 'object_id', 'object_privacy_view', 'content', 'title', 'description', 'views', 'rate', 'votes', 'comments', 'reports', 'reposts', 'date', 'active', 'hidden', 'pinned'),
  22. 'searchFields' => array('description'),
  23. 'restriction' => array(
  24. 'internal' => array('value' => 'timeline_common_post', 'field' => 'type', 'operator' => '='),
  25. 'active' => array('value' => '1', 'field' => 'active', 'operator' => '='),
  26. ),
  27. 'paginate' => array('perPage' => getParam('bx_timeline_events_per_page'), 'start' => 0),
  28. 'sorting' => 'last',
  29. 'ident' => 'id',
  30. );
  31. $this->sFilterName = 'bx_timeline_filter';
  32. $this->oModule = $this->getMain();
  33. switch ($sMode) {
  34. case '': // search results
  35. $this->sBrowseUrl = BX_DOL_SEARCH_KEYWORD_PAGE;
  36. $this->aCurrent['title'] = _t('_bx_timeline');
  37. $this->aCurrent['paginate']['perPage'] = 3;
  38. break;
  39. default:
  40. $sMode = '';
  41. $this->isError = true;
  42. }
  43. $this->setProcessPrivateContent(false);
  44. }
  45. function displayResultBlock ()
  46. {
  47. $sResult = parent::displayResultBlock();
  48. if(empty($sResult))
  49. return $sResult;
  50. return $this->oModule->_oTemplate->getSearchBlock($sResult);
  51. }
  52. function getAlterOrder()
  53. {
  54. $aSql = array();
  55. switch ($this->aCurrent['sorting']) {
  56. case 'last':
  57. $aSql['order'] = ' ORDER BY `bx_timeline_events`.`date` DESC';
  58. break;
  59. }
  60. return $aSql;
  61. }
  62. }
  63. /** @} */