Quellcode durchsuchen

Ticket #268 - Non-Editable mixes and system settings.

AntonLV vor 10 Jahren
Ursprung
Commit
0ffc1fcc81

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

@@ -1241,6 +1241,7 @@
 	<string name="_adm_stg_txt_create_mix_popup"><![CDATA[Add New Mix]]></string>
 	<string name="_adm_stg_txt_import_mix_popup"><![CDATA[Import Mix]]></string>
 	<string name="_adm_stg_txt_mix_duplicate"><![CDATA[Duplicate from]]></string>
+	<string name="_adm_stg_txt_mix_duplicate_inf"><![CDATA[Use 'None' to duplicate System values]]></string>
 	<string name="_adm_stg_txt_mix_title"><![CDATA[Mix Title]]></string>
 	<string name="_adm_stg_txt_mix_title_err"><![CDATA[Title is essential. Please, fill in this field.]]></string>
 	<string name="_adm_stg_txt_mix_system"><![CDATA[System]]></string>

+ 1 - 0
modules/boonex/protean/classes/BxProteanStudioPage.php

@@ -52,6 +52,7 @@ class BxProteanStudioPage extends BxTemplStudioDesign
 			$sPrefix . '_viewport_mobile'
 		);
     	$oPage = new BxTemplStudioSettings($this->sTemplate, $aCategories, $sMix);
+    	$oPage->enableReadOnly(true);
     	$oPage->enableMixes(true);
 
     	$oTemplate->addJs(array('codemirror/codemirror.min.js'));

+ 2 - 2
modules/boonex/protean/install/sql/install.sql

@@ -343,8 +343,8 @@ INSERT INTO `sys_options`(`category_id`, `name`, `caption`, `value`, `type`, `ex
 
 
 -- MIXES
-INSERT INTO `sys_options_mixes` (`type`, `category`, `name`, `title`, `active`) VALUES
-(@sName, '', 'Neat-Mix', 'Neat Mix', 0);
+INSERT INTO `sys_options_mixes` (`type`, `category`, `name`, `title`, `active`, `editable`) VALUES
+(@sName, '', 'Neat-Mix', 'Neat Mix', 0, 0);
 SET @iMixId = LAST_INSERT_ID();
 
 INSERT INTO `sys_options_mixes2options` (`option`, `mix_id`, `value`) VALUES

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

@@ -1239,6 +1239,7 @@
 	<string name="_adm_stg_txt_create_mix_popup"><![CDATA[Добавить новый набор]]></string>
 	<string name="_adm_stg_txt_import_mix_popup"><![CDATA[Импортировать набор]]></string>
 	<string name="_adm_stg_txt_mix_duplicate"><![CDATA[Продублировать]]></string>
+	<string name="_adm_stg_txt_mix_duplicate_inf"><![CDATA[Используйте 'Никакой', чтобы продублировать Системные значения]]></string>
 	<string name="_adm_stg_txt_mix_title"><![CDATA[Название набора]]></string>
 	<string name="_adm_stg_txt_mix_title_err"><![CDATA[Нужно указать название. Пожалуйста, заполните это поле.]]></string>
 	<string name="_adm_stg_txt_mix_system"><![CDATA[Системный]]></string>

+ 16 - 1
studio/classes/BxDolStudioSettings.php

@@ -29,7 +29,9 @@ class BxDolStudioSettings extends BxTemplStudioPage
     protected $aCategories;
     protected $aCustomCategories;
 
-    protected $bMixes;
+    protected $bReadOnly;	//--- Enable/Disable ReadOnly mode for system settings. Note. It doesn't affect Editable mixes.
+
+    protected $bMixes;	//--- Enable/Disable mixes feature.
     protected $sMix;
     protected $aMix;
 
@@ -59,6 +61,8 @@ class BxDolStudioSettings extends BxTemplStudioPage
         	}
         }
 
+        $this->bReadOnly = false;
+
 		$this->bMixes = false;
 		$this->sMix = '';
 		$this->aMix = array();
@@ -115,6 +119,11 @@ class BxDolStudioSettings extends BxTemplStudioPage
         }
     }
 
+	public function enableReadOnly($bReadOnly = true)
+    {
+    	$this->bReadOnly = $bReadOnly;
+    }
+
     public function enableMixes($bMixes = true)
     {
     	$this->bMixes = $bMixes;
@@ -250,6 +259,12 @@ class BxDolStudioSettings extends BxTemplStudioPage
         return $this->getJsResult('_adm_stg_scs_save');
     }
 
+    protected function isReadOnly()
+    {
+    	$bMix = !empty($this->aMix);
+    	return (!$bMix && $this->bReadOnly) || ($bMix && (int)$this->aMix['editable'] == 0);
+    }
+
     protected function getSubmittedValue($aOption, &$oForm)
     {
     	$mixedValue = '';

+ 12 - 9
studio/template/scripts/BxBaseStudioSettings.php

@@ -151,13 +151,16 @@ class BxBaseStudioSettings extends BxDolStudioSettings
                     'db' => array (
                         'pass' => 'Xss',
                     ),
-                ),
+                )
+            ),
+
+            ($this->isReadOnly() ? array() : array(
                 'save' => array(
                     'type' => 'submit',
                     'name' => 'save',
                     'value' => _t("_adm_btn_settings_save"),
-                )
-            )
+                ),
+            ))
         );
 
         $oForm = new BxTemplStudioFormView($aForm, $oTemplate);
@@ -284,6 +287,7 @@ class BxBaseStudioSettings extends BxDolStudioSettings
 					'type' => 'select',
                     'name' => 'duplicate',
                     'caption' => _t('_adm_stg_txt_mix_duplicate'),
+					'info' => _t('_adm_stg_txt_mix_duplicate_inf'),
 					'values' => array(
 						array('key' => '', 'value' => _t('_None'))
 					),
@@ -489,14 +493,13 @@ class BxBaseStudioSettings extends BxDolStudioSettings
 
     protected function field($aItem, $aItems2Mixes)
     {
-    	$oTemplate = BxDolStudioTemplate::getInstance();
-
     	$mixedValue = isset($aItems2Mixes[$aItem['name']]) ? $aItems2Mixes[$aItem['name']] : $aItem['value'];
+
     	$aAttributes = array();
-    	if(!empty($this->aMix) && (int)$this->aMix['editable'] == 0)
-    	$aAttributes = array_merge($aAttributes, array(
-    		'disabled' => 'disabled'
-    	)); 	
+    	if($this->isReadOnly())
+	    	$aAttributes = array_merge($aAttributes, array(
+	    		'disabled' => 'disabled'
+	    	));
 
         $aField = array();
         switch($aItem['type']) {