Index: branches/5.3.x/core/units/themes/themes_eh.php =================================================================== diff -u -N -r15698 -r16124 --- branches/5.3.x/core/units/themes/themes_eh.php (.../themes_eh.php) (revision 15698) +++ branches/5.3.x/core/units/themes/themes_eh.php (.../themes_eh.php) (revision 16124) @@ -1,6 +1,6 @@ Special == 'current' ) { + $event->setEventParam('live_table', true); + } + + parent::dbBuild($object, $event); + } + + /** + * Ensures that current theme detection will fallback to primary without extra DB query. + * + * @param kEvent $event Event. + * + * @return integer + */ + public function getPassedID(kEvent $event) + { + if ( $event->Special == 'current' ) { + $theme_id = $this->Application->GetVar('m_theme'); + + if ( !$theme_id ) { + $theme_id = 'default'; + } + + $this->Application->SetVar('m_theme', $theme_id); + $this->Application->SetVar($event->getPrefixSpecial() . '_id', $theme_id); + } + + return parent::getPassedID($event); + } + + /** * Allows to set selected theme as primary * * @param kEvent $event @@ -92,6 +132,25 @@ } /** + * Validate entered stylesheet path. + * + * @param kEvent $event Event. + * + * @return void + */ + protected function OnBeforeItemUpdate(kEvent $event) + { + parent::OnBeforeItemUpdate($event); + + /** @var ThemeItem $object */ + $object = $event->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