From 59eef96b970c9ad69ce382fa47a8f659bc48424e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sat, 29 Sep 2018 14:59:21 -0300 Subject: [PATCH] Prepare Theme class for Sass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- .editorconfig | 5 +---- libraries/classes/Theme.php | 31 +++++++++--------------------- libraries/classes/ThemeManager.php | 2 +- test/classes/ThemeTest.php | 1 - 4 files changed, 11 insertions(+), 28 deletions(-) diff --git a/.editorconfig b/.editorconfig index c1f1fab90748..b3c46648541a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,11 +7,8 @@ end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true charset = utf-8 - -[*.{js,php,twig,phtml,json,css}] indent_style = space indent_size = 4 -[{*.sql,package.json,.travis.yml}] -indent_style = space +[{*.{sql,scss,css},package.json,.travis.yml}] indent_size = 2 diff --git a/libraries/classes/Theme.php b/libraries/classes/Theme.php index 2351eb7131d0..7eb5dbf7279f 100644 --- a/libraries/classes/Theme.php +++ b/libraries/classes/Theme.php @@ -378,31 +378,18 @@ public function loadCss() { $success = true; - /* Variables to be used by the themes: */ - $theme = $this; - if ($GLOBALS['text_dir'] === 'ltr') { - $right = 'right'; - $left = 'left'; + $file = $GLOBALS['text_dir'] === 'rtl' ? '/css/theme-rtl.css' : '/css/theme.css'; + $path = $this->getPath() . $file; + $fallback = './themes/' . ThemeManager::FALLBACK_THEME . $file; + + if (is_readable($path)) { + include $path; + } elseif (is_readable($fallback)) { + include $fallback; } else { - $right = 'left'; - $left = 'right'; + $success = false; } - foreach ($this->_cssFiles as $file) { - $path = $this->getPath() . "/css/$file.css.php"; - $fallback = "./themes/" - . ThemeManager::FALLBACK_THEME . "/css/$file.css.php"; - - if (is_readable($path)) { - echo "\n/* FILE: " , $file , ".css.php */\n"; - include $path; - } elseif (is_readable($fallback)) { - echo "\n/* FILE: " , $file , ".css.php */\n"; - include $fallback; - } else { - $success = false; - } - } return $success; } diff --git a/libraries/classes/ThemeManager.php b/libraries/classes/ThemeManager.php index 86ffda0549d1..89ee24d2b00c 100644 --- a/libraries/classes/ThemeManager.php +++ b/libraries/classes/ThemeManager.php @@ -121,7 +121,7 @@ public function __construct() /** * Returns the singleton Response object * - * @return Response object + * @return ThemeManager object */ public static function getInstance() { diff --git a/test/classes/ThemeTest.php b/test/classes/ThemeTest.php index 5c578859ea8d..6c47e0094dcd 100644 --- a/test/classes/ThemeTest.php +++ b/test/classes/ThemeTest.php @@ -148,7 +148,6 @@ public function testLoadCss($theme) $out = ob_get_contents(); ob_end_clean(); $this->assertTrue($ret); - $this->assertContains('FILE: navigation.css.php', $out); $this->assertContains('.ic_b_bookmark', $out); }