BxBaseModGeneralCmtsSearchResult.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup BaseGeneral Base classes for modules
  7. * @ingroup TridentModules
  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. );
  33. $this->sBrowseUrl = BX_DOL_SEARCH_KEYWORD_PAGE;
  34. }
  35. function getMain()
  36. {
  37. return BxDolModule::getInstance($this->sModule);
  38. }
  39. function displaySearchUnit($aData)
  40. {
  41. $oCmts = BxDolCmts::getObjectInstance($this->sModuleObjectComments, $aData['object_id']);
  42. $oCmts->addCssJs();
  43. if($this->_bLiveSearch) {
  44. $aCnf = &$this->oModule->_oConfig->CNF;
  45. return $oCmts->getCommentLiveSearch($aData['id'], array(
  46. 'txt_sample_single' => isset($aCnf['T']['txt_sample_comment_single']) ? $aCnf['T']['txt_sample_comment_single'] : ''
  47. ));
  48. }
  49. else
  50. return $oCmts->getComment($aData['id'], array(), array('type' => BX_CMT_DISPLAY_FLAT, 'view_only' => true));
  51. }
  52. function displayResultBlock ()
  53. {
  54. $s = parent::displayResultBlock ();
  55. $s = '<ul class="cmts">' . $s . '</ul>';
  56. return $s;
  57. }
  58. function getAlterOrder()
  59. {
  60. if($this->aCurrent['sorting'] == 'last')
  61. return array(
  62. 'order' => " ORDER BY `" . $this->aCurrent['table'] . "`.`cmt_time` DESC"
  63. );
  64. return array();
  65. }
  66. function _getPseud ()
  67. {
  68. return array(
  69. 'id' => 'cmt_id',
  70. 'object_id' => 'cmt_object_id',
  71. 'author' => 'cmt_author_id',
  72. 'text' => 'cmt_text',
  73. 'added' => 'cmt_time'
  74. );
  75. }
  76. }
  77. /** @} */