Index: branches/5.1.x/core/units/themes/themes_eh.php =================================================================== diff -u -N -r12127 -r12657 --- branches/5.1.x/core/units/themes/themes_eh.php (.../themes_eh.php) (revision 12127) +++ branches/5.1.x/core/units/themes/themes_eh.php (.../themes_eh.php) (revision 12657) @@ -1,6 +1,6 @@ setPrimary($id); + + $rebuild_event = new kEvent('adm:OnRebuildThemes'); + $this->Application->HandleEvent($rebuild_event); } $this->clearSelectedIDs($event); @@ -66,7 +71,7 @@ } /** - * Set correct parent path for newly created categories + * Set's primary theme (when checkbox used on editing form) * * @param kEvent $event */ @@ -83,6 +88,35 @@ } /** + * Also rebuilds theme files, when enabled theme is saved + * + * @param kEvent $event + */ + function OnSave(&$event) + { + parent::OnSave($event); + + if (($event->status != erSUCCESS) || !$event->getEventParam('ids')) { + return ; + } + + $ids = $event->getEventParam('ids'); + + $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField'); + $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName'); + + $sql = 'SELECT COUNT(*) + FROM ' . $table_name . ' + WHERE ' . $id_field . ' IN (' . $ids . ') AND (Enabled = 1)'; + $enabled_themes = $this->Conn->GetOne($sql); + + if ($enabled_themes) { + $rebuild_event = new kEvent('adm:OnRebuildThemes'); + $this->Application->HandleEvent($rebuild_event); + } + } + + /** * Allows to change the theme * * @param kEvent $event @@ -100,9 +134,10 @@ $this->Application->SetVar('m_cat_id', 0); if (MOD_REWRITE) { - foreach ($this->Application->ModuleInfo as $module_name => $module_data) { - $this->Application->DeleteVar($module_data['Var'].'_Page'); - } + $mod_rewrite_helper =& $this->Application->recallObject('ModRewriteHelper'); + /* @var $mod_rewrite_helper kModRewriteHelper */ + + $mod_rewrite_helper->removePages(); } $this->Application->SetVar('m_theme', $this->Application->GetVar('theme')); @@ -127,5 +162,3 @@ } } } - -?> \ No newline at end of file