- Timestamp:
- 01/23/12 05:07:47 (4 months ago)
- Location:
- trunk
- Files:
-
- 10 edited
-
install/sql/v70.sql (modified) (1 diff)
-
modules/boonex/english/install/data/langs/en.xml (modified) (1 diff)
-
studio/classes/BxDolStudioFormsField.php (modified) (1 diff)
-
studio/classes/BxDolStudioFormsFields.php (modified) (2 diffs)
-
studio/classes/BxDolStudioFormsQuery.php (modified) (6 diffs)
-
studio/js/forms_fields.js (modified) (1 diff)
-
studio/templates/base/scripts/BxBaseStudioFormsDisplays.php (modified) (1 diff)
-
studio/templates/base/scripts/BxBaseStudioFormsField.php (modified) (40 diffs)
-
studio/templates/base/scripts/BxBaseStudioFormsFields.php (modified) (8 diffs)
-
studio/templates/tmpl_uni/scripts/BxTemplStudioFormsField.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/install/sql/v70.sql
r15905 r15906 4623 4623 ('sys_studio_forms', 'Sql', 'SELECT * FROM `sys_objects_form` WHERE 1 ', 'sys_objects_form', 'id', '', 'active', '', 100, NULL, 'start', '', 'title,module', 'auto', '', 'BxTemplStudioFormsForms', ''), 4624 4624 ('sys_studio_forms_displays', 'Sql', 'SELECT `td`.`id` AS `id`, `td`.`object` AS `object`, `td`.`display_name` AS `display_name`, `td`.`title` AS `title`, `td`.`module` AS `module`, `tf`.`title` AS `form_title` FROM `sys_form_displays` AS `td` LEFT JOIN `sys_objects_form` AS `tf` ON `td`.`object`=`tf`.`object` WHERE 1 ', 'sys_form_displays', 'id', '', '', '', 100, NULL, 'start', '', 'td`.`title,td`.`module', 'auto', '', 'BxTemplStudioFormsDisplays', ''), 4625 ('sys_studio_forms_fields', 'Sql', 'SELECT `tdi`.`id` AS `id`, `ti`.`caption` AS `title`, `ti`.`type` AS `type`, `ti`.`module` AS `module`, `tdi`.` active` AS `active`, `ti`.`editable` AS `editable`, `ti`.`deletable` AS `deletable`, `tdi`.`order` AS `order` FROM `sys_form_display_inputs` AS `tdi` LEFT JOIN `sys_form_inputs` AS `ti` ON `tdi`.`input_name`=`ti`.`name` AND `ti`.`object`=? WHERE 1 AND `tdi`.`display_name`=?', 'sys_form_display_inputs', 'id', 'order', 'active', '', 100, NULL, 'start', '', 'ti`.`type,ti`.`caption', 'auto', '', 'BxTemplStudioFormsFields', ''),4625 ('sys_studio_forms_fields', 'Sql', 'SELECT `tdi`.`id` AS `id`, `ti`.`caption` AS `title`, `ti`.`type` AS `type`, `ti`.`module` AS `module`, `tdi`.`visible_for_levels` AS `visible_for_levels`, `tdi`.`active` AS `active`, `ti`.`editable` AS `editable`, `ti`.`deletable` AS `deletable`, `tdi`.`order` AS `order` FROM `sys_form_display_inputs` AS `tdi` LEFT JOIN `sys_form_inputs` AS `ti` ON `tdi`.`input_name`=`ti`.`name` AND `ti`.`object`=? WHERE 1 AND `tdi`.`display_name`=?', 'sys_form_display_inputs', 'id', 'order', 'active', '', 100, NULL, 'start', '', 'ti`.`type,ti`.`caption', 'auto', '', 'BxTemplStudioFormsFields', ''), 4626 4626 ('sys_studio_forms_pre_lists', 'Sql', 'SELECT * FROM `sys_form_pre_lists` WHERE 1 ', 'sys_form_pre_lists', 'id', '', '', '', 100, NULL, 'start', '', 'module,key,title', 'auto', '', 'BxTemplStudioFormsPreLists', ''), 4627 4627 ('sys_studio_forms_pre_values', 'Sql', 'SELECT * FROM `sys_form_pre_values` WHERE 1 ', 'sys_form_pre_values', 'id', 'Order', '', '', 100, NULL, 'start', '', 'Key,Value,LKey,LKey2', 'auto', '', 'BxTemplStudioFormsPreValues', ''); -
trunk/modules/boonex/english/install/data/langs/en.xml
r15902 r15906 2327 2327 <string name="_adm_form_txt_field_value"><![CDATA[Value]]></string> 2328 2328 <string name="_adm_form_dsc_field_value"><![CDATA[Enter default value (optional)]]></string> 2329 <string name="_adm_form_txt_field_value_button"><![CDATA[Title]]></string> 2330 <string name="_adm_form_dsc_field_value_button"><![CDATA[Enter button title here]]></string> 2331 <string name="_adm_form_txt_field_value_checkbox"><![CDATA[Value]]></string> 2332 <string name="_adm_form_dsc_field_value_checkbox"><![CDATA[If enabled the value to be passed on form submit]]></string> 2329 2333 <string name="_adm_form_txt_field_values"><![CDATA[Values]]></string> 2330 2334 <string name="_adm_form_txt_field_manage_values"><![CDATA[Manage values]]></string> -
trunk/studio/classes/BxDolStudioFormsField.php
r15870 r15906 15 15 class BxDolStudioFormsField extends BxDol { 16 16 protected $oDb; 17 protected $aParams = array(); 17 18 protected $aField = array(); 19 protected $aCheckFunctions = array(); 18 20 19 public function __construct($a Field = array()) {21 public function __construct($aParams = array(), $aField = array()) { 20 22 parent::__construct(); 21 23 22 24 $this->oDb = new BxDolStudioFormsQuery(); 23 25 26 $this->aParams = $aParams; 24 27 $this->aField = $aField; 28 29 if(isset($this->aParams['object']) && isset($this->aParams['display'])) { 30 $aForm = array(); 31 $this->oDb->getForms(array('type' => 'by_object_display', 'object' => $this->aParams['object'], 'display' => $this->aParams['display']), $aForm, false); 32 33 $this->aParams['table'] = $aForm['table']; 34 } 35 } 36 37 function alterAdd($sName) { 38 if(!isset($this->aParams['table']) || !isset($this->aParams['table_field_type'])) 39 return ''; 40 41 return $this->oDb->alterAdd($this->aParams['table'], $sName, $this->aParams['table_field_type']); 42 } 43 44 function alterRemove($sName) { 45 if(!isset($this->aParams['table'])) 46 return ''; 47 48 return $this->oDb->alterRemove($this->aParams['table'], $sName); 25 49 } 26 50 -
trunk/studio/classes/BxDolStudioFormsFields.php
r15896 r15906 16 16 17 17 class BxDolStudioFormsFields extends BxTemplStudioGrid { 18 protected $sObject = ''; 18 19 protected $sDisplay = ''; 19 20 … … 23 24 $this->oDb = new BxDolStudioFormsQuery(); 24 25 26 $sObject = bx_process_input(bx_get('object')); 27 if($sObject != '') 28 $this->sObject = $sObject; 29 25 30 $sDisplay = bx_process_input(bx_get('display')); 26 31 if($sDisplay != '') 27 32 $this->sDisplay = $sDisplay; 28 33 34 $this->_aQueryAppend['object'] = $this->sObject; 29 35 $this->_aQueryAppend['display'] = $this->sDisplay; 30 36 } 31 37 32 38 protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage) { 33 if(empty($this->s Display))39 if(empty($this->sObject) || empty($this->sDisplay)) 34 40 return array(); 35 41 36 $this->oDb->checkFieldsInDisplays($this->s Display);42 $this->oDb->checkFieldsInDisplays($this->sObject, $this->sDisplay); 37 43 38 $aDisplay = array(); 39 $this->oDb->getDisplays(array('type' => 'by_name', 'value' => $this->sDisplay), $aDisplay, false); 40 if(empty($aDisplay) || !is_array($aDisplay)) 41 return array(); 42 43 $this->_aOptions['source'] = $this->oDb->prepare($this->_aOptions['source'], $aDisplay['object'], $aDisplay['name']); 44 $this->_aOptions['source'] = $this->oDb->prepare($this->_aOptions['source'], $this->sObject, $this->sDisplay); 44 45 return parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage); 45 46 } -
trunk/studio/classes/BxDolStudioFormsQuery.php
r15905 r15906 28 28 $sWhereClause = $this->prepare(" AND `tf`.`id`=? ", $aParams['value']); 29 29 break; 30 case 'by_object': 31 $sWhereClause = $this->prepare(" AND `tf`.`object`=? ", $aParams['value']); 30 case 'by_object_display': 31 $aMethod['name'] = 'getRow'; 32 $sJoinClause = "LEFT JOIN `sys_form_displays` AS `td` ON `tf`.`object`=`td`.`object` "; 33 $sWhereClause = $this->prepare(" AND `td`.`object`=? AND `td`.`display_name`=? ", $aParams['object'], $aParams['display']); 32 34 break; 33 35 case 'all': … … 76 78 $sLimitClause = "LIMIT 1"; 77 79 break; 80 case 'by_object_display': 81 $aMethod['name'] = 'getRow'; 82 $sWhereClause = $this->prepare(" AND `td`.`object`=? AND `td`.`display_name`=? ", $aParams['object'], $aParams['display']); 83 $sLimitClause = "LIMIT 1"; 84 break; 78 85 case 'by_name': 79 $aMethod['name'] = 'getRow';80 86 $sWhereClause = $this->prepare(" AND `td`.`display_name`=? ", $aParams['value']); 81 87 $sLimitClause = "LIMIT 1"; … … 111 117 LIMIT 1"; 112 118 return (int)$this->getOne($sQuery); 119 } 120 121 function isField($sObject, $sName) { 122 $sSql = $this->prepare("SELECT `id` FROM `sys_form_inputs` WHERE `object`=? AND `name`=? LIMIT 1", $sObject, $sName); 123 return (int)$this->getOne($sSql) > 0; 113 124 } 114 125 … … 134 145 $sWhereClause = $this->prepare(" AND `tdi`.`id`=? ", $aParams['value']); 135 146 break; 136 case 'by_ id_object':147 case 'by_object_id': 137 148 $aMethod['name'] = 'getRow'; 138 149 $sSelectClause = "`ti`.*, `tdi`.`id` AS `di_id`, `tdi`.`display_name` AS `display_name`"; 139 $sWhereClause = $this->prepare(" AND `tdi`.`id`=? AND `ti`.`object`=? ", $aParams['id'], $aParams['object']); 140 break; 141 case 'by_display_name': 142 $sWhereClause = $this->prepare(" AND `tdi`.`display_name`=? ", $aParams['value']); 143 break; 144 case 'by_object_display_names': 150 $sWhereClause = $this->prepare(" AND `ti`.`object`=? AND `tdi`.`id`=? ", $aParams['object'], $aParams['id']); 151 break; 152 case 'by_object_display': 145 153 $sWhereClause = $this->prepare(" AND `ti`.`object`=? AND `tdi`.`display_name`=? ", $aParams['object'], $aParams['display']); 146 154 break; … … 181 189 } 182 190 183 function checkFieldsInDisplays($sDisplayName) { 184 $aDisplay = array(); 185 $this->getDisplays(array('type' => 'by_name', 'value' => $sDisplayName), $aDisplay, false); 186 if(empty($aDisplay) || !is_array($aDisplay)) 187 return false; 188 189 $sSql = $this->prepare("INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`) SELECT ? AS `display_name`,`ti`.`name` AS `input_name` FROM `sys_form_inputs` AS `ti` LEFT JOIN `sys_form_display_inputs` AS `tdi` ON `ti`.`name`=`tdi`.`input_name` AND `tdi`.`display_name`=? WHERE 1 AND `ti`.`object`=? AND `tdi`.`id` IS NULL", $sDisplayName, $sDisplayName, $aDisplay['object']); 191 function checkFieldsInDisplays($sObject, $sDisplayName) { 192 $sSql = $this->prepare("INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`) SELECT ? AS `display_name`,`ti`.`name` AS `input_name` FROM `sys_form_inputs` AS `ti` LEFT JOIN `sys_form_display_inputs` AS `tdi` ON `ti`.`name`=`tdi`.`input_name` AND `tdi`.`display_name`=? WHERE 1 AND `ti`.`object`=? AND `tdi`.`id` IS NULL", $sDisplayName, $sDisplayName, $sObject); 190 193 return (int)$this->query($sSql) > 0; 191 194 } … … 309 312 return (int)$this->getOne($sSql); 310 313 } 314 315 function alterAdd($sTable, $sField, $sType) { 316 $sSql = "ALTER TABLE `" . $sTable . "` ADD `" . $sField . "` " . $sType; 317 $this->query($sSql); 318 } 319 320 function alterRemove($sTable, $sField) { 321 $sSql = "ALTER TABLE `" . $sTable . "` DROP `" . $sField . "`"; 322 $this->query($sSql); 323 } 311 324 } 312 325 /** @} */ -
trunk/studio/js/forms_fields.js
r15902 r15906 19 19 20 20 BxDolStudioFormsFields.prototype.onChangeDisplay = function() { 21 var sDisplay = $('#bx-grid-display-' + this.sObjNameGrid).val(); 22 document.location.href = this.sPageUrl + (sDisplay.length > 0 ? '&display=' + sDisplay : ''); 21 var aValue = $('#bx-grid-display-' + this.sObjNameGrid).val().split(this.sParamsDivider); 22 23 document.location.href = this.sPageUrl + (aValue.length == 2 ? '&object=' + aValue[0] + '&display=' + aValue[1] : ''); 23 24 }; 24 25 -
trunk/studio/templates/base/scripts/BxBaseStudioFormsDisplays.php
r15878 r15906 167 167 protected function _getCellFields ($mixedValue, $sKey, $aField, $aRow) { 168 168 $aFields = array(); 169 $this->oDb->getFields(array('type' => 'by_object_display _names', 'object' => $aRow['object'], 'display' => $aRow['display_name']), $aFields, false);169 $this->oDb->getFields(array('type' => 'by_object_display', 'object' => $aRow['object'], 'display' => $aRow['display_name']), $aFields, false); 170 170 171 171 $mixedValue = $this->_oTemplate->parseHtmlByName('bx_a.html', array( 172 'href' => BX_DOL_URL_STUDIO . 'builder_forms.php?page=fields& display=' . $aRow['display_name'],172 'href' => BX_DOL_URL_STUDIO . 'builder_forms.php?page=fields&object=' . $aRow['object'] . '&display=' . $aRow['display_name'], 173 173 'title' => _t('_adm_form_txt_displays_manage_fields'), 174 174 'bx_repeat:attrs' => array(), -
trunk/studio/templates/base/scripts/BxBaseStudioFormsField.php
r15902 r15906 19 19 protected $aForm; 20 20 21 function __construct($a Field = array()) {22 parent::__construct($a Field);21 function __construct($aParams = array(), $aField = array()) { 22 parent::__construct($aParams, $aField); 23 23 24 24 $this->aForm = array( … … 99 99 } 100 100 101 function getCode($sAction, $sObject , $sDisplay) {101 function getCode($sAction, $sObject) { 102 102 $sFunction = 'getCode' . $this->getClassName($sAction); 103 103 if(method_exists($this, $sFunction)) 104 return $this->$sFunction($sAction, $sObject , $sDisplay);104 return $this->$sFunction($sAction, $sObject); 105 105 106 106 return false; 107 107 } 108 108 109 protected function getCodeAdd($sAction, $sObject , $sDisplay) {110 $aForm = $this->getFormAdd($sAction, $sObject , $sDisplay);109 protected function getCodeAdd($sAction, $sObject) { 110 $aForm = $this->getFormAdd($sAction, $sObject); 111 111 $oForm = new BxTemplStudioFormView($aForm); 112 112 … … 116 116 $oForm->initChecker(); 117 117 if($oForm->isSubmittedAndValid()) { 118 $sName = $oForm->getCleanValue('name'); 119 BxDolForm::setSubmittedValue('name', $this->getSystemName($sName), $oForm->aFormAttrs['method']); 118 $sFormObject = $oForm->getCleanValue('object'); 119 120 $sName = $this->getSystemName($oForm->getCleanValue('name')); 121 if($this->oDb->isField($sFormObject, $sName)) 122 return false; 123 124 BxDolForm::setSubmittedValue('name', $sName, $oForm->aFormAttrs['method']); 120 125 121 126 $bCaption = false; … … 123 128 if(($bCaption = isset($oForm->aInputs['caption'])) === true) { 124 129 $sTitleValue = $oForm->getCleanValue('caption'); 125 $sTitleKey = '_sys_form_txt_caption_' . $this->getSystemName($s TitleValue);130 $sTitleKey = '_sys_form_txt_caption_' . $this->getSystemName($sFormObject . ' ' . $sTitleValue); 126 131 BxDolForm::setSubmittedValue('caption', $sTitleKey, $oForm->aFormAttrs['method']); 127 132 } … … 148 153 $sCheckerErrorValue = ""; 149 154 if(($bCheckError = isset($oForm->aInputs['checker_error'])) === true) { 150 $sInputObject = $oForm->getCleanValue('object');151 155 $sInputName = $oForm->getCleanValue('name'); 152 $sCheckerErrorKey = '_adm_form_txt_field_checker_error_' . $this->getSystemName($s InputObject . ' ' . $sInputName);156 $sCheckerErrorKey = '_adm_form_txt_field_checker_error_' . $this->getSystemName($sFormObject . ' ' . $sInputName); 153 157 $sCheckerErrorValue = $oForm->getCleanValue('checker_error'); 154 158 … … 172 176 return false; 173 177 178 $this->alterAdd($sName); 179 174 180 $oLanguages = BxDolStudioLanguagesUtils::getInstance(); 175 181 if($bCaption) … … 181 187 } 182 188 else 183 return BxTemplStudioFunctions::getInstance()->popupBox('adm-form-field-add-' . $ sDisplay. '-popup', _t('_adm_form_txt_field_add_popup'), BxDolStudioTemplate::getInstance()->parseHtmlByName('form_add_field.html', array(189 return BxTemplStudioFunctions::getInstance()->popupBox('adm-form-field-add-' . $this->aParams['display'] . '-popup', _t('_adm_form_txt_field_add_popup'), BxDolStudioTemplate::getInstance()->parseHtmlByName('form_add_field.html', array( 184 190 'form_id' => $aForm['form_attrs']['id'], 185 191 'form' => $oForm->getCode(), … … 189 195 } 190 196 191 protected function getCodeEdit($sAction, $sObject , $sDisplay) {192 $aForm = $this->getFormEdit($sAction, $sObject , $sDisplay);197 protected function getCodeEdit($sAction, $sObject) { 198 $aForm = $this->getFormEdit($sAction, $sObject); 193 199 $oForm = new BxTemplStudioFormView($aForm); 194 200 … … 198 204 $oForm->initChecker(); 199 205 if($oForm->isSubmittedAndValid()) { 206 $sName = $oForm->getCleanValue('name'); 207 200 208 $sTitleValue = ''; 201 209 if(($bCaption = isset($oForm->aInputs['caption'])) === true) { … … 249 257 return false; 250 258 259 $this->alterRemove($sName); 260 $this->alterAdd($sName); 261 251 262 $oLanguages = BxDolStudioLanguagesUtils::getInstance(); 252 263 … … 267 278 } 268 279 269 protected function getFormAdd($sAction, $sObject , $sDisplay) {280 protected function getFormAdd($sAction, $sObject) { 270 281 $aForm = $this->aForm; 271 $aForm['form_attrs']['id'] = 'adm-form-field-add-' . $sDisplay; 272 $aForm['form_attrs']['action'] = BX_DOL_URL_ROOT . 'grid.php?o=' . $sObject . '&a=' . $sAction . '&display=' . $sDisplay; 273 274 if(isset($aForm['inputs']['object'])) { 275 $aDisplay = array(); 276 $this->oDb->getDisplays(array('type' => 'by_name', 'value' => $sDisplay), $aDisplay, false); 277 if(!empty($aDisplay)) 278 $aForm['inputs']['object']['value'] = $aDisplay['object']; 279 } 282 $aForm['form_attrs']['id'] = 'adm-form-field-add-' . $this->aParams['display']; 283 $aForm['form_attrs']['action'] = BX_DOL_URL_ROOT . 'grid.php?o=' . $sObject . '&a=' . $sAction . '&object=' . $this->aParams['object'] . '&display=' . $this->aParams['display']; 284 285 if(isset($aForm['inputs']['object'])) 286 $aForm['inputs']['object']['value'] = $this->aParams['object']; 280 287 281 288 return $aForm; 282 289 } 283 290 284 protected function getFormEdit($sAction, $sObject , $sDisplay) {291 protected function getFormEdit($sAction, $sObject) { 285 292 $aForm = $this->aForm; 286 $aForm['form_attrs']['id'] = 'adm-form-field-edit-' . $ sDisplay;287 $aForm['form_attrs']['action'] = BX_DOL_URL_ROOT . 'grid.php?o=' . $sObject . '&a=' . $sAction . '& display=' . $sDisplay. '&di_id=' . (int)$this->aField['di_id'];293 $aForm['form_attrs']['id'] = 'adm-form-field-edit-' . $this->aParams['display']; 294 $aForm['form_attrs']['action'] = BX_DOL_URL_ROOT . 'grid.php?o=' . $sObject . '&a=' . $sAction . '&object=' . $this->aParams['object'] . '&display=' . $this->aParams['display'] . '&di_id=' . (int)$this->aField['di_id']; 288 295 289 296 foreach($aForm['inputs'] as $sKey => $aInput) … … 399 406 } 400 407 protected function getCheckerFields() { 401 returnarray(408 $aResult = array( 402 409 'checker_func' => array( 403 410 'type' => 'select', … … 407 414 'value' => '', 408 415 'values' => array( 409 array('key' => '', 'value' => _t('_adm_form_txt_field_checker_empty')), 410 array('key' => 'avail', 'value' => _t('_adm_form_txt_field_checker_avail')), 411 array('key' => 'length', 'value' => _t('_adm_form_txt_field_checker_length')), 412 array('key' => 'date', 'value' => _t('_adm_form_txt_field_checker_date')), 413 array('key' => 'date_time', 'value' => _t('_adm_form_txt_field_checker_date_time')), 414 array('key' => 'preg', 'value' => _t('_adm_form_txt_field_checker_preg')), 415 array('key' => 'email', 'value' => _t('_adm_form_txt_field_checker_email')), 416 array('key' => 'captcha', 'value' => _t('_adm_form_txt_field_checker_captcha')), 417 array('key' => 'no_spam', 'value' => _t('_adm_form_txt_field_checker_no_spam')) 416 array('key' => '', 'value' => _t('_adm_form_txt_field_checker_empty')) 418 417 ), 419 418 'required' => '1', … … 519 518 ), 520 519 ); 520 521 foreach($this->aCheckFunctions as $sCheckFunction) 522 $aResult['checker_func']['values'][] = array('key' => $sCheckFunction, 'value' => _t('_adm_form_txt_field_checker_' . $sCheckFunction)); 523 524 return $aResult; 521 525 } 522 526 … … 569 573 570 574 class BxBaseStudioFormsFieldBlockHeader extends BxBaseStudioFormsField { 571 function __construct($a Field = array()) {572 parent::__construct($a Field);575 function __construct($aParams = array(), $aField = array()) { 576 parent::__construct($aParams, $aField); 573 577 574 578 $this->aForm = array( … … 680 684 681 685 class BxBaseStudioFormsFieldValue extends BxBaseStudioFormsFieldBlockHeader { 682 function __construct($a Field = array()) {683 parent::__construct($a Field);686 function __construct($aParams = array(), $aField = array()) { 687 parent::__construct($aParams, $aField); 684 688 685 689 $this->aForm['inputs']['type']['value'] = 'value'; … … 708 712 709 713 class BxBaseStudioFormsFieldText extends BxBaseStudioFormsFieldBlockHeader { 710 function __construct($aField = array()) { 711 parent::__construct($aField); 714 protected $aCheckFunctions = array('avail', 'length', 'preg', 'email'); 715 716 function __construct($aParams = array(), $aField = array()) { 717 parent::__construct($aParams, $aField); 718 719 $this->aParams['table_field_type'] = 'varchar(255)'; 712 720 713 721 $this->aForm['inputs']['type']['value'] = 'text'; … … 753 761 ) 754 762 ); 755 763 756 764 $aFields = array_merge($aFields, $this->getCheckerFields()); 757 765 … … 765 773 766 774 class BxBaseStudioFormsFieldPassword extends BxBaseStudioFormsFieldText { 767 function __construct($aField = array()) { 768 parent::__construct($aField); 775 protected $aCheckFunctions = array('avail', 'length', 'preg'); 776 777 function __construct($aParams = array(), $aField = array()) { 778 parent::__construct($aParams, $aField); 769 779 770 780 $this->aForm['inputs']['type']['value'] = 'password'; … … 774 784 775 785 class BxBaseStudioFormsFieldTextarea extends BxBaseStudioFormsFieldText { 776 function __construct($aField = array()) { 777 parent::__construct($aField); 786 protected $aCheckFunctions = array('avail', 'length', 'preg'); 787 788 function __construct($aParams = array(), $aField = array()) { 789 parent::__construct($aParams, $aField); 790 791 $this->aParams['table_field_type'] = 'text'; 778 792 779 793 $this->aForm['inputs']['type']['value'] = 'textarea'; … … 805 819 806 820 class BxBaseStudioFormsFieldNumber extends BxBaseStudioFormsFieldText { 807 function __construct($aField = array()) { 808 parent::__construct($aField); 821 protected $aCheckFunctions = array('avail', 'length', 'preg'); 822 823 function __construct($aParams = array(), $aField = array()) { 824 parent::__construct($aParams, $aField); 825 826 $this->aParams['table_field_type'] = 'int(11)'; 809 827 810 828 $this->aForm['inputs']['type']['value'] = 'number'; … … 814 832 815 833 class BxBaseStudioFormsFieldDatepicker extends BxBaseStudioFormsFieldText { 816 function __construct($aField = array()) { 817 parent::__construct($aField); 834 protected $aCheckFunctions = array('date'); 835 836 function __construct($aParams = array(), $aField = array()) { 837 parent::__construct($aParams, $aField); 838 839 $this->aParams['table_field_type'] = 'int(11)'; 818 840 819 841 $this->aForm['inputs']['type']['value'] = 'date'; … … 823 845 824 846 class BxBaseStudioFormsFieldDatetime extends BxBaseStudioFormsFieldDatepicker { 825 function __construct($aField = array()) { 826 parent::__construct($aField); 847 protected $aCheckFunctions = array('date_time'); 848 849 function __construct($aParams = array(), $aField = array()) { 850 parent::__construct($aParams, $aField); 851 852 $this->aParams['table_field_type'] = 'int(11)'; 827 853 828 854 $this->aForm['inputs']['type']['value'] = 'datetime'; … … 832 858 833 859 class BxBaseStudioFormsFieldCheckbox extends BxBaseStudioFormsFieldText { 834 function __construct($aField = array()) { 835 parent::__construct($aField); 860 protected $aCheckFunctions = array('avail', 'length', 'preg'); 861 862 function __construct($aParams = array(), $aField = array()) { 863 parent::__construct($aParams, $aField); 836 864 837 865 $this->aForm['inputs']['type']['value'] = 'checkbox'; 838 866 $this->aForm['inputs']['type_display']['value'] = 'checkbox'; 867 $this->aForm['inputs']['value']['caption'] = _t('_adm_form_txt_field_value_checkbox'); 868 $this->aForm['inputs']['value']['info'] = _t('_adm_form_dsc_field_value_checkbox'); 839 869 840 870 $aFields = array( … … 856 886 857 887 class BxBaseStudioFormsFieldSwitcher extends BxBaseStudioFormsFieldCheckbox { 858 function __construct($aField = array()) { 859 parent::__construct($aField); 888 protected $aCheckFunctions = array('avail', 'length', 'preg'); 889 890 function __construct($aParams = array(), $aField = array()) { 891 parent::__construct($aParams, $aField); 860 892 861 893 $this->aForm['inputs']['type']['value'] = 'switcher'; … … 865 897 866 898 class BxBaseStudioFormsFieldFile extends BxBaseStudioFormsFieldText { 867 function __construct($aField = array()) { 868 parent::__construct($aField); 899 protected $aCheckFunctions = array('avail', 'length', 'preg'); 900 901 function __construct($aParams = array(), $aField = array()) { 902 parent::__construct($aParams, $aField); 869 903 870 904 $this->aForm['inputs']['type']['value'] = 'file'; … … 878 912 879 913 class BxBaseStudioFormsFieldSlider extends BxBaseStudioFormsFieldText { 880 function __construct($aField = array()) { 881 parent::__construct($aField); 914 protected $aCheckFunctions = array('avail', 'length'); 915 916 function __construct($aParams = array(), $aField = array()) { 917 parent::__construct($aParams, $aField); 918 919 $this->aParams['table_field_type'] = 'int(11)'; 882 920 883 921 $this->aForm['inputs']['type']['value'] = 'slider'; … … 932 970 933 971 class BxBaseStudioFormsFieldDoublerange extends BxBaseStudioFormsFieldSlider { 934 function __construct($aField = array()) { 935 parent::__construct($aField); 972 protected $aCheckFunctions = array('avail', 'length'); 973 974 function __construct($aParams = array(), $aField = array()) { 975 parent::__construct($aParams, $aField); 976 977 $this->aParams['table_field_type'] = 'varchar(255)'; 936 978 937 979 $this->aForm['inputs']['type']['value'] = 'doublerange'; … … 941 983 942 984 class BxBaseStudioFormsFieldHidden extends BxBaseStudioFormsFieldText { 943 function __construct($aField = array()) { 944 parent::__construct($aField); 985 protected $aCheckFunctions = array('avail', 'length', 'preg', 'date', 'date_time', 'email'); 986 987 function __construct($aParams = array(), $aField = array()) { 988 parent::__construct($aParams, $aField); 945 989 946 990 $this->aForm['inputs']['type']['value'] = 'hidden'; … … 962 1006 963 1007 class BxBaseStudioFormsFieldButton extends BxBaseStudioFormsFieldText { 964 function __construct($a Field = array()) {965 parent::__construct($a Field);1008 function __construct($aParams = array(), $aField = array()) { 1009 parent::__construct($aParams, $aField); 966 1010 967 1011 $this->aForm['inputs']['type']['value'] = 'button'; 968 1012 $this->aForm['inputs']['type_display']['value'] = 'button'; 969 1013 $this->aForm['inputs']['value']['caption'] = _t('_adm_form_txt_field_value_button'); 1014 $this->aForm['inputs']['value']['info'] = _t('_adm_form_dsc_field_value_button'); 1015 970 1016 unset( 971 1017 $this->aForm['inputs']['caption'], … … 983 1029 984 1030 class BxBaseStudioFormsFieldReset extends BxBaseStudioFormsFieldButton { 985 function __construct($a Field = array()) {986 parent::__construct($a Field);1031 function __construct($aParams = array(), $aField = array()) { 1032 parent::__construct($aParams, $aField); 987 1033 988 1034 $this->aForm['inputs']['type']['value'] = 'reset'; … … 992 1038 993 1039 class BxBaseStudioFormsFieldSubmit extends BxBaseStudioFormsFieldButton { 994 function __construct($a Field = array()) {995 parent::__construct($a Field);1040 function __construct($aParams = array(), $aField = array()) { 1041 parent::__construct($aParams, $aField); 996 1042 997 1043 $this->aForm['inputs']['type']['value'] = 'submit'; … … 1001 1047 1002 1048 class BxBaseStudioFormsFieldImage extends BxBaseStudioFormsFieldButton { 1003 function __construct($a Field = array()) {1004 parent::__construct($a Field);1049 function __construct($aParams = array(), $aField = array()) { 1050 parent::__construct($aParams, $aField); 1005 1051 1006 1052 $this->aForm['inputs']['type']['value'] = 'image'; … … 1037 1083 1038 1084 class BxBaseStudioFormsFieldSelect extends BxBaseStudioFormsFieldText { 1039 function __construct($aField = array()) { 1040 parent::__construct($aField); 1085 protected $aCheckFunctions = array('avail', 'length', 'preg'); 1086 1087 function __construct($aParams = array(), $aField = array()) { 1088 parent::__construct($aParams, $aField); 1089 1090 $this->aParams['table_field_type'] = 'int(11)'; 1041 1091 1042 1092 $this->aForm['inputs']['type']['value'] = 'select'; … … 1068 1118 1069 1119 class BxBaseStudioFormsFieldRadioSet extends BxBaseStudioFormsFieldSelect { 1070 function __construct($aField = array()) { 1071 parent::__construct($aField); 1120 protected $aCheckFunctions = array('avail', 'length', 'preg'); 1121 1122 function __construct($aParams = array(), $aField = array()) { 1123 parent::__construct($aParams, $aField); 1124 1125 $this->aParams['table_field_type'] = 'int(11)'; 1072 1126 1073 1127 $this->aForm['inputs']['type']['value'] = 'radio_set'; … … 1077 1131 1078 1132 class BxBaseStudioFormsFieldSelectMultiple extends BxBaseStudioFormsFieldSelect { 1079 function __construct($aField = array()) { 1080 parent::__construct($aField); 1133 protected $aCheckFunctions = array('avail', 'length', 'preg'); 1134 1135 function __construct($aParams = array(), $aField = array()) { 1136 parent::__construct($aParams, $aField); 1137 1138 $this->aParams['table_field_type'] = 'varchar(255)'; 1081 1139 1082 1140 $this->aForm['inputs']['type']['value'] = 'select_multiple'; … … 1086 1144 1087 1145 class BxBaseStudioFormsFieldCheckboxSet extends BxBaseStudioFormsFieldSelect { 1088 function __construct($aField = array()) { 1089 parent::__construct($aField); 1146 protected $aCheckFunctions = array('avail', 'length', 'preg'); 1147 1148 function __construct($aParams = array(), $aField = array()) { 1149 parent::__construct($aParams, $aField); 1150 1151 $this->aParams['table_field_type'] = 'varchar(255)'; 1090 1152 1091 1153 $this->aForm['inputs']['type']['value'] = 'checkbox_set'; … … 1095 1157 1096 1158 class BxBaseStudioFormsFieldCustom extends BxBaseStudioFormsFieldText { 1097 function __construct($aField = array()) { 1098 parent::__construct($aField); 1159 function __construct($aParams = array(), $aField = array()) { 1160 parent::__construct($aParams, $aField); 1161 1162 $this->aParams['table_field_type'] = 'varchar(255)'; 1099 1163 1100 1164 $this->aForm['inputs']['type']['value'] = 'custom'; … … 1114 1178 1115 1179 class BxBaseStudioFormsFieldInputSet extends BxBaseStudioFormsFieldCustom { 1116 function __construct($a Field = array()) {1117 parent::__construct($a Field);1180 function __construct($aParams = array(), $aField = array()) { 1181 parent::__construct($aParams, $aField); 1118 1182 1119 1183 $this->aForm['inputs']['type']['value'] = 'input_set'; … … 1137 1201 1138 1202 class BxBaseStudioFormsFieldCaptcha extends BxBaseStudioFormsFieldText { 1139 function __construct($aField = array()) { 1140 parent::__construct($aField); 1203 protected $aCheckFunctions = array('captcha'); 1204 1205 function __construct($aParams = array(), $aField = array()) { 1206 parent::__construct($aParams, $aField); 1141 1207 1142 1208 $this->aForm['inputs']['type']['value'] = 'captcha'; -
trunk/studio/templates/base/scripts/BxBaseStudioFormsFields.php
r15902 r15906 11 11 12 12 bx_import('BxDolStudioFormsFields'); 13 bx_import('BxTemplStudioFormsField'); 13 14 14 15 define('BX_DOL_STUDIO_FORMS_FIELDS_JS_OBJECT', 'oBxDolStudioFormsFields'); … … 26 27 $sType = bx_process_input($mixedType); 27 28 28 bx_import('BxTemplStudioFormsField');29 29 $sClass = 'BxTemplStudioFormsField' . $this->getClassName($sType); 30 $oClass = new $sClass( );31 32 $mixedResult = $oClass->getCode($sAction, $this->_sObject , $this->sDisplay);30 $oClass = new $sClass(array('object' => $this->sObject, 'display' => $this->sDisplay)); 31 32 $mixedResult = $oClass->getCode($sAction, $this->_sObject); 33 33 if(is_string($mixedResult)) 34 34 $this->_echoResultJson(array('popup' => $mixedResult), true); … … 55 55 $iId = $aIds[0]; 56 56 57 $a Display= array();58 $this->oDb->get Displays(array('type' => 'by_name', 'value' => $this->sDisplay), $aDisplay, false);59 if( !is_array($aDisplay) || empty($aDisplay)){57 $aField = array(); 58 $this->oDb->getFields(array('type' => 'by_object_id', 'object' => $this->sObject, 'id' => (int)$iId), $aField, false); 59 if(empty($aField) || !is_array($aField)) { 60 60 $this->_echoResultJson(array()); 61 61 exit; 62 62 } 63 63 64 $aField = array();65 $this->oDb->getFields(array('type' => 'by_id_object', 'id' => $iId, 'object' => $aDisplay['object']), $aField, false);66 if(!is_array($aField) || empty($aField)) {67 $this->_echoResultJson(array());68 exit;69 }70 71 bx_import('BxTemplStudioFormsField');72 64 $sClass = "BxTemplStudioFormsField" . $this->getClassName($aField['type']); 73 65 if(!class_exists($sClass)) { … … 76 68 } 77 69 78 $oClass = new $sClass( $aField);79 $mixedResult = $oClass->getCode($sAction, $this->_sObject , $this->sDisplay);70 $oClass = new $sClass(array('object' => $this->sObject, 'display' => $this->sDisplay), $aField); 71 $mixedResult = $oClass->getCode($sAction, $this->_sObject); 80 72 if(is_string($mixedResult)) 81 73 $this->_echoResultJson(array('popup' => $mixedResult), true); … … 96 88 } 97 89 98 $aDisplay = array();99 $this->oDb->getDisplays(array('type' => 'by_name', 'value' => $this->sDisplay), $aDisplay, false);100 if(!is_array($aDisplay) || empty($aDisplay)){101 $this->_echoResultJson(array());102 exit;103 }104 105 90 $aIdsAffected = array (); 106 91 foreach($aIds as $iId) { 107 92 $aField = array(); 108 $ iField = $this->oDb->getFields(array('type' => 'by_id_object', 'id' => (int)$iId, 'object' => $aDisplay['object']), $aField);109 if( $iField != 1 || empty($aField))93 $this->oDb->getFields(array('type' => 'by_object_id', 'object' => $this->sObject, 'id' => (int)$iId), $aField, false); 94 if(empty($aField) || !is_array($aField)) 110 95 continue; 111 96 … … 113 98 continue; 114 99 100 $sClass = 'BxTemplStudioFormsField' . $this->getClassName($aField['type']); 101 $oClass = new $sClass(array('object' => $this->sObject, 'display' => $this->sDisplay)); 102 115 103 if((int)$this->_delete($iId) <= 0 || !$this->oDb->deleteFieds(array('type' => 'by_id', 'value' => $aField['id']))) 116 104 continue; 105 106 $oClass->alterRemove($aField['name']); 117 107 118 108 bx_import('BxDolStudioLanguagesUtils'); … … 197 187 'onChange' => 'javascript:' . $this->getJsObject() . '.onChangeDisplay()' 198 188 ), 199 'value' => $this->s Display,189 'value' => $this->sObject . $this->sParamsDivider . $this->sDisplay, 200 190 'values' => array( 201 191 array('key' => '', 'value' => _t('_adm_form_txt_select_display')), … … 214 204 215 205 foreach($aDisplays as $aDisplay) 216 $aInputDisplays['values'][] = array('key' => $aDisplay[' name'], 'value' => _t($aDisplay['title']));206 $aInputDisplays['values'][] = array('key' => $aDisplay['object'] . $this->sParamsDivider . $aDisplay['name'], 'value' => _t($aDisplay['title'])); 217 207 218 208 if(count($aDisplays) > 0) -
trunk/studio/templates/tmpl_uni/scripts/BxTemplStudioFormsField.php
r15870 r15906 13 13 14 14 class BxTemplStudioFormsField extends BxBaseStudioFormsField { 15 function __construct($a Field = array()) {16 parent::__construct($a Field);15 function __construct($aParams = array(), $aField = array()) { 16 parent::__construct($aParams, $aField); 17 17 } 18 18 } 19 19 20 20 class BxTemplStudioFormsFieldBlockHeader extends BxBaseStudioFormsFieldBlockHeader { 21 function __construct($a Field = array()) {22 parent::__construct($a Field);21 function __construct($aParams = array(), $aField = array()) { 22 parent::__construct($aParams, $aField); 23 23 } 24 24 } 25 25 26 26 class BxTemplStudioFormsFieldValue extends BxBaseStudioFormsFieldValue { 27 function __construct($a Field = array()) {28 parent::__construct($a Field);27 function __construct($aParams = array(), $aField = array()) { 28 parent::__construct($aParams, $aField); 29 29 } 30 30 } 31 31 32 32 class BxTemplStudioFormsFieldText extends BxBaseStudioFormsFieldText { 33 function __construct($a Field = array()) {34 parent::__construct($a Field);33 function __construct($aParams = array(), $aField = array()) { 34 parent::__construct($aParams, $aField); 35 35 } 36 36 } 37 37 38 38 class BxTemplStudioFormsFieldPassword extends BxBaseStudioFormsFieldPassword { 39 function __construct($a Field = array()) {40 parent::__construct($a Field);39 function __construct($aParams = array(), $aField = array()) { 40 parent::__construct($aParams, $aField); 41 41 } 42 42 } 43 43 44 44 class BxTemplStudioFormsFieldTextarea extends BxBaseStudioFormsFieldTextarea { 45 function __construct($a Field = array()) {46 parent::__construct($a Field);45 function __construct($aParams = array(), $aField = array()) { 46 parent::__construct($aParams, $aField); 47 47 } 48 48 } 49 49 50 50 class BxTemplStudioFormsFieldNumber extends BxBaseStudioFormsFieldNumber { 51 function __construct($a Field = array()) {52 parent::__construct($a Field);51 function __construct($aParams = array(), $aField = array()) { 52 parent::__construct($aParams, $aField); 53 53 } 54 54 } 55 55 56 56 class BxTemplStudioFormsFieldDatepicker extends BxBaseStudioFormsFieldDatepicker { 57 function __construct($a Field = array()) {58 parent::__construct($a Field);57 function __construct($aParams = array(), $aField = array()) { 58 parent::__construct($aParams, $aField); 59 59 } 60 60 } 61 61 62 62 class BxTemplStudioFormsFieldDatetime extends BxBaseStudioFormsFieldDatetime { 63 function __construct($a Field = array()) {64 parent::__construct($a Field);63 function __construct($aParams = array(), $aField = array()) { 64 parent::__construct($aParams, $aField); 65 65 } 66 66 } 67 67 68 68 class BxTemplStudioFormsFieldCheckbox extends BxBaseStudioFormsFieldCheckbox { 69 function __construct($a Field = array()) {70 parent::__construct($a Field);69 function __construct($aParams = array(), $aField = array()) { 70 parent::__construct($aParams, $aField); 71 71 } 72 72 } 73 73 74 74 class BxTemplStudioFormsFieldSwitcher extends BxBaseStudioFormsFieldSwitcher { 75 function __construct($a Field = array()) {76 parent::__construct($a Field);75 function __construct($aParams = array(), $aField = array()) { 76 parent::__construct($aParams, $aField); 77 77 } 78 78 } 79 79 80 80 class BxTemplStudioFormsFieldFile extends BxBaseStudioFormsFieldFile { 81 function __construct($a Field = array()) {82 parent::__construct($a Field);81 function __construct($aParams = array(), $aField = array()) { 82 parent::__construct($aParams, $aField); 83 83 } 84 84 } 85 85 86 86 class BxTemplStudioFormsFieldSlider extends BxBaseStudioFormsFieldSlider { 87 function __construct($a Field = array()) {88 parent::__construct($a Field);87 function __construct($aParams = array(), $aField = array()) { 88 parent::__construct($aParams, $aField); 89 89 } 90 90 } 91 91 92 92 class BxTemplStudioFormsFieldDoublerange extends BxBaseStudioFormsFieldDoublerange { 93 function __construct($a Field = array()) {94 parent::__construct($a Field);93 function __construct($aParams = array(), $aField = array()) { 94 parent::__construct($aParams, $aField); 95 95 } 96 96 } 97 97 98 98 class BxTemplStudioFormsFieldHidden extends BxBaseStudioFormsFieldHidden { 99 function __construct($a Field = array()) {100 parent::__construct($a Field);99 function __construct($aParams = array(), $aField = array()) { 100 parent::__construct($aParams, $aField); 101 101 } 102 102 } 103 103 104 104 class BxTemplStudioFormsFieldButton extends BxBaseStudioFormsFieldButton { 105 function __construct($a Field = array()) {106 parent::__construct($a Field);105 function __construct($aParams = array(), $aField = array()) { 106 parent::__construct($aParams, $aField); 107 107 } 108 108 } 109 109 110 110 class BxTemplStudioFormsFieldReset extends BxBaseStudioFormsFieldReset { 111 function __construct($a Field = array()) {112 parent::__construct($a Field);111 function __construct($aParams = array(), $aField = array()) { 112 parent::__construct($aParams, $aField); 113 113 } 114 114 } 115 115 116 116 class BxTemplStudioFormsFieldSubmit extends BxBaseStudioFormsFieldSubmit { 117 function __construct($a Field = array()) {118 parent::__construct($a Field);117 function __construct($aParams = array(), $aField = array()) { 118 parent::__construct($aParams, $aField); 119 119 } 120 120 } 121 121 122 122 class BxTemplStudioFormsFieldImage extends BxBaseStudioFormsFieldImage { 123 function __construct($a Field = array()) {124 parent::__construct($a Field);123 function __construct($aParams = array(), $aField = array()) { 124 parent::__construct($aParams, $aField); 125 125 } 126 126 } 127 127 128 128 class BxTemplStudioFormsFieldSelect extends BxBaseStudioFormsFieldSelect { 129 function __construct($a Field = array()) {130 parent::__construct($a Field);129 function __construct($aParams = array(), $aField = array()) { 130 parent::__construct($aParams, $aField); 131 131 } 132 132 } 133 133 134 134 class BxTemplStudioFormsFieldSelectMultiple extends BxBaseStudioFormsFieldSelectMultiple { 135 function __construct($a Field = array()) {136 parent::__construct($a Field);135 function __construct($aParams = array(), $aField = array()) { 136 parent::__construct($aParams, $aField); 137 137 } 138 138 } 139 139 140 140 class BxTemplStudioFormsFieldCheckboxSet extends BxBaseStudioFormsFieldCheckboxSet { 141 function __construct($a Field = array()) {142 parent::__construct($a Field);141 function __construct($aParams = array(), $aField = array()) { 142 parent::__construct($aParams, $aField); 143 143 } 144 144 } 145 145 146 146 class BxTemplStudioFormsFieldRadioSet extends BxBaseStudioFormsFieldRadioSet { 147 function __construct($a Field = array()) {148 parent::__construct($a Field);147 function __construct($aParams = array(), $aField = array()) { 148 parent::__construct($aParams, $aField); 149 149 } 150 150 } 151 151 152 152 class BxTemplStudioFormsFieldCustom extends BxBaseStudioFormsFieldCustom { 153 function __construct($a Field = array()) {154 parent::__construct($a Field);153 function __construct($aParams = array(), $aField = array()) { 154 parent::__construct($aParams, $aField); 155 155 } 156 156 } 157 157 158 158 class BxTemplStudioFormsFieldInputSet extends BxBaseStudioFormsFieldInputSet { 159 function __construct($a Field = array()) {160 parent::__construct($a Field);159 function __construct($aParams = array(), $aField = array()) { 160 parent::__construct($aParams, $aField); 161 161 } 162 162 } 163 163 164 164 class BxTemplStudioFormsFieldCaptcha extends BxBaseStudioFormsFieldCaptcha { 165 function __construct($a Field = array()) {166 parent::__construct($a Field);165 function __construct($aParams = array(), $aField = array()) { 166 parent::__construct($aParams, $aField); 167 167 } 168 168 }
Note: See TracChangeset
for help on using the changeset viewer.