Commit 22e2f0c1 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

get_languages,get_themes added

parent 27a3550b
......@@ -252,6 +252,50 @@ function get_string_location($identifier, $section, $variables, $replacefunc='fo
}
/**
* Return a list of available languages
*
*/
function get_languages() {
$langs = array();
$langbase = get_config('docroot') . 'lang/';
if (!$langdir = opendir($langbase)) {
throw new Exception('Unable to read language directory '.$langbase);
}
while (false !== ($subdir = readdir($langdir))) {
$langfile = $langbase . $subdir . '/langconfig.php';
if ($subdir != "." && $subdir != ".." && is_readable($langfile)) {
if ($langname = get_string_from_file('thislanguage',$langfile)) {
$langs[$subdir] = $langname;
}
}
}
closedir($langdir);
return $langs;
}
/**
* Return a list of available themes
* Need to add the theme names sometime; for now use get_string().
*
*/
function get_themes() {
$themes = array();
$themebase = get_config('docroot') . 'theme/';
if (!$themedir = opendir($themebase)) {
throw new Exception('Unable to read theme directory '.$themebase);
}
while (false !== ($subdir = readdir($themedir))) {
// Where do we get theme names from?
if ($subdir != "." && $subdir != "..") {
$themes[$subdir] = get_string($subdir);
}
}
closedir($themedir);
return $themes;
}
/**
* This function is only used from {@link get_string()}.
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment