From c70115120d050ea8ec156d526e6323076d54b1bd Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 28 Jun 2017 13:29:15 +0200 Subject: [PATCH] Allow applications to inject ACP SCSS stylesheets --- .../lib/system/style/StyleCompiler.class.php | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php b/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php index 342f72ac39..bd584a451b 100644 --- a/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php +++ b/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php @@ -4,6 +4,7 @@ use Leafo\ScssPhp\Compiler; use wcf\data\application\Application; use wcf\data\option\Option; use wcf\data\style\Style; +use wcf\system\application\ApplicationHandler; use wcf\system\event\EventHandler; use wcf\system\exception\SystemException; use wcf\system\SingletonFactory; @@ -120,6 +121,13 @@ class StyleCompiler extends SingletonFactory { // ACP uses a slightly different layout $files[] = WCF_DIR . 'acp/style/layout.scss'; + // include stylesheets from other apps in arbitrary order + if (PACKAGE_ID) { + foreach (ApplicationHandler::getInstance()->getApplications() as $application) { + $files = array_merge($files, $this->getAcpStylesheets($application)); + } + } + // read default values $sql = "SELECT variableName, defaultValue FROM wcf".WCF_N."_style_variable @@ -194,6 +202,25 @@ class StyleCompiler extends SingletonFactory { return $files; } + /** + * Returns the list of SCSS stylesheets of an application. + * + * @param Application $application + * @return string[] + */ + protected function getAcpStylesheets(Application $application) { + if ($application->packageID == 1) return []; + + $files = []; + + $basePath = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR . $application->getPackage()->packageDir)) . 'acp/style/'; + foreach (glob($basePath . '*.scss') as $file) { + $files[] = $file; + } + + return $files; + } + /** * Prepares the style compiler by adding variables to environment. * -- 2.20.1