function _ctools_list_themes
Helper to build a ctools-friendly list of themes capable of providing plugins.
Return value
array A list of themes that can act as plugin providers, sorted parent-first with the active theme placed last.
2 calls to _ctools_list_themes()
- ctools_plugin_api_info in includes/
plugins.inc - Get an array of information about modules that support an API.
- ctools_plugin_get_directories in includes/
plugins.inc - Get a list of directories to search for plugins of the given type.
File
-
includes/
plugins.inc, line 550
Code
function _ctools_list_themes() {
static $themes;
if (is_null($themes)) {
$current = variable_get('theme_default', FALSE);
$themes = $active = array();
$all_themes = list_themes();
foreach ($all_themes as $name => $theme) {
// Only search from active themes.
if (empty($theme->status) && $theme->name != $current) {
continue;
}
$active[$name] = $theme;
// Prior to drupal 6.14, $theme->base_themes does not exist. Build it.
if (!isset($theme->base_themes) && !empty($theme->base_theme)) {
$active[$name]->base_themes = ctools_find_base_themes($all_themes, $name);
}
}
// Construct a parent-first list of all themes.
foreach ($active as $name => $theme) {
$base_themes = isset($theme->base_themes) ? $theme->base_themes : array();
$themes = array_merge($themes, $base_themes, array(
$name => $theme->info['name'],
));
}
// Put the actual theme info objects into the array.
foreach (array_keys($themes) as $name) {
if (isset($all_themes[$name])) {
$themes[$name] = $all_themes[$name];
}
}
// Make sure the current default theme always gets the last word.
if ($current_key = array_search($current, array_keys($themes))) {
$themes += array_splice($themes, $current_key, 1);
}
}
return $themes;
}