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

Ticket #3778 - Add support for icons in form buttons.

AntonLV 1 год назад
Родитель
Сommit
af65f747c1

+ 9 - 7
inc/classes/BxDolTemplate.php

@@ -1982,7 +1982,7 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
             case 'is_profile_page':
                 $sRet = (defined('BX_PROFILE_PAGE')) ? 'true' : 'false';
                 break;
-			case 'system_js_requred':
+            case 'system_js_requred':
                 $sRet = _t('_sys_javascript_requred');
                 break;
             case 'included_css':
@@ -3291,16 +3291,18 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
             return false;
         }
 
-        $aKeys = array_merge($aKeys, array(
+        $aKeys = array_merge($aKeys, [
             "'<bx_menu:([^\s]+) \/>'s",
             "'<bx_url_root />'",
-            "'<bx_url_studio />'"
-        ));
-        $aValues = array_merge($aValues, array(
+            "'<bx_url_studio />'",
+            "'<bx_site_title />'"
+        ]);
+        $aValues = array_merge($aValues, [
             "<?php echo \$this->getMenu('\\1'); ?>",
             BX_DOL_URL_ROOT,
-            BX_DOL_URL_STUDIO
-        ));
+            BX_DOL_URL_STUDIO,
+            getParam('site_title')
+        ]);
 
         //--- Parse Predefined Keys ---//
         $sContent = preg_replace($aKeys, $aValues, $sContent);

+ 4 - 1
template/form_field_button.html

@@ -1 +1,4 @@
-<button __attrs__>__value__</button>
+<button __attrs__>
+    <bx_if:show_icon><u>__icon__</u></bx_if:show_icon>
+    <u>__value__</u>
+</button>

+ 3 - 0
template/form_input_icon.html

@@ -0,0 +1,3 @@
+<bx_if:icon><i class="sys-icon __icon__"></i></bx_if:icon>
+<bx_if:icon-html>__icon__</bx_if:icon-html>
+<bx_if:image_inline>__image__</bx_if:image_inline>

+ 1 - 5
template/form_view_row.html

@@ -1,11 +1,7 @@
 <div class="bx-form-row-view-wrapper bx-form-row-view-wrapper-__type__ __class__ bx-def-padding-sec-top">
     <div class="bx-form-row-view-caption">
         <bx_if:show_icon>
-            <span class="bx-form-row-vc-icon">
-                <bx_if:icon><i class="sys-icon __icon__"></i></bx_if:icon>
-                <bx_if:icon-html>__icon__</bx_if:icon-html>
-                <bx_if:image_inline>__image__</bx_if:image_inline>
-            </span>
+            <span class="bx-form-row-vc-icon">__icon__</span>
         </bx_if:show_icon>
         <span class="bx-form-row-vc-text">__caption__:</span>
     </div>

+ 33 - 16
template/scripts/BxBaseFormView.php

@@ -852,24 +852,10 @@ BLAH;
         $sClassValue = !empty($aParams['class_value']) ? $aParams['class_value'] : '';
 
         $aTmplVarsIcon = [];
-        if(!empty($aInput['icon'])) {
-            list ($sIcon, $sIconUrl, $sIconA, $sIconHtml) = BxTemplFunctions::getInstanceWithTemplate($this->oTemplate)->getIcon($aInput['icon']);
-
+        if(!empty($aInput['icon']))
             $aTmplVarsIcon = [
-                'bx_if:icon' => [
-                    'condition' => (bool)$sIcon,
-                    'content' => ['icon' => $sIcon],
-                ],
-                'bx_if:icon-html' => [
-                    'condition' => (bool)$sIconHtml,
-                    'content' => ['icon' => $sIconHtml],
-                ],
-                'bx_if:image_inline' => [
-                    'condition' => false,
-                    'content' => ['image' => ''],
-                ]
+                'icon' => $this->genIcon($aInput['icon'])
             ];
-        }
 
         return $this->oTemplate->parseHtmlByName('form_view_row.html', [
             'type' => $aInput['type'], 
@@ -1561,8 +1547,16 @@ BLAH;
         if($aInput['type'] == 'submit')
             $sClassAdd .= ' bx-btn-primary';
 
+        $aTmplVarsIcon = [];
+        if(isset($aInput['icon']) && ($sIcon = $this->genIcon($aInput['icon'])))
+            $aTmplVarsIcon = ['icon' => $sIcon];
+
         return $this->oTemplate->parseHtmlByName('form_field_button.html', [
             'attrs' => bx_convert_array2attrs($aAttrs, $sClassAdd),
+            'bx_if:show_icon' => [
+                'condition' => !empty($aTmplVarsIcon),
+                'content' => $aTmplVarsIcon
+            ],
             'value' => $aInput['value']
         ]);
     }
@@ -2403,6 +2397,29 @@ BLAH;
         ]);
     }
 
+    function genIcon($sIcon)
+    {
+        if(!$sIcon)
+            return '';
+
+        list ($sIcon, $sIconUrl, $sIconA, $sIconHtml) = BxTemplFunctions::getInstanceWithTemplate($this->oTemplate)->getIcon($sIcon);
+
+        return $this->oTemplate->parseHtmlByName('form_input_icon.html', [
+            'bx_if:icon' => [
+                'condition' => (bool)$sIcon,
+                'content' => ['icon' => $sIcon],
+            ],
+            'bx_if:icon-html' => [
+                'condition' => (bool)$sIconHtml,
+                'content' => ['icon' => $sIconHtml],
+            ],
+            'bx_if:image_inline' => [
+                'condition' => false,
+                'content' => ['image' => ''],
+            ]
+        ]);
+    }
+
     function genInfoIcon($sInfo)
     {
         return '<div class="bx-form-info bx-def-font-grayed bx-def-font-small mt-1">' . bx_process_output($sInfo, BX_DATA_HTML) . '</div>';