| 5 theme.inc | list_themes($refresh = FALSE) |
| 6 theme.inc | list_themes($refresh = FALSE) |
| 7 theme.inc | list_themes($refresh = FALSE) |
| 8 theme.inc | list_themes($refresh = FALSE) |
Return a list of all currently available themes.
Retrieved from the database, if available and the site is not in maintenance mode; otherwise compiled freshly from the filesystem.
Parameters
$refresh: Whether to reload the list of themes from the database. Defaults to FALSE.
Return value
An associative array of the currently available themes. The keys are the names of the themes and the values are objects having the following properties:
- 'filename': The name of the .info file.
- 'name': The machine name of the theme.
- 'status': 1 for enabled, 0 for disabled themes.
- 'info': The contents of the .info file.
- 'stylesheets': A two dimensional array, using the first key for the 'media' attribute (e.g. 'all'), the second for the name of the file (e.g. style.css). The value is a complete filepath (e.g. themes/bartik/style.css).
- 'scripts': An associative array of JavaScripts, using the filename as key and the complete filepath as value.
- 'engine': The name of the theme engine.
- 'base_theme': The name of the base theme.
- 'base_themes': An ordered array of all the base themes. If the first item is NULL, a base theme is missing for this theme.
- 'sub_themes': An unordered array of sub-themes of this theme.
25 calls to list_themes()
1 string reference to 'list_themes'
File
- core/
includes/ theme.inc, line 755 - The theme system, which controls the output of Drupal.
Code
function list_themes($refresh = FALSE) {
$list = &drupal_static(__FUNCTION__, array());
if ($refresh) {
$list = array();
system_list_reset();
}
if (empty($list)) {
$list = array();
$themes = array();
// Extract from the database only when it is available.
// Also check that the site is not in the middle of an install or update.
if (!defined('MAINTENANCE_MODE')) {
try {
$themes = system_list('theme');
}
catch (Exception $e) {
// If the database is not available, rebuild the theme data.
$themes = _system_rebuild_theme_data();
}
}
else {
// Scan the installation when the database should not be read.
$themes = _system_rebuild_theme_data();
}
foreach ($themes as $theme) {
foreach ($theme->info['stylesheets'] as $media => $stylesheets) {
foreach ($stylesheets as $stylesheet => $path) {
$theme->stylesheets[$media][$stylesheet] = $path;
}
}
foreach ($theme->info['scripts'] as $script => $path) {
$theme->scripts[$script] = $path;
}
if (isset($theme->info['engine'])) {
$theme->engine = $theme->info['engine'];
}
if (isset($theme->info['base theme'])) {
$theme->base_theme = $theme->info['base theme'];
}
// Status is normally retrieved from the database. Add zero values when
// read from the installation directory to prevent notices.
if (!isset($theme->status)) {
$theme->status = 0;
}
$list[$theme->name] = $theme;
}
}
return $list;
}
Login or register to post comments