Index: branches/RC/core/units/skins/skin_eh.php =================================================================== diff -u -N --- branches/RC/core/units/skins/skin_eh.php (revision 11892) +++ branches/RC/core/units/skins/skin_eh.php (revision 0) @@ -1,128 +0,0 @@ - Array ('self' => true), - ); - - $this->permMapping = array_merge($this->permMapping, $permissions); - } - - /** - * With "primary" special loads primary skin - * - * @param kEvent $event - * @return int - */ - function getPassedID(&$event) - { - if ($event->Special == 'primary') { - return Array ('IsPrimary' => 1); - } - - return parent::getPassedID($event); - } - - /** - * Allows to set selected theme as primary - * - * @param kEvent $event - */ - function OnSetPrimary(&$event) - { - if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) { - return; - } - - $ids = $this->StoreSelectedIDs($event); - if ($ids) { - $id = array_shift($ids); - $this->setPrimary($id); - } - - $this->clearSelectedIDs($event); - } - - function setPrimary($id) - { - $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField'); - $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName'); - - $sql = 'UPDATE '.$table_name.' - SET IsPrimary = 0'; - $this->Conn->Query($sql); - - - $sql = 'UPDATE '.$table_name.' - SET IsPrimary = 1 - WHERE '.$id_field.' = '.$id; - $this->Conn->Query($sql); - } - - - /** - * [HOOK] Compile stylesheet file based on theme definitions - * - * @param kEvent $event - */ - function OnCompileStylesheet(&$event) - { - $object =& $event->getObject( Array('skip_autoload' => true) ); - $object->SwitchToLive(); - - $ids = $event->MasterEvent->getEventParam('ids'); - if (!is_array($ids)) $ids = explode(',', $ids); - - if(!$ids) return false; - foreach($ids as $id) - { - $object->Load($id); - $this->Compile($object); - } - } - - function Compile(&$object) - { - $ret = $object->GetDBField('CSS'); - $options = $object->GetDBField('Options'); - $options = unserialize($options); - $options['base_url'] = array('Value'=>rtrim($this->Application->BaseURL(), '/')); - foreach ($options as $key => $row) { - $ret = str_replace('@@'.$key.'@@', $row['Value'], $ret); - } - - $compile_ts = adodb_mktime(); - $css_path = (defined('WRITEABLE') ? WRITEABLE : FULL_PATH.'/kernel').'/user_files/'; - - $css_file = $css_path.'admin-'.mb_strtolower($object->GetDBField('Name')).'-'.$compile_ts.'.css'; - - $fp = fopen($css_file,'w'); - if($fp) - { - $prev_css = $css_path.'admin-'.mb_strtolower($object->GetDBField('Name')).'-'.$object->GetDBField('LastCompiled').'.css'; - if( file_exists($prev_css) ) unlink($prev_css); - - fwrite($fp, $ret); - fclose($fp); - - $sql = 'UPDATE '.$object->TableName.' SET LastCompiled = '.$compile_ts.' WHERE '.$object->IDField.' = '.$object->GetID(); - $this->Conn->Query($sql); - } - } -} \ No newline at end of file