| | |
| | | */ |
| | | protected function add_autovalues(&$attrs) |
| | | { |
| | | if (empty($this->prop['autovalues'])) { |
| | | return; |
| | | } |
| | | |
| | | $attrvals = array(); |
| | | foreach ($attrs as $k => $v) { |
| | | $attrvals['{'.$k.'}'] = is_array($v) ? $v[0] : $v; |
| | |
| | | if (strpos($templ, '(') !== false) { |
| | | // replace {attr} placeholders with (escaped!) attribute values to be safely eval'd |
| | | $code = preg_replace('/\{\w+\}/', '', strtr($templ, array_map('addslashes', $attrvals))); |
| | | $attrs[$lf] = eval("return ($code);"); |
| | | $fn = create_function('', "return ($code);"); |
| | | if (!$fn) { |
| | | rcube::raise_error(array( |
| | | 'code' => 505, 'type' => 'php', |
| | | 'file' => __FILE__, 'line' => __LINE__, |
| | | 'message' => "Expression parse error on: ($code)"), true, false); |
| | | continue; |
| | | } |
| | | |
| | | $attrs[$lf] = $fn(); |
| | | } |
| | | else { |
| | | // replace {attr} placeholders with concrete attribute values |