mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Merge pull request #351 from Flynsarmy/themeFixes
Add Theme::exists(), Fix getPath()
This commit is contained in:
commit
460039cb57
@ -7,7 +7,7 @@ use Config;
|
||||
use System\Classes\SystemException;
|
||||
|
||||
/**
|
||||
* This class represents the CMS theme.
|
||||
* This class represents the CMS theme.
|
||||
* CMS theme is a directory that contains all CMS objects - pages, layouts, partials and asset files..
|
||||
* The theme parameters are specified in the theme.ini file in the theme root directory.
|
||||
*
|
||||
@ -31,10 +31,13 @@ class Theme
|
||||
|
||||
/**
|
||||
* Returns the absolute theme path.
|
||||
* @param string $dir Optional theme directory. Defaults to $this->getDirName()
|
||||
*/
|
||||
public function getPath()
|
||||
public function getPath($dir = NULL)
|
||||
{
|
||||
return base_path().Config::get('cms.themesDir').'/'.$this->dirName;
|
||||
if ( !$dir ) $dir = $this->getDirName();
|
||||
|
||||
return base_path().Config::get('cms.themesDir').'/'.$dir;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,6 +49,19 @@ class Theme
|
||||
return $this->dirName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a theme with given path exists
|
||||
* @param string $dir The theme directory
|
||||
* @return bool
|
||||
*/
|
||||
public static function exists($dir)
|
||||
{
|
||||
$theme = new self;
|
||||
$path = $theme->getPath($dir);
|
||||
|
||||
return File::isDirectory($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of pages in the theme.
|
||||
* This method is used internally in the routing process and in the back-end UI.
|
||||
@ -112,4 +128,4 @@ class Theme
|
||||
|
||||
return $theme;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user