From: Marcin Haba Date: Tue, 1 May 2018 11:09:01 +0000 (+0200) Subject: baculum: Add manual loading CSS files with versioning X-Git-Tag: Release-9.2.0~78 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f90b0fe51f1aa5b565322df64cdb35ce7d34cb9b;p=thirdparty%2Fbacula.git baculum: Add manual loading CSS files with versioning --- diff --git a/gui/baculum/protected/Common/Class/BaculumPage.php b/gui/baculum/protected/Common/Class/BaculumPage.php index 97b5985097..1327f7f395 100644 --- a/gui/baculum/protected/Common/Class/BaculumPage.php +++ b/gui/baculum/protected/Common/Class/BaculumPage.php @@ -21,6 +21,7 @@ */ Prado::using('System.Web.UI.TPage'); +Prado::using('Application.Common.Class.BClientScript'); /** * Base pages module. @@ -36,6 +37,11 @@ class BaculumPage extends TPage { $this->setURLPrefixForSubdir(); } + public function onInit($param) { + parent::onInit($param); + $this->setStyleSheetFiles(); + } + /** * Shortcut method for getting application modules instances by * module name. @@ -141,5 +147,33 @@ class BaculumPage extends TPage { // Log in by header header("Location: $location"); } + + public function setStyleSheetFiles(){ + $theme = $this->getPage()->getTheme(); + if (is_null($theme)) { + return; + } + $css_path = $theme->getBaseUrl() . '/css/'; + $css_dir = APPLICATION_DIRECTORY . $css_path; + if (!is_dir($css_dir)) { + return; + } + $files = new FilesystemIterator($css_dir); + foreach ($files as $file) { + $filename = $file->getFilename(); + if (!is_file($css_dir . $filename)) { + continue; + } + if (preg_match('/\.css$/', $filename) === 1) { + $url = sprintf( + '%s%s?ver=%s', + $css_path, + $filename, + BClientScript::SCRIPTS_VERSION + ); + $this->getPage()->getClientScript()->registerStyleSheetFile($filename, $url); + } + } + } } ?>