BxBaseModGeneralCmtsSearchResult.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 BaseGeneral Base classes for modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxBaseModGeneralCmtsSearchResult extends BxBaseModGeneralSearchResult
  12. {
  13. protected $sModule;
  14. protected $sModuleObjectComments;
  15. function __construct($sMode = '', $aParams = array())
  16. {
  17. parent::__construct($sMode, $aParams);
  18. $this->oModule = $this->getMain();
  19. $this->sModuleObjectComments = $this->oModule->_oConfig->CNF['OBJECT_COMMENTS'];
  20. $this->aCurrent = array(
  21. 'name' => $this->oModule->_oConfig->getName() . '_cmts',
  22. 'module_name' => $this->oModule->_oConfig->getName(),
  23. 'title' => '',
  24. 'table' => $this->oModule->_oConfig->getDbPrefix() . 'cmts',
  25. 'ownFields' => array('cmt_id', 'cmt_object_id', 'cmt_author_id', 'cmt_text', 'cmt_time'),
  26. 'searchFields' => array('cmt_text'),
  27. 'restriction' => array(
  28. 'author' => array('value' => '', 'field' => 'cmt_author_id', 'operator' => '='),
  29. ),
  30. 'paginate' => array('start' => 0, 'perPage' => 3),
  31. 'sorting' => 'last',
  32. 'ident' => 'cmt_id'
  33. );
  34. $this->sBrowseUrl = BX_DOL_SEARCH_KEYWORD_PAGE;
  35. }
  36. function getMain()
  37. {
  38. return BxDolModule::getInstance($this->sModule);
  39. }
  40. function displaySearchUnit($aData)
  41. {
  42. $oCmts = BxDolCmts::getObjectInstance($this->sModuleObjectComments, $aData['object_id']);
  43. $oCmts->addCssJs();
  44. if($this->_bLiveSearch) {
  45. $aCnf = &$this->oModule->_oConfig->CNF;
  46. return $oCmts->getCommentLiveSearch($aData['id'], array(
  47. 'txt_sample_single' => isset($aCnf['T']['txt_sample_comment_single']) ? $aCnf['T']['txt_sample_comment_single'] : ''
  48. ));
  49. }
  50. else
  51. return $oCmts->getComment($aData['id'], array(), array('type' => BX_CMT_DISPLAY_FLAT, 'view_only' => true));
  52. }
  53. function displayResultBlock ()
  54. {
  55. $s = parent::displayResultBlock ();
  56. $s = '<ul class="cmts">' . $s . '</ul>';
  57. return $s;
  58. }
  59. function getAlterOrder()
  60. {
  61. if($this->aCurrent['sorting'] == 'last')
  62. return array(
  63. 'order' => " ORDER BY `" . $this->aCurrent['table'] . "`.`cmt_time` DESC"
  64. );
  65. return array();
  66. }
  67. function _getPseud ()
  68. {
  69. return array(
  70. 'id' => 'cmt_id',
  71. 'object_id' => 'cmt_object_id',
  72. 'author' => 'cmt_author_id',
  73. 'text' => 'cmt_text',
  74. 'added' => 'cmt_time'
  75. );
  76. }
  77. }
  78. /** @} */