Index: branches/5.2.x/core/install/english.lang =================================================================== diff -u -N -r16080 -r16084 --- branches/5.2.x/core/install/english.lang (.../english.lang) (revision 16080) +++ branches/5.2.x/core/install/english.lang (.../english.lang) (revision 16084) @@ -265,6 +265,7 @@ RXJyb3IgY29weWluZyBzdWJzZWN0aW9ucw== Q3VzdG9tIGZpZWxkIHdpdGggaWRlbnRpY2FsIG5hbWUgYWxyZWFkeSBleGlzdHM= RW1haWwgRGVzaWduIFRlbXBsYXRlIHNob3VsZCBjb250YWluIGF0IGxlYXN0ICIkYm9keSIgdGFnIGluIGl0Lg== + RmlsZSBub3QgZm91bmQ= RmlsZSBpcyB0b28gbGFyZ2U= Z3JvdXAgbm90IGZvdW5k RmllbGQgZG9lc24ndCBleGlzdCBpbiAiJXMiIHVuaXQgY29uZmln @@ -669,6 +670,7 @@ U3RhdHVz U3RpY2t5 U3RvcCBXb3Jk + U3R5bGVzaGVldCBGaWxl U3ViamVjdA== U3VibWl0dGVkIE9u U3VibWlzc2lvbiBOb3RpZmljYXRpb24gRW1haWw= Index: branches/5.2.x/core/kernel/db/db_tag_processor.php =================================================================== diff -u -N -r15958 -r16084 --- branches/5.2.x/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 15958) +++ branches/5.2.x/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 16084) @@ -1,6 +1,6 @@ Field($params); $name = array_key_exists('name', $params) ? $params['name'] : $this->InputName($params); - $theme_path = $this->Application->GetFrontThemePath() . '/inc'; + /** @var ThemeItem $theme */ + $theme = $this->Application->recallObject('theme.current'); + $stylesheet_file = $theme->getStylesheetFile(true); - if ( file_exists(FULL_PATH . $theme_path . '/style.css') ) { + if ( $stylesheet_file ) { + $stylesheet_folder_url = dirname($stylesheet_file) . '/'; + $url_params = Array ( 'events[fck]' => 'OnGetsEditorStyles', 'no_pass_through' => 1, 'pass' => 'm', 'no_amp' => 1 @@ -2545,11 +2549,11 @@ $styles_css = $this->Application->HREF('index', '_FRONT_END_', $url_params, 'index.php'); } else { - $theme_path = rtrim(EDITOR_PATH, '/'); - $styles_css = $this->Application->BaseURL($theme_path) . 'style.css'; + $stylesheet_folder_url = $this->Application->BaseURL(rtrim(EDITOR_PATH, '/')); + $styles_css = $stylesheet_folder_url . 'style.css'; } - $styles_js = $this->Application->BaseURL($theme_path) . 'styles.js'; + $styles_js = $stylesheet_folder_url . 'styles.js'; /*$page_id = $this->Application->GetVar('c_id'); $content_id = $this->Application->GetVar('content_id'); @@ -3156,4 +3160,4 @@ return ''; } -} \ No newline at end of file +} Index: branches/5.2.x/core/units/fck/fck_eh.php =================================================================== diff -u -N -r15856 -r16084 --- branches/5.2.x/core/units/fck/fck_eh.php (.../fck_eh.php) (revision 15856) +++ branches/5.2.x/core/units/fck/fck_eh.php (.../fck_eh.php) (revision 16084) @@ -1,6 +1,6 @@ Application->recallObject('theme.current'); + + /** @var MinifyHelper $minify_helper */ $minify_helper = $this->Application->recallObject('MinifyHelper'); - /* @var $minify_helper MinifyHelper */ $this->Application->InitParser(); - $styles_css = $minify_helper->CompressScriptTag( Array ('files' => 'inc/style.css') ); + $styles_css = $minify_helper->CompressScriptTag(array('files' => $theme->getStylesheetFile(true))); $event->redirect = 'external:' . $styles_css; } - } \ No newline at end of file + } Index: branches/5.2.x/core/units/themes/themes_config.php =================================================================== diff -u -N -r15012 -r16084 --- branches/5.2.x/core/units/themes/themes_config.php (.../themes_config.php) (revision 15012) +++ branches/5.2.x/core/units/themes/themes_config.php (.../themes_config.php) (revision 16084) @@ -1,6 +1,6 @@ 1, 'default' => 0 ), 'TemplateAliases' => Array ('type' => 'string', 'formatter' => 'kSerializedFormatter', 'default' => 'a:0:{}'), + 'StylesheetFile' => array( + 'type' => 'string', 'max_len' => 255, + 'error_msgs' => array('not_found' => '!la_error_FileNotFound!'), + 'not_null' => 1, 'default' => '' + ), ), 'Grids' => Array( @@ -147,7 +152,8 @@ 'Enabled' => Array( 'title'=>'column:la_fld_Status', 'filter_block' => 'grid_options_filter', 'width' => 200, ), // 'PrimaryTheme' => Array( 'title'=>'column:la_fld_Primary', 'filter_block' => 'grid_options_filter'), 'LanguagePackInstalled' => Array ('title' => 'la_col_LanguagePackInstalled', 'filter_block' => 'grid_options_filter', 'width' => 200,), + 'StylesheetFile' => array('filter_block' => 'grid_like_filter', 'width' => 150, 'hidden' => 1), ), ), ), - ); \ No newline at end of file + ); Index: branches/5.2.x/core/install/upgrades.sql =================================================================== diff -u -N -r16080 -r16084 --- branches/5.2.x/core/install/upgrades.sql (.../upgrades.sql) (revision 16080) +++ branches/5.2.x/core/install/upgrades.sql (.../upgrades.sql) (revision 16084) @@ -2922,3 +2922,6 @@ UPDATE LanguageLabels SET l1_Translation = 'Field value length is out of range, possible value length from {min_length} to {max_length}' WHERE PhraseKey = 'LA_ERR_LENGTH_OUT_OF_RANGE'; + +ALTER TABLE Themes ADD StylesheetFile VARCHAR( 255 ) NOT NULL DEFAULT ''; +UPDATE Themes SET StylesheetFile = 'platform/inc/styles.css' WHERE `Name` = 'advanced'; Index: branches/5.2.x/core/units/themes/theme_item.php =================================================================== diff -u -N -r14244 -r16084 --- branches/5.2.x/core/units/themes/theme_item.php (.../theme_item.php) (revision 14244) +++ branches/5.2.x/core/units/themes/theme_item.php (.../theme_item.php) (revision 16084) @@ -1,6 +1,6 @@ GetDBField('StylesheetFile') ?: 'inc/style.css', '/'); + + $theme_path = FULL_PATH . '/themes/' . $this->GetDBField('Name'); + $stylesheet_file = $theme_path . '/' . $stylesheet_file; + + if ( !file_exists($stylesheet_file) ) { + return false; + } + + if ( $as_url ) { + /** @var FileHelper $file_helper */ + $file_helper = $this->Application->recallObject('FileHelper'); + + return $file_helper->pathToUrl($stylesheet_file); + } + + return $stylesheet_file; + } + } Index: branches/5.2.x/core/units/themes/themes_eh.php =================================================================== diff -u -N -r16081 -r16084 --- branches/5.2.x/core/units/themes/themes_eh.php (.../themes_eh.php) (revision 16081) +++ branches/5.2.x/core/units/themes/themes_eh.php (.../themes_eh.php) (revision 16084) @@ -1,6 +1,6 @@ getObject(); + + if ( $object->GetDBField('StylesheetFile') && !$object->getStylesheetFile() ) { + $object->SetError('StylesheetFile', 'not_found'); + } + } + + /** * Set's primary theme (when checkbox used on editing form) * * @param kEvent $event Index: branches/5.2.x/core/units/helpers/themes_helper.php =================================================================== diff -u -N -r15805 -r16084 --- branches/5.2.x/core/units/helpers/themes_helper.php (.../themes_helper.php) (revision 15805) +++ branches/5.2.x/core/units/helpers/themes_helper.php (.../themes_helper.php) (revision 16084) @@ -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 @@ -95,14 +97,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); @@ -115,7 +120,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 @@ -233,6 +237,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 @@ -616,4 +651,4 @@ return $this->Conn->GetOne($sql); } - } \ No newline at end of file + } Index: branches/5.2.x/core/install/install_schema.sql =================================================================== diff -u -N -r15747 -r16084 --- branches/5.2.x/core/install/install_schema.sql (.../install_schema.sql) (revision 15747) +++ branches/5.2.x/core/install/install_schema.sql (.../install_schema.sql) (revision 16084) @@ -352,6 +352,7 @@ StylesheetId int(10) unsigned NOT NULL DEFAULT '0', LanguagePackInstalled tinyint(3) unsigned NOT NULL DEFAULT '0', TemplateAliases text, + StylesheetFile varchar(255) NOT NULL DEFAULT '', PRIMARY KEY (ThemeId), KEY Enabled (Enabled), KEY StylesheetId (StylesheetId), @@ -1422,4 +1423,4 @@ TransitionEffect varchar(255) NOT NULL DEFAULT '', TransitionEffectCustom varchar(255) NOT NULL DEFAULT '', PRIMARY KEY (PromoBlockGroupId) -); \ No newline at end of file +); Index: branches/5.2.x/core/admin_templates/themes/themes_edit.tpl =================================================================== diff -u -N -r14244 -r16084 --- branches/5.2.x/core/admin_templates/themes/themes_edit.tpl (.../themes_edit.tpl) (revision 14244) +++ branches/5.2.x/core/admin_templates/themes/themes_edit.tpl (.../themes_edit.tpl) (revision 16084) @@ -61,6 +61,8 @@ + +