function system_get_available_themes
Search API
7.x system.module | system_get_available_themes() |
6.x system.module | system_get_available_themes() |
5.x system.module | system_get_available_themes() |
Returns back an array (suitable for FAPI) of the available themes in the system.
1 call to system_get_available_themes()
- system_settings_form in modules/
system/ system.module - This is the "system settings" form.
File
- modules/
system/ system.module, line 1753
Code
function system_get_available_themes() {
$rtn = array();
// First, search for themes in our core folder. Themes must have a .info file which matches
// their folder name, just like modules.
$theme_dirs = array();
$theme_dirs [] = array("start" => "themes", "type" => t("Core"));
$theme_dirs [] = array("start" => "custom/themes", "type" => t("Custom"));
foreach ($theme_dirs as $theme_dir) {
$start_dir = $theme_dir ["start"];
$type_dir = $theme_dir ['type'];
if ($dh = @opendir($start_dir)) {
$dir_files = scandir($start_dir);
foreach ($dir_files as $file) {
if ($file == "." || $file == "..") {
continue;
}
if (is_dir($start_dir . "/" . $file)) {
// Okay, now look inside and see if there is a .info file.
if (file_exists("$start_dir/$file/$file.info")) {
$theme = $file;
$info_contents = file_get_contents("$start_dir/$file/$file.info");
// From the info_contents variable, split up and place into an array.
$info_details_array = array("name" => t("Name Not Set. Configure theme's .info file."), "path" => "", "module" => "",
"schema" => "", "core" => "", "description" => "",
"requires" => "", "version" => "",
"required" => "",);
$lines = explode("\n", $info_contents);
foreach ($lines as $line) {
if (trim($line) == "") {
continue;
}
$temp = explode("=", trim($line));
$info_details_array [trim($temp [0])] = trim(substr($line, strlen($temp [0]) + 1));
}
$path = "$start_dir/$file";
$rtn [$path] = $info_details_array ['name'] . "<div style='font-size: 0.8em; font-style: italic; padding-left: 40px;'>{$info_details_array ['description']}
<br>(Type: $type_dir Location: $path)</div>";
} // if file_exists
} //if is_dir
} //foreach dir_files as $file
} // if we can opendir
} // foreach theme_dirs as theme_dir
return $rtn;
}