add a method to Theme class to list available themes
This commit is contained in:
parent
cbae1b0c8b
commit
f086dddf43
|
@ -70,7 +70,7 @@ class Theme
|
||||||
|
|
||||||
// Check to see if it's in the local dir
|
// Check to see if it's in the local dir
|
||||||
|
|
||||||
$localroot = Theme::localRoot();
|
$localroot = self::localRoot();
|
||||||
|
|
||||||
$fulldir = $localroot.'/'.$name;
|
$fulldir = $localroot.'/'.$name;
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ class Theme
|
||||||
|
|
||||||
// Check to see if it's in the distribution dir
|
// Check to see if it's in the distribution dir
|
||||||
|
|
||||||
$instroot = Theme::installRoot();
|
$instroot = self::installRoot();
|
||||||
|
|
||||||
$fulldir = $instroot.'/'.$name;
|
$fulldir = $instroot.'/'.$name;
|
||||||
|
|
||||||
|
@ -172,6 +172,51 @@ class Theme
|
||||||
return $theme->getPath($relative);
|
return $theme->getPath($relative);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list available theme names
|
||||||
|
*
|
||||||
|
* @return array list of available theme names
|
||||||
|
*/
|
||||||
|
|
||||||
|
static function listAvailable()
|
||||||
|
{
|
||||||
|
$local = self::subdirsOf(self::localRoot());
|
||||||
|
$install = self::subdirsOf(self::installRoot());
|
||||||
|
|
||||||
|
$i = array_search('base', $install);
|
||||||
|
|
||||||
|
unset($install[$i]);
|
||||||
|
|
||||||
|
return array_merge($local, $install);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility for getting subdirs of a directory
|
||||||
|
*
|
||||||
|
* @param string $dir full path to directory to check
|
||||||
|
*
|
||||||
|
* @return array relative filenames of subdirs, or empty array
|
||||||
|
*/
|
||||||
|
|
||||||
|
protected static function subdirsOf($dir)
|
||||||
|
{
|
||||||
|
$subdirs = array();
|
||||||
|
|
||||||
|
if (is_dir($dir)) {
|
||||||
|
if ($dh = opendir($dir)) {
|
||||||
|
while (($filename = readdir($dh)) !== false) {
|
||||||
|
if ($filename != '..' && $filename !== '.' &&
|
||||||
|
is_dir($dir.'/'.$filename)) {
|
||||||
|
$subdirs[] = $filename;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir($dh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $subdirs;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Local root dir for themes
|
* Local root dir for themes
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user