AntonLV před 7 roky
rodič
revize
3a607dd81c

+ 12 - 21
inc/classes/BxDolDb.php

@@ -661,34 +661,25 @@ class BxDolDb extends BxDolFactory implements iBxDolSingleton
 
         list($sTmplCode, $sTmplName) = BxDolTemplate::retrieveCode();
         if(!empty($sTmplCode) && !empty($sTmplName)) {
+            $iTmplMix = 0;
             if(is_array($sTmplCode))
                 list($sTmplCode, $iTmplMix) = $sTmplCode;
 
-            $sCacheNameMixed = self::$_sParamsCacheNameMixed . $sTmplCode;
+            if(empty($iTmplMix))
+                $iTmplMix = (int)$this->getParam($sTmplName . '_default_mix');
 
-            $bTmplMix = !empty($iTmplMix);
-            if($bTmplMix)
-                $sCacheNameMixed .= '_' . $iTmplMix;
+            if(!empty($iTmplMix)) {
+                $sCacheNameMixed = self::$_sParamsCacheNameMixed . $sTmplCode .  '_' . $iTmplMix;
+                if($bForceCacheInvalidateMixed)
+                    $this->cacheParamsClear($sCacheNameMixed);
 
-            if($bForceCacheInvalidateMixed)
-                $this->cacheParamsClear($sCacheNameMixed);
+                $aMixed = $this->fromCache($sCacheNameMixed, 'getPairs', "SELECT `option`, `value` FROM `sys_options_mixes2options` WHERE `mix_id`=:mix_id", "option", "value", array(
+                    'mix_id' => $iTmplMix
+                ));
 
-            $sQuery = "SELECT `tmo`.`option` AS `option`, `tmo`.`value` AS `value` FROM `sys_options_mixes2options` AS `tmo` INNER JOIN `sys_options_mixes` AS `tm` ON `tmo`.`mix_id`=`tm`.`id`";
-            $aBindings = array();
-
-            if($bTmplMix) {
-                $sQuery .= " AND `tm`.`id`=:mix_id";
-                $aBindings['mix_id'] = $iTmplMix;
-            }
-            else {
-                $sQuery .= " AND `tm`.`type`=:type AND `tm`.`active`='1'";
-                $aBindings['type'] = $sTmplName;
+                if(!empty($aMixed) && is_array($aMixed))
+                    self::$_aParams = array_merge(self::$_aParams, $aMixed);
             }
-
-            $aMixed = $this->fromCache($sCacheNameMixed, 'getPairs', $sQuery, "option", "value", $aBindings);
-
-            if(!empty($aMixed))
-            	self::$_aParams = array_merge(self::$_aParams, $aMixed);
         }
 
         if (empty(self::$_aParams)) {

+ 4 - 4
inc/classes/BxDolTemplate.php

@@ -370,7 +370,7 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
 
         $fCheckMix = function($aResult, $iMix, $bSetCookie) use($sMixKey, $sRootPath) {
             list($sCode, $sName) = $aResult;
-            if(empty($sName))
+            if(empty($sName) || empty($iMix))
                 return false;
 
             $aMix = BxDolDb::getInstance()->getParamsMix($iMix);
@@ -425,9 +425,9 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
 
         //--- Get default mix for currently selected template ---//
         if(empty($aResult[0][1]) && !empty($aResult[1])) {
-            $aMix = BxDolDb::getInstance()->getParamsMixActive($aResult[1]);
-            if(!empty($aMix) && is_array($aMix)) {
-                $iResultCheck = $fCheckMix($aResult, $aMix['id'], true);
+            $iMixId = (int)getParam($aResult[1] . '_default_mix');
+            if(!empty($iMixId)) {
+                $iResultCheck = $fCheckMix($aResult, $iMixId, false);
                 if($iResultCheck !== false)
                     $aResult[0][1] = $iResultCheck;
             }

+ 17 - 0
modules/base/template/classes/BxBaseModTemplateModule.php

@@ -19,6 +19,23 @@ class BxBaseModTemplateModule extends BxBaseModGeneralModule
 
         $this->_oConfig->init($this->_oDb);
     }
+
+    public function serviceGetOptionsDefaultMix()
+    {
+        $aResult = array(
+            array('key' => '', 'value' => _t('_Select_one'))
+        );
+
+        $aMixes = $this->_oDb->getMixes($this->_oConfig->getName());
+        foreach($aMixes as $aMix) {
+            $aResult[] = array(
+                'key' => $aMix['id'],
+                'value' => $aMix['title']
+            );
+        }
+
+        return $aResult;
+    }
 }
 
 /** @} */

+ 2 - 2
modules/boonex/decorous/classes/BxDecorousDb.php

@@ -9,12 +9,12 @@
  * @{
  */
 
-bx_import('BxBaseModGeneralDb');
+bx_import('BxBaseModTemplateDb');
 
 /*
  * Module database queries
  */
-class BxDecorousDb extends BxBaseModGeneralDb
+class BxDecorousDb extends BxBaseModTemplateDb
 {
     function __construct(&$oConfig)
     {

+ 1 - 0
modules/boonex/decorous/install/langs/en.xml

@@ -5,6 +5,7 @@
 	<string name="_bx_decorous_stg_cpt_type"><![CDATA[Decorous]]></string>
 	<string name="_bx_decorous_stg_cpt_category_system"><![CDATA[General]]></string>
 	<string name="_bx_decorous_stg_cpt_option_switcher_name"><![CDATA[Name In Template Switcher]]></string>
+        <string name="_bx_decorous_stg_cpt_option_default_mix"><![CDATA[Default mix]]></string>
 
 	<string name="_bx_decorous_stg_cpt_category_styles_general"><![CDATA[General]]></string>
 	<string name="_bx_decorous_stg_cpt_option_general_item_bg_color_hover"><![CDATA[On-hover item background color]]></string>

+ 2 - 1
modules/boonex/decorous/install/sql/install.sql

@@ -12,7 +12,8 @@ INSERT INTO `sys_options_categories`(`type_id`, `name`, `caption`, `order`) VALU
 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'), '_bx_decorous_stg_cpt_option_switcher_name', 'Decorous', 'digit', '', '', '', 1);
+(@iCategoryId, CONCAT(@sName, '_switcher_title'), '_bx_decorous_stg_cpt_option_switcher_name', 'Decorous', 'digit', '', '', '', 1),
+(@iCategoryId, CONCAT(@sName, '_default_mix'), '_bx_decorous_stg_cpt_option_default_mix', '', 'select', 'a:2:{s:6:"module";s:11:"bx_decorous";s:6:"method";s:23:"get_options_default_mix";}', '', '', 10);
 
 
 -- SETTINGS: Decorous template Styles General

+ 2 - 2
modules/boonex/lucid/classes/BxLucidDb.php

@@ -9,12 +9,12 @@
  * @{
  */
 
-bx_import('BxBaseModGeneralDb');
+bx_import('BxBaseModTemplateDb');
 
 /*
  * Module database queries
  */
-class BxLucidDb extends BxBaseModGeneralDb
+class BxLucidDb extends BxBaseModTemplateDb
 {
     function __construct(&$oConfig)
     {

+ 1 - 0
modules/boonex/lucid/install/langs/en.xml

@@ -6,6 +6,7 @@
 	<string name="_bx_lucid_stg_cpt_type"><![CDATA[Lucid]]></string>
 	<string name="_bx_lucid_stg_cpt_category_system"><![CDATA[General]]></string>
 	<string name="_bx_lucid_stg_cpt_option_switcher_name"><![CDATA[Name In Template Switcher]]></string>
+        <string name="_bx_lucid_stg_cpt_option_default_mix"><![CDATA[Default mix]]></string>
 
 	<string name="_bx_lucid_stg_cpt_category_styles_general"><![CDATA[General]]></string>
 	<string name="_bx_lucid_stg_cpt_option_general_item_bg_color_hover"><![CDATA[On-hover item background color]]></string>

+ 4 - 1
modules/boonex/lucid/install/sql/install.sql

@@ -12,7 +12,8 @@ INSERT INTO `sys_options_categories`(`type_id`, `name`, `caption`, `order`) VALU
 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'), '_bx_lucid_stg_cpt_option_switcher_name', 'Lucid', 'digit', '', '', '', 1);
+(@iCategoryId, CONCAT(@sName, '_switcher_title'), '_bx_lucid_stg_cpt_option_switcher_name', 'Lucid', 'digit', '', '', '', 1),
+(@iCategoryId, CONCAT(@sName, '_default_mix'), '_bx_lucid_stg_cpt_option_default_mix', '', 'select', 'a:2:{s:6:"module";s:8:"bx_lucid";s:6:"method";s:23:"get_options_default_mix";}', '', '', 10);
 
 
 -- SETTINGS: Lucid template Styles General
@@ -511,6 +512,8 @@ INSERT INTO `sys_options_mixes` (`type`, `category`, `name`, `title`, `active`,
 (@sName, '', 'Light-Mix', 'Light Mix', 1, 0);
 SET @iMixId = LAST_INSERT_ID();
 
+UPDATE `sys_options` SET `value`=@iMixId WHERE `name`=CONCAT(@sName, '_default_mix');
+
 INSERT INTO `sys_options_mixes2options` (`option`, `mix_id`, `value`) VALUES
 ('bx_lucid_button_nlp_bg_color_hover', @iMixId, 'rgba(50, 100, 180, 1)'),
 ('bx_lucid_button_nlp_bg_color', @iMixId, 'rgba(50, 150, 250, 1)'),

+ 2 - 2
modules/boonex/ocean/classes/BxOceanDb.php

@@ -9,12 +9,12 @@
  * @{
  */
 
-bx_import('BxBaseModGeneralDb');
+bx_import('BxBaseModTemplateDb');
 
 /*
  * Module database queries
  */
-class BxOceanDb extends BxBaseModGeneralDb
+class BxOceanDb extends BxBaseModTemplateDb
 {
     function __construct(&$oConfig)
     {

+ 1 - 1
modules/boonex/protean/classes/BxProteanDb.php

@@ -14,7 +14,7 @@ bx_import('BxBaseModGeneralDb');
 /*
  * Module database queries
  */
-class BxProteanDb extends BxBaseModGeneralDb
+class BxProteanDb extends BxBaseModTemplateDb
 {
     function __construct(&$oConfig)
     {

+ 2 - 1
modules/boonex/protean/install/langs/en.xml

@@ -4,7 +4,8 @@
 
 	<string name="_bx_protean_stg_cpt_type"><![CDATA[Protean]]></string>
 	<string name="_bx_protean_stg_cpt_category_system"><![CDATA[General]]></string>
-	<string name="_bx_protean_stg_cpt_option_switcher_name"><![CDATA[Name In Template Switcher]]></string>
+	<string name="_bx_protean_stg_cpt_option_switcher_name"><![CDATA[Name in Template Switcher]]></string>
+        <string name="_bx_protean_stg_cpt_option_default_mix"><![CDATA[Default mix]]></string>
 
 	<string name="_bx_protean_stg_cpt_category_styles_general"><![CDATA[General]]></string>
 	<string name="_bx_protean_stg_cpt_option_general_item_bg_color_hover"><![CDATA[On-hover item background color]]></string>

+ 4 - 1
modules/boonex/protean/install/sql/install.sql

@@ -12,7 +12,8 @@ INSERT INTO `sys_options_categories`(`type_id`, `name`, `caption`, `order`) VALU
 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'), '_bx_protean_stg_cpt_option_switcher_name', 'Protean', 'digit', '', '', '', 1);
+(@iCategoryId, CONCAT(@sName, '_switcher_title'), '_bx_protean_stg_cpt_option_switcher_name', 'Protean', 'digit', '', '', '', 1),
+(@iCategoryId, CONCAT(@sName, '_default_mix'), '_bx_protean_stg_cpt_option_default_mix', '', 'select', 'a:2:{s:6:"module";s:10:"bx_protean";s:6:"method";s:23:"get_options_default_mix";}', '', '', 10);
 
 
 -- SETTINGS: Protean template Styles General
@@ -629,6 +630,8 @@ INSERT INTO `sys_options_mixes` (`type`, `category`, `name`, `title`, `active`,
 (@sName, '', 'Protean-Light-Mix', 'Light Mix', 1, 1, 0);
 SET @iMixId = LAST_INSERT_ID();
 
+UPDATE `sys_options` SET `value`=@iMixId WHERE `name`=CONCAT(@sName, '_default_mix');
+
 INSERT INTO `sys_options_mixes2options` (`option`, `mix_id`, `value`) VALUES
 ('bx_protean_block_bg_color', @iMixId, 'rgba(255, 255, 255, 0.9)'),
 ('bx_protean_block_bg_image', @iMixId, '0'),

+ 1 - 0
modules/boonex/russian/data/langs/bx_decorous/ru.xml

@@ -5,6 +5,7 @@
 	<string name="_bx_decorous_stg_cpt_type"><![CDATA[Decorous]]></string>
 	<string name="_bx_decorous_stg_cpt_category_system"><![CDATA[Общие]]></string>
 	<string name="_bx_decorous_stg_cpt_option_switcher_name"><![CDATA[Название в переключателе тем]]></string>
+        <string name="_bx_decorous_stg_cpt_option_default_mix"><![CDATA[Набор по умолчанию]]></string>
 
 	<string name="_bx_decorous_stg_cpt_category_styles_general"><![CDATA[Общие]]></string>
 	<string name="_bx_decorous_stg_cpt_option_general_item_bg_color_hover"><![CDATA[Цвет фона пункта при наведении курсора]]></string>

+ 1 - 0
modules/boonex/russian/data/langs/bx_protean/ru.xml

@@ -5,6 +5,7 @@
 	<string name="_bx_protean_stg_cpt_type"><![CDATA[Protean]]></string>
 	<string name="_bx_protean_stg_cpt_category_system"><![CDATA[Общие]]></string>
 	<string name="_bx_protean_stg_cpt_option_switcher_name"><![CDATA[Название в переключателе тем]]></string>
+        <string name="_bx_protean_stg_cpt_option_default_mix"><![CDATA[Набор по умолчанию]]></string>
 
 	<string name="_bx_protean_stg_cpt_category_styles_general"><![CDATA[Общие]]></string>
 	<string name="_bx_protean_stg_cpt_option_general_item_bg_color_hover"><![CDATA[Цвет фона пункта при наведении курсора]]></string>