BxForumCmts.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 Forum Forum
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxForumCmts extends BxTemplCmts
  12. {
  13. protected $MODULE;
  14. protected $_oModule;
  15. public function __construct($sSystem, $iId, $iInit = 1)
  16. {
  17. $this->MODULE = 'bx_forum';
  18. $this->_oModule = BxDolModule::getInstance($this->MODULE);
  19. $this->_sTableImages = 'bx_forum_files';
  20. parent::__construct($sSystem, $iId, $iInit, $this->_oModule->_oTemplate);
  21. $this->_bPostQuote = true;
  22. }
  23. public function registerTranscoders()
  24. {
  25. parent::registerTranscoders();
  26. $aTranscoders = array(
  27. $this->getTranscoderPreviewName()
  28. );
  29. BxDolTranscoderImage::registerHandlersArray($aTranscoders);
  30. }
  31. public function unregisterTranscoders()
  32. {
  33. parent::unregisterTranscoders();
  34. $aTranscoders = array(
  35. $this->getTranscoderPreviewName()
  36. );
  37. BxDolTranscoderImage::unregisterHandlersArray($aTranscoders);
  38. BxDolTranscoderImage::cleanupObjectsArray($aTranscoders);
  39. }
  40. public function isPostAllowed($isPerformAction = false)
  41. {
  42. $aContentInfo = $this->_oModule->_oDb->getContentInfoById($this->_iId);
  43. if(!$aContentInfo || (int)$aContentInfo[$this->_oModule->_oConfig->CNF['FIELD_LOCK']] == 1)
  44. return false;
  45. return parent::isPostAllowed($isPerformAction);
  46. }
  47. public function onPostAfter($iId, $aDp = [])
  48. {
  49. $CNF = &$this->_oModule->_oConfig->CNF;
  50. $mixedResult = parent::onPostAfter($iId, $aDp);
  51. if($mixedResult === false)
  52. return $mixedResult;
  53. if(getParam($CNF['PARAM_AUTOSUBSCRIBE_REPLIED']) == 'on')
  54. BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTION_SUBSCRIBERS'])->actionAdd((int)$this->getId(), (int)$this->_getAuthorId());
  55. return $mixedResult;
  56. }
  57. public function getCommentsBlock($aBp = array(), $aDp = array())
  58. {
  59. $mixedBlock = parent::getCommentsBlock($aBp, $aDp);
  60. if(is_array($mixedBlock) && isset($mixedBlock['title']))
  61. $mixedBlock['title'] = _t('_bx_forum_page_block_title_entry_comments', $this->getCommentsCount());
  62. return $mixedBlock;
  63. }
  64. public function getCommentBlock($iCmtId = 0, $aBp = [], $aDp = [])
  65. {
  66. $sResult = parent::getCommentBlock($iCmtId, $aBp, $aDp);
  67. if(!empty($sResult))
  68. $this->_oModule->_oTemplate->addCss('main.css');
  69. return $sResult;
  70. }
  71. protected function _getCounterItems($iCmtsLimit, $iCmtsStart = 0)
  72. {
  73. $aContentInfo = $this->_oModule->_oDb->getContentInfoById($this->_iId);
  74. $a = $this->_oQuery->getCommentsBy(array('type' => 'object_id', 'object_id' => $this->getId(), 'order_way' => 'desc', 'start' => $iCmtsStart, 'per_page' => $iCmtsLimit * 4));
  75. return array_merge($a, [['cmt_author_id' => $aContentInfo['author']]]);
  76. }
  77. protected function _getFormObject($sAction = BX_CMT_ACTION_POST)
  78. {
  79. $CNF = &$this->_oModule->_oConfig->CNF;
  80. $oResult = parent::_getFormObject($sAction);
  81. if(!isset($oResult->aInputs['cmt_image']))
  82. return $oResult;
  83. $oResult->aInputs['cmt_image']['storage_object'] = $CNF['OBJECT_STORAGE_CMTS'];
  84. $oResult->aInputs['cmt_image']['images_transcoder'] = $CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW_CMTS'];
  85. $oResult->aInputs['cmt_image']['upload_buttons_titles'] = array('Simple' => 'paperclip', 'HTML5' => 'paperclip');
  86. return $oResult;
  87. }
  88. }
  89. /** @} */