Просмотр исходного кода

Ticket #5273 - Get rid of duplicates in code.

AntonLV 11 месяцев назад
Родитель
Сommit
4ca24b157b

+ 2 - 67
studio/classes/BxDolStudioAgentsAsstChatsCmts.php

@@ -7,45 +7,21 @@
  * @{
  */
 
-class BxDolStudioAgentsAsstChatsCmts extends BxTemplCmts
+class BxDolStudioAgentsAsstChatsCmts extends BxDolStudioAgentsCmts
 {
     protected static $_sPrefixLoad = '#-#';
     protected static $_sPrefixRetrieve = '|-|';
     protected static $_sParamAllowDelete = 'allow_delete';
-
-    protected $_oQueryAgents;
-    
-    protected $_oAI;
-    protected $_iProfileIdAi;
-    
+       
     protected $_iAssistantId;
     protected $_sAssistantUrl;
 
-    protected $_bAuto;
-
     public function __construct($sSystem, $iId, $iInit = true, $oTemplate = false)
     {
         $this->_sTableImages = 'sys_agents_assistants_chats_files';
 
         parent::__construct($sSystem, $iId, $iInit, $oTemplate);
 
-        if ($oTemplate)
-            $this->_oTemplate = $oTemplate;
-        else
-            $this->_oTemplate = BxDolStudioTemplate::getInstance();
-
-        $this->_sFormObject = 'sys_agents_comment';
-        $this->_sFormDisplayPost = 'sys_agents_comment_post';
-        $this->_sFormDisplayEdit = 'sys_agents_comment_edit';
-
-        $this->_sTmplNameItemContent = 'agents_comment_content.html';
-        $this->_bLiveUpdates = false;
-
-        $this->_oQueryAgents = new BxDolStudioAgentsQuery();
-
-        $this->_oAI = BxDolAI::getInstance();
-        $this->_iProfileIdAi = $this->_oAI->getProfileId();
-
         $this->_iAssistantId = 0;
         if(($iAssistantId = bx_get('aid')) !== false) {
             $this->_iAssistantId = bx_process_input($iAssistantId, BX_DATA_INT);
@@ -55,34 +31,6 @@ class BxDolStudioAgentsAsstChatsCmts extends BxTemplCmts
 
         if(!$this->isParam(self::$_sParamAllowDelete))
             $this->setAllowDelete(true);
-
-        $this->_bAuto = false;
-    }
-
-    public function actionGetCmt ()
-    {
-        if(!$this->isEnabled())
-            return echoJson([]);
-
-        if($this->isViewAllowed() !== CHECK_ACTION_RESULT_ALLOWED)
-            return echoJson([]);
-
-        $mixedCmtId = bx_process_input(bx_get('Cmt'));
-        $sCmtBrowse = ($sCmtBrowse = bx_get('CmtBrowse')) !== false ? bx_process_input($sCmtBrowse, BX_DATA_TEXT) : '';
-        $sCmtDisplay = ($sCmtDisplay = bx_get('CmtDisplay')) !== false ? bx_process_input($sCmtDisplay, BX_DATA_TEXT) : '';
-
-        $aCmtIds = strpos($mixedCmtId, ',') !== false ? explode(',', $mixedCmtId) : [$mixedCmtId];
-
-        $sContent = '';
-        foreach($aCmtIds as $iCmtId)
-            $sContent .= $this->getComment((int)$iCmtId, ['type' => $sCmtBrowse], ['type' => $sCmtDisplay, 'dynamic_mode' => true]);
-
-        $aCmt = $this->getCommentRow((int)reset($aCmtIds));
-        echoJson([
-            'parent_id' => $aCmt['cmt_parent_id'],
-            'vparent_id' => $aCmt['cmt_parent_id'],
-            'content' => $sContent
-        ]);
     }
 
     public function getPageJsObject()
@@ -266,19 +214,6 @@ class BxDolStudioAgentsAsstChatsCmts extends BxTemplCmts
             'id' => $aCmt['cmt_id']
         ]);
     }
-
-    protected function _getCountersBox(&$aCmt, $aBp = [], $aDp = [])
-    {
-        return '';
-    }
-
-    protected function _getFormBox($sType, $aBp, $aDp)
-    {
-        return parent::_getFormBox($sType, $aBp, array_merge($aDp, [
-            'min_post_form' => false, 
-            'class_body' => $this->_sStylePrefix . '-body-agents'
-        ]));
-    }
     
     protected function _getForm($sAction, $iId, $aDp = [])
     {

+ 1 - 64
studio/classes/BxDolStudioAgentsAutomatorsCmts.php

@@ -7,65 +7,15 @@
  * @{
  */
 
-class BxDolStudioAgentsAutomatorsCmts extends BxTemplCmts
+class BxDolStudioAgentsAutomatorsCmts extends BxDolStudioAgentsCmts
 {
-    protected $_oQueryAgents;
     protected $_sUrlPageAgents;
-    protected $_iProfileIdAi;
-
-    protected $_bAuto;
-    
-    protected $_oAI;
 
     public function __construct($sSystem, $iId, $iInit = true, $oTemplate = false)
     {
         parent::__construct($sSystem, $iId, $iInit, $oTemplate);
 
-        if ($oTemplate)
-            $this->_oTemplate = $oTemplate;
-        else
-            $this->_oTemplate = BxDolStudioTemplate::getInstance();
-
-        $this->_sFormObject = 'sys_agents_comment';
-        $this->_sFormDisplayPost = 'sys_agents_comment_post';
-        $this->_sFormDisplayEdit = 'sys_agents_comment_edit';
-        
-        $this->_sTmplNameItemContent = 'agents_comment_content.html';
-        $this->_bLiveUpdates = false;
-
-        $this->_oQueryAgents = new BxDolStudioAgentsQuery();
         $this->_sUrlPageAgents = BX_DOL_URL_STUDIO . 'agents.php?page=automators';
-        $this->_iProfileIdAi = BxDolAI::getInstance()->getProfileId();
-
-        $this->_bAuto = false;
-        
-        $this->_oAI = BxDolAI::getInstance();
-    }
-
-    public function actionGetCmt ()
-    {
-        if(!$this->isEnabled())
-            return echoJson([]);
-
-        if($this->isViewAllowed() !== CHECK_ACTION_RESULT_ALLOWED)
-            return echoJson([]);
-
-        $mixedCmtId = bx_process_input(bx_get('Cmt'));
-        $sCmtBrowse = ($sCmtBrowse = bx_get('CmtBrowse')) !== false ? bx_process_input($sCmtBrowse, BX_DATA_TEXT) : '';
-        $sCmtDisplay = ($sCmtDisplay = bx_get('CmtDisplay')) !== false ? bx_process_input($sCmtDisplay, BX_DATA_TEXT) : '';
-
-        $aCmtIds = strpos($mixedCmtId, ',') !== false ? explode(',', $mixedCmtId) : [$mixedCmtId];
-
-        $sContent = '';
-        foreach($aCmtIds as $iCmtId)
-            $sContent .= $this->getComment((int)$iCmtId, ['type' => $sCmtBrowse], ['type' => $sCmtDisplay, 'dynamic_mode' => true]);
-
-        $aCmt = $this->getCommentRow((int)reset($aCmtIds));
-        echoJson([
-            'parent_id' => $aCmt['cmt_parent_id'],
-            'vparent_id' => $aCmt['cmt_parent_id'],
-            'content' => $sContent
-        ]);
     }
     
     public function actionApproveCode()
@@ -224,19 +174,6 @@ class BxDolStudioAgentsAutomatorsCmts extends BxTemplCmts
         ]);
     }
 
-    protected function _getCountersBox(&$aCmt, $aBp = [], $aDp = [])
-    {
-        return '';
-    }
-
-    protected function _getFormBox($sType, $aBp, $aDp)
-    {
-        return parent::_getFormBox($sType, $aBp, array_merge($aDp, [
-            'min_post_form' => false, 
-            'class_body' => $this->_sStylePrefix . '-body-agents'
-        ]));
-    }
-
     protected function _getTmplVarsText($aCmt)
     {
         $aResult = parent::_getTmplVarsText($aCmt);

+ 83 - 0
studio/classes/BxDolStudioAgentsCmts.php

@@ -0,0 +1,83 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaStudio UNA Studio
+ * @{
+ */
+
+class BxDolStudioAgentsCmts extends BxTemplCmts
+{
+    protected $_oQueryAgents;
+
+    protected $_oAI;
+    protected $_iProfileIdAi;
+
+    protected $_bAuto;
+
+    public function __construct($sSystem, $iId, $iInit = true, $oTemplate = false)
+    {
+        parent::__construct($sSystem, $iId, $iInit, $oTemplate);
+
+        if ($oTemplate)
+            $this->_oTemplate = $oTemplate;
+        else
+            $this->_oTemplate = BxDolStudioTemplate::getInstance();
+
+        $this->_sFormObject = 'sys_agents_comment';
+        $this->_sFormDisplayPost = 'sys_agents_comment_post';
+        $this->_sFormDisplayEdit = 'sys_agents_comment_edit';
+        
+        $this->_sTmplNameItemContent = 'agents_comment_content.html';
+        $this->_bLiveUpdates = false;
+
+        $this->_oQueryAgents = new BxDolStudioAgentsQuery();
+
+        $this->_oAI = BxDolAI::getInstance();
+        $this->_iProfileIdAi = $this->_oAI->getProfileId();
+
+        $this->_bAuto = false;
+    }
+
+    public function actionGetCmt ()
+    {
+        if(!$this->isEnabled())
+            return echoJson([]);
+
+        if($this->isViewAllowed() !== CHECK_ACTION_RESULT_ALLOWED)
+            return echoJson([]);
+
+        $mixedCmtId = bx_process_input(bx_get('Cmt'));
+        $sCmtBrowse = ($sCmtBrowse = bx_get('CmtBrowse')) !== false ? bx_process_input($sCmtBrowse, BX_DATA_TEXT) : '';
+        $sCmtDisplay = ($sCmtDisplay = bx_get('CmtDisplay')) !== false ? bx_process_input($sCmtDisplay, BX_DATA_TEXT) : '';
+
+        $aCmtIds = strpos($mixedCmtId, ',') !== false ? explode(',', $mixedCmtId) : [$mixedCmtId];
+
+        $sContent = '';
+        foreach($aCmtIds as $iCmtId)
+            $sContent .= $this->getComment((int)$iCmtId, ['type' => $sCmtBrowse], ['type' => $sCmtDisplay, 'dynamic_mode' => true]);
+
+        $aCmt = $this->getCommentRow((int)reset($aCmtIds));
+        echoJson([
+            'parent_id' => $aCmt['cmt_parent_id'],
+            'vparent_id' => $aCmt['cmt_parent_id'],
+            'content' => $sContent
+        ]);
+    }
+
+    protected function _getCountersBox(&$aCmt, $aBp = [], $aDp = [])
+    {
+        return '';
+    }
+
+    protected function _getFormBox($sType, $aBp, $aDp)
+    {
+        return parent::_getFormBox($sType, $aBp, array_merge($aDp, [
+            'min_post_form' => false, 
+            'class_body' => $this->_sStylePrefix . '-body-agents'
+        ]));
+    }
+}
+
+/** @} */