diff --git a/Services/Style/System/classes/Less/class.ilSystemStyleLessFile.php b/Services/Style/System/classes/Less/class.ilSystemStyleLessFile.php index 4599c43fb187..9d0c17f4b98e 100644 --- a/Services/Style/System/classes/Less/class.ilSystemStyleLessFile.php +++ b/Services/Style/System/classes/Less/class.ilSystemStyleLessFile.php @@ -139,6 +139,9 @@ public function read(){ } } + /** + * Write the complete file back to the file system (including comments and random content) + */ public function write(){ file_put_contents($this->getLessVariablesFile(),$this->getContent()); } @@ -269,4 +272,36 @@ public function setLessVariablesFile($less_variables_file) { $this->less_variables_file = $less_variables_file; } + + /** + * @return ilSystemStyleLessVariable[] + */ + public function getItems() + { + return $this->items; + } + + /** + * @return array + */ + public function getCommentsIds() + { + return $this->comments_ids; + } + + /** + * @return array + */ + public function getVariablesIds() + { + return $this->variables_ids; + } + + /** + * @return array + */ + public function getCategoriesIds() + { + return $this->categories_ids; + } } \ No newline at end of file diff --git a/Services/Style/System/test/fixtures/skins/customSkins/skin1/style1css-variables.less b/Services/Style/System/test/fixtures/skins/customSkins/skin1/style1css-variables.less index 2bbd82bee052..861ad79017ae 100644 --- a/Services/Style/System/test/fixtures/skins/customSkins/skin1/style1css-variables.less +++ b/Services/Style/System/test/fixtures/skins/customSkins/skin1/style1css-variables.less @@ -1,289 +1,24 @@ -//== Colors -// -//## ILIAS works with a base color scheme consisting of six main colors and ... -// -/* Color scheme - Dark BLue: #0f2152; - Mid Blue: #4c6586; - Green: #6ea03c; - Light Brown: #dcb496; - Dark Brown: #523228; - Orange: #fa8228; - External Blue: #21c5d8; - ILIAS 4 MainMenu Color: #c8e6ff; -*/ - -//** brand-primary is used as main colors for links and buttons. -@brand-primary: #4c6586; -@brand-secondary: #6ea03c; -@brand-success: #6ea03c; -@brand-info: #dcb496; -@brand-warning: #fa8228; -@brand-danger: #fa8228; - -@mid-gray: #434343; -@il-primary-container-bg: #FFFFFF; -@il-secondary-container-bg: #F9F9F9; - -@il-highlight-bg: #FFFFD0; -/* @il-highlight-bg: saturate(lighten(@brand-warning, 34%), 80%); */ -/* @il-highlight-bg: lighten(@brand-secondary, 44%); */ -/* @il-highlight-bg: lighten(#21c5d8, 40%); */ -@il-brand-3rd: #21c5d8; - - -/** if left unchanged, you have to copy all the background images to your skin/images folder. -* To use the delos background images in your skin, -* please change this value (in custom less data or in variables.less of your custom skin) to "../../../../templates/default/images/" -*/ -@background-images-path: "images/"; - -/** if left unchanged, you have to copy delos fonts folder to your skin folder. -* To use the delos fonts in your skin, -* please change this value (in custom less data or variables.less of your custom skin) to "../../../../templates/default/fonts/" -*/ -@web-font-path: "fonts/"; - -//== Scaffolding -// -//## -@body-bg: #f0f0f0; -@text-color: @gray-dark; -@link-color: lighten(@brand-primary, 5%); -@link-hover-color: darken(@link-color, 15%); - - -//== Typography -// -//## -@font-family-sans-serif: 'Open Sans', Verdana, Arial, Helvetica, sans-serif; - -@font-size-base: 14px; -@font-size-large: ceil((@font-size-base * 1.25)); -@font-size-small: ceil((@font-size-base * 0.85)); - -@font-size-h1: floor((@font-size-base * 1.6)); -@font-size-h2: floor((@font-size-base * 1.4)); -@font-size-h3: ceil((@font-size-base * 1.3)); -@font-size-h4: ceil((@font-size-base * 1.2)); -@font-size-h5: ceil((@font-size-base * 1.1)); -@font-size-h6: @font-size-base; - - -//== Iconography -// -//## -@icon-font-path: "../../../../Services/UICore/lib/bootstrap-3.2.0/fonts/"; - -//== Components -// -//## -//== Components -// -//## Define common padding and border radius sizes and more. Values based on 14px text and 1.428 line-height (~20px to start). -// - -@padding-base-vertical: 3px; -@padding-base-horizontal: 8px; - -@padding-large-vertical: 6px; -@padding-large-horizontal: 12px; - -@padding-small-vertical: 3px; -@padding-small-horizontal: 6px; - -@padding-xs-vertical: 1px; -@padding-xs-horizontal: 5px; - -@line-height-large: 1.33; -@line-height-small: 1.5; - -@border-radius-base: 0px; -@border-radius-large: 0px; -@border-radius-small: 0px; - -//== Navs -// -//## -@nav-link-padding: 5px 10px; -@nav-tabs-border-color: #e0e0e0; -/* @nav-tabs-link-hover-border-color: @brand-primary; */ -@nav-tabs-active-link-hover-border-color: #e0e0e0; - -// this is related to the main menu -@il-fixed-menu-height: 117px; -@il-fixed-menu-height-bar-only: 40px; - -//== Breadcrumbs -// -//## -// - -@breadcrumb-padding-vertical: 6px; -@breadcrumb-padding-horizontal: 6px; -//** Breadcrumb background color -@breadcrumb-bg: transparent; -//** Breadcrumb text color -@breadcrumb-color: @link-color; -//** Text color of current page in the breadcrumb -@breadcrumb-active-color: @link-hover-color; -//** Textual separator for between breadcrumb elements -@breadcrumb-separator: "»"; - -//== Buttons -// -//## -// - -@btn-default-color: @link-color; -@btn-default-border: #d0d0d0; -@btn-default-bg: #fefefe; -@disabled-btn-bg: #b0b0b0; -@disabled-btn-border: #b0b0b0; -@disabled-btn-color: #e0e0e0; - -//== Badges -// -//## -// - -@badge-color: #fff; -//** Linked badge text color on hover -@badge-link-hover-color: #fff; -@badge-bg: darken(@brand-warning, 10%); - -//** Badge text color in active nav link -@badge-active-color: #fff; -//** Badge background color in active nav link -@badge-active-bg: darken(@brand-warning, 10%); - -@badge-font-weight: bold; -@badge-line-height: 1; -@badge-border-radius: 10px; - -//== Forms -// -//## -// -@input-border-radius: 0; -@input-border: #ccc; -@input-border-focus: lighten(@brand-primary, 20%); -@ilFormInputFontSize: @font-size-small; -@input-height-base: (floor((@ilFormInputFontSize * @line-height-base)) + (@padding-base-vertical * 2) + 2); - -@ilFormColor: #808080; -@ilFormBgColor: #fdfdfd; - -/* ILIAS variables candidates */ -@ilMainMenuColor: lighten(@brand-primary, 10%); -@ilButtonFontSize: @font-size-small; - - -//== Panels -// -//## -// - -@panel-bg: @il-secondary-container-bg; -@panel-body-padding: 15px; -@panel-heading-padding: 10px 15px; -@panel-footer-padding: @panel-heading-padding; -@panel-border-radius: @border-radius-base; - -//** Border color for elements within panels -@panel-inner-border: #ddd; -@panel-footer-bg: #f5f5f5; - -@panel-default-text: @gray-dark; -@panel-default-border: none; -@panel-default-heading-bg: @il-secondary-container-bg; - -@panel-primary-text: @gray-dark; -@panel-primary-border: none; -@panel-primary-heading-bg: @il-primary-container-bg; - -//== DropDowns -// -//## -// -@dropdown-link-hover-bg: #f2f2f2; -@dropdown-link-hover-bg: lighten(@brand-primary, 53%);; - -//== Tables -// -//## Customizes the `.table` component with basic values, each used across all table variations. -// - -//** Padding for ``s and ``s. -@table-cell-padding: 8px; -//** Padding for cells in `.table-condensed`. -@table-condensed-cell-padding: 5px; - -//** Default background color used for all tables. -@table-bg: transparent; -//** Background color used for `.table-striped`. -@table-bg-accent: #ffffff; - -//** Border color for table and cell borders. -@table-border-color: #ddd; - -@il-table-head-bg: lighten(@il-secondary-container-bg, 1%); -@il-data-table-bg: @il-secondary-container-bg; -@il-table-cmd-bg: @il-secondary-container-bg; - -//== Toolbar -// -//## -@navbar-height: 40px; -@il-toolbar-margin: 15px; -@il-toolbar-bg: @il-secondary-container-bg; -@il-toolbar-height: @navbar-height; -@il-toolbar-border: 1px solid #d8d8d8; - -//== Postings -// -//## -@il-posting-by-moderator-bg: #FF9; -@il-posting-needs-moderation-bg: #FFE4E4; - -//== bootstrap date time picker (/Services/Calendar/) -// -//## -@bs-datetimepicker-timepicker-font-size: 1.2em; -@bs-datetimepicker-active-bg: @btn-primary-bg; -@bs-datetimepicker-active-color: @btn-primary-color; -@bs-datetimepicker-border-radius: @border-radius-base; -@bs-datetimepicker-btn-hover-bg: @gray-lighter; -@bs-datetimepicker-disabled-color: @gray-light; -@bs-datetimepicker-alternate-color: @gray-light; -@bs-datetimepicker-secondary-border-color: #ccc; -@bs-datetimepicker-secondary-border-color-rgba: rgba(0, 0, 0, 0.2); -@bs-datetimepicker-primary-border-color: white; -@bs-datetimepicker-text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); - -//== Glyph -// -//## -@il-glyph-color: @link-color; -@il-glyph-hover-color: @link-hover-color; -@il-glyph-highlighted-color: @brand-warning; -@il-glyph-highlighted-hover-color: darken(@brand-warning, 15%); - -//== Counter -// -//## -@il-counter-padding: 2px 4px; -@il-counter-font-size: 9px; -@il-counter-margin-left: -4px; - -//== Status Counter -// -//## -@il-counter-status-bg: lighten(@mid-gray, 40%); -@il-counter-status-margin-top: 10px; - -//== Novelty Counter -// -//## -@il-counter-novelty-bg: @brand-warning; -@il-counter-novelty-margin-top: -5px; +//== Category 1 +// +//## Comment Category 1 +// Random Section 1 + +//** comment variable 11 +@variable11: value11; +//** comment variable 12 +@variable12: value12; +//** comment variable 13 +@variable13: @variable11; + +//== Category 2 +// +//## Comment Category 2 +/** + Random Section 2 **/ + +//** comment variable 21 +@variable21: @variable11; +//** comment variable 22 +@variable22: value21; +//** comment variable 23 +@variable23: @variable21; \ No newline at end of file diff --git a/Services/Style/System/test/fixtures/skins/customSkins/skin1/style2css-variables.less b/Services/Style/System/test/fixtures/skins/customSkins/skin1/style2css-variables.less index 2bbd82bee052..17e69ed67deb 100644 --- a/Services/Style/System/test/fixtures/skins/customSkins/skin1/style2css-variables.less +++ b/Services/Style/System/test/fixtures/skins/customSkins/skin1/style2css-variables.less @@ -1,289 +1,24 @@ -//== Colors -// -//## ILIAS works with a base color scheme consisting of six main colors and ... -// -/* Color scheme - Dark BLue: #0f2152; - Mid Blue: #4c6586; - Green: #6ea03c; - Light Brown: #dcb496; - Dark Brown: #523228; - Orange: #fa8228; - External Blue: #21c5d8; - ILIAS 4 MainMenu Color: #c8e6ff; -*/ - -//** brand-primary is used as main colors for links and buttons. -@brand-primary: #4c6586; -@brand-secondary: #6ea03c; -@brand-success: #6ea03c; -@brand-info: #dcb496; -@brand-warning: #fa8228; -@brand-danger: #fa8228; - -@mid-gray: #434343; -@il-primary-container-bg: #FFFFFF; -@il-secondary-container-bg: #F9F9F9; - -@il-highlight-bg: #FFFFD0; -/* @il-highlight-bg: saturate(lighten(@brand-warning, 34%), 80%); */ -/* @il-highlight-bg: lighten(@brand-secondary, 44%); */ -/* @il-highlight-bg: lighten(#21c5d8, 40%); */ -@il-brand-3rd: #21c5d8; - - -/** if left unchanged, you have to copy all the background images to your skin/images folder. -* To use the delos background images in your skin, -* please change this value (in custom less data or in variables.less of your custom skin) to "../../../../templates/default/images/" -*/ -@background-images-path: "images/"; - -/** if left unchanged, you have to copy delos fonts folder to your skin folder. -* To use the delos fonts in your skin, -* please change this value (in custom less data or variables.less of your custom skin) to "../../../../templates/default/fonts/" -*/ -@web-font-path: "fonts/"; - -//== Scaffolding -// -//## -@body-bg: #f0f0f0; -@text-color: @gray-dark; -@link-color: lighten(@brand-primary, 5%); -@link-hover-color: darken(@link-color, 15%); - - -//== Typography -// -//## -@font-family-sans-serif: 'Open Sans', Verdana, Arial, Helvetica, sans-serif; - -@font-size-base: 14px; -@font-size-large: ceil((@font-size-base * 1.25)); -@font-size-small: ceil((@font-size-base * 0.85)); - -@font-size-h1: floor((@font-size-base * 1.6)); -@font-size-h2: floor((@font-size-base * 1.4)); -@font-size-h3: ceil((@font-size-base * 1.3)); -@font-size-h4: ceil((@font-size-base * 1.2)); -@font-size-h5: ceil((@font-size-base * 1.1)); -@font-size-h6: @font-size-base; - - -//== Iconography -// -//## -@icon-font-path: "../../../../Services/UICore/lib/bootstrap-3.2.0/fonts/"; - -//== Components -// -//## -//== Components -// -//## Define common padding and border radius sizes and more. Values based on 14px text and 1.428 line-height (~20px to start). -// - -@padding-base-vertical: 3px; -@padding-base-horizontal: 8px; - -@padding-large-vertical: 6px; -@padding-large-horizontal: 12px; - -@padding-small-vertical: 3px; -@padding-small-horizontal: 6px; - -@padding-xs-vertical: 1px; -@padding-xs-horizontal: 5px; - -@line-height-large: 1.33; -@line-height-small: 1.5; - -@border-radius-base: 0px; -@border-radius-large: 0px; -@border-radius-small: 0px; - -//== Navs -// -//## -@nav-link-padding: 5px 10px; -@nav-tabs-border-color: #e0e0e0; -/* @nav-tabs-link-hover-border-color: @brand-primary; */ -@nav-tabs-active-link-hover-border-color: #e0e0e0; - -// this is related to the main menu -@il-fixed-menu-height: 117px; -@il-fixed-menu-height-bar-only: 40px; - -//== Breadcrumbs -// -//## -// - -@breadcrumb-padding-vertical: 6px; -@breadcrumb-padding-horizontal: 6px; -//** Breadcrumb background color -@breadcrumb-bg: transparent; -//** Breadcrumb text color -@breadcrumb-color: @link-color; -//** Text color of current page in the breadcrumb -@breadcrumb-active-color: @link-hover-color; -//** Textual separator for between breadcrumb elements -@breadcrumb-separator: "»"; - -//== Buttons -// -//## -// - -@btn-default-color: @link-color; -@btn-default-border: #d0d0d0; -@btn-default-bg: #fefefe; -@disabled-btn-bg: #b0b0b0; -@disabled-btn-border: #b0b0b0; -@disabled-btn-color: #e0e0e0; - -//== Badges -// -//## -// - -@badge-color: #fff; -//** Linked badge text color on hover -@badge-link-hover-color: #fff; -@badge-bg: darken(@brand-warning, 10%); - -//** Badge text color in active nav link -@badge-active-color: #fff; -//** Badge background color in active nav link -@badge-active-bg: darken(@brand-warning, 10%); - -@badge-font-weight: bold; -@badge-line-height: 1; -@badge-border-radius: 10px; - -//== Forms -// -//## -// -@input-border-radius: 0; -@input-border: #ccc; -@input-border-focus: lighten(@brand-primary, 20%); -@ilFormInputFontSize: @font-size-small; -@input-height-base: (floor((@ilFormInputFontSize * @line-height-base)) + (@padding-base-vertical * 2) + 2); - -@ilFormColor: #808080; -@ilFormBgColor: #fdfdfd; - -/* ILIAS variables candidates */ -@ilMainMenuColor: lighten(@brand-primary, 10%); -@ilButtonFontSize: @font-size-small; - - -//== Panels -// -//## -// - -@panel-bg: @il-secondary-container-bg; -@panel-body-padding: 15px; -@panel-heading-padding: 10px 15px; -@panel-footer-padding: @panel-heading-padding; -@panel-border-radius: @border-radius-base; - -//** Border color for elements within panels -@panel-inner-border: #ddd; -@panel-footer-bg: #f5f5f5; - -@panel-default-text: @gray-dark; -@panel-default-border: none; -@panel-default-heading-bg: @il-secondary-container-bg; - -@panel-primary-text: @gray-dark; -@panel-primary-border: none; -@panel-primary-heading-bg: @il-primary-container-bg; - -//== DropDowns -// -//## -// -@dropdown-link-hover-bg: #f2f2f2; -@dropdown-link-hover-bg: lighten(@brand-primary, 53%);; - -//== Tables -// -//## Customizes the `.table` component with basic values, each used across all table variations. -// - -//** Padding for ``s and ``s. -@table-cell-padding: 8px; -//** Padding for cells in `.table-condensed`. -@table-condensed-cell-padding: 5px; - -//** Default background color used for all tables. -@table-bg: transparent; -//** Background color used for `.table-striped`. -@table-bg-accent: #ffffff; - -//** Border color for table and cell borders. -@table-border-color: #ddd; - -@il-table-head-bg: lighten(@il-secondary-container-bg, 1%); -@il-data-table-bg: @il-secondary-container-bg; -@il-table-cmd-bg: @il-secondary-container-bg; - -//== Toolbar -// -//## -@navbar-height: 40px; -@il-toolbar-margin: 15px; -@il-toolbar-bg: @il-secondary-container-bg; -@il-toolbar-height: @navbar-height; -@il-toolbar-border: 1px solid #d8d8d8; - -//== Postings -// -//## -@il-posting-by-moderator-bg: #FF9; -@il-posting-needs-moderation-bg: #FFE4E4; - -//== bootstrap date time picker (/Services/Calendar/) -// -//## -@bs-datetimepicker-timepicker-font-size: 1.2em; -@bs-datetimepicker-active-bg: @btn-primary-bg; -@bs-datetimepicker-active-color: @btn-primary-color; -@bs-datetimepicker-border-radius: @border-radius-base; -@bs-datetimepicker-btn-hover-bg: @gray-lighter; -@bs-datetimepicker-disabled-color: @gray-light; -@bs-datetimepicker-alternate-color: @gray-light; -@bs-datetimepicker-secondary-border-color: #ccc; -@bs-datetimepicker-secondary-border-color-rgba: rgba(0, 0, 0, 0.2); -@bs-datetimepicker-primary-border-color: white; -@bs-datetimepicker-text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); - -//== Glyph -// -//## -@il-glyph-color: @link-color; -@il-glyph-hover-color: @link-hover-color; -@il-glyph-highlighted-color: @brand-warning; -@il-glyph-highlighted-hover-color: darken(@brand-warning, 15%); - -//== Counter -// -//## -@il-counter-padding: 2px 4px; -@il-counter-font-size: 9px; -@il-counter-margin-left: -4px; - -//== Status Counter -// -//## -@il-counter-status-bg: lighten(@mid-gray, 40%); -@il-counter-status-margin-top: 10px; - -//== Novelty Counter -// -//## -@il-counter-novelty-bg: @brand-warning; -@il-counter-novelty-margin-top: -5px; +//== Category 1 +// +//## Comment Category 1 +// Random Section 1 + +//** comment variable 11 +@variable11: value11; +//** comment variable 12 +@variable12: value12; +//** comment variable 13 +@variable13: @variable11; + +//== Category 2 +// +//## Comment Category 2 +/** + Random Section 2 **/ + +//** comment variable 21 +@variable21: @variable11; +//** comment variable 22 +@variable22: value2; +//** comment variable 23 +@variable23: @variable21; \ No newline at end of file diff --git a/Services/Style/System/test/ilSkinStyleLessFileTest.php b/Services/Style/System/test/ilSkinStyleLessFileTest.php new file mode 100644 index 000000000000..96b177243fa8 --- /dev/null +++ b/Services/Style/System/test/ilSkinStyleLessFileTest.php @@ -0,0 +1,85 @@ + + * @version $Id$* + */ +class ilSkinStyleLessVariableTest extends PHPUnit_Framework_TestCase { + + + /** + * @var ilSystemStyleConfigMock + */ + protected $system_style_config; + + /** + * @var ilSystemStyleSkinContainer + */ + protected $container; + + /** + * @var ilSkinStyleXML + */ + protected $style; + + protected function setUp() + { + global $DIC; + + $DIC = new DICMock(); + + $this->system_style_config = new ilSystemStyleConfigMock(); + + mkdir($this->system_style_config->test_skin_temp_path); + ilSystemStyleSkinContainer::xCopy($this->system_style_config->test_skin_original_path, $this->system_style_config->test_skin_temp_path); + + $this->container = ilSystemStyleSkinContainer::generateFromId("skin1", null, $this->system_style_config); + $this->style = $this->container->getSkin()->getStyle("style1"); + } + + protected function tearDown() + { + ilSystemStyleSkinContainer::recursiveRemoveDir($this->system_style_config->test_skin_temp_path); + } + + public function testConstructAndRead() { + $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId())); + $this->assertEquals(16,count($file->getItems())); + } + + public function testReadCorrectTypes() { + $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId())); + + $this->assertEquals(2,count($file->getCategories())); + $this->assertEquals(6,count($file->getVariablesIds())); + $this->assertEquals(8,count($file->getCommentsIds())); + } + + + public function testGetVariableByName(){ + $file = new ilSystemStyleLessFile($this->container->getLessVariablesFilePath($this->style->getId())); + + $expected_variable11 = new ilSystemStyleLessVariable("variable11", "value11", "comment variable 11","Category 1", []); + $expected_variable12 = new ilSystemStyleLessVariable("variable12", "value12", "comment variable 12","Category 1", []); + $expected_variable13 = new ilSystemStyleLessVariable("variable13", "@variable11", "comment variable 13","Category 1", ["variable11"]); + + $expected_variable21 = new ilSystemStyleLessVariable("variable21", "@variable11", "comment variable 21","Category 2", ["variable11"]); + $expected_variable22 = new ilSystemStyleLessVariable("variable22", "value21", "comment variable 22","Category 2", []); + $expected_variable23 = new ilSystemStyleLessVariable("variable23", "@variable21", "comment variable 23","Category 2", ["variable21"]); + + $this->assertEquals($expected_variable11,$file->getVariableByName("variable11")); + $this->assertEquals($expected_variable12,$file->getVariableByName("variable12")); + $this->assertEquals($expected_variable13,$file->getVariableByName("variable13")); + + $this->assertEquals($expected_variable21,$file->getVariableByName("variable21")); + $this->assertEquals($expected_variable22,$file->getVariableByName("variable22")); + $this->assertEquals($expected_variable23,$file->getVariableByName("variable23")); + } +}