Merge pull request #351 from Flynsarmy/themeFixes

Add Theme::exists(), Fix getPath()
This commit is contained in:
Samuel Georges 2014-06-25 19:00:43 +10:00
commit 460039cb57

View File

@ -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.