From 26e0ec96b74b737e5b8b40bacd3d325dbf9bf1b3 Mon Sep 17 00:00:00 2001 From: AntonLV Date: Mon, 7 Aug 2023 08:58:19 +0300 Subject: [PATCH] Ticket #4370 - Placeholder for empty block. Core changes and usage in Connections pages. --- install/sql/system.sql | 15 +++-- .../boonex/english/data/langs/system/en.xml | 2 + .../boonex/russian/data/langs/system/ru.xml | 2 + .../classes/BxDolStudioBuilderPageQuery.php | 1 + .../scripts/BxBaseStudioBuilderPage.php | 10 +++ template/scripts/BxBasePage.php | 7 +- template/scripts/BxBaseServiceProfiles.php | 67 ++++++++++++++++--- 7 files changed, 87 insertions(+), 17 deletions(-) diff --git a/install/sql/system.sql b/install/sql/system.sql index c66c620b47..c6ed478258 100644 --- a/install/sql/system.sql +++ b/install/sql/system.sql @@ -5707,6 +5707,7 @@ CREATE TABLE IF NOT EXISTS `sys_pages_blocks` ( `hidden_on` varchar(255) NOT NULL DEFAULT '', `type` enum('raw','html','lang','image','rss','menu','custom','service','wiki') NOT NULL DEFAULT 'raw', `content` text NOT NULL, + `content_empty` varchar(255) NOT NULL DEFAULT '', `text` mediumtext NOT NULL, `text_updated` int(11) NOT NULL, `help` varchar(255) NOT NULL, @@ -5836,15 +5837,15 @@ INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title_system`, ` ('sys_sub_wiki_pages_list', 1, 'system', '', '_sys_page_block_title_wiki_pages_list', 0, 0, 0, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:10:"pages_list";s:6:"params";a:0:{}s:5:"class";s:16:"TemplServiceWiki";}', 0, 1, 1, 1), ('sys_sub_wiki_page_contents', 1, 'system', '', '_sys_page_block_title_wiki_page_contents', 0, 0, 0, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:13:"page_contents";s:6:"params";a:0:{}s:5:"class";s:16:"TemplServiceWiki";}', 0, 1, 1, 1), -('sys_con_friends', 1, 'system', '', '_sys_page_block_title_con_friends', 11, 0, 0, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:14:"browse_friends";s:6:"params";a:2:{i:0;s:12:"{profile_id}";i:1;a:1:{s:13:"empty_message";b:1;}}s:5:"class";s:20:"TemplServiceProfiles";}', 0, 1, 1, 1), -('sys_con_friend_requests', 1, 'system', '', '_sys_page_block_title_con_friend_requests', 11, 0, 0, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:22:"browse_friend_requests";s:6:"params";a:2:{i:0;s:12:"{profile_id}";i:1;a:1:{s:13:"empty_message";b:1;}}s:5:"class";s:20:"TemplServiceProfiles";}', 0, 1, 1, 1), -('sys_con_friend_requested', 1, 'system', '', '_sys_page_block_title_con_friend_requested', 11, 0, 0, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:23:"browse_friend_requested";s:6:"params";a:2:{i:0;s:12:"{profile_id}";i:1;a:1:{s:13:"empty_message";b:1;}}s:5:"class";s:20:"TemplServiceProfiles";}', 0, 1, 1, 1), +('sys_con_friends', 1, 'system', '', '_sys_page_block_title_con_friends', 11, 0, 0, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:14:"browse_friends";s:6:"params";a:2:{i:0;s:12:"{profile_id}";i:1;a:2:{s:13:"empty_message";b:1;s:18:"empty_message_text";s:15:"{content_empty}";}}s:5:"class";s:20:"TemplServiceProfiles";}', 0, 1, 1, 1), +('sys_con_friend_requests', 1, 'system', '', '_sys_page_block_title_con_friend_requests', 11, 0, 0, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:22:"browse_friend_requests";s:6:"params";a:2:{i:0;s:12:"{profile_id}";i:1;a:2:{s:13:"empty_message";b:1;s:18:"empty_message_text";s:15:"{content_empty}";}}s:5:"class";s:20:"TemplServiceProfiles";}', 0, 1, 1, 1), +('sys_con_friend_requested', 1, 'system', '', '_sys_page_block_title_con_friend_requested', 11, 0, 0, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:23:"browse_friend_requested";s:6:"params";a:2:{i:0;s:12:"{profile_id}";i:1;a:2:{s:13:"empty_message";b:1;s:18:"empty_message_text";s:15:"{content_empty}";}}s:5:"class";s:20:"TemplServiceProfiles";}', 0, 1, 1, 1), -('sys_con_following', 1, 'system', '', '_sys_page_block_title_con_following', 11, 0, 0, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:20:"browse_subscriptions";s:6:"params";a:2:{i:0;s:12:"{profile_id}";i:1;a:1:{s:13:"empty_message";b:1;}}s:5:"class";s:20:"TemplServiceProfiles";}', 0, 1, 1, 1), -('sys_con_followers', 1, 'system', '', '_sys_page_block_title_con_followers', 11, 0, 0, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:20:"browse_subscribed_me";s:6:"params";a:2:{i:0;s:12:"{profile_id}";i:1;a:1:{s:13:"empty_message";b:1;}}s:5:"class";s:20:"TemplServiceProfiles";}', 0, 1, 1, 1), +('sys_con_following', 1, 'system', '', '_sys_page_block_title_con_following', 11, 0, 0, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:20:"browse_subscriptions";s:6:"params";a:2:{i:0;s:12:"{profile_id}";i:1;a:2:{s:13:"empty_message";b:1;s:18:"empty_message_text";s:15:"{content_empty}";}}s:5:"class";s:20:"TemplServiceProfiles";}', 0, 1, 1, 1), +('sys_con_followers', 1, 'system', '', '_sys_page_block_title_con_followers', 11, 0, 0, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:20:"browse_subscribed_me";s:6:"params";a:2:{i:0;s:12:"{profile_id}";i:1;a:2:{s:13:"empty_message";b:1;s:18:"empty_message_text";s:15:"{content_empty}";}}s:5:"class";s:20:"TemplServiceProfiles";}', 0, 1, 1, 1), -('sys_recom_friends', 1, 'system', '', '_sys_page_block_title_recom_friends', 11, 0, 0, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:30:"browse_recommendations_friends";s:6:"params";a:2:{i:0;s:12:"{profile_id}";i:1;a:1:{s:13:"empty_message";b:1;}}s:5:"class";s:20:"TemplServiceProfiles";}', 0, 1, 1, 1), -('sys_recom_subscriptions', 1, 'system', '', '_sys_page_block_title_recom_subscriptions', 11, 0, 0, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:36:"browse_recommendations_subscriptions";s:6:"params";a:2:{i:0;s:12:"{profile_id}";i:1;a:1:{s:13:"empty_message";b:1;}}s:5:"class";s:20:"TemplServiceProfiles";}', 0, 1, 1, 1), +('sys_recom_friends', 1, 'system', '', '_sys_page_block_title_recom_friends', 11, 0, 0, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:30:"browse_recommendations_friends";s:6:"params";a:2:{i:0;s:12:"{profile_id}";i:1;a:2:{s:13:"empty_message";b:1;s:18:"empty_message_text";s:15:"{content_empty}";}}s:5:"class";s:20:"TemplServiceProfiles";}', 0, 1, 1, 1), +('sys_recom_subscriptions', 1, 'system', '', '_sys_page_block_title_recom_subscriptions', 11, 0, 0, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:36:"browse_recommendations_subscriptions";s:6:"params";a:2:{i:0;s:12:"{profile_id}";i:1;a:2:{s:13:"empty_message";b:1;s:18:"empty_message_text";s:15:"{content_empty}";}}s:5:"class";s:20:"TemplServiceProfiles";}', 0, 1, 1, 1), -- studio dashboard blocks diff --git a/modules/boonex/english/data/langs/system/en.xml b/modules/boonex/english/data/langs/system/en.xml index 70edc59ca8..74cb1a5bcd 100644 --- a/modules/boonex/english/data/langs/system/en.xml +++ b/modules/boonex/english/data/langs/system/en.xml @@ -493,6 +493,7 @@ + @@ -550,6 +551,7 @@ + diff --git a/modules/boonex/russian/data/langs/system/ru.xml b/modules/boonex/russian/data/langs/system/ru.xml index fcc7c45fdd..cc6a452d6b 100644 --- a/modules/boonex/russian/data/langs/system/ru.xml +++ b/modules/boonex/russian/data/langs/system/ru.xml @@ -493,6 +493,7 @@ + @@ -550,6 +551,7 @@ + diff --git a/studio/classes/BxDolStudioBuilderPageQuery.php b/studio/classes/BxDolStudioBuilderPageQuery.php index 26f149c4c9..2163e95fbb 100644 --- a/studio/classes/BxDolStudioBuilderPageQuery.php +++ b/studio/classes/BxDolStudioBuilderPageQuery.php @@ -428,6 +428,7 @@ function getBlocks($aParams, &$aItems, $bReturnCount = true) `tpb`.`visible_for_levels` AS `visible_for_levels`, `tpb`.`type` AS `type`, `tpb`.`content` AS `content`, + `tpb`.`content_empty` AS `content_empty`, `tpb`.`help` AS `help`, `tpb`.`deletable` AS `deletable`, `tpb`.`copyable` AS `copyable`, diff --git a/studio/template/scripts/BxBaseStudioBuilderPage.php b/studio/template/scripts/BxBaseStudioBuilderPage.php index f2076f0e72..98dc5b294b 100644 --- a/studio/template/scripts/BxBaseStudioBuilderPage.php +++ b/studio/template/scripts/BxBaseStudioBuilderPage.php @@ -784,6 +784,16 @@ protected function actionBlockEdit() 'pass' => 'Int', ) ), + 'content_empty' => array( + 'type' => 'text_translatable', + 'name' => 'content_empty', + 'caption' => _t('_adm_bp_txt_block_content_empty'), + 'info' => _t('_adm_bp_dsc_block_content_empty'), + 'value' => $aBlock['content_empty'], + 'db' => array ( + 'pass' => 'Xss', + ), + ), 'help' => array( 'type' => 'textarea_translatable', 'name' => 'help', diff --git a/template/scripts/BxBasePage.php b/template/scripts/BxBasePage.php index 2e87af17e8..bc6f5ed41e 100644 --- a/template/scripts/BxBasePage.php +++ b/template/scripts/BxBasePage.php @@ -947,7 +947,12 @@ protected function _getBlockMenu ($aBlock) */ protected function _getBlockService ($aBlock) { - return BxDolService::callSerialized($aBlock['content'], $this->_aMarkers); + $aMarkers = array_merge($this->_aMarkers, [ + 'block_id' => $aBlock['id'], + 'content_empty' => $aBlock['content_empty'] + ]); + + return BxDolService::callSerialized($aBlock['content'], $aMarkers); } /** diff --git a/template/scripts/BxBaseServiceProfiles.php b/template/scripts/BxBaseServiceProfiles.php index bdfcc22860..8f88b1776c 100644 --- a/template/scripts/BxBaseServiceProfiles.php +++ b/template/scripts/BxBaseServiceProfiles.php @@ -495,7 +495,14 @@ public function serviceBrowseFriends ($iProfileId = 0, $aParams = []) if(!empty($aParams['params']) && is_array($aParams['params'])) $aParamsBrowse = array_merge($aParamsBrowse, $aParams['params']); - return $this->_serviceBrowseConnections('friends', $aParamsBrowse, $aParams['design_box'], $aParams['empty_message'], $aParams['ajax_paginate']); + $sEmpty = !empty($aParams['empty_message_text']) ? _t($aParams['empty_message_text']) : ''; + $bEmpty = (bool)$aParams['empty_message']; + + $mixedResult = $this->_serviceBrowseConnections('friends', $aParamsBrowse, $aParams['design_box'], empty($sEmpty) ? $bEmpty : false, $aParams['ajax_paginate']); + if(empty($mixedResult) && $bEmpty) + $mixedResult = MsgBox($sEmpty); + + return $mixedResult; } public function serviceBrowseFriendRequests ($iProfileId = 0, $aParams = []) @@ -519,7 +526,14 @@ public function serviceBrowseFriendRequests ($iProfileId = 0, $aParams = []) if(!empty($aParams['params']) && is_array($aParams['params'])) $aParamsBrowse = array_merge($aParamsBrowse, $aParams['params']); - return $this->_serviceBrowseConnections('friend_requests', $aParamsBrowse, $aParams['design_box'], $aParams['empty_message'], $aParams['ajax_paginate']); + $sEmpty = !empty($aParams['empty_message_text']) ? _t($aParams['empty_message_text']) : ''; + $bEmpty = (bool)$aParams['empty_message']; + + $mixedResult = $this->_serviceBrowseConnections('friend_requests', $aParamsBrowse, $aParams['design_box'], empty($sEmpty) ? $bEmpty : false, $aParams['ajax_paginate']); + if(empty($mixedResult) && $bEmpty) + $mixedResult = MsgBox($sEmpty); + + return $mixedResult; } public function serviceBrowseFriendRequested ($iProfileId = 0, $aParams = []) @@ -543,7 +557,14 @@ public function serviceBrowseFriendRequested ($iProfileId = 0, $aParams = []) if(!empty($aParams['params']) && is_array($aParams['params'])) $aParamsBrowse = array_merge($aParamsBrowse, $aParams['params']); - return $this->_serviceBrowseConnections('friend_requested', $aParamsBrowse, $aParams['design_box'], $aParams['empty_message'], $aParams['ajax_paginate']); + $sEmpty = !empty($aParams['empty_message_text']) ? _t($aParams['empty_message_text']) : ''; + $bEmpty = (bool)$aParams['empty_message']; + + $mixedResult = $this->_serviceBrowseConnections('friend_requested', $aParamsBrowse, $aParams['design_box'], empty($sEmpty) ? $bEmpty : false, $aParams['ajax_paginate']); + if(empty($mixedResult) && $bEmpty) + $mixedResult = MsgBox($sEmpty); + + return $mixedResult; } public function serviceBrowseSubscriptions ($iProfileId = 0, $aParams = []) @@ -567,7 +588,14 @@ public function serviceBrowseSubscriptions ($iProfileId = 0, $aParams = []) if(!empty($aParams['params']) && is_array($aParams['params'])) $aParamsBrowse = array_merge($aParamsBrowse, $aParams['params']); - return $this->_serviceBrowseConnections('subscriptions', $aParamsBrowse, $aParams['design_box'], $aParams['empty_message'], $aParams['ajax_paginate']); + $sEmpty = !empty($aParams['empty_message_text']) ? _t($aParams['empty_message_text']) : ''; + $bEmpty = (bool)$aParams['empty_message']; + + $mixedResult = $this->_serviceBrowseConnections('subscriptions', $aParamsBrowse, $aParams['design_box'], empty($sEmpty) ? $bEmpty : false, $aParams['ajax_paginate']); + if(empty($mixedResult) && $bEmpty) + $mixedResult = MsgBox($sEmpty); + + return $mixedResult; } public function serviceBrowseSubscribedMe ($iProfileId = 0, $aParams = []) @@ -591,7 +619,14 @@ public function serviceBrowseSubscribedMe ($iProfileId = 0, $aParams = []) if(!empty($aParams['params']) && is_array($aParams['params'])) $aParamsBrowse = array_merge($aParamsBrowse, $aParams['params']); - return $this->_serviceBrowseConnections('subscribed_me', $aParamsBrowse, $aParams['design_box'], $aParams['empty_message'], $aParams['ajax_paginate']); + $sEmpty = !empty($aParams['empty_message_text']) ? _t($aParams['empty_message_text']) : ''; + $bEmpty = (bool)$aParams['empty_message']; + + $mixedResult = $this->_serviceBrowseConnections('subscribed_me', $aParamsBrowse, $aParams['design_box'], empty($sEmpty) ? $bEmpty : false, $aParams['ajax_paginate']); + if(empty($mixedResult) && $bEmpty) + $mixedResult = MsgBox($sEmpty); + + return $mixedResult; } public function serviceBrowseMembers($iProfileId, $sObject, $aParams = []) @@ -618,7 +653,14 @@ public function serviceBrowseMembers($iProfileId, $sObject, $aParams = []) if(!empty($aParams['params']) && is_array($aParams['params'])) $aParamsBrowse = array_merge($aParamsBrowse, $aParams['params']); - return $this->_serviceBrowseConnections('members', $aParamsBrowse, $aParams['design_box'], $aParams['empty_message'], $aParams['ajax_paginate']); + $sEmpty = !empty($aParams['empty_message_text']) ? _t($aParams['empty_message_text']) : ''; + $bEmpty = (bool)$aParams['empty_message']; + + $mixedResult = $this->_serviceBrowseConnections('members', $aParamsBrowse, $aParams['design_box'], empty($sEmpty) ? $bEmpty : false, $aParams['ajax_paginate']); + if(empty($mixedResult) && $bEmpty) + $mixedResult = MsgBox($sEmpty); + + return $mixedResult; } public function serviceBrowseConnections ($iProfileId = 0, $aParams = []) @@ -648,7 +690,14 @@ public function serviceBrowseConnections ($iProfileId = 0, $aParams = []) if(!empty($aParams['params']) && is_array($aParams['params'])) $aParamsBrowse = array_merge($aParamsBrowse, $aParams['params']); - return $this->_serviceBrowseConnections('connections', $aParamsBrowse, $aParams['design_box'], $aParams['empty_message'], $aParams['ajax_paginate']); + $sEmpty = !empty($aParams['empty_message_text']) ? _t($aParams['empty_message_text']) : ''; + $bEmpty = (bool)$aParams['empty_message']; + + $mixedResult = $this->_serviceBrowseConnections('connections', $aParamsBrowse, $aParams['design_box'], empty($sEmpty) ? $bEmpty : false, $aParams['ajax_paginate']); + if(empty($mixedResult) && $bEmpty) + $mixedResult = MsgBox($sEmpty); + + return $mixedResult; } public function serviceBrowseRecommendationsFriends ($iProfileId = 0, $aParams = []) @@ -690,7 +739,7 @@ public function serviceBrowseRecommendationsFriends ($iProfileId = 0, $aParams = $sCode = $oRecommendation->getCode($iProfileId, $aParams['start'], $aParams['per_page']); if(!$sCode && $aParams['empty_message']) - $sCode = MsgBox(_t('_Empty')); + $sCode = MsgBox(_t(!empty($aParams['empty_message_text']) ? $aParams['empty_message_text'] : '_Empty')); return $sCode; } @@ -734,7 +783,7 @@ public function serviceBrowseRecommendationsSubscriptions ($iProfileId = 0, $aPa $sCode = $oRecommendation->getCode($iProfileId, $aParams['start'], $aParams['per_page']); if(!$sCode && $aParams['empty_message']) - $sCode = MsgBox(_t('_Empty')); + $sCode = MsgBox(_t(!empty($aParams['empty_message_text']) ? $aParams['empty_message_text'] : '_Empty')); return $sCode; }