Преглед изворни кода

Ticket #4747 - Allow to overwrite main logo.

AntonLV пре 2 година
родитељ
комит
f35ccd2193

+ 4 - 4
modules/boonex/artificer/data/template/system/logo_main.html

@@ -1,9 +1,9 @@
 <a __attrs__>
     <bx_if:show_title><span>__logo__</span></bx_if:show_title>
-    <bx_if:show_logo><img class="__class__" style="__style__" src="__src__" id="bx-logo" alt="__alt__" /></bx_if:show_logo>
-    <bx_if:show_logo_dark><img class="__class__" style="__style__" src="__src__" id="bx-logo-dark" alt="__alt__" /></bx_if:show_logo_dark>
+    <bx_if:show_logo><img class="__class__" style="__style__" src="__src__" id="__id__" alt="__alt__" /></bx_if:show_logo>
+    <bx_if:show_logo_dark><img class="__class__" style="__style__" src="__src__" id="__id__" alt="__alt__" /></bx_if:show_logo_dark>
     <bx_if:show_logo_inline><span class="bx-logo-inline __class__" style="height: __height__">__content__</span></bx_if:show_logo_inline>
-    <bx_if:show_mark><img class="__class__" style="__style__" src="__src__" id="bx-mark" alt="__alt__" /></bx_if:show_mark>
-    <bx_if:show_mark_dark><img class="__class__" style="__style__" src="__src__" id="bx-mark-dark" alt="__alt__" /></bx_if:show_mark_dark>
+    <bx_if:show_mark><img class="__class__" style="__style__" src="__src__" id="__id__" alt="__alt__" /></bx_if:show_mark>
+    <bx_if:show_mark_dark><img class="__class__" style="__style__" src="__src__" id="__id__" alt="__alt__" /></bx_if:show_mark_dark>
     <bx_if:show_mark_inline><span class="bx-logo-inline __class__" style="height: __height__">__content__</span></bx_if:show_mark_inline>
 </a>

+ 10 - 3
modules/boonex/artificer/data/template/system/scripts/BxTemplFunctions.php

@@ -78,10 +78,11 @@ class BxTemplFunctions extends BxBaseFunctions
                 $sLogoWidth = $iLogoWidth > 0 ? 'width:' . round($iLogoWidth/16, 3) . 'rem;' : '';
 
                 $aTmplVarsImages[$sType] = [
+                    'id' => 'bx-' . str_replace('_', '-', $sType),
+                    'src' => $sFileUrl,
+                    'alt' => $sAltAttr,
                     'class' => '',
                     'style' => $sLogoWidth . ' ' . $sLogoHeight,
-                    'src' => $sFileUrl,
-                    'alt' => $sAltAttr
                 ];
 
                 ${'b' . $aParams['uc']} = true;
@@ -141,6 +142,7 @@ class BxTemplFunctions extends BxBaseFunctions
         if(!empty($aParams['attrs']) && is_array($aParams['attrs']))
             $aAttrs = array_merge($aAttrs, $aParams['attrs']);
 
+        $sTmplName = 'logo_main.html';
         $aTmplVars = [
             'attrs' => bx_convert_array2attrs($aAttrs),
             'bx_if:show_title' => [
@@ -180,7 +182,12 @@ class BxTemplFunctions extends BxBaseFunctions
                 ];
         }
 
-        return $this->_oTemplate->parseHtmlByName('logo_main.html', $aTmplVars);
+        bx_alert('system', 'get_logo', 0, 0, [
+            'tmpl_name' => &$sTmplName,
+            'tmpl_vars' => &$aTmplVars
+        ]);
+
+        return $this->_oTemplate->parseHtmlByName($sTmplName, $aTmplVars);
     }
 
     public function TemplPageAddComponent($sKey)

+ 8 - 0
template/logo_main.html

@@ -0,0 +1,8 @@
+<a __attrs__>
+    <bx_if:show_title><span>__logo__</span></bx_if:show_title>
+    <bx_if:show_logo>
+        <bx_repeat:images>
+            <img id="__id__" src="__src__" alt="__alt__" style="__style__" />
+        </bx_repeat:images>
+    </bx_if:show_logo>
+</a>

+ 31 - 4
template/scripts/BxBaseFunctions.php

@@ -551,8 +551,7 @@ class BxBaseFunctions extends BxDolFactory implements iBxDolSingleton
         if(empty($sAlt))
             $sAlt = getParam('site_title');
 
-        $sLogo = '<span>' . $sAlt . '</span>';
-
+        $aLogoImages = [];
         if(($mixedFileUrl = $this->getMainLogoUrl()) && !empty($mixedFileUrl)) {
             if(!is_array($mixedFileUrl))
                 $mixedFileUrl = ['light' => $mixedFileUrl];
@@ -564,9 +563,15 @@ class BxBaseFunctions extends BxDolFactory implements iBxDolSingleton
                 $iLogoHeight = (int)$oDesigns->getSiteLogoHeight();
                 $sHeight = $iLogoHeight > 0 ? 'height:' . round($iLogoHeight/16, 3) . 'rem;' : '';
 
-                $sLogo = '<img style="' . $sWidth . ' ' . $sHeight . '" src="' . $sFileUrl . '" id="bx-logo" alt="' . bx_html_attribute($sAlt, BX_ESCAPE_STR_QUOTE) . '" />';
+                $aLogoImages[] = [
+                    'id' => 'bx-logo', 
+                    'src' => $sFileUrl, 
+                    'alt' => bx_html_attribute($sAlt, BX_ESCAPE_STR_QUOTE),
+                    'style' => $sWidth . ' ' . $sHeight
+                ];
             }
         }
+        $bLogoImages = !empty($aLogoImages) && is_array($aLogoImages);
 
         $aAttrs = array(
             'class' => 'bx-def-font-contrasted',
@@ -576,7 +581,29 @@ class BxBaseFunctions extends BxDolFactory implements iBxDolSingleton
         if(!empty($aParams['attrs']) && is_array($aParams['attrs']))
             $aAttrs = array_merge($aAttrs, $aParams['attrs']);
 
-        return '<a' . bx_convert_array2attrs($aAttrs) . '>' . $sLogo . '</a>';
+        $sTmplName = 'logo_main.html';
+        $aTmplVars = [
+            'attrs' => bx_convert_array2attrs($aAttrs),
+             'bx_if:show_title' => [
+                'condition' => !$bLogoImages,
+                'content' => [
+                    'logo' => $sAlt,
+                ]
+            ],
+            'bx_if:show_logo' => [
+                'condition' => $bLogoImages,
+                'content' => [
+                    'bx_repeat:images' => $aLogoImages,
+                ]
+            ],
+        ];
+
+        bx_alert('system', 'get_logo', 0, 0, [
+            'tmpl_name' => &$sTmplName,
+            'tmpl_vars' => &$aTmplVars
+        ]);
+
+        return $this->_oTemplate->parseHtmlByName($sTmplName, $aTmplVars);
     }
 
     /**