Răsfoiți Sursa

Ticket #5186 - Tasks: Functionality improvements. Point 4.

AntonLV 11 luni în urmă
părinte
comite
fc5bcfc65c

+ 5 - 15
template/comment.html

@@ -4,24 +4,14 @@
         <div class="__style_prefix__-blink-plate"></div>
         <div class="__style_prefix__-blink-plate"></div>
         <div class="__style_prefix__-avatar bx-def-thumb-size flex-none">__author_unit__</div>
         <div class="__style_prefix__-avatar bx-def-thumb-size flex-none">__author_unit__</div>
         <div class="__style_prefix__-info bx-def-thumb-size-min-height flex-auto min-w-0 ltr:pl-2 ltr:lg:pl-4 rtl:pr-2 rtl:lg:pr-4">
         <div class="__style_prefix__-info bx-def-thumb-size-min-height flex-auto min-w-0 ltr:pl-2 ltr:lg:pl-4 rtl:pr-2 rtl:lg:pr-4">
-            <bx_if:show_notes>
-                <div class="__style_prefix__-notes mb-1">
-                    <bx_repeat:notes>
-                        <div class="__style_prefix__-note mt-1 first:mt-0 text-sm text-gray-500 dark:text-gray-400">
-                            <div class="__style_prefix__-n-text<bx_if:show_note_color> col-__item_note_color__</bx_if:show_note_color>">__item_note__</div>
-                        </div>
-                    </bx_repeat:notes>
-                </div>
-            </bx_if:show_notes>
-            <div class="__style_prefix__-head flex">
-                <bx_if:meta><span class="__style_prefix__-meta bx-base-general-unit-meta">__meta__</span></bx_if:meta>
-                <bx_if:show_pinned><span class="__style_prefix__-pinned ml-2"><i class="sys-icon thumbtack" title="<bx_text:_cmt_txt_pinned />"></i></span></bx_if:show_pinned>
-            </div>
+            __header__
             <div class="__style_prefix__-cont mt-2">
             <div class="__style_prefix__-cont mt-2">
                 <div class="__style_prefix__-cont-cnt">__content__</div>
                 <div class="__style_prefix__-cont-cnt">__content__</div>
             </div>
             </div>
             __actions__
             __actions__
         </div>
         </div>
     </div>
     </div>
-    <ul class="cmts cmts-all cmts-margin">__replies__</ul>
-</li>
+    <bx_if:show_replies>
+        <ul class="cmts cmts-all cmts-margin">__replies__</ul>
+    </bx_if:show_replies>
+</li>

+ 3 - 1
template/comment_content.html

@@ -5,4 +5,6 @@
 <bx_if:show_attached>
 <bx_if:show_attached>
     <div class="__style_prefix__-attached bx-clearfix -mx-1 -mb-1">__attached__</div>
     <div class="__style_prefix__-attached bx-clearfix -mx-1 -mb-1">__attached__</div>
 </bx_if:show_attached>
 </bx_if:show_attached>
-<div class="__style_prefix__-counters -mx-1 mt-1">__counters__</div>
+<bx_if:show_counters>
+    <div class="__style_prefix__-counters -mx-1 mt-1">__counters__</div>
+</bx_if:show_counters>

+ 13 - 0
template/comment_header.html

@@ -0,0 +1,13 @@
+<bx_if:show_notes>
+    <div class="__style_prefix__-notes mb-1">
+        <bx_repeat:notes>
+            <div class="__style_prefix__-note mt-1 first:mt-0 text-sm text-gray-500 dark:text-gray-400">
+                <div class="__style_prefix__-n-text<bx_if:show_note_color> col-__item_note_color__</bx_if:show_note_color>">__item_note__</div>
+            </div>
+        </bx_repeat:notes>
+    </div>
+</bx_if:show_notes>
+<div class="__style_prefix__-head flex">
+    <bx_if:meta><span class="__style_prefix__-meta bx-base-general-unit-meta">__meta__</span></bx_if:meta>
+    <bx_if:show_pinned><span class="__style_prefix__-pinned ml-2"><i class="sys-icon thumbtack" title="<bx_text:_cmt_txt_pinned />"></i></span></bx_if:show_pinned>
+</div>

+ 75 - 56
template/scripts/BxBaseCmts.php

@@ -432,26 +432,8 @@ class BxBaseCmts extends BxDolCmts
         if(!empty($aDp['class_comment_content']))
         if(!empty($aDp['class_comment_content']))
             $sClassCnt .= ' ' . $aDp['class_comment_content'];
             $sClassCnt .= ' ' . $aDp['class_comment_content'];
 
 
-        $sActions = $this->_getActionsBox($aCmt, $aBp, $aDp);
-
-        $aTmplReplyTo = array();
-        if((int)$aCmt['cmt_parent_id'] != 0) {
-            $aParent = $this->getCommentRow($aCmt['cmt_parent_id']);
-
-            if(!empty($aParent) && is_array($aParent)) {
-                $oProfile = $this->_getAuthorObject($aParent['cmt_author_id']);
-                $sParAuthorName = $oProfile->getDisplayName();
-                $sParAuthorUnit = $oProfile->getUnit(0, array('template' => array('name' => 'unit_wo_info_links', 'size' => 'icon')));
-
-                $aTmplReplyTo = array(
-                    'style_prefix' => $this->_sStylePrefix,
-                    'par_cmt_link' => $this->getItemUrl($aCmt['cmt_parent_id']),
-                    'par_cmt_title' => bx_html_attribute(_t('_in_reply_to_x', $sParAuthorName)),
-                    'par_cmt_author' => $sParAuthorName,
-                    'par_cmt_author_unit' => $sParAuthorUnit
-                );
-            }
-        }
+        $sHeader = $this->_getHeaderBox($aCmt, $aBp, $aDp);
+        $sActions = $this->_getActionsBox($aCmt, $aBp, $aDp);        
 
 
         $sReplies = '';
         $sReplies = '';
         if(!(isset($aBp['pinned']) && (int)$aBp['pinned'] != 0 && (int)$aCmt['cmt_pinned'] != 0) && !empty($aDp)) {
         if(!(isset($aBp['pinned']) && (int)$aBp['pinned'] != 0 && (int)$aCmt['cmt_pinned'] != 0) && !empty($aDp)) {
@@ -467,19 +449,6 @@ class BxBaseCmts extends BxDolCmts
                 $sReplies = $this->getComments(['parent_id' => $aCmt['cmt_id'], 'vparent_id' => $aCmt['cmt_id'], 'type' => $aBp['type'], 'order_way' => BX_CMT_ORDER_WAY_ASC], $aDp);
                 $sReplies = $this->getComments(['parent_id' => $aCmt['cmt_id'], 'vparent_id' => $aCmt['cmt_id'], 'type' => $aBp['type'], 'order_way' => BX_CMT_ORDER_WAY_ASC], $aDp);
         }
         }
 
 
-        $aTmplVarsMeta = array();
-        if(!empty($this->_sMenuObjMeta)) {
-            $oMenuMeta = BxDolMenu::getObjectInstance($this->_sMenuObjMeta, $this->_oTemplate);
-            if($oMenuMeta) {
-                $oMenuMeta->setCmtsData($this, $aCmt['cmt_id']);
-
-                $aTmplVarsMeta = array(
-                    'style_prefix' => $this->_sStylePrefix,
-                    'meta' => $oMenuMeta->getCode()
-                );
-            }
-        }
-
         if($this->_isShowContent($aCmt)) {
         if($this->_isShowContent($aCmt)) {
             $sContent = $this->_getContent($aCmt, $aBp, $aDp);
             $sContent = $this->_getContent($aCmt, $aBp, $aDp);
         }
         }
@@ -488,7 +457,7 @@ class BxBaseCmts extends BxDolCmts
             $sContent = _t('_hidden_comment', BxDolProfileUndefined::getInstance()->getDisplayName());
             $sContent = _t('_hidden_comment', BxDolProfileUndefined::getInstance()->getDisplayName());
         }
         }
 
 
-        $aVars = array_merge(array(
+        $aVars = array_merge([
             'system' => $this->_sSystem,
             'system' => $this->_sSystem,
             'style_prefix' => $this->_sStylePrefix,
             'style_prefix' => $this->_sStylePrefix,
             'js_object' => $this->_sJsObjName,
             'js_object' => $this->_sJsObjName,
@@ -496,24 +465,17 @@ class BxBaseCmts extends BxDolCmts
             'anchor' => $this->getItemAnchor($aCmt['cmt_id']),
             'anchor' => $this->getItemAnchor($aCmt['cmt_id']),
             'class' => $sClass,
             'class' => $sClass,
             'class_cnt' => $sClassCnt,
             'class_cnt' => $sClassCnt,
-            'bx_if:show_reply_to' => array(
-                'condition' => !empty($aTmplReplyTo),
-                'content' => $aTmplReplyTo
-            ),
-            'bx_if:meta' => array(
-                'condition' => !empty($aTmplVarsMeta),
-                'content' => $aTmplVarsMeta
-            ),
-            'bx_if:show_pinned' => array(
-                'condition' => (int)$aCmt['cmt_pinned'] > 0,
-                'content' => array(
-                    'style_prefix' => $this->_sStylePrefix,
-                )
-            ),
+            'header' => $sHeader,
             'content' => $sContent,
             'content' => $sContent,
             'actions' => $sActions,
             'actions' => $sActions,
-            'replies' =>  $sReplies,
-        ), $this->_getTmplVarsAuthor($aCmt), $this->_getTmplVarsNotes($aCmt));
+            'bx_if:show_replies' => [
+                'condition' => !empty($sReplies),
+                'content' => [
+                    'style_prefix' => $this->_sStylePrefix,
+                    'replies' =>  $sReplies,
+                ]
+            ],
+        ], $this->_getTmplVarsAuthor($aCmt));
         
         
         $sResult = $this->_oTemplate->parseHtmlByName($this->_sTmplNameItem, $aVars);
         $sResult = $this->_oTemplate->parseHtmlByName($this->_sTmplNameItem, $aVars);
         
         
@@ -1104,6 +1066,56 @@ class BxBaseCmts extends BxDolCmts
         ));
         ));
     }
     }
 
 
+    protected function _getHeaderBox(&$aCmt, $aBp = [], $aDp = [])
+    {
+        $aTmplReplyTo = [];
+        if((int)$aCmt['cmt_parent_id'] != 0) {
+            $aParent = $this->getCommentRow($aCmt['cmt_parent_id']);
+
+            if(!empty($aParent) && is_array($aParent)) {
+                $oProfile = $this->_getAuthorObject($aParent['cmt_author_id']);
+                $sParAuthorName = $oProfile->getDisplayName();
+                $sParAuthorUnit = $oProfile->getUnit(0, ['template' => ['name' => 'unit_wo_info_links', 'size' => 'icon']]);
+
+                $aTmplReplyTo = [
+                    'style_prefix' => $this->_sStylePrefix,
+                    'par_cmt_link' => $this->getItemUrl($aCmt['cmt_parent_id']),
+                    'par_cmt_title' => bx_html_attribute(_t('_in_reply_to_x', $sParAuthorName)),
+                    'par_cmt_author' => $sParAuthorName,
+                    'par_cmt_author_unit' => $sParAuthorUnit
+                ];
+            }
+        }
+
+        $aTmplVarsMeta = [];
+        if(!empty($this->_sMenuObjMeta) && ($oMenuMeta = BxDolMenu::getObjectInstance($this->_sMenuObjMeta, $this->_oTemplate)) !== false) {
+            $oMenuMeta->setCmtsData($this, $aCmt['cmt_id']);
+
+            $aTmplVarsMeta = [
+                'style_prefix' => $this->_sStylePrefix,
+                'meta' => $oMenuMeta->getCode()
+            ];
+        }
+
+        return $this->_oTemplate->parseHtmlByName('comment_header.html', array_merge([
+            'style_prefix' => $this->_sStylePrefix,
+            'bx_if:show_reply_to' => [
+                'condition' => !empty($aTmplReplyTo),
+                'content' => $aTmplReplyTo
+            ],
+            'bx_if:meta' => [
+                'condition' => !empty($aTmplVarsMeta),
+                'content' => $aTmplVarsMeta
+            ],
+            'bx_if:show_pinned' => [
+                'condition' => (int)$aCmt['cmt_pinned'] > 0,
+                'content' => [
+                    'style_prefix' => $this->_sStylePrefix,
+                ]
+            ],
+        ], $this->_getTmplVarsNotes($aCmt)));
+    }
+
     protected function _getActionsBox(&$aCmt, $aBp = [], $aDp = [])
     protected function _getActionsBox(&$aCmt, $aBp = [], $aDp = [])
     {
     {
     	$bViewOnly = isset($aDp['view_only']) && $aDp['view_only'] === true;
     	$bViewOnly = isset($aDp['view_only']) && $aDp['view_only'] === true;
@@ -1506,18 +1518,25 @@ class BxBaseCmts extends BxDolCmts
     protected function _getContent($aCmt, $aBp = [], $aDp = [])
     protected function _getContent($aCmt, $aBp = [], $aDp = [])
     {
     {
         $sAttachments = $this->_getAttachments($aCmt);
         $sAttachments = $this->_getAttachments($aCmt);
+        $sCounters = $this->_getCountersBox($aCmt, $aBp, $aDp);
 
 
         return $this->_oTemplate->parseHtmlByName($this->_sTmplNameItemContent, array_merge(array(
         return $this->_oTemplate->parseHtmlByName($this->_sTmplNameItemContent, array_merge(array(
             'style_prefix' => $this->_sStylePrefix,
             'style_prefix' => $this->_sStylePrefix,
             'js_object' => $this->_sJsObjName,
             'js_object' => $this->_sJsObjName,
-            'bx_if:show_attached' => array(
+            'bx_if:show_attached' => [
                 'condition' => !empty($sAttachments),
                 'condition' => !empty($sAttachments),
-                'content' => array(
+                'content' => [
                     'style_prefix' => $this->_sStylePrefix,
                     'style_prefix' => $this->_sStylePrefix,
                     'attached' => $sAttachments
                     'attached' => $sAttachments
-                )
-            ),
-            'counters' => $this->_getCountersBox($aCmt, $aBp, $aDp),
+                ]
+            ],
+            'bx_if:show_counters' => [
+                'condition' => !empty($sCounters),
+                'content' => [
+                    'style_prefix' => $this->_sStylePrefix,
+                    'counters' => $sCounters,
+                ]
+            ]
         ), $this->_getTmplVarsText($aCmt)));
         ), $this->_getTmplVarsText($aCmt)));
     }
     }
 
 
@@ -1602,7 +1621,7 @@ class BxBaseCmts extends BxDolCmts
             return ''; 
             return ''; 
 
 
         $aFiles = $this->_oQuery->getFiles($this->_aSystem['system_id'], $aCmt['cmt_id']);
         $aFiles = $this->_oQuery->getFiles($this->_aSystem['system_id'], $aCmt['cmt_id']);
-        if(!empty($aFiles) && is_array($aFiles)) {
+        if(!empty($aFiles) && is_array($aFilecounterss)) {
             $oStorage = BxDolStorage::getObjectInstance($this->getStorageObjectName());
             $oStorage = BxDolStorage::getObjectInstance($this->getStorageObjectName());
             $oTranscoder = BxDolTranscoderImage::getObjectInstance($this->getTranscoderPreviewName());
             $oTranscoder = BxDolTranscoderImage::getObjectInstance($this->getTranscoderPreviewName());