]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add manual loading CSS files with versioning
authorMarcin Haba <marcin.haba@bacula.pl>
Tue, 1 May 2018 11:09:01 +0000 (13:09 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Tue, 1 May 2018 11:09:01 +0000 (13:09 +0200)
gui/baculum/protected/Common/Class/BaculumPage.php

index 97b5985097e45e358be88e4d9da3b56e78ca7dc1..1327f7f395e8151b1ffb36449236391c0da5532e 100644 (file)
@@ -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);
+                       }
+               }
+       }
 }
 ?>