Index: trunk/kernel/include/theme.php =================================================================== diff -u -r1566 -r1888 --- trunk/kernel/include/theme.php (.../theme.php) (revision 1566) +++ trunk/kernel/include/theme.php (.../theme.php) (revision 1888) @@ -694,7 +694,7 @@ return $l; } - function CreateMissingThemes() + function CreateMissingThemes($compile_css = false) { global $objConfig,$pathchar, $pathtoroot; @@ -741,10 +741,41 @@ $sql = 'DELETE FROM '.GetTablePrefix().'ThemeFiles WHERE ThemeId IN('.join(',',array_keys($orphanThemes)).')'; $this->adodbConnection->Execute($sql); } + + // make stylesheet/theme hash + $css_hash = Array(); + $css_rs = $this->adodbConnection->Execute('SELECT Name, StylesheetId FROM '.GetTablePrefix().'Stylesheets'); + while(!$css_rs->EOF) + { + $css_hash[ strtolower($css_rs->fields['Name']) ] = $css_rs->fields['StylesheetId']; + $css_rs->MoveNext(); + } + + if($compile_css) + { + define('FULL_PATH', realpath(dirname(__FILE__).'/../..')); + define('APPLICATION_CLASS', 'MyApplication'); + include_once(FULL_PATH.'/kernel/kernel4/startup.php'); + $application =& kApplication::Instance(); + $application->Init(); + + $application->setUnitOption('css', 'AutoLoad', false); + $css_table = $application->getUnitOption('css','TableName'); + $css_idfield = $application->getUnitOption('css','IDField'); + + foreach($css_hash as $stylesheet_id) + { + $css_item =& $application->recallObject('css'); + $css_item->Load($stylesheet_id); + $css_item->Compile(); + } + $application->Done(); + } + $this->Clear(); foreach($missingThemes as $theme) { - $t=$this->AddTheme($theme,"New Theme",0,0); + $t=$this->AddTheme($theme,"New Theme",0,0, 3600, getArrayValue($css_hash, $theme) ); $t->Files->FindMissingFiles($t->Get('Name')); } }