1
0

BxBaseModGeneralCmtsSearchResult.php 2.7 KB

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