Kaynağa Gözat

Ticket #5388 - Fix profile badge layout in comments.

AntonLV 8 ay önce
ebeveyn
işleme
2974f074d2

+ 0 - 19
modules/boonex/artificer/data/template/system/scripts/BxTemplCmtsMenuUnitMeta.php

@@ -16,25 +16,6 @@ class BxTemplCmtsMenuUnitMeta extends BxBaseCmtsMenuUnitMeta
     {
         parent::__construct ($aObject, $oTemplate);
     }
-    
-    protected function _getMenuItemAuthor($aItem)
-    {
-        list($sAuthorName, $sAuthorLink, $sAuthorIcon, $sAuthorUnit, $sAuthorBadges) = $this->_oCmts->getAuthorInfo($this->_aCmt['cmt_author_id']);
-    
-        $sResult = '';
-        if(!empty($sAuthorLink))
-            $sResult = $this->getUnitMetaItemLink($sAuthorName, array(
-                'href' => $sAuthorLink,
-                'class' => $this->_sStylePrefix . '-username bx-def-font-author whitespace-nowrap hover:underline',
-                'title' => bx_html_attribute($sAuthorName),
-            )). $sAuthorBadges;
-        else
-            $sResult = $this->getUnitMetaItemText($sAuthorName, array(
-                'class' => $this->_sStylePrefix . '-username bx-def-font-author whitespace-nowrap'
-            )). $sAuthorBadges;
-
-        return $sResult;
-    }
 }
 
 /** @} */

+ 9 - 0
template/comment_author.html

@@ -0,0 +1,9 @@
+<span class="__style_prefix__-author flex items-center space-x-1">
+    <bx_if:show_link>
+        <a href="__href__" title="__title__" class="__style_prefix__-username bx-def-font-author whitespace-nowrap hover:underline">__content__</a>
+    </bx_if:show_link>
+    <bx_if:show_text>
+        <span class="__style_prefix__-username bx-def-font-author whitespace-nowrap">__content__</span>
+    </bx_if:show_text>
+    __badges__
+</span>

+ 23 - 13
template/scripts/BxBaseCmtsMenuUnitMeta.php

@@ -70,20 +70,30 @@ class BxBaseCmtsMenuUnitMeta extends BxTemplMenuUnitMeta
     protected function _getMenuItemAuthor($aItem)
     {
         list($sAuthorName, $sAuthorLink, $sAuthorIcon, $sAuthorUnit, $sAuthorBadges) = $this->_oCmts->getAuthorInfo($this->_aCmt['cmt_author_id']);
-    
-        $sResult = '';
-        if(!empty($sAuthorLink))
-            $sResult = $this->getUnitMetaItemLink($sAuthorName, array(
-                'href' => $sAuthorLink,
-                'class' => $this->_sStylePrefix . '-username',
-                'title' => bx_html_attribute($sAuthorName),
-            )). $sAuthorBadges;
-        else
-            $sResult = $this->getUnitMetaItemText($sAuthorName, array(
-                'class' => $this->_sStylePrefix . '-username'
-            )). $sAuthorBadges;
+        $bAuthorLink = !empty($sAuthorLink);
 
-        return $sResult;
+        $sResult = $this->_oTemplate->parseHtmlByName('comment_author.html', [
+            'style_prefix' => $this->_sCmtStylePrefix,
+            'bx_if:show_link' => [
+                'condition' => $bAuthorLink,
+                'content' => [
+                    'style_prefix' => $this->_sCmtStylePrefix,
+                    'href' => $sAuthorLink,
+                    'title' => bx_html_attribute($sAuthorName),
+                    'content' => $sAuthorName
+                ]
+            ],
+            'bx_if:show_text' => [
+                'condition' => !$bAuthorLink,
+                'content' => [
+                    'style_prefix' => $this->_sCmtStylePrefix,
+                    'content' => $sAuthorName
+                ]
+            ],
+            'badges' => $sAuthorBadges
+        ]);
+
+        return $this->getUnitMetaItemCustom($sResult);
     }
 
     protected function _getMenuItemDate($aItem)