Index: branches/5.3.x/core/units/helpers/themes_helper.php =================================================================== diff -u -N -r15483 -r15574 --- branches/5.3.x/core/units/helpers/themes_helper.php (.../themes_helper.php) (revision 15483) +++ branches/5.3.x/core/units/helpers/themes_helper.php (.../themes_helper.php) (revision 15574) @@ -1,6 +1,6 @@ Conn->doUpdate($fields_hash, $table_name, $id_field . ' = ' . $theme_id); } - $fields_hash = Array ( - 'TemplateAliases' => serialize( $this->getTemplateAliases($theme_id, $theme_path) ), - ); + $this->_saveThemeSettings($theme_id, $theme_path); - $this->Conn->doUpdate($fields_hash, $table_name, $id_field . ' = ' . $theme_id); - return $theme_id; } /** + * Saves information from "/_install/theme.xml" files in theme + * + * @param int $theme_id + * @param string $theme_path + * @return void + * @access protected + */ + protected function _saveThemeSettings($theme_id, $theme_path) + { + $id_field = $this->Application->getUnitOption('theme', 'IDField'); + $table_name = $this->Application->getUnitOption('theme', 'TableName'); + $this->Conn->doUpdate($this->_getThemeSettings($theme_id, $theme_path), $table_name, $id_field . ' = ' . $theme_id); + } + + /** * Installs module(-s) language pack for given theme * * @param string $theme_path @@ -176,16 +187,17 @@ } /** - * Returns template aliases from "/_install/theme.xml" files in theme + * Parses information, discovered from "/_install/theme.xml" files in theme * * @param int $theme_id * @param string $theme_path * @return Array * @access protected */ - protected function getTemplateAliases($theme_id, $theme_path) + protected function _getThemeSettings($theme_id, $theme_path) { - $template_aliases = Array (); + $setting_mapping = Array ('image_resize_rules' => 'ImageResizeRules'); + $ret = Array ('TemplateAliases' => Array (), 'ImageResizeRules' => Array ()); foreach ($this->Application->ModuleInfo as $module_name => $module_info) { $xml_file = $theme_path . '/' . $module_info['TemplatePath'] . '_install/theme.xml'; @@ -201,12 +213,20 @@ continue; } - foreach ($theme as $design) { - /* @var $design SimpleXMLElement */ + foreach ($theme as $setting) { + /* @var $setting SimpleXMLElement */ - $template_path = trim($design); - $module_override = (string)$design['module']; + $setting_name = $setting->getName(); + $setting_value = trim($setting); + if ( isset($setting_mapping[$setting_name]) ) { + $ret[$setting_mapping[$setting_name]][] = $setting_value; + continue; + } + + // this is template alias + $module_override = (string)$setting['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'); @@ -217,19 +237,22 @@ } // only store alias, when template exists on disk - if ( $this->getTemplateId($template_path, $theme_id) ) { - $alias = '#' . $module_folder . strtolower($design->getName()) . '#'; + if ( $this->getTemplateId($setting_value, $theme_id) ) { + $alias = '#' . $module_folder . strtolower($setting->getName()) . '#'; // remember alias in global theme mapping - $template_aliases[$alias] = $template_path; + $ret['TemplateAliases'][$alias] = $setting_value; // store alias in theme file record to use later in design dropdown - $this->updateTemplate($template_path, $theme_id, Array ('TemplateAlias' => $alias)); + $this->updateTemplate($setting_value, $theme_id, Array ('TemplateAlias' => $alias)); } } } - return $template_aliases; + $ret['TemplateAliases'] = serialize($ret['TemplateAliases']); + $ret['ImageResizeRules'] = implode("\n", array_filter($ret['ImageResizeRules'])); + + return $ret; } /** @@ -307,11 +330,7 @@ $this->installThemeLanguagePack($theme_path, $module_name); // update TemplateAliases mapping - $fields_hash = Array ( - 'TemplateAliases' => serialize( $this->getTemplateAliases($theme_id, $theme_path) ), - ); - - $this->Conn->doUpdate($fields_hash, TABLE_PREFIX . 'Themes', 'ThemeId = ' . $theme_id); + $this->_saveThemeSettings($theme_id, $theme_path); } }