Index: branches/unlabeled/unlabeled-1.1.2/core/admin_templates/stylesheets/stylesheets_list.tpl =================================================================== diff -u -r1406 -r1412 --- branches/unlabeled/unlabeled-1.1.2/core/admin_templates/stylesheets/stylesheets_list.tpl (.../stylesheets_list.tpl) (revision 1406) +++ branches/unlabeled/unlabeled-1.1.2/core/admin_templates/stylesheets/stylesheets_list.tpl (.../stylesheets_list.tpl) (revision 1412) @@ -44,6 +44,13 @@ a_toolbar.AddButton( new ToolBarSeparator('sep2') ); + a_toolbar.AddButton( new ToolBarButton('compile', '', function() { + submit_event('css','OnCompile'); + } + ) ); + + a_toolbar.AddButton( new ToolBarSeparator('sep3') ); + a_toolbar.AddButton( new ToolBarButton('view', '', function() { show_viewmenu(a_toolbar,'view'); } @@ -62,7 +69,7 @@ \ No newline at end of file Index: branches/unlabeled/unlabeled-1.1.2/core/units/stylesheets/stylesheets_config.php =================================================================== diff -u -r1410 -r1412 --- branches/unlabeled/unlabeled-1.1.2/core/units/stylesheets/stylesheets_config.php (.../stylesheets_config.php) (revision 1410) +++ branches/unlabeled/unlabeled-1.1.2/core/units/stylesheets/stylesheets_config.php (.../stylesheets_config.php) (revision 1412) @@ -4,7 +4,7 @@ 'Prefix' => 'css', 'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'), 'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'), - 'EventHandlerClass' => Array('class'=>'InpDBEventHandler','file'=>'','build_event'=>'OnBuild'), + 'EventHandlerClass' => Array('class'=>'StylesheetsEventHandler','file'=>'stylesheets_event_handler.php','build_event'=>'OnBuild'), 'TagProcessorClass' => Array('class'=>'kDBTagProcessor','file'=>'','build_event'=>'OnBuild'), 'AutoLoad' => true, 'Hooks' => Array(), @@ -87,6 +87,7 @@ 'Name' => Array( 'title'=>'la_col_Name', 'data_block' => 'grid_checkbox_td'), 'Description' => Array( 'title'=>'la_col_Description', 'data_block' => 'grid_description_td' ), 'Enabled' => Array( 'title'=>'la_col_Status' ), + 'LastCompiled' => Array('title' => 'la_col_LastCompiled'), ), ), Index: branches/unlabeled/unlabeled-1.1.2/core/units/selectors/selectors_config.php =================================================================== diff -u -r1410 -r1412 --- branches/unlabeled/unlabeled-1.1.2/core/units/selectors/selectors_config.php (.../selectors_config.php) (revision 1410) +++ branches/unlabeled/unlabeled-1.1.2/core/units/selectors/selectors_config.php (.../selectors_config.php) (revision 1412) @@ -1,6 +1,8 @@ 'selectors', 'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'), 'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'), @@ -41,7 +43,7 @@ 'SelectorName' => Array('type' => 'string','not_null' => '1','default' => ''), 'SelectorData' => Array('not_null' => '1','default' => ''), 'Description' => Array('type' => 'string','not_null' => '1','default' => ''), - 'Type' => Array('type' => 'int', 'formatter'=>'kOptionsFormatter', 'options'=>Array( 1 => 'la_BaseSelectors', 2 => 'la_BlockSelectors'), 'use_phrases' => 1, 'not_null' => '1','default' => '0'), + 'Type' => Array('type' => 'int', 'formatter'=>'kOptionsFormatter', 'options'=>Array( STYLE_BASE => 'la_BaseSelectors', STYLE_BLOCK => 'la_BlockSelectors'), 'use_phrases' => 1, 'not_null' => '1','default' => '0'), 'ParentId' => Array('type' => 'int','not_null' => '1','default' => '0'), ), Index: branches/unlabeled/unlabeled-1.1.2/core/units/stylesheets/stylesheets_event_handler.php =================================================================== diff -u --- branches/unlabeled/unlabeled-1.1.2/core/units/stylesheets/stylesheets_event_handler.php (revision 0) +++ branches/unlabeled/unlabeled-1.1.2/core/units/stylesheets/stylesheets_event_handler.php (revision 1412) @@ -0,0 +1,78 @@ +Application->setUnitOption($event->Prefix,'AutoLoad',false); + $object =& $event->getObject(); + + $this->StoreSelectedIDs($event); + + $ids = $this->getSelectedIDs($event); + + $selectors =& $this->Application->recallObject('selectors','selectors_List',Array('skip_counting'=>true,'per_page'=>-1) ); + + $ret = '/* This file is generated automatically. Don\'t edit it manually ! */'."\n\n"; + if($ids) + { + foreach($ids as $id) + { + $object->Load($id); + + $selectors->linkToParent(''); + $selectors->Query(); + $selectors->GoFirst(); + + while( !$selectors->EOL() ) + { + $selector_name = $selectors->GetDBField('Name'); + $selector_data = $selectors->GetDBField('SelectorData'); + $ret .= $this->prepareSelector($selector_name, $selector_data); + $selectors->GoNext(); + } + + $compile_ts = time(); + $css_path = DOC_ROOT.BASE_PATH.'/themes/'; + + $css_file = $css_path.$compile_ts.'-'.strtolower($object->GetDBField('Name')).'.css'; + + $fp = fopen($css_file,'w'); + if($fp) + { + $prev_css = $css_path.$object->GetDBField('LastCompiled').'-'.strtolower($object->GetDBField('Name')).'.css'; + if( file_exists($prev_css) ) unlink($prev_css); + + fwrite($fp, $ret); + fclose($fp); + + $object->SetDBField('LastCompiled_date', $compile_ts); + $object->SetDBField('LastCompiled_time', $compile_ts); + $object->Update(); + } + } + } + $this->clearSelectedIDs($event); + } + + function prepareSelector($selector_name, $selector_data) + { + if( IsSerialized($selector_data) ) $selector_data = unserialize($selector_data); + $ret = '.'.$selector_name." {\n"; + foreach($selector_data as $property_name => $property_value) + { + $ret .= "\t$property_name: $property_value;\n"; + } + + $ret .= "}\n\n"; + return $ret; + } + } + +?> \ No newline at end of file