From 0b920163a6b4a0444b8125ab8c5b437049112427 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 29 Jan 2017 11:08:43 -0800 Subject: [PATCH] Send field and field-type values to e_parse toDB --- e107_handlers/admin_ui.php | 8 +++++++ e107_handlers/e_parse_class.php | 9 ++++---- e107_handlers/model_class.php | 40 ++++++++++++++++++++++++++++++++- 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/e107_handlers/admin_ui.php b/e107_handlers/admin_ui.php index a27f8be0d..acd5d403e 100644 --- a/e107_handlers/admin_ui.php +++ b/e107_handlers/admin_ui.php @@ -4269,6 +4269,7 @@ class e_admin_ui extends e_admin_controller_ui protected $fieldTypes = array(); protected $dataFields = array(); + protected $fieldInputTypes = array(); protected $validationRules = array(); protected $table; @@ -5696,6 +5697,10 @@ class e_admin_ui extends e_admin_controller_ui if(($key !== 'options' && false !== varset($att['data']) && null !== varset($att['type'],null) && !vartrue($att['noedit'])) || vartrue($att['forceSave'])) { $this->dataFields[$key] = vartrue($att['data'], 'str'); + if(!empty($att['type'])) + { + $this->fieldInputTypes[$key] = $att['type']; + } } @@ -5728,12 +5733,15 @@ class e_admin_ui extends e_admin_controller_ui if($this->_model) return $this; // default model + + $this->_model = new e_admin_model(); $this->_model->setModelTable($this->table) ->setFieldIdName($this->pid) ->setUrl($this->url) ->setValidationRules($this->validationRules) ->setDbTypes($this->fieldTypes) + ->setFieldInputTypes($this->fieldInputTypes) ->setDataFields($this->dataFields) ->setMessageStackName('admin_ui_model_'.$this->table) ->setParam('db_query', $this->editQry); diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php index 9489330f0..f544a6956 100644 --- a/e107_handlers/e_parse_class.php +++ b/e107_handlers/e_parse_class.php @@ -489,7 +489,7 @@ class e_parse extends e_parser * @return string * @todo complete the documentation of this essential method */ - public function toDB($data, $nostrip =false, $no_encode = false, $mod = false, $original_author = false) + public function toDB($data, $nostrip =false, $no_encode = false, $mod = false, $parm = null) { $core_pref = e107::getConfig(); @@ -550,12 +550,11 @@ class e_parse extends e_parser $no_encode = true; } - if (is_numeric($original_author) && !check_class($core_pref->get('post_html'), '', $original_author)) + if($parm !== null && is_numeric($parm) && !check_class($core_pref->get('post_html'), '', $parm)) { $no_encode = false; } - if ($no_encode === true && strpos($mod, 'no_html') === false) { $search = array('$', '"', "'", '\\', ' $nostrip, 'noencode' => $no_encode, - 'mode' => $mod, - 'author' => $original_author + 'type' => $parm['type'], + 'field' => $parm['field'] ); foreach($eParseList as $plugin) diff --git a/e107_handlers/model_class.php b/e107_handlers/model_class.php index 63b89b0d8..20c1a2a9b 100644 --- a/e107_handlers/model_class.php +++ b/e107_handlers/model_class.php @@ -514,6 +514,17 @@ class e_model extends e_object */ protected $_data_fields = array(); + + + /** + * Current model field types eg. text, bbarea, dropdown etc. + * + * + * @var string + */ + protected $_field_input_types = array(); + + /** * Current model DB table, used in all db calls * @@ -719,6 +730,21 @@ class e_model extends e_object return $this->_data_fields; } + + /** + * @param $key + * @return bool + */ + public function getFieldInputType($key) + { + if(isset($this->_field_input_types[$key])) + { + return $this->_field_input_types[$key]; + } + + return false; + } + /** * Set Predefined data fields in format key => type * @return e_model @@ -729,6 +755,16 @@ class e_model extends e_object return $this; } + /** + * Set Predefined data fields in format key => type + * @return e_model + */ + public function setFieldInputTypes($fields) + { + $this->_field_input_types = $fields; + return $this; + } + /** * Set Predefined data field * @return e_model @@ -2646,6 +2682,7 @@ class e_front_model extends e_model $value = $this->getPostedData($key); } + switch ($type) { case 'int': @@ -2660,7 +2697,8 @@ class e_front_model extends e_model case 'str': case 'string': case 'array': - return $tp->toDB($value, false, false, 'model'); + $type = $this->getFieldInputType($key); + return $tp->toDB($value, false, false, 'model', array('type'=>$type, 'field'=>$key)); break; case 'json':