AntonLV 11 лет назад
Родитель
Сommit
207633cc8f

+ 10 - 0
modules/boonex/developer/classes/BxDevFormsFields.php

@@ -41,6 +41,16 @@ class BxDevFormsFields extends BxTemplStudioFormsFields
             $this->_aQueryAppend['display'] = $this->sDisplay;
         }
     }
+
+	protected function _isEditable(&$aRow)
+    {
+    	return true;
+    }
+
+	protected function _isDeletable(&$aRow)
+    {
+    	return true;
+    }
 }
 
 /** @} */

+ 26 - 0
modules/boonex/developer/classes/BxDevFunctions.php

@@ -49,6 +49,32 @@ class BxDevFunctions
                 if(isset($aInput['checker']['func']) && stripos($aInput['checker']['func'], $sTrlCheckFuncPostfix) !== false)
                     $aInputs[$sName]['checker']['func'] = str_ireplace($sTrlCheckFuncPostfix, '', $aInput['checker']['func']);
             }
+
+		$aFields = array(
+            'editable' => array(
+                'type' => 'switcher',
+                'name' => 'editable',
+                'caption' => _t('_bx_dev_frm_txt_field_title_editable'),
+                'info' => _t('_bx_dev_frm_txt_field_info_editable'),
+                'value' => '1',
+                'required' => '0',
+                'db' => array (
+                    'pass' => 'Int',
+                )
+            ),
+            'deletable' => array(
+                'type' => 'switcher',
+                'name' => 'deletable',
+                'caption' => _t('_bx_dev_frm_txt_field_title_deletable'),
+                'info' => _t('_bx_dev_frm_txt_field_info_deletable'),
+                'value' => '1',
+                'required' => '0',
+                'db' => array (
+                    'pass' => 'Int',
+                )
+            ),
+        );
+        $aInputs = BxDolStudioUtils::addInArray($aInputs, 'controls', $aFields, false);
     }
 
     public static function serializeString($sValue)

+ 4 - 0
modules/boonex/developer/install/langs/en.xml

@@ -103,6 +103,10 @@
     <string name="_bx_dev_frm_btn_displays_save"><![CDATA[Save]]></string>
     <string name="_bx_dev_frm_btn_sys_displays_cancel"><![CDATA[Cancel]]></string>
     <string name="_bx_dev_frm_btn_displays_cancel"><![CDATA[Cancel]]></string>
+    <string name="_bx_dev_frm_txt_field_title_editable"><![CDATA[Editable]]></string>
+    <string name="_bx_dev_frm_txt_field_info_editable"><![CDATA[Make the field Editable in Studio Forms Builder]]></string>
+    <string name="_bx_dev_frm_txt_field_title_deletable"><![CDATA[Deletable]]></string>
+    <string name="_bx_dev_frm_txt_field_info_deletable"><![CDATA[Make the field Deletable in Studio Forms Builder]]></string>
     <string name="_bx_dev_frm_txt_prelists_create_popup"><![CDATA[Add Data List]]></string>
     <string name="_bx_dev_frm_err_prelists_create"><![CDATA[Cannot add data list]]></string>
     <string name="_bx_dev_frm_txt_prelists_edit_popup"><![CDATA[Edit "{0}" Data List]]></string>

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

@@ -103,6 +103,10 @@
     <string name="_bx_dev_frm_btn_displays_save"><![CDATA[Сохранить]]></string>
     <string name="_bx_dev_frm_btn_sys_displays_cancel"><![CDATA[Отменить]]></string>
     <string name="_bx_dev_frm_btn_displays_cancel"><![CDATA[Отменить]]></string>
+    <string name="_bx_dev_frm_txt_field_title_editable"><![CDATA[Редактируемое]]></string>
+    <string name="_bx_dev_frm_txt_field_info_editable"><![CDATA[Сделать поле Редактируемым в Редакторе Форм в Студии]]></string>
+    <string name="_bx_dev_frm_txt_field_title_deletable"><![CDATA[Удаляемое]]></string>
+    <string name="_bx_dev_frm_txt_field_info_deletable"><![CDATA[Сделать поле Удаляемым в Редакторе Форм в Студии]]></string>
     <string name="_bx_dev_frm_txt_prelists_create_popup"><![CDATA[Добавить список данных]]></string>
     <string name="_bx_dev_frm_err_prelists_create"><![CDATA[Невозможно добавить список данных]]></string>
     <string name="_bx_dev_frm_txt_prelists_edit_popup"><![CDATA[Редактировать список данных "{0}"]]></string>

+ 2 - 2
studio/classes/BxDolStudioFormsField.php

@@ -95,9 +95,9 @@ class BxDolStudioFormsField extends BxDol
         return BxDolStudioUtils::getClassName($sValue);
     }
 
-    protected function addInArray($aInput, $sKey, $aValues)
+    protected function addInArray($aInput, $sKey, $aValues, $bAddAfter = true)
     {
-        return BxDolStudioUtils::addInArray($aInput, $sKey, $aValues);
+        return BxDolStudioUtils::addInArray($aInput, $sKey, $aValues, $bAddAfter);
     }
 }
 

+ 6 - 3
studio/classes/BxDolStudioUtils.php

@@ -177,7 +177,7 @@ class BxDolStudioUtils extends BxDol
         }
     }
 
-    public static function addInArray($aInput, $sKey, $aValues)
+    public static function addInArray($aInput, $sKey, $aValues, $bAddAfter = true)
     {
         reset($aInput);
         $iInput = count($aInput);
@@ -185,9 +185,12 @@ class BxDolStudioUtils extends BxDol
             if(key($aInput) == $sKey)
                 break;
 
-        $aOutput = array_slice($aInput, 0, $i + 1);
+		if($bAddAfter)
+			$i += 1;
+
+        $aOutput = array_slice($aInput, 0, $i);
         $aOutput = array_merge($aOutput, $aValues);
-        $aOutput = array_merge($aOutput, array_slice($aInput, $i + 1));
+        $aOutput = array_merge($aOutput, array_slice($aInput, $i));
 
         return $aOutput;
     }

+ 6 - 0
studio/template/scripts/BxBaseStudioFormsField.php

@@ -268,6 +268,12 @@ class BxBaseStudioFormsField extends BxDolStudioFormsField
                         $aParams = unserialize($this->aField['attrs']);
                         $aForm['inputs'][$sKey]['value'] = isset($aParams['src']) ? $aParams['src'] : '';
                         break;
+                    case 'editable':
+                        $aForm['inputs'][$sKey]['checked'] = (int)$this->aField[$sKey];
+                        break;
+					case 'deletable':
+                        $aForm['inputs'][$sKey]['checked'] = (int)$this->aField[$sKey];
+                        break;
                     default:
                         $aForm['inputs'][$sKey]['value'] = $this->aField[$sKey];
                 }

+ 14 - 4
studio/template/scripts/BxBaseStudioFormsFields.php

@@ -347,7 +347,7 @@ class BxBaseStudioFormsFields extends BxDolStudioFormsFields
 
     protected function _getCellSwitcher ($mixedValue, $sKey, $aField, $aRow)
     {
-        if((int)$aRow['editable'] == 0)
+        if(!$this->_isEditable($aRow))
             return parent::_getCellDefault('', $sKey, $aField, $aRow);
 
         return parent::_getCellSwitcher($mixedValue, $sKey, $aField, $aRow);
@@ -367,7 +367,7 @@ class BxBaseStudioFormsFields extends BxDolStudioFormsFields
 
     protected function _getCellVisibleForLevels ($mixedValue, $sKey, $aField, $aRow)
     {
-        if((int)$aRow['editable'] == 0)
+        if(!$this->_isEditable($aRow))
             return parent::_getCellDefault('', $sKey, $aField, $aRow);
 
         $mixedValue = $this->_oTemplate->parseHtmlByName('bx_a.html', array(
@@ -393,7 +393,7 @@ class BxBaseStudioFormsFields extends BxDolStudioFormsFields
 
     protected function _getActionEdit ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
     {
-        if($sType == 'single' && (int)$aRow['editable'] == 0)
+        if($sType == 'single' && !$this->_isEditable($aRow))
             return '';
 
         return  parent::_getActionDefault($sType, $sKey, $a, false, $isDisabled, $aRow);
@@ -401,7 +401,7 @@ class BxBaseStudioFormsFields extends BxDolStudioFormsFields
 
     protected function _getActionDelete ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
     {
-        if($sType == 'single' && (int)$aRow['deletable'] == 0)
+        if($sType == 'single' && !$this->_isDeletable($aRow))
             return '';
 
         return  parent::_getActionDefault($sType, $sKey, $a, false, $isDisabled, $aRow);
@@ -439,6 +439,16 @@ class BxBaseStudioFormsFields extends BxDolStudioFormsFields
 
         return  $sContent;
     }
+
+    protected function _isEditable(&$aRow)
+    {
+    	return (int)$aRow['editable'] != 0;
+    }
+
+	protected function _isDeletable(&$aRow)
+    {
+    	return (int)$aRow['deletable'] != 0;
+    }
 }
 
 /** @} */