BxForumCmts.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. }
  22. public function registerTranscoders()
  23. {
  24. parent::registerTranscoders();
  25. $aTranscoders = array(
  26. $this->getTranscoderPreviewName()
  27. );
  28. BxDolTranscoderImage::registerHandlersArray($aTranscoders);
  29. }
  30. public function unregisterTranscoders()
  31. {
  32. parent::unregisterTranscoders();
  33. $aTranscoders = array(
  34. $this->getTranscoderPreviewName()
  35. );
  36. BxDolTranscoderImage::unregisterHandlersArray($aTranscoders);
  37. BxDolTranscoderImage::cleanupObjectsArray($aTranscoders);
  38. }
  39. public function isPostAllowed($isPerformAction = false)
  40. {
  41. $aContentInfo = $this->_oModule->_oDb->getContentInfoById($this->_iId);
  42. if(!$aContentInfo || (int)$aContentInfo[$this->_oModule->_oConfig->CNF['FIELD_LOCK']] == 1)
  43. return false;
  44. return parent::isPostAllowed($isPerformAction);
  45. }
  46. public function onPostAfter($iId)
  47. {
  48. $CNF = &$this->_oModule->_oConfig->CNF;
  49. $mixedResult = parent::onPostAfter($iId);
  50. if($mixedResult === false)
  51. return $mixedResult;
  52. if(getParam($CNF['PARAM_AUTOSUBSCRIBE_REPLIED']) == 'on')
  53. BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTION_SUBSCRIBERS'])->actionAdd((int)$this->getId(), (int)$this->_getAuthorId());
  54. return $mixedResult;
  55. }
  56. public function getCommentsBlock($aBp = array(), $aDp = array())
  57. {
  58. $mixedBlock = parent::getCommentsBlock($aBp, $aDp);
  59. if (is_array($mixedBlock) && isset($mixedBlock['title']))
  60. $mixedBlock['title'] = _t('_bx_forum_page_block_title_entry_comments', $this->getCommentsCount());
  61. return $mixedBlock;
  62. }
  63. public function getComment($mixedCmt, $aBp = array(), $aDp = array())
  64. {
  65. return parent::getComment($mixedCmt, $aBp, array_merge($aDp, array(
  66. 'class_comment' => 'bx-def-box bx-def-padding bx-def-round-corners bx-def-color-bg-box'
  67. )));
  68. }
  69. protected function _getEmpty($aDp = array())
  70. {
  71. return parent::_getEmpty(array_merge($aDp, array(
  72. 'class' => 'bx-def-box bx-def-padding bx-def-round-corners bx-def-color-bg-box'
  73. )));
  74. }
  75. protected function _getFormBox($sType, $aBp, $aDp)
  76. {
  77. if(!isset($aBp['parent_id']) || (int)$aBp['parent_id'] == 0)
  78. $aDp = array_merge($aDp, array(
  79. 'class' => 'bx-def-box bx-def-padding bx-def-round-corners bx-def-color-bg-box'
  80. ));
  81. return parent::_getFormBox($sType, $aBp, $aDp);
  82. }
  83. protected function _getFormObject($sAction = BX_CMT_ACTION_POST)
  84. {
  85. $CNF = &$this->_oModule->_oConfig->CNF;
  86. $oResult = parent::_getFormObject($sAction);
  87. if(!isset($oResult->aInputs['cmt_image']))
  88. return $oResult;
  89. $oResult->aInputs['cmt_image']['storage_object'] = $CNF['OBJECT_STORAGE_CMTS'];
  90. $oResult->aInputs['cmt_image']['images_transcoder'] = $CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW_CMTS'];
  91. $oResult->aInputs['cmt_image']['upload_buttons_titles'] = array('Simple' => 'paperclip');
  92. return $oResult;
  93. }
  94. }
  95. /** @} */