Index: branches/5.2.x/core/kernel/utility/formatters/left_formatter.php =================================================================== diff -u -N -r14585 -r14628 --- branches/5.2.x/core/kernel/utility/formatters/left_formatter.php (.../left_formatter.php) (revision 14585) +++ branches/5.2.x/core/kernel/utility/formatters/left_formatter.php (.../left_formatter.php) (revision 14628) @@ -1,6 +1,6 @@ GetFieldOptions($field_name); - if ( isset($format) ) $options['format'] = $format; + if ( isset($format) ) { + $options['format'] = $format; + } - if( !isset($options['options'][$value]) ) - { + if ( !isset($options['options'][$value]) ) { // required option is not defined in config => query for it - $sql = sprintf($options['left_sql'],$options['left_title_field'],$options['left_key_field'], $db->escape($value)); + $sql = sprintf($options['left_sql'], $options['left_title_field'], $options['left_key_field'], $this->Conn->escape($value)); $options['options'][$value] = $this->Conn->GetOne($sql); - if ($options['options'][$value] === false) return $value; + + if ( $options['options'][$value] === false ) { + return $value; + } } + return $options['options'][$value]; } /** - * Parse value from form submit + * Performs basic type validation on form field value * * @param mixed $value * @param string $field_name * @param kDBItem $object * @return mixed + * @access public */ - function Parse($value, $field_name, &$object) + public function Parse($value, $field_name, &$object) { - if ($value == '') return NULL; + if ( $value == '' ) { + return NULL; + } $options = $object->GetFieldOptions($field_name); $found = isset($options['options']) ? array_search($value, $options['options']) : false; - if ($found !== false) { + + if ( $found !== false ) { // requested option found among field options return $found; } // requested option is not found in field options -> query for it - $sql = sprintf($options['left_sql'], $options['left_key_field'], $options['left_title_field'], $db->escape($value)); + $sql = sprintf($options['left_sql'], $options['left_key_field'], $options['left_title_field'], $this->Conn->escape($value)); $found = $this->Conn->GetOne($sql); - if ($found !== false) { + + if ( $found !== false ) { // option successfully retrieved from db -> cache it $options['options'][$found] = $value; } $skip_errors = array_key_exists('skip_errors', $options) && $options['skip_errors']; - if ($found === false && !$skip_errors) { + + if ( $found === false && !$skip_errors ) { // option not found at all -> return not formatted value & set error $object->SetError($field_name, 'invalid_option', 'la_error_InvalidOption'); return $value;