Procházet zdrojové kódy

Ticket #5472 - Pages: Add Description and Icon fields for a block.

AntonLV před 5 měsíci
rodič
revize
43c45b252e

+ 3 - 9
install/sql/system.sql

@@ -6338,6 +6338,8 @@ CREATE TABLE IF NOT EXISTS `sys_pages_blocks` (
   `module` varchar(32) NOT NULL,
   `title_system` varchar(255) NOT NULL,
   `title` varchar(255) NOT NULL,
+  `description` varchar(255) NOT NULL DEFAULT '',
+  `icon` text NOT NULL,
   `designbox_id` int(11) NOT NULL DEFAULT '11',
   `class` varchar(128) NOT NULL DEFAULT '',
   `submenu` varchar(64) NOT NULL DEFAULT '',
@@ -7316,12 +7318,6 @@ INSERT INTO `sys_agents_tools` (`type`, `title`, `docs`, `params`, `params_user`
 ('mysql_select', 'MySQL Select', 'Use this tool to make your agent able to run SELECT query against the database. It''s like read-only access without ability to change anything in the DB. It works the best in par of MySQL Schema tool.  \r\nNo parameters are needed for this tool.', '{}', NULL, 0, 0, 1, '', ''),
 ('mysql_write', 'MySQL Write', 'Use this tool to make your agent able to performs write operations against the database (INSERT, UPDATE, DELETE). It works the best in par of MySQL Schema tool.   \r\nNo parameters are needed for this tool.  \r\n**USE WITH CAUTION**', '{}', NULL, 0, 0, 0, '', ''),
 
-('tavily_web_search', 'Tavily Web Search', 'This tool makes your Agent able to search the web. It requires Tavily API key - https://tavily.com/', '{\"key\":"TAVILY_API_KEY_HERE"}', NULL, 0, 0, 1, '', ''),
-('tavily_extract', 'Tavily Extract URL', 'This tool makes your Agent to extract web page content from an URL. It requires Tavily API key - https://tavily.com/', '{\"key\":"TAVILY_API_KEY_HERE"}', NULL, 0, 0, 1, '', ''),
-
-('jina_web_search', 'Jina Web Search', 'This tool makes your Agent able to search the web. It requires Jina API key - https://jina.ai/', '{\"key\":"JINA_API_KEY_HERE"}', NULL, 0, 0, 1, '', ''),
-('jina_url_reader', 'Jina URL Reader', 'This tool makes your Agent to extract web page content from an URL. It requires Jina API key - https://jina.ai/', '{\"key\":"JINA_API_KEY_HERE"}', NULL, 0, 0, 1, '', ''),
-
 ('content_structure', 'Content modules structure', 'This tool allows agents to understand the structure of content modules fields,  allowing them to call content adding and editing with correct data. It provide knowledge of what content modules are available and what the fields in them, event if fields are changed in fields builder.', '{}', NULL, 0, 0, 1, 'BxDolAIToolContentStructure', ''),
 ('content_get', 'Content modules get', 'This tool allows agents to get info about specific content by module name and content id.', '{}', NULL, 0, 0, 1, 'BxDolAIToolContentGet', ''),
 ('content_search', 'Content modules search', 'This tool allows agents to search for content items based on a keyword and optional sections.', '{}', NULL, 0, 0, 1, 'BxDolAIToolContentSearch', ''),
@@ -7332,9 +7328,7 @@ INSERT INTO `sys_agents_tools` (`type`, `title`, `docs`, `params`, `params_user`
 ('comments_get', 'Comments get', 'This tool allows agents to get comments for specific content by module name and content id.', '{}', NULL, 0, 0, 1, 'BxDolAIToolCmtsGet', ''),
 ('comments_add', 'Comments add', 'This tool allows agents to post comments for specific content.', '{}', NULL, 0, 0, 1, 'BxDolAIToolCmtsAdd', ''),
 ('comments_update', 'Comments update', 'This tool allows agents to edit comments.', '{}', NULL, 0, 0, 1, 'BxDolAIToolCmtsUpdate', ''),
-('comments_delete', 'Comments delete', 'This tool allows agents to delete comments.', '{}', NULL, 0, 0, 1, 'BxDolAIToolCmtsDelete', ''),
-
-('email_send', 'E-mail send', 'This tool allows agents to send e-mails.', '{}', NULL, 0, 0, 1, 'BxDolAIToolEmailSend', '');
+('comments_delete', 'Comments delete', 'This tool allows agents to delete comments.', '{}', NULL, 0, 0, 1, 'BxDolAIToolCmtsDelete', '');
 
 CREATE TABLE IF NOT EXISTS `sys_agents_chat_history` (
   `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,

+ 4 - 0
modules/boonex/english/data/langs/system/en.xml

@@ -509,6 +509,8 @@
 	<string name="_adm_bp_dsc_block_content_rss_length"><![CDATA[Enter a number of displayed items here]]></string>
 	<string name="_adm_bp_dsc_block_content_rss_url"><![CDATA[Enter URL to RSS resource here]]></string>
         <string name="_adm_bp_dsc_block_content_empty"><![CDATA[Leave empty to use default one]]></string>
+        <string name="_adm_bp_dsc_block_description"><![CDATA[Short description for the block, visible in block header.]]></string>
+        <string name="_adm_bp_dsc_block_icon"><![CDATA[An icon (font icon, SVG or Emoji code) for the block, visible in block header.]]></string>
 	<string name="_adm_bp_dsc_block_title"><![CDATA[Short name for the block, visible in block header.]]></string>
 	<string name="_adm_bp_dsc_block_visible_for_levels"><![CDATA[Select user levels that can see this block]]></string>
 	<string name="_adm_bp_dsc_page_cache_lifetime"><![CDATA[Store page in cache for this number of seconds]]></string>
@@ -567,6 +569,7 @@
 	<string name="_adm_bp_txt_block_content_service_method"><![CDATA[Method]]></string>
 	<string name="_adm_bp_txt_block_content_service_module"><![CDATA[Module]]></string>
         <string name="_adm_bp_txt_block_content_empty"><![CDATA[Placeholder text for empty block]]></string>
+        <string name="_adm_bp_txt_block_description"><![CDATA[Description]]></string>
 	<string name="_adm_bp_txt_block_designbox"><![CDATA[Block Layout]]></string>
 	<string name="_adm_bp_txt_block_designbox_empty"><![CDATA[Select layout...]]></string>
         <string name="_adm_bp_txt_block_class"><![CDATA[CSS Class]]></string>
@@ -576,6 +579,7 @@
 	<string name="_adm_bp_txt_block_hidden_on_tablet"><![CDATA[tablet]]></string>
 	<string name="_adm_bp_txt_block_hidden_on_desktop"><![CDATA[desktop]]></string>
         <string name="_adm_bp_txt_block_hidden_on_mobile"><![CDATA[mobile app]]></string>
+        <string name="_adm_bp_txt_block_icon"><![CDATA[Icon]]></string>
 	<string name="_adm_bp_txt_block_selected"><![CDATA[blocks selected]]></string>
         <string name="_adm_bp_txt_block_submenu"><![CDATA[Block submenu]]></string>
         <string name="_adm_bp_txt_block_tabs"><![CDATA[Use 'tabs' based block submenu]]></string>

+ 4 - 0
modules/boonex/russian/data/langs/system/ru.xml

@@ -507,6 +507,8 @@
 	<string name="_adm_bp_dsc_block_content_rss_length"><![CDATA[Введите здесь количество отображаемых элементов]]></string>
 	<string name="_adm_bp_dsc_block_content_rss_url"><![CDATA[Введите здесь URL RSS-ресурса]]></string>
         <string name="_adm_bp_dsc_block_content_empty"><![CDATA[Оставьте пустым, чтобы использовать значение по умолчанию.]]></string>
+        <string name="_adm_bp_dsc_block_description"><![CDATA[Короткое описание блока, отображаемое в заголовке блока.]]></string>
+        <string name="_adm_bp_dsc_block_icon"><![CDATA[Изображение (шрифтовая иконка, SVG код или эмодзи) для блока, отображаемое в заголовке блока.]]></string>
 	<string name="_adm_bp_dsc_block_title"><![CDATA[Короткое название для блока, отображаемое в заголовке блока.]]></string>
 	<string name="_adm_bp_dsc_block_visible_for_levels"><![CDATA[Выбрать уровни пользователей, которые могут видеть этот блок]]></string>
 	<string name="_adm_bp_dsc_page_cache_lifetime"><![CDATA[Сохранять страницу в кэше в течение данного количества секунд]]></string>
@@ -565,6 +567,7 @@
 	<string name="_adm_bp_txt_block_content_service_method"><![CDATA[Метод]]></string>
 	<string name="_adm_bp_txt_block_content_service_module"><![CDATA[Модуль]]></string>
         <string name="_adm_bp_txt_block_content_empty"><![CDATA[Текст-заполнитель для пустого блока]]></string>
+        <string name="_adm_bp_txt_block_description"><![CDATA[Описание]]></string>
 	<string name="_adm_bp_txt_block_designbox"><![CDATA[Отображение блока]]></string>
 	<string name="_adm_bp_txt_block_designbox_empty"><![CDATA[Выбрать отображение...]]></string>
         <string name="_adm_bp_txt_block_class"><![CDATA[CSS класс]]></string>
@@ -574,6 +577,7 @@
 	<string name="_adm_bp_txt_block_hidden_on_tablet"><![CDATA[планшете]]></string>
 	<string name="_adm_bp_txt_block_hidden_on_desktop"><![CDATA[настольном компьютере]]></string>
         <string name="_adm_bp_txt_block_hidden_on_mobile"><![CDATA[мобильное приложение]]></string>
+        <string name="_adm_bp_txt_block_icon"><![CDATA[Изображение]]></string>
 	<string name="_adm_bp_txt_block_selected"><![CDATA[блоков выбрано]]></string>
         <string name="_adm_bp_txt_block_submenu"><![CDATA[Подменю блока]]></string>
         <string name="_adm_bp_txt_block_tabs"><![CDATA[Использовать подменю блока в виде вкладок]]></string>

+ 2 - 0
studio/classes/BxDolStudioBuilderPageQuery.php

@@ -387,6 +387,8 @@ class BxDolStudioBuilderPageQuery extends BxDolStudioPageQuery
             `tpb`.`module` AS `module`,
             `tpb`.`title_system` AS `title_system`,
             `tpb`.`title` AS `title`,
+            `tpb`.`description` AS `description`,
+            `tpb`.`icon` AS `icon`,
             `tpb`.`designbox_id` AS `designbox_id`,
             `tpb`.`class` AS `class`,
             `tpb`.`async` AS `async`,

+ 24 - 0
studio/template/scripts/BxBaseStudioBuilderPage.php

@@ -642,6 +642,30 @@ class BxBaseStudioBuilderPage extends BxDolStudioBuilderPage
                         'error' => _t('_adm_bp_err_block_title'),
                     ),
                 ),
+                'description' => array(
+                    'type' => 'text_translatable',
+                    'name' => 'description',
+                    'caption' => _t('_adm_bp_txt_block_description'),
+                    'info' => _t('_adm_bp_dsc_block_description'),
+                    'value' => $aBlock['description'],
+                    'required' => '0',
+                    'db' => array (
+                        'pass' => 'Xss',
+                    ),
+                ),
+                'icon' => array(
+                    'type' => 'textarea',
+                    'name' => 'icon',
+                    'caption' => _t('_adm_bp_txt_block_icon'),
+                    'info' => _t('_adm_bp_dsc_block_icon'),
+                    'value' => $aBlock['icon'],
+                    'code' => 1,
+                    'required' => '0',
+                    'db' => array (
+                        'pass' => 'Xss',
+                    ),
+                    'attrs' => array('class' => 'bx-form-input-textarea-small'),
+                ),
                 'designbox_id' => array(
                     'type' => 'select',
                     'name' => 'designbox_id',

+ 14 - 1
template/designbox_1.html

@@ -1,7 +1,20 @@
 <!-- Design Box 1 [start]: Content + title + background -->
 <div class="bx-db-container bx-dbc-nopadding bx-def-color-bg-block bx-def-border-block bx-def-border-radius-block">
     <div class="bx-db-header px-3 md:px-4 pt-2 md:pt-3 pb-4">
-        <div class="bx-db-title">__title__</div>__caption_item__
+        <div class="bx-db-title flex items-center space-x-4">
+            <bx_if:show_db_icon>
+                <div class="bx-dbt-ic grow-0"><i class="sys-icon __icon__"></i></div>
+            </bx_if:show_db_icon>
+            <bx_if:show_db_icon_html>
+                <div class="bx-dbt-ic grow-0">__icon_html__</div>
+            </bx_if:show_db_icon_html>
+            <div class="bx-dbt-cnt">
+                __title__
+                <bx_if:show_db_description>
+                    <div class="bx-dbt-dsc text-sm font-normal">__description__</div>
+                </bx_if:show_db_description>
+            </div>
+        </div>__caption_item__
     </div>
     <div class="bx-db-content relative">__designbox_content__</div>
 </div>

+ 14 - 1
template/designbox_11.html

@@ -1,7 +1,20 @@
 <!-- Design Box 11 [start]: Content + title + background + padding -->
 <div class="bx-db-container bx-def-color-bg-block bx-def-border-block bx-def-border-radius-block">
     <div class="bx-db-header px-3 md:px-4 pt-2 md:pt-3">
-        <div class="bx-db-title">__title__</div>__caption_item__
+        <div class="bx-db-title flex items-center space-x-4">
+            <bx_if:show_db_icon>
+                <div class="bx-dbt-ic grow-0"><i class="sys-icon __icon__"></i></div>
+            </bx_if:show_db_icon>
+            <bx_if:show_db_icon_html>
+                <div class="bx-dbt-ic grow-0">__icon_html__</div>
+            </bx_if:show_db_icon_html>
+            <div class="bx-dbt-cnt">
+                __title__
+                <bx_if:show_db_description>
+                    <div class="bx-dbt-dsc text-sm font-normal">__description__</div>
+                </bx_if:show_db_description>
+            </div>
+        </div>__caption_item__
     </div>
     <div class="bx-db-content bx-content-padding-block relative">__designbox_content__</div>
 </div>

+ 14 - 1
template/designbox_14.html

@@ -1,7 +1,20 @@
 <!-- Design Box 14 [start]: Content + title + padding -->
 <div class="bx-db-container bx-dbc-nobg bx-def-border-radius-block">
     <div class="bx-db-header px-3 md:px-4 pt-2 md:pt-3">
-        <div class="bx-db-title">__title__</div>__caption_item__
+        <div class="bx-db-title flex items-center space-x-4">
+            <bx_if:show_db_icon>
+                <div class="bx-dbt-ic grow-0"><i class="sys-icon __icon__"></i></div>
+            </bx_if:show_db_icon>
+            <bx_if:show_db_icon_html>
+                <div class="bx-dbt-ic grow-0">__icon_html__</div>
+            </bx_if:show_db_icon_html>
+            <div class="bx-dbt-cnt">
+                __title__
+                <bx_if:show_db_description>
+                    <div class="bx-dbt-dsc text-sm font-normal">__description__</div>
+                </bx_if:show_db_description>
+            </div>
+        </div>__caption_item__
     </div>
     <div class="bx-db-content bx-content-padding-block relative">__designbox_content__</div>
 </div>

+ 14 - 1
template/designbox_4.html

@@ -1,7 +1,20 @@
 <!-- Design Box 4 [start]: Content + title -->
 <div class="bx-db-container bx-dbc-nopadding bx-dbc-nobg bx-def-border-radius-block">
     <div class="bx-db-header px-3 md:px-4 pt-2 md:pt-3 pb-4">
-        <div class="bx-db-title">__title__</div>__caption_item__
+        <div class="bx-db-title flex items-center space-x-4">
+            <bx_if:show_db_icon>
+                <div class="bx-dbt-ic grow-0"><i class="sys-icon __icon__"></i></div>
+            </bx_if:show_db_icon>
+            <bx_if:show_db_icon_html>
+                <div class="bx-dbt-ic grow-0">__icon_html__</div>
+            </bx_if:show_db_icon_html>
+            <div class="bx-dbt-cnt">
+                __title__
+                <bx_if:show_db_description>
+                    <div class="bx-dbt-dsc text-sm font-normal">__description__</div>
+                </bx_if:show_db_description>
+            </div>
+        </div>__caption_item__
     </div>
     <div class="bx-db-content relative">__designbox_content__</div>
 </div>

+ 30 - 0
template/scripts/BxBaseFunctions.php

@@ -424,8 +424,38 @@ class BxBaseFunctions extends BxDolFactory implements iBxDolSingleton
                 'caption_item' => $sMenu
             ];
 
+        $sDescription = $sIcon = $sIconHtml = '';
+        if(is_array($sTitle)) {
+            list($sTitle, $sDescription, $sIcon) = $sTitle;
+
+            if($sIcon) {
+                list($sIcon, $sIconUrl, $sIconA, $sIconHtml) = $this->getIcon($sIcon);
+
+                if($sIcon)
+                    $sIcon = BxDolIconset::getObjectInstance()->getIcon($sIcon);
+            }
+        }
+
         return $this->_oTemplate->parseHtmlByName('designbox_' . (int)$iTemplateNum . '.html', array_merge([
+                'bx_if:show_db_icon' => [
+                    'condition' => !empty($sIcon),
+                    'content' =>  [
+                        'icon' => $sIcon,
+                    ]
+                ],
+                'bx_if:show_db_icon_html' => [
+                    'condition' => !empty($sIconHtml),
+                    'content' =>  [
+                        'icon_html' => $sIconHtml,
+                    ]
+                ],
                 'title' => $sTitle,
+                'bx_if:show_db_description' => [
+                    'condition' => !empty($sDescription),
+                    'content' =>  [
+                        'description' => $sDescription,
+                    ]
+                ],
                 'designbox_content' => $sContent,
             ], ($bNoTitle ? [
                 'bx_if:show_db_menu' => [

+ 40 - 7
template/scripts/BxBasePage.php

@@ -464,6 +464,24 @@ class BxBasePage extends BxDolPage
         return $this->_replaceMarkers(_t($aBlock['title']), array('block_id' => $aBlock['id']));
     }
 
+    /**
+     * Get block description.
+     * @return string
+     */
+    public function getBlockDescription ($aBlock)
+    {
+        return $this->_replaceMarkers(_t($aBlock['description']), ['block_id' => $aBlock['id']]);
+    }
+
+    /**
+     * Get block icon.
+     * @return string
+     */
+    public function getBlockIcon ($aBlock)
+    {
+        return $aBlock['icon'] ?? '';
+    }
+
     /**
      * Get help control if help is available for the block.
      * @return string
@@ -799,8 +817,20 @@ class BxBasePage extends BxDolPage
                     continue;
                 }
 
+                $sIcon = '';
+                if(($sIcon = $this->getBlockIcon($aBlock))) {
+                    list($sIcon, $sIconUrl, $sIconA, $sIconHtml) = $this->_oTemplate->getTemplateFunctions()->getIcon($sIcon);
+                    
+                    if($sIcon)
+                        $sIcon = BxDolIconset::getObjectInstance()->getIcon($sIcon);
+                    else if($sIconHtml)
+                        $sIcon = $sIconHtml;
+                }
+
                 $aCells[$sKey][$i] = array_merge($aCells[$sKey][$i], [
                     'title' => isset($mBlock['title']) ? $mBlock['title'] : $this->getBlockTitle($aBlock),
+                    'description' => isset($mBlock['description']) ? $mBlock['description'] : $this->getBlockDescription($aBlock),
+                    'icon' => $sIcon,
                     'content' => isset($mBlock['content']) ? $mBlock['content'] : $mBlock,
                     'menu' => isset($mBlock['menu']) ? $mBlock['menu'] : '',
                     'source' => $sSource
@@ -957,6 +987,8 @@ class BxBasePage extends BxDolPage
         $aDbNoTitle = [BX_DB_CONTENT_ONLY, BX_DB_PADDING_CONTENT_ONLY, BX_DB_NO_CAPTION, BX_DB_PADDING_NO_CAPTION];
 
         $sTitle = $this->getBlockTitle($aBlock);
+        $sDescription = $this->getBlockDescription($aBlock);
+        $sIcon = $this->getBlockIcon($aBlock);
         $sHelp = $this->getBlockHelp($aBlock);
 
         $sFunc = '_getBlock' . ucfirst($aBlock['type']);
@@ -971,11 +1003,11 @@ class BxBasePage extends BxDolPage
                 $sHelpContent = $sHelp;
 
             $sContent = $this->getBlockAsyncCode($aBlock, $iAsync);
-            $aParams = array(
-                $sTitle . $sHelpTitle,
+            $aParams = [
+                ($sBlTitle = $sTitle . $sHelpTitle) && ($sDescription || $sIcon) ? [$sBlTitle, $sDescription, $sIcon] : $sBlTitle,
                 $sContent . $sHelpContent,
                 $iDesignboxId
-            );
+            ];
             $sContentWithBox = call_user_func_array(array($oFunctions, 'designBoxContent'), $aParams);
         } 
         elseif ($bBlockVisible && method_exists($this, $sFunc)) {
@@ -999,6 +1031,7 @@ class BxBasePage extends BxDolPage
                     $this->addMarkers($mixedContent['markers']);
 
                     $sTitle = $this->getBlockTitle($aBlock);
+                    $sDescription = $this->getBlockDescription($aBlock);
                 }
 
                 $sHelpTitle = $sHelpContent = '';
@@ -1007,11 +1040,11 @@ class BxBasePage extends BxDolPage
                 else
                     $sHelpContent = $sHelp;
 
-                $aParams = array(
-                    (isset($mixedContent['title']) ? $mixedContent['title'] : $sTitle) . $sHelpTitle,
+                $aParams = [
+                    ($sBlTitle = ($mixedContent['title'] ?? $sTitle) . $sHelpTitle) && ($sDescription || $sIcon) ? [$sBlTitle, $sDescription, $sIcon] : $sBlTitle,
                     $mixedContent['content'] . $sHelpContent,
                     $iDesignboxId
-                );
+                ];
 
                 $mixedMenu = false;
                 if(isset($mixedContent['menu']))
@@ -1038,7 +1071,7 @@ class BxBasePage extends BxDolPage
                     $sHelpContent = $sHelp;
 
                 $aParams = array(
-                    $sTitle . $sHelpTitle,
+                    ($sBlTitle = $sTitle . $sHelpTitle) && ($sDescription || $sIcon) ? [$sBlTitle, $sDescription, $sIcon] : $sBlTitle,
                     $mixedContent . $sHelpContent,
                     $iDesignboxId
                 );