Index: branches/5.3.x/core/units/helpers/themes_helper.php =================================================================== diff -u -N -r15698 -r16124 --- branches/5.3.x/core/units/helpers/themes_helper.php (.../themes_helper.php) (revision 15698) +++ branches/5.3.x/core/units/helpers/themes_helper.php (.../themes_helper.php) (revision 16124) @@ -1,6 +1,6 @@ themeFiles = Array (); + $theme_path = $this->themesFolder . '/' . $theme_name; + if ($theme_id) { if (!$theme_enabled) { // don't process existing theme files, that are disabled @@ -96,14 +98,17 @@ } else { // theme was not found in db, but found on hdd -> create new + $config = $this->getConfiguration($theme_path); + $theme_info = Array ( 'Name' => $theme_name, 'Enabled' => 0, 'Description' => $theme_name, 'PrimaryTheme' => 0, 'CacheTimeout' => 3600, // not in use right now 'StylesheetId' => 0, // not in use right now - 'LanguagePackInstalled' => 0 + 'LanguagePackInstalled' => 0, + 'StylesheetFile' => isset($config['stylesheet_file']) ? $config['stylesheet_file'] : '', ); $this->Conn->doInsert($theme_info, $table_name); @@ -116,7 +121,6 @@ } $this->_themeNames[$theme_id] = $theme_name; - $theme_path = $this->themesFolder.'/'.$theme_name; $this->FindThemeFiles('', $theme_path, $theme_id); // search from base theme directory // delete file records from db, that were not found on hdd @@ -259,6 +263,37 @@ } /** + * Returns theme configuration. + * + * @param string $theme_path Absolute path to theme. + * + * @return array + */ + protected function getConfiguration($theme_path) + { + $xml_file = $theme_path . '/_install/theme.xml'; + + if ( !file_exists($xml_file) ) { + return array(); + } + + $theme = simplexml_load_file($xml_file); + + if ( $theme === false ) { + // broken xml OR no aliases defined + return array(); + } + + $ret = array(); + + foreach ( $theme->attributes() as $name => $value ) { + $ret[(string)$name] = (string)$value; + } + + return $ret; + } + + /** * Returns ID of given physical template (relative to theme) given from ThemeFiles table * @param string $template_path * @param int $theme_id @@ -639,4 +674,4 @@ return $this->Conn->GetOne($sql); } - } \ No newline at end of file + }