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

Ticket #4980 - Studio: Layout changes.

AntonLV 3 месяцев назад
Родитель
Сommit
665ff10d18

+ 13 - 2
studio/template/block_caption.html

@@ -5,8 +5,19 @@
             <bx_repeat:actions>
             	<div class="bx-std-bcap-action-div bx-def-padding-sec-leftright">&bull;</div>
                 <div id="bx-std-bca-__name__" class="bx-std-bcap-action">
-                    <a href="__url__" title="__title__" <bx_if:show_onclick>onclick="__onclick__"</bx_if:show_onclick>>
-                        __caption__
+                    <a class="bx-btn bx-btn-small flex flex-nowrap items-center space-x-1" href="__url__" title="__title__" <bx_if:show_onclick>onclick="__onclick__"</bx_if:show_onclick>>
+                        <bx_if:show_bc_icon>
+                            <div><i class="sys-icon __icon__"></i></div>
+                        </bx_if:show_bc_icon>
+                        <bx_if:show_bc_icon_url>
+                            <div><img class="w-4 h-4" src="__icon_url__" /></div>
+                        </bx_if:show_bc_icon_url>
+                        <bx_if:show_bc_icon_html>
+                            <div>__icon_html__</div>
+                        </bx_if:show_bc_icon_html>
+                        <bx_if:show_bc_text>
+                            <div>__caption__</div>
+                        </bx_if:show_bc_text>
                     </a>
                 </div>
             </bx_repeat:actions>

+ 62 - 19
studio/template/scripts/BxBaseStudioWidget.php

@@ -171,14 +171,18 @@ class BxBaseStudioWidget extends BxDolStudioWidget
             if(!$bWrap || in_array($sPage, $this->aPageCodeNoWrap))
                 $sResult .= $mixedContent;
             else if(is_string($mixedContent))
-                $sResult .= $this->getBlockCode(array(
+                $sResult .= $this->getBlockCode([
                     'content' => $mixedContent
-                ));
-            else if(is_array($mixedContent))
-                foreach($mixedContent as $sBlock)
-                    $sResult .= $this->getBlockCode(array(
-                        'content' => $sBlock
-                    ));
+                ]);
+            else if(is_array($mixedContent)) {
+                if(isset($mixedContent['content']))
+                    $sResult .= $this->getBlockCode($mixedContent);
+                else
+                    foreach($mixedContent as $sBlock)
+                        $sResult .= $this->getBlockCode([
+                            'content' => $sBlock
+                        ]);
+            }
             else if(is_a($mixedContent, 'BxDolPage'))
                 $sResult .= $mixedContent->getCode();
         }
@@ -234,36 +238,75 @@ class BxBaseStudioWidget extends BxDolStudioWidget
     {
         if(empty($aBlock) || !is_array($aBlock) || (empty($aBlock['caption']) && empty($aBlock['actions'])))
             return '';
+        
+        $oTemplate = BxDolStudioTemplate::getInstance();
 
         $aTmplActions = array();
         if(!empty($aBlock['actions']) && is_array($aBlock['actions']))
             foreach($aBlock['actions'] as $aAction) {
+                $aTmplVarsIcon = $aTmplVarsIconUrl = $aTmplVarsIconHtml = [];
+                if(($sIcon = $aAction['icon'] ?? false)) {
+                    list($sIcon, $sIconUrl, $sIconA, $sIconHtml) = $oTemplate->getTemplateFunctions()->getIcon($sIcon);
+                    
+                    if($sIcon)
+                        $aTmplVarsIcon = [
+                            'icon' => BxDolIconset::getObjectInstance()->getIcon($sIcon)
+                        ];
+                    else if($sIconUrl)
+                        $aTmplVarsIconUrl = [
+                            'icon_url' => $sIconUrl,
+                        ];
+                    else if($sIconHtml)
+                        $aTmplVarsIconHtml = [
+                            'icon_html' => $sIconHtml
+                        ];
+                }
+
                 $sCaption = is_array($aAction['caption']) ? call_user_func_array('_t', $aAction['caption']) : _t($aAction['caption']);
+                $bTitleOnly = $aAction['title_only'] ?? false;
 
                 $bOnClick = !empty($aAction['onclick']);
                 $aOnClick = $bOnClick ? array('onclick' => $aAction['onclick']) : array();
 
-                $aTmplActions[] = array(
+                $aTmplActions[] = [
                     'name' => $aAction['name'],
                     'url' => $aAction['url'],
-                    'title' => $sCaption,
-                    'bx_if:show_onclick' => array(
+                    'title' => bx_html_attribute($sCaption),
+                    'bx_if:show_onclick' => [
                         'condition' => $bOnClick,
                         'content' => $aOnClick
-                    ),
-                    'caption' => $sCaption
-                );
+                    ],
+                    'bx_if:show_bc_icon' => [
+                        'condition' => !empty($aTmplVarsIcon),
+                        'content' => $aTmplVarsIcon
+                    ],
+                    'bx_if:show_bc_icon_url' => [
+                        'condition' => !empty($aTmplVarsIconUrl),
+                        'content' => $aTmplVarsIconUrl
+                    ],
+                    'bx_if:show_bc_icon_html' => [
+                        'condition' => !empty($aTmplVarsIconHtml),
+                        'content' => $aTmplVarsIconHtml
+                    ],
+                    'bx_if:show_bc_text' => [
+                        'condition' => (bool)$sCaption && !$bTitleOnly,
+                        'content' => [
+                            'caption' => $sCaption
+                        ]
+                    ],
+                    
+                ];
             }
 
-        return BxDolStudioTemplate::getInstance()->parseHtmlByName('block_caption.html', array(
+        return $oTemplate->parseHtmlByName('block_caption.html', [
             'caption' => is_array($aBlock['caption']) ? call_user_func_array('_t', $aBlock['caption']) : _t($aBlock['caption']),
-            'bx_if:show_actions' => array(
+            'bx_if:show_actions' => [
                 'condition' => !empty($aTmplActions),
-                'content' => array(
+                'content' => [
                     'bx_repeat:actions' => $aTmplActions
-                )
-            ),
-        ));
+                ]
+            ],
+        ]);
     }
 
     public function getBlockPanelTop($aBlock)

+ 1 - 0
template/css/tailwind.css

@@ -469,6 +469,7 @@
     }
 
     /* Borders */
+    .bx-std .bx-def-border,
     .bx-artificer .bx-def-border {
         @apply border border-gray-200 dark:border-gray-700;
     }