Exemple #1
0
 /**
  * Collect Web 2 and module LESS files and add them to the LESS compiler
  */
 protected function collect()
 {
     foreach (self::$lessFiles as $lessFile) {
         $this->lessCompiler->addLessFile($this->pubPath . '/' . $lessFile);
     }
     $mm = $this->app->getModuleManager();
     foreach ($mm->getLoadedModules() as $moduleName => $module) {
         if ($module->hasCss()) {
             foreach ($module->getCssFiles() as $lessFilePath) {
                 $this->lessCompiler->addModuleLessFile($moduleName, $lessFilePath);
             }
         }
     }
     $themingConfig = $this->app->getConfig()->getSection('themes');
     $defaultTheme = $themingConfig->get('default');
     $theme = null;
     if ((bool) $themingConfig->get('disabled', false)) {
         if ($defaultTheme !== null && $defaultTheme !== self::DEFAULT_THEME) {
             $theme = $defaultTheme;
         }
     } else {
         $auth = Auth::getInstance();
         if ($auth->isAuthenticated()) {
             $userTheme = $auth->getUser()->getPreferences()->getValue('icingaweb', 'theme');
             if ($userTheme !== null) {
                 $theme = $userTheme;
             } elseif ($defaultTheme !== null && $defaultTheme !== self::DEFAULT_THEME) {
                 $theme = $defaultTheme;
             }
         }
     }
     if ($theme) {
         if (($pos = strpos($theme, '/')) !== false) {
             $moduleName = substr($theme, 0, $pos);
             $theme = substr($theme, $pos + 1);
             if ($mm->hasLoaded($moduleName)) {
                 $module = $mm->getModule($moduleName);
                 $this->lessCompiler->setTheme($module->getCssDir() . '/themes/' . $theme . '.less');
             }
         } else {
             $this->lessCompiler->setTheme($this->pubPath . '/css/themes/' . $theme . '.less');
         }
     }
 }
Exemple #2
0
 /**
  * Collect Web 2 and module LESS files and add them to the LESS compiler
  */
 protected function collect()
 {
     foreach (self::$lessFiles as $lessFile) {
         $this->lessCompiler->addLessFile($this->pubPath . '/' . $lessFile);
     }
     $mm = $this->app->getModuleManager();
     foreach ($mm->getLoadedModules() as $moduleName => $module) {
         if ($module->hasCss()) {
             foreach ($module->getCssFiles() as $lessFilePath) {
                 $this->lessCompiler->addModuleLessFile($moduleName, $lessFilePath);
             }
         }
     }
     $themingConfig = $this->app->getConfig()->getSection('themes');
     $defaultTheme = $themingConfig->get('default', self::DEFAULT_THEME);
     $theme = null;
     if ((bool) $themingConfig->get('disabled', false)) {
         if ($defaultTheme !== self::DEFAULT_THEME) {
             $theme = $defaultTheme;
         }
     } else {
         if (($userTheme = $this->app->getRequest()->getCookie('theme', $defaultTheme)) && $userTheme !== $defaultTheme) {
             $theme = $userTheme;
         }
     }
     if ($theme) {
         if (($pos = strpos($theme, '/')) !== false) {
             $moduleName = substr($theme, 0, $pos);
             $theme = substr($theme, $pos + 1);
             if ($mm->hasLoaded($moduleName)) {
                 $module = $mm->getModule($moduleName);
                 $this->lessCompiler->setTheme($module->getCssDir() . '/themes/' . $theme . '.less');
             }
         } else {
             $this->lessCompiler->setTheme($this->pubPath . '/css/themes/' . $theme . '.less');
         }
     }
 }