AntonLV 12 лет назад
Родитель
Сommit
78fab587bf

+ 1 - 1
inc/classes/BxDolTemplate.php

@@ -485,7 +485,7 @@ class BxDolTemplate extends BxDol implements iBxDolSingleton {
         $this->_sCode = $oConfig->getUri();
         $this->_sSubPath = $oConfig->getDirectory();
 
-        if(!$bSetCookie)
+        if(!$bSetCookie || bx_get('preview'))
             return;
 
         $aUrl = parse_url(BX_DOL_URL_ROOT);

+ 8 - 3
inc/utils.inc.php

@@ -463,9 +463,14 @@ function sendMail($sRecipientEmail, $sMailSubject, $sMailBody, $iRecipientID = 0
 /*
  * Getting an array with Templates' Names
  */
-function get_templates_array($bEnabledOnly = true) {
-    bx_import('BxDolDb');
-    return BxDolDb::getInstance()->getPairs("SELECT `uri`, `title` FROM `sys_modules` WHERE 1 AND `type`='" . BX_DOL_MODULE_TYPE_TEMPLATE . "'" . ($bEnabledOnly ? " AND `enabled`='1'" : ""), "uri", "title");
+function get_templates_array($bEnabledOnly = true, $bShortInfo = true) {
+	bx_import('BxDolDb');
+	$oDb = BxDolDb::getInstance();
+
+	if($bEnabledOnly)
+		return $oDb->getPairs("SELECT `uri`, `title` FROM `sys_modules` WHERE 1 AND `type`='" . BX_DOL_MODULE_TYPE_TEMPLATE . "'" . ($bEnabledOnly ? " AND `enabled`='1'" : ""), "uri", "title");
+	else 
+		return $oDb->getAllWithKey("SELECT * FROM `sys_modules` WHERE 1 AND `type`='" . BX_DOL_MODULE_TYPE_TEMPLATE . "'" . ($bEnabledOnly ? " AND `enabled`='1'" : ""), "uri"); 
 }
 
 /*

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

@@ -1805,6 +1805,10 @@ Please click "Continue" below to navigate to the home page of the site.]]></stri
 	<string name="_adm_wgt_cpt_designer"><![CDATA[Designer]]></string>
 	<string name="_adm_lmi_cpt_logo"><![CDATA[Logo]]></string>
 	<string name="_adm_lmi_cpt_icon"><![CDATA[Site Icon]]></string>
+	<string name="_adm_lmi_cpt_settings"><![CDATA[Settings]]></string>
+	<string name="_adm_dsg_txt_default"><![CDATA[default]]></string>
+	<string name="_adm_dsg_btn_make_default"><![CDATA[Make Default]]></string>
+	<string name="_adm_dsg_err_make_default"><![CDATA[Cannot make the template default.]]></string>
 	<string name="_adm_dsg_txt_upload_image"><![CDATA[Upload New Logo Image]]></string>
 	<string name="_adm_dsg_txt_upload_image_preview"><![CDATA[Current Logo Image]]></string>
 	<string name="_adm_dsg_txt_alt_text"><![CDATA[Logo Text]]></string>

+ 0 - 3
modules/boonex/uni/install/sql/disable.sql

@@ -1,4 +1 @@
---
--- General section.
---
 SET @sName = 'bx_uni';

+ 0 - 3
modules/boonex/uni/install/sql/enable.sql

@@ -1,4 +1 @@
---
--- General section.
---
 SET @sName = 'bx_uni';

+ 14 - 21
modules/boonex/uni/install/sql/install.sql

@@ -1,26 +1,6 @@
---
--- General section.
---
 SET @sName = 'bx_uni';
 
---
--- Studio page and widget.
---
-INSERT INTO `sys_std_pages`(`index`, `name`, `header`, `caption`, `icon`) VALUES
-(3, @sName, '', '', 'bx_uni@modules/boonex/uni/|std-pi.png');
-SET @iPageId = LAST_INSERT_ID();
-
-SET @iParentPageId = (SELECT `id` FROM `sys_std_pages` WHERE `name`='home');
-SET @iParentPageOrder = (SELECT MAX(`order`) FROM `sys_std_pages_widgets` WHERE `page_id`=@iParentPageId);
-INSERT INTO `sys_std_widgets`(`page_id`, `module`, `url`, `click`, `icon`, `caption`, `cnt_notices`, `cnt_actions`) VALUES
-(@iPageId, @sName, CONCAT('{url_studio}design.php?name=', @sName), '', 'bx_uni@modules/boonex/uni/|std-wi.png', '_bx_uni_wgt_cpt', '', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:11:"get_actions";s:6:"params";a:0:{}s:5:"class";s:18:"TemplStudioDesigns";}');
-INSERT INTO `sys_std_pages_widgets`(`page_id`, `widget_id`, `order`) VALUES
-(@iParentPageId, LAST_INSERT_ID(), @iParentPageOrder + 1);
-
-
---
--- Settings.
---
+-- SETTINGS
 INSERT INTO `sys_options_types`(`group`, `name`, `caption`, `icon`, `order`) VALUES 
 ('templates', @sName, '_bx_uni_stg_cpt_type', 'bx_uni@modules/boonex/uni/|std-mi.png', 2);
 SET @iTypeId = LAST_INSERT_ID();
@@ -31,3 +11,16 @@ SET @iCategoryId = LAST_INSERT_ID();
 
 INSERT INTO `sys_options`(`category_id`, `name`, `caption`, `value`, `type`, `extra`, `check`, `check_error`, `order`) VALUES
 (@iCategoryId, CONCAT(@sName, '_switcher_title'), 'Name In Template Switcher', 'UNI', 'digit', '', '', '', 1);
+
+
+-- STUDIO PAGE & WIDGET
+INSERT INTO `sys_std_pages`(`index`, `name`, `header`, `caption`, `icon`) VALUES
+(3, @sName, '', '', 'bx_uni@modules/boonex/uni/|std-pi.png');
+SET @iPageId = LAST_INSERT_ID();
+
+SET @iParentPageId = (SELECT `id` FROM `sys_std_pages` WHERE `name`='home');
+SET @iParentPageOrder = (SELECT MAX(`order`) FROM `sys_std_pages_widgets` WHERE `page_id`=@iParentPageId);
+INSERT INTO `sys_std_widgets`(`page_id`, `module`, `url`, `click`, `icon`, `caption`, `cnt_notices`, `cnt_actions`) VALUES
+(@iPageId, @sName, CONCAT('{url_studio}design.php?name=', @sName), '', 'bx_uni@modules/boonex/uni/|std-wi.png', '_bx_uni_wgt_cpt', '', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:11:"get_actions";s:6:"params";a:0:{}s:5:"class";s:18:"TemplStudioDesigns";}');
+INSERT INTO `sys_std_pages_widgets`(`page_id`, `widget_id`, `order`) VALUES
+(@iParentPageId, LAST_INSERT_ID(), @iParentPageOrder + 1);

+ 4 - 13
modules/boonex/uni/install/sql/uninstall.sql

@@ -1,18 +1,9 @@
---
--- General section.
---
 SET @sName = 'bx_uni';
 
+-- SETTINGS
+DELETE FROM `top`, `toc`, `to` USING `sys_options_types` AS `top` LEFT JOIN `sys_options_categories` AS `toc` ON `top`.`id`=`toc`.`type_id` LEFT JOIN `sys_options` AS `to` ON `toc`.`id`=`to`.`category_id` WHERE `top`.`name`=@sName;
 
---
--- Studio page and widget.
---
+-- STUDIO PAGE & WIDGET
 DELETE FROM `tp`, `tw`, `tpw`
 USING `sys_std_pages` AS `tp`, `sys_std_widgets` AS `tw`, `sys_std_pages_widgets` AS `tpw`
-WHERE `tp`.`id`=`tw`.`page_id` AND `tw`.`id`=`tpw`.`widget_id` AND `tp`.`name`=@sName;
-
-
---
--- Settings.
---
-DELETE FROM `top`, `toc`, `to` USING `sys_options_types` AS `top` LEFT JOIN `sys_options_categories` AS `toc` ON `top`.`id`=`toc`.`type_id` LEFT JOIN `sys_options` AS `to` ON `toc`.`id`=`to`.`category_id` WHERE `top`.`name`=@sName;
+WHERE `tp`.`id` = `tw`.`page_id` AND `tw`.`id` = `tpw`.`widget_id` AND `tp`.`name` = @sName;

+ 16 - 0
studio/classes/BxDolStudioDesigner.php

@@ -14,6 +14,7 @@ bx_import('BxDolStudioDesignerQuery');
 define('BX_DOL_STUDIO_DSG_TYPE_GENERAL', 'general');
 define('BX_DOL_STUDIO_DSG_TYPE_LOGO', 'logo');
 define('BX_DOL_STUDIO_DSG_TYPE_ICON', 'icon');
+define('BX_DOL_STUDIO_DSG_TYPE_SETTINGS', 'settings');
 
 define('BX_DOL_STUDIO_DSG_TYPE_DEFAULT', 'general');
 
@@ -39,6 +40,12 @@ class BxDolStudioDesigner extends BxTemplStudioPage {
 	                $aResult = array('code' => 0, 'message' => '');
                     if(!$this->deleteLogo())
                         $aResult = array('code' => 2, 'message' => _t('_adm_dsg_err_remove_old_logo'));
+	                break;
+
+				case 'make_default':
+	                $aResult = array('code' => 0, 'message' => '');
+                    if(!$this->makeDefault())
+                        $aResult = array('code' => 2, 'message' => _t('_adm_dsg_err_make_default'));
 	                break;
 
 	            case 'get-page-by-type':
@@ -57,6 +64,15 @@ class BxDolStudioDesigner extends BxTemplStudioPage {
         }
     }
 
+    function makeDefault() {
+    	$sValue = bx_get('dsg_value');
+    	if($sValue === false)
+    		return false;
+
+    	$sValue = bx_process_input($sValue);
+    	return $this->oDb->setParam('template', $sValue);
+    }
+
     function submitLogo(&$oForm) {
         $iProfileId = getLoggedId();
 

+ 2 - 2
studio/classes/BxDolStudioPage.php

@@ -113,8 +113,8 @@ class BxDolStudioPage extends BxDol {
         return BxDolStudioUtils::getModuleTitle($sName);
     }
 
-    protected function getModuleIcon($sName) {
-        return BxDolStudioUtils::getModuleIcon($sName);
+    protected function getModuleIcon($sName, $sType = 'menu') {
+        return BxDolStudioUtils::getModuleIcon($sName, $sType);
     }
     
     protected function getModules($bShowCustom = true, $bShowSystem = true) {

+ 1 - 1
studio/classes/BxDolStudioUtils.php

@@ -30,7 +30,7 @@ class BxDolStudioUtils extends BxDol {
     }
 
     public static function getModuleIcon($sName, $sType = 'menu') {
-        $aType2Prefix = array('menu' => 'mi', 'page' => 'pi');
+        $aType2Prefix = array('menu' => 'mi', 'page' => 'pi', 'store' => 'si');
 
         $oTemplate = BxDolStudioTemplate::getInstance();
         $sDefaultIcon = $oTemplate->getIconUrl($aType2Prefix[$sType] . '-mod-empty.png'); 

+ 23 - 0
studio/js/designer.js

@@ -12,6 +12,29 @@ function BxDolStudioDesigner(oOptions) {
     this.iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed;
 }
 
+BxDolStudioDesigner.prototype.makeDefault = function(sUri) {
+	var $this = this;
+	var oDate = new Date();
+
+	$.post(
+		this.sActionsUrl,
+		{
+			dsg_action: 'make_default',
+			dsg_value: sUri,
+			_t: oDate.getTime()
+		},
+		function(oData) {
+			if(oData.code != 0 && oData.message.length > 0) {
+				alert(oData.message);
+				return;
+			}
+
+			document.location.href = document.location.href; 
+		},
+		'json'
+	);
+};
+
 BxDolStudioDesigner.prototype.deleteLogo = function() {
 	var $this = this;
 	var oDate = new Date();

+ 18 - 0
studio/template/css/designer.css

@@ -0,0 +1,18 @@
+/*--- Template Switcher ---*/
+div.bx-dsg-template {
+	position: relative;
+	width: 100%;
+}
+
+div.bx-dsg-icon {
+	position: absolute;
+	top: 0px;
+	left: 0px;
+	overflow: hidden;
+}
+div.bx-dsg-template-info {
+	overflow: hidden;
+}
+span.bx-dsg-template-version {
+	font-weight: bold;
+}

BIN
studio/template/images/icons/mi-dsg-settings.png


+ 0 - 0
studio/template/images/icons/pi-str-dump.png → studio/template/images/icons/si-mod-empty.png


+ 52 - 7
studio/template/scripts/BxBaseStudioDesigner.php

@@ -36,9 +36,10 @@ class BxBaseStudioDesigner extends BxDolStudioDesigner {
 
         $aMenu = array();
         $aMenuItems = array(
-            BX_DOL_STUDIO_DSG_TYPE_GENERAL, 
-            BX_DOL_STUDIO_DSG_TYPE_LOGO, 
-            BX_DOL_STUDIO_DSG_TYPE_ICON
+            BX_DOL_STUDIO_DSG_TYPE_GENERAL,
+            BX_DOL_STUDIO_DSG_TYPE_LOGO,
+            BX_DOL_STUDIO_DSG_TYPE_ICON,
+            BX_DOL_STUDIO_DSG_TYPE_SETTINGS
         );
         foreach($aMenuItems as $sMenuItem)
             $aMenu[] = array(
@@ -60,14 +61,44 @@ class BxBaseStudioDesigner extends BxDolStudioDesigner {
     }
 
     protected function getGeneral() {
+    	$sJsObject = $this->getPageJsObject();
         $oTemplate = BxDolStudioTemplate::getInstance();
-        
-        bx_import('BxTemplStudioSettings');
-        $oPage = new BxTemplStudioSettings(BX_DOL_STUDIO_STG_TYPE_SYSTEM, BX_DOL_STUDIO_STG_CATEGORY_TEMPLATES);
+
+        $sResult = '';
+
+        $sTemplate = getParam('template');
+        $aTemplates = get_templates_array(false, false);        
+
+	    $aTmplVarsTemplates = array ();
+	    foreach($aTemplates as $sUri => $aTemplate) {
+	        $aTmplVarsTemplates[] = array(
+	            'uri' => $sUri,
+	            'title' => htmlspecialchars_adv($aTemplate['title']),
+	            'version' => htmlspecialchars_adv($aTemplate['version']),
+	            'vendor' => htmlspecialchars_adv($aTemplate['vendor']),
+	        	'icon' => $this->getModuleIcon($aTemplate['name'], 'store'),
+	            'bx_if:default' => array (
+	                'condition' => $sUri == $sTemplate,
+	                'content' => array (),
+	            ),
+	            'bx_if:make_default' => array (
+	                'condition' => $sUri != $sTemplate,
+	                'content' => array(
+	            		'js_object' => $sJsObject,
+	                	'uri' => $sUri
+	            	),
+	            )
+	        );
+	    }
+
+	    $sContent  = $sResult ? MsgBox($sResult, 10) : '';
+	    $sContent .= $oTemplate->parseHtmlByName('templates.html', array(
+	        'bx_repeat:templates' => $aTmplVarsTemplates,
+	    ));
 
         $aTmplVars = array(
             'js_object' => $this->getPageJsObject(),
-        	'bx_repeat:blocks' => $oPage->getPageCode(),
+        	'bx_repeat:blocks' => $sContent,
         );
 
         return $oTemplate->parseHtmlByName('designer.html', $aTmplVars);
@@ -250,6 +281,20 @@ class BxBaseStudioDesigner extends BxDolStudioDesigner {
             )
         );
 
+        return $oTemplate->parseHtmlByName('designer.html', $aTmplVars);
+    }
+
+	protected function getSettings() {
+        $oTemplate = BxDolStudioTemplate::getInstance();
+        
+        bx_import('BxTemplStudioSettings');
+        $oPage = new BxTemplStudioSettings(BX_DOL_STUDIO_STG_TYPE_SYSTEM, BX_DOL_STUDIO_STG_CATEGORY_TEMPLATES);
+
+        $aTmplVars = array(
+            'js_object' => $this->getPageJsObject(),
+        	'bx_repeat:blocks' => $oPage->getPageCode(),
+        );
+
         return $oTemplate->parseHtmlByName('designer.html', $aTmplVars);
     }
 }

+ 5 - 5
studio/template/scripts/BxBaseStudioStore.php

@@ -292,9 +292,9 @@ class BxBaseStudioStore extends BxDolStudioStore {
 
 		//--- Prepare modules.
         foreach($aProducts['modules'] as $aModule) {
-            $sIcon = $oTemplate->getIconUrl($aModule['name'] . '@modules/' . $aModule['dir'] . '|std-si.png');
+        	$sIcon = $oTemplate->getIconUrl($aModule['name'] . '@modules/' . $aModule['dir'] . '|std-si.png');
             if(empty($sIcon))
-                $sIcon = $oTemplate->getIconUrl('pi-str-dump.png');
+                $sIcon = $oTemplate->getIconUrl('si-mod-empty.png');
 
             $sModules .= $oTemplate->parseHtmlByName('str_product_v1.html', array(
             	'js_object' => $sJsObject,
@@ -319,7 +319,7 @@ class BxBaseStudioStore extends BxDolStudioStore {
         foreach($aProducts['updates'] as $aUpdate) {
             $sIcon = $oTemplate->getIconUrl($aUpdate['module_name'] . '@modules/' . $aUpdate['module_dir'] . '|std-si.png');
             if(empty($sIcon))
-                $sIcon = $oTemplate->getIconUrl('pi-str-dump.png');
+                $sIcon = $oTemplate->getIconUrl('si-mod-empty.png');
 
             $sUpdates .= $oTemplate->parseHtmlByName('str_update_v1.html', array(
             	'js_object' => $sJsObject,
@@ -500,7 +500,7 @@ class BxBaseStudioStore extends BxDolStudioStore {
         		'js_object' => $sJsObject,
         		'id' => $aItem['id'],
 	            'url' => $aItem['url'],
-	            'icon' => !empty($aItem['thumbnail']['big']) ? $aItem['thumbnail']['big'] : $oTemplate->getIconUrl('pi-str-dump.png'),
+	            'icon' => !empty($aItem['thumbnail']['big']) ? $aItem['thumbnail']['big'] : $oTemplate->getIconUrl('si-mod-empty.png'),
 	            'title' => $aItem['title'],
         		'bx_if:show_vendor_price' => array(
         			'condition' => !$bShoppingCart,
@@ -563,7 +563,7 @@ class BxBaseStudioStore extends BxDolStudioStore {
         		'js_object' => $sJsObject,
         		'id' => $aItem['id'],
 	            'url' => $aItem['url'],
-	            'icon' => !empty($aItem['thumbnail']['big']) ? $aItem['thumbnail']['big'] : $oTemplate->getIconUrl('pi-str-dump.png'),
+	            'icon' => !empty($aItem['thumbnail']['big']) ? $aItem['thumbnail']['big'] : $oTemplate->getIconUrl('si-mod-empty.png'),
 	            'title' => $aItem['title'],
 	            'vendor' => $aItem['author'],
         		'versions' => _t('_adm_str_txt_update_from_to', $aItem['file_version'], $aItem['file_version_to']),

+ 26 - 0
studio/template/templates.html

@@ -0,0 +1,26 @@
+<div class="bx-dsg-templates">
+    <bx_repeat:templates>
+        <div class="bx-def-hr-auto bx-def-margin-top bx-def-margin-bottom"></div>
+        <div class="bx-dsg-template">
+            <div class="bx-dsg-icon bx-def-widget-size bx-def-round-corners-widget">
+				<img class="bx-def-widget-size" src="__icon__" />
+            </div>
+            <div class="bx-dsg-template-info bx-def-widget-size-min-height bx-def-widget-size-left-indent">
+                <div class="bx-dsg-template-title bx-def-margin-sec-top">
+                    <span class="bx-def-font-large">__title__</span>
+                    <bx_if:default>
+                        (<bx_text:_adm_dsg_txt_default />)
+                    </bx_if:default>
+                </div>
+                <div class="bx-dsg-template-subinfo bx-def-margin-thd-top bx-def-font-small">__vendor__ &bull; <span class="bx-dsg-template-version">__version__</span></div>
+                <div class="bx-dsg-template-actions bx-def-margin-thd-top">
+                    <bx_if:make_default>
+                        <a class="bx-btn bx-btn-small bx-def-margin-sec-left-auto" href="javascript:void(0)" onclick="javascript:__js_object__.makeDefault('__uri__')"><bx_text:_adm_dsg_btn_make_default /></a>
+                    </bx_if:make_default>
+                    <a class="bx-btn bx-btn-small bx-def-margin-sec-left-auto" href="<bx_url_root />?skin=__uri__&preview=1" target="_blank"><bx_text:_Preview /></a>
+                </div>
+            </div>
+            <div class="clear_both"></div>
+        </div>
+    </bx_repeat:templates>
+</div>