Index: branches/5.2.x/core/units/helpers/themes_helper.php =================================================================== diff -u -N -r15390 -r15717 --- branches/5.2.x/core/units/helpers/themes_helper.php (.../themes_helper.php) (revision 15390) +++ branches/5.2.x/core/units/helpers/themes_helper.php (.../themes_helper.php) (revision 15717) @@ -1,6 +1,6 @@
||
+ ##-->*/ $comment_end = strpos($template_data, '##-->'); @@ -441,21 +442,36 @@ return Array (); } + $ret = Array (); $comment = trim( substr($template_data, 6, $comment_end - 6) ); - if (preg_match_all('/<(NAME|DESC|SECTION)>(.*?)<\/(NAME|DESC|SECTION)>/is', $comment, $regs)) { - $ret = Array (); - foreach ($regs[1] as $param_order => $param_name) { - $ret[ strtolower($param_name) ] = trim($regs[2][$param_order]); - } + $allowed_settings = Array ('name', 'desc', 'section', 'section_aware'); - if (array_key_exists('section', $ret) && $ret['section']) { - $category_path = explode('||', $ret['section']); - $category_path = array_map('trim', $category_path); - $ret['section'] = implode('||', $category_path); + $meta_info = simplexml_load_string('' . $comment . ''); + /* @var $meta_info SimpleXMLElement[] */ + + if ( $meta_info === false ) { + // Malformed XML. SimpleXML will print an error itself. + return Array (); + } + + foreach ($meta_info as $setting) { + $setting_name = strtolower($setting->getName()); + + if ( !in_array($setting_name, $allowed_settings) ) { + trigger_error('Setting "' . $setting_name . '" not supported in "' . $template_file . '" template', E_USER_WARNING); + continue; } - return $ret; + $ret[$setting_name] = trim($setting); } + + if ( array_key_exists('section', $ret) && $ret['section'] ) { + $category_path = explode('||', $ret['section']); + $category_path = array_map('trim', $category_path); + $ret['section'] = implode('||', $category_path); + } + + return $ret; } return Array ();