From f06535bc47191e0df1c998ae602c6306b3e4c2d5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 3 Feb 2021 14:24:20 +0100 Subject: [PATCH] Add StyleCompiler::writeCss() --- .../lib/system/style/StyleCompiler.class.php | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php b/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php index 8c42a51c97..7c4ee85a80 100644 --- a/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php +++ b/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php @@ -552,15 +552,7 @@ EOT; $content = $callback($content); - // write stylesheet - \file_put_contents($filename . '.css', $content); - FileUtil::makeWritable($filename . '.css'); - - $content = $this->convertToRtl($content); - - // write stylesheet for RTL - \file_put_contents($filename . '-rtl.css', $content); - FileUtil::makeWritable($filename . '-rtl.css'); + $this->writeCss($filename, $content); } /** @@ -585,6 +577,18 @@ EOT; return $css; } + /** + * Writes the given css into the file with the given prefix. + */ + private function writeCss(string $filePrefix, string $css): void + { + \file_put_contents($filePrefix . '.css', $css); + FileUtil::makeWritable($filePrefix . '.css'); + + \file_put_contents($filePrefix . '-rtl.css', $this->convertToRtl($css)); + FileUtil::makeWritable($filePrefix . '-rtl.css'); + } + /** * Returns the name of the CSS file for a specific style. * -- 2.20.1