| | |
| | | * |
| | | * @param string Input string to parse |
| | | * @return string Altered input string |
| | | * @todo Use DOM-parser to traverse template HTML |
| | | * @todo Maybe a cache. |
| | | */ |
| | | private function parse_xml($input) |
| | | { |
| | | return preg_replace('/<roundcube:([-_a-z]+)\s+([^>]+)>/Uie', "\$this->xml_command('\\1', '\\2')", $input); |
| | | return preg_replace_callback('/<roundcube:([-_a-z]+)\s+([^>]+)>/Ui', array($this, 'xml_command_callback'), $input); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * This is a callback function for preg_replace_callback (see #1485286) |
| | | * It's only purpose is to reconfigure parameters for xml_command, so that the signature isn't disturbed |
| | | */ |
| | | private function xml_command_callback($matches) |
| | | { |
| | | $str_attrib = isset($matches[2]) ? $matches[2] : ''; |
| | | $add_attrib = isset($matches[3]) ? $matches[3] : array(); |
| | | |
| | | $command = $matches[1]; |
| | | //matches[0] is the entire matched portion of the string |
| | | |
| | | return $this->xml_command($command, $str_attrib, $add_attrib); |
| | | } |
| | | |
| | | |