function fn_exim_get_values($values, $pattern, $options, $vars = array(), $data = array(), $quote = "'") { $val = array(); foreach ($values as $field => $value) { if (is_array($value)) { $val[$field] = fn_exim_set_quotes($value); } else { $operator = substr($value, 0, 1); if ($operator === '@') { $opt = str_replace('@', '', $value); $val[$field] = isset($options[$opt]) ? fn_exim_set_quotes($options[$opt], $quote) : ''; } elseif ($value === '#this') { if (!empty($vars['field'])) { $val[$field] = fn_exim_set_quotes($data[$vars['field']], $quote); } else { $val[$field] = fn_exim_set_quotes($data[$field], $quote); } } elseif ($value === '#key') { $val[$field] = sizeof($vars['key']) == 1 ? reset($vars['key']) : (isset($vars['key'][$field]) ? $vars['key'][$field] : $vars['key']); } elseif ($operator === '&') { $val[$field] = $pattern['table'] . '.' . substr($value, 1); } elseif ($value === '#field') { if (!empty($vars['field'])) { $val[$field] = $vars['field']; } else { $val[$field] = $field; } } elseif ($value === '#lang_code') { $val[$field] = !empty($vars['lang_code']) ? fn_exim_set_quotes($vars['lang_code'], $quote) : ''; } elseif ($value === '#row') { $val[$field] = $data; } elseif ($operator === '#') { $val[$field] = substr($value, 1); } elseif ($operator === '$') { $opt = str_replace('$', '', $value); if (isset($data[$opt])) { $data[$opt] = fn_exim_set_quotes($data[$opt], $quote); $val[$field] =& $data[$opt]; } else { $val[$field] = ''; } } else { $val[$field] = fn_exim_set_quotes($value, $quote); } } } return $val; }
/** * @deprecated, use fn_exim_quote instead */ function fn_exim_set_quotes($value, $quote = "'") { if (is_array($value) && !empty($value)) { foreach ($value as $k => $v) { $values[$k] = fn_exim_set_quotes($v, $quote); } $result = $values; } elseif (gettype($value) == 'string') { $result = $quote . $value . $quote; } else { $result = $value; } return $result; }