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

Ticket #4139 - Ads: Issues with Reviews.

AntonLV 3 лет назад
Родитель
Сommit
59b6b7c145

+ 7 - 4
inc/classes/BxDolCmts.php

@@ -1532,7 +1532,7 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
         return echoJson($aSiblings);
     }
 
-    public function onPostAfter($iCmtId)
+    public function onPostAfter($iCmtId, $aDp = [])
     {
         $iObjId = (int)$this->getId();
 
@@ -1562,12 +1562,15 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
         return array('id' => $iCmtId, 'parent_id' => $iCmtPrntId);
     }
 
-    public function onEditAfter($iCmtId)
+    public function onEditAfter($iCmtId, $aDp = [])
     {
     	$aCmt = $this->getCommentRow($iCmtId);
         if(empty($aCmt) || !is_array($aCmt))
             return false;
 
+        $aBp = [];
+        $this->_getParams($aBp, $aDp);
+
         $iObjId = (int)$this->getId();
         $iPerformerId = $this->_getAuthorId();
 
@@ -1575,10 +1578,10 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
         bx_alert($this->_sSystem, 'commentUpdated', $iObjId, $iPerformerId, $aAlertParams);
         bx_alert('comment', 'edited', $iCmtId, $iPerformerId, $aAlertParams);
 
-        $aAuditParams = $this->_prepareAuditParams($iCmtId, array('comment_author_id' => $aCmt['cmt_author_id'], 'comment_text' => $aCmt['cmt_text']));
+        $aAuditParams = $this->_prepareAuditParams($iCmtId, ['comment_author_id' => $aCmt['cmt_author_id'], 'comment_text' => $aCmt['cmt_text']]);
         bx_audit($iObjId, $this->_aSystem['module'], '_sys_audit_action_edit_comment', $aAuditParams);
 
-        return array('id' => $iCmtId, 'content' => $this->_getContent($aCmt));
+        return ['id' => $iCmtId, 'content' => $this->_getContent($aCmt, $aBp, $aDp)];
     }
 
     public function serviceGetAuthor ($iContentId)

+ 4 - 4
inc/classes/BxDolCmtsReviews.php

@@ -147,18 +147,18 @@ class BxDolCmtsReviews extends BxTemplCmts
         return $this->_oQuery->getReviewAuthorId($this->getId(), $mixedCmt);
     }
 
-    public function onEditAfter($iCmtId)
+    public function onEditAfter($iCmtId, $aDp = [])
     {
-        $mixedResult = parent::onEditAfter($iCmtId);
+        $mixedResult = parent::onEditAfter($iCmtId, $aDp);
         if($mixedResult === false)
             return $mixedResult;
 
         $aCmt = $this->getCommentSimple($iCmtId);
 
-        return array_merge($mixedResult, array(
+        return array_merge($mixedResult, [
             'mood' => (int)$aCmt['cmt_mood'],
             'mood_legend_id' => $this->getMoodLegendId($iCmtId)
-        ));
+        ]);
     }
 
     protected function _triggerComment()

+ 2 - 2
modules/boonex/forum/classes/BxForumCmts.php

@@ -58,11 +58,11 @@ class BxForumCmts extends BxTemplCmts
     	return parent::isPostAllowed($isPerformAction);
     }
 
-    public function onPostAfter($iId)
+    public function onPostAfter($iId, $aDp = [])
     {
         $CNF = &$this->_oModule->_oConfig->CNF;
 
-        $mixedResult = parent::onPostAfter($iId);
+        $mixedResult = parent::onPostAfter($iId, $aDp);
         if($mixedResult === false)
             return $mixedResult;
 

+ 2 - 2
modules/boonex/timeline/classes/BxTimelineCmts.php

@@ -24,11 +24,11 @@ class BxTimelineCmts extends BxTemplCmts
         $this->_aSystem['trigger_field_privacy_view'] = 'object_privacy_view';
     }
     
-    public function onPostAfter($iCmtId)
+    public function onPostAfter($iCmtId, $aDp = [])
     {
         $CNF = &$this->_oModule->_oConfig->CNF;
 
-        $mixedResult = parent::onPostAfter($iCmtId);
+        $mixedResult = parent::onPostAfter($iCmtId, $aDp);
         if($mixedResult !== false)
             $this->_oModule->_oDb->updateEvent([$CNF['FIELD_REACTED'] => time()], [$CNF['FIELD_ID'] => $this->getId()]);
 

+ 3 - 1
template/review_mood_form_field.html

@@ -14,6 +14,8 @@
 </div>
 <bx_if:show_init>
     <script language="javascript">
-        __js_object__.cmtInitRating($('#__form_id__ .__style_prefix__-rating-element'));
+        $(document).ready(function() {
+            __js_object__.cmtInitRating($('#__form_id__ .__style_prefix__-rating-element'));
+        });
     </script>
 </bx_if:show_init>

+ 3 - 1
template/review_mood_legend.html

@@ -10,6 +10,8 @@
 </div>
 <bx_if:show_init>
     <script language="javascript">
-        __js_object__.cmtInitRating($('#__html_id__'));
+        $(document).ready(function() {
+            __js_object__.cmtInitRating($('#__html_id__'));
+        });
     </script>
 </bx_if:show_init>

+ 4 - 4
template/scripts/BxBaseCmts.php

@@ -1090,7 +1090,7 @@ class BxBaseCmts extends BxDolCmts
         return $mixedResult;
     }
 
-    protected function _getFormPost($iCmtParentId = 0, $aDp = array())
+    protected function _getFormPost($iCmtParentId = 0, $aDp = [])
     {
         $bCmtParentId = !empty($iCmtParentId);
         if(!$bCmtParentId && !$this->isPostAllowed())
@@ -1176,7 +1176,7 @@ class BxBaseCmts extends BxDolCmts
                 if($this->_sMetatagsObj && ($oMetatags = BxDolMetatags::getObjectInstance($this->_sMetatagsObj)) !== false)
                     $oMetatags->metaAdd($iCmtUniqId, $sCmtText);
 
-                if(($mixedResult = $this->onPostAfter($iCmtId)) !== false)
+                if(($mixedResult = $this->onPostAfter($iCmtId, $aDp)) !== false)
                     return $mixedResult;
             }
 
@@ -1186,7 +1186,7 @@ class BxBaseCmts extends BxDolCmts
         return array('form' => $oForm->getCode($bDynamic), 'form_id' => $oForm->id);
     }
 
-    protected function _getFormEdit($iCmtId, $aDp = array())
+    protected function _getFormEdit($iCmtId, $aDp = [])
     {
         $bDynamic = isset($aDp['dynamic_mode']) && (bool)$aDp['dynamic_mode'];
 
@@ -1221,7 +1221,7 @@ class BxBaseCmts extends BxDolCmts
                 if($this->_sMetatagsObj && ($oMetatags = BxDolMetatags::getObjectInstance($this->_sMetatagsObj)) !== false)
                     $oMetatags->metaAdd($iCmtUniqId, $sCmtText);
 
-                if(($mixedResult = $this->onEditAfter($iCmtId)) !== false)
+                if(($mixedResult = $this->onEditAfter($iCmtId, $aDp)) !== false)
                     return $mixedResult;
             }
 

+ 15 - 0
template/scripts/BxBaseCmtsReviews.php

@@ -102,6 +102,21 @@ class BxBaseCmtsReviews extends BxDolCmtsReviews
         return $oForm;
     }
 
+    protected function _getContent($aCmt, $aBp = [], $aDp = [])
+    {
+        $sMood = $this->_getMood($aCmt, $aDp);
+        $sContent = parent::_getContent($aCmt, $aBp, $aDp);
+        return $this->_oTemplate->parseHtmlByContent($sContent, [
+            'bx_if:show_mood' => [
+                'condition' => !empty($sMood),
+                'content' => [
+                    'style_prefix' => $this->_sStylePrefix,
+                    'mood' => $sMood
+                ]
+            ]
+        ]);
+    }
+
     protected function _getMood(&$aCmt, $aDp = array())
     {
         if(!is_array($aCmt))