BxForumCmts.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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)
  48. {
  49. $CNF = &$this->_oModule->_oConfig->CNF;
  50. $mixedResult = parent::onPostAfter($iId);
  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 getComment($mixedCmt, $aBp = array(), $aDp = array())
  65. {
  66. return parent::getComment($mixedCmt, $aBp, array_merge($aDp, array(
  67. 'class_comment' => 'bx-def-box bx-def-padding bx-def-round-corners bx-def-color-bg-box'
  68. )));
  69. }
  70. protected function _getEmpty($aDp = array())
  71. {
  72. return parent::_getEmpty(array_merge($aDp, array(
  73. 'class' => 'bx-def-box bx-def-padding bx-def-round-corners bx-def-color-bg-box'
  74. )));
  75. }
  76. protected function _getFormBox($sType, $aBp, $aDp)
  77. {
  78. if(!isset($aBp['parent_id']) || (int)$aBp['parent_id'] == 0)
  79. $aDp = array_merge($aDp, array(
  80. 'class' => 'bx-def-box bx-def-padding bx-def-round-corners bx-def-color-bg-box'
  81. ));
  82. return parent::_getFormBox($sType, $aBp, $aDp);
  83. }
  84. protected function _getFormObject($sAction = BX_CMT_ACTION_POST)
  85. {
  86. $CNF = &$this->_oModule->_oConfig->CNF;
  87. $oResult = parent::_getFormObject($sAction);
  88. if(!isset($oResult->aInputs['cmt_image']))
  89. return $oResult;
  90. $oResult->aInputs['cmt_image']['storage_object'] = $CNF['OBJECT_STORAGE_CMTS'];
  91. $oResult->aInputs['cmt_image']['images_transcoder'] = $CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW_CMTS'];
  92. $oResult->aInputs['cmt_image']['upload_buttons_titles'] = array('Simple' => 'paperclip');
  93. return $oResult;
  94. }
  95. }
  96. /** @} */