diff --git a/modules/cms/classes/Theme.php b/modules/cms/classes/Theme.php index 43040f319..6e1c3dafc 100644 --- a/modules/cms/classes/Theme.php +++ b/modules/cms/classes/Theme.php @@ -47,10 +47,13 @@ class Theme /** * Loads the theme. + * @return self */ - public function load($dirName) + public static function load($dirName) { - $this->dirName = $dirName; + $theme = new static; + $theme->setDirName($dirName); + return $theme; } /** @@ -67,6 +70,15 @@ class Theme return base_path().Config::get('cms.themesDir').'/'.$dirName; } + /** + * Sets the theme directory name. + * @return void + */ + public function setDirName($dirName) + { + $this->dirName = $dirName; + } + /** * Returns the theme directory name. * @return string @@ -135,8 +147,8 @@ class Theme throw new SystemException(Lang::get('cms::lang.theme.active.not_set')); } - $theme = new static; - $theme->load($activeTheme); + $theme = static::load($activeTheme); + if (!File::isDirectory($theme->getPath())) { return self::$activeThemeCache = null; } @@ -184,8 +196,8 @@ class Theme throw new SystemException(Lang::get('cms::lang.theme.edit.not_set')); } - $theme = new static; - $theme->load($editTheme); + $theme = static::load($editTheme); + if (!File::isDirectory($theme->getPath())) { return self::$editThemeCache = null; } @@ -210,8 +222,8 @@ class Theme continue; } - $theme = new static; - $theme->load($fileinfo->getFilename()); + $theme = static::load($fileinfo->getFilename()); + $result[] = $theme; }