Index: branches/5.2.x/core/units/helpers/themes_helper.php =================================================================== diff -u -N -r15137 -r15158 --- branches/5.2.x/core/units/helpers/themes_helper.php (.../themes_helper.php) (revision 15137) +++ branches/5.2.x/core/units/helpers/themes_helper.php (.../themes_helper.php) (revision 15158) @@ -1,6 +1,6 @@ Application->recallObject('kXMLHelper'); - /* @var $xml_parser kXMLHelper */ - foreach ($this->Application->ModuleInfo as $module_name => $module_info) { - if ( $module_name == 'In-Portal' ) { + $xml_file = $theme_path . '/' . $module_info['TemplatePath'] . '_install/theme.xml'; + + if ( $module_name == 'In-Portal' || !file_exists($xml_file) ) { continue; } - $xml_file = $theme_path . '/' . $module_info['TemplatePath'] . '_install/theme.xml'; + $theme = simplexml_load_file($xml_file); - if ( file_exists($xml_file) ) { - $xml_data = file_get_contents($xml_file); - $root_node =& $xml_parser->Parse($xml_data); + if ( $theme === false ) { + // broken xml OR no aliases defined + continue; + } - if ( !is_object($root_node) || !is_a($root_node, 'kXMLNode') || !$root_node->Children ) { - // broken xml OR no aliases defined - continue; - } + foreach ($theme as $design) { + /* @var $design SimpleXMLElement */ - $current_node =& $root_node->firstChild; - /* @var $current_node kXMLNode */ + $template_path = trim($design); + $module_override = (string)$design['module']; - do { - $template_path = trim($current_node->Data); - $module_override = $current_node->GetAttribute('module'); + if ( $module_override ) { + // allow to put template mappings form all modules into single theme.xml file + $module_folder = $this->Application->findModule('Name', $module_override, 'TemplatePath'); + } + else { + // no module specified -> use module based on theme.xml file location + $module_folder = $module_info['TemplatePath']; + } - if ( $module_override ) { - // allow to put template mappings form all modules into single theme.xml file - $module_folder = $this->Application->findModule('Name', $module_override, 'TemplatePath'); - } - else { - // no module specified -> use module based on theme.xml file location - $module_folder = $module_info['TemplatePath']; - } + // only store alias, when template exists on disk + if ( $this->getTemplateId($template_path, $theme_id) ) { + $alias = '#' . $module_folder . strtolower($design->getName()) . '#'; - // only store alias, when template exists on disk - if ( $this->getTemplateId($template_path, $theme_id) ) { - $alias = '#' . $module_folder . strtolower($current_node->Name) . '#'; + // remember alias in global theme mapping + $template_aliases[$alias] = $template_path; - // remember alias in global theme mapping - $template_aliases[$alias] = $template_path; - - // store alias in theme file record to use later in design dropdown - $this->updateTemplate($template_path, $theme_id, Array ('TemplateAlias' => $alias)); - } - } while ( ($current_node =& $current_node->NextSibling()) ); + // store alias in theme file record to use later in design dropdown + $this->updateTemplate($template_path, $theme_id, Array ('TemplateAlias' => $alias)); + } } }