/** * In form inputs, we should have called htmlentities and addslashes on form inputs, * so we need to undo that on setting of these fields * @param string $value_inputted_for_field_on_model_object * @return string */ function prepare_for_set($value_inputted_for_field_on_model_object) { return stripslashes(html_entity_decode(parent::prepare_for_set($value_inputted_for_field_on_model_object), ENT_QUOTES, 'UTF-8')); }
/** * Consolidates code for preparing a value supplied to the model for use int eh db. Calls the field's prepare_for_use_in_db method on the value, * and depending on $value_already_prepare_by_model_obj, may also call the field's prepare_for_set() method. * @param mixed $value value in the client code domain if $value_already_prepared_by_model_object is false, otherwise a value * in the model object's domain (see lengthy comment at top of file) * @param EE_Model_Field_Base $field field which will be doing the preparing of the value. If null, we assume $value is a custom selection * @return mixed a value ready for use in the database for insertions, updating, or in a where clause */ private function _prepare_value_for_use_in_db($value, $field) { if ($field && $field instanceof EE_Model_Field_Base) { switch ($this->_values_already_prepared_by_model_object) { /** @noinspection PhpMissingBreakStatementInspection */ case self::not_prepared_by_model_object: $value = $field->prepare_for_set($value); //purposefully left out "return" //purposefully left out "return" case self::prepared_by_model_object: $value = $field->prepare_for_use_in_db($value); case self::prepared_for_use_in_db: //leave the value alone } return $value; } else { return $value; } }
/** * Consolidates code for preparing a value supplied to the model for use int eh db. Calls the field's prepare_for_use_in_db method on the value, * and depending on $value_already_prepare_by_model_obj, may also call the field's prepare_for_set() method. * @param mixed $value value in the client code domain if $value_already_prepared_by_model_object is false, otherwise a value * in the model object's domain (see lengthy comment at top of file) * @param EE_Model_Field_Base $field field which will be doing the preparing of the value. If null, we assume $value is a custom selection * @return mixed a value ready for use in the database for insertions, updating, or in a where clause */ private function _prepare_value_for_use_in_db($value, $field) { if ($field && $field instanceof EE_Model_Field_Base) { $value = $this->_values_already_prepared_by_model_object ? $value : $field->prepare_for_set($value); return $field->prepare_for_use_in_db($value); } else { return $value; } }