/**
  * Builds the theme registry
  */
 public static function buildRegistry()
 {
     self::$_themes = array();
     $dirs = array("themes/", "custom/themes/");
     // check for a default themedef file
     $themedefDefault = array();
     if (sugar_is_file("custom/themes/default/themedef.php")) {
         $themedef = array();
         require "custom/themes/default/themedef.php";
         $themedefDefault = $themedef;
     }
     foreach ($dirs as $dirPath) {
         if (sugar_is_dir('./' . $dirPath) && is_readable('./' . $dirPath) && ($dir = opendir('./' . $dirPath))) {
             while (($file = readdir($dir)) !== false) {
                 if ($file == ".." || $file == "." || $file == ".svn" || $file == "CVS" || $file == "Attic" || $file == "default" || !sugar_is_dir("./{$dirPath}" . $file) || !sugar_is_file("./{$dirPath}{$file}/themedef.php")) {
                     continue;
                 }
                 $themedef = array();
                 require "./{$dirPath}{$file}/themedef.php";
                 $themedef = array_merge($themedef, $themedefDefault);
                 $themedef['dirName'] = $file;
                 // check for theme already existing in the registry
                 // if so, then it will override the current one
                 if (self::exists($themedef['dirName'])) {
                     $existingTheme = self::get($themedef['dirName']);
                     foreach (SugarTheme::getThemeDefFields() as $field) {
                         if (!isset($themedef[$field])) {
                             $themedef[$field] = $existingTheme->{$field};
                         }
                     }
                     self::remove($themedef['dirName']);
                 }
                 if (isset($themedef['name'])) {
                     self::add($themedef);
                 }
             }
             closedir($dir);
         }
     }
     // default to setting the default theme as the current theme
     if (!isset($GLOBALS['sugar_config']['default_theme']) || !self::set($GLOBALS['sugar_config']['default_theme'])) {
         if (count(self::availableThemes()) == 0) {
             sugar_die('No valid themes are found on this instance');
         } else {
             self::set(self::getDefaultThemeKey());
         }
     }
 }
 public function testGetImageWithInvalidImage()
 {
     $this->assertFalse($this->_themeObject->getImage('ThisImageDoesNotExist'));
 }
Exemple #3
0
 /**
  * Builds the theme registry
  */
 public static function buildRegistry()
 {
     self::$_themes = array();
     // check for a default themedef file
     $themedefDefault = array();
     if (SugarAutoLoader::existing("custom/themes/default/themedef.php")) {
         $themedef = array();
         require "custom/themes/default/themedef.php";
         $themedefDefault = $themedef;
     }
     foreach (SugarAutoLoader::getFilesCustom("themes", true) as $file) {
         if (SugarAutoLoader::existing("{$file}/themedef.php")) {
             $themedef = array();
             require "{$file}/themedef.php";
             $themedef = array_merge($themedef, $themedefDefault);
             $themedef['dirName'] = basename($file);
             if (self::exists($themedef['dirName'])) {
                 $existingTheme = self::get($themedef['dirName']);
                 foreach (SugarTheme::getThemeDefFields() as $field) {
                     if (!isset($themedef[$field])) {
                         $themedef[$field] = $existingTheme->{$field};
                     }
                 }
                 self::remove($themedef['dirName']);
             }
             if (isset($themedef['name'])) {
                 self::add($themedef);
             }
         }
     }
     // default to setting the default theme as the current theme
     if (!isset($GLOBALS['sugar_config']['default_theme']) || !self::set($GLOBALS['sugar_config']['default_theme'])) {
         if (count(self::availableThemes()) == 0) {
             sugar_die('No valid themes are found on this instance');
         } else {
             self::set(self::getDefaultThemeKey());
         }
     }
 }
 /**
  * Builds the theme registry
  */
 public static function buildRegistry()
 {
     self::$_themes = array();
     $dirs = array("themes/", "custom/themes/");
     foreach ($dirs as $dirPath) {
         if (sugar_is_dir('./' . $dirPath) && ($dir = opendir('./' . $dirPath))) {
             while (($file = readdir($dir)) !== false) {
                 if ($file == ".." || $file == "." || $file == ".svn" || $file == "CVS" || $file == "Attic" || !sugar_is_dir("./{$dirPath}" . $file) || !sugar_is_file("./{$dirPath}{$file}/themedef.php")) {
                     continue;
                 }
                 $themedef = array();
                 require "./{$dirPath}{$file}/themedef.php";
                 $themedef['dirName'] = $file;
                 // check for theme already existing in the registry
                 // if so, then it will override the current one
                 if (self::exists($themedef['dirName'])) {
                     $existingTheme = self::get($themedef['dirName']);
                     foreach (SugarTheme::getThemeDefFields() as $field) {
                         if (!isset($themedef[$field])) {
                             $themedef[$field] = $existingTheme->{$field};
                         }
                     }
                     self::remove($themedef['dirName']);
                 }
                 if (isset($themedef['name'])) {
                     self::add($themedef);
                 }
             }
             closedir($dir);
         }
     }
     // default to setting the default theme as the current theme
     self::set($GLOBALS['sugar_config']['default_theme']);
 }