function list_themes

You are here

7 theme.inc list_themes($refresh = FALSE)
4.6 theme.inc list_themes($refresh = FALSE)
4.7 theme.inc list_themes($refresh = FALSE)
5 theme.inc list_themes($refresh = FALSE)
6 theme.inc list_themes($refresh = FALSE)
8 theme.inc list_themes($refresh = FALSE)

Provides a list of currently available themes.

If the database is active then it will be retrieved from the database. Otherwise it will retrieve a new list.

Parameters

$refresh: Whether to reload the list of themes from the database.

Return value

An array of the currently available themes.

12 calls to list_themes()
block_add_block_form_submit in modules/block/block.admin.inc
Save the new custom block.
block_menu in modules/block/block.module
Implementation of hook_menu().
color_form_alter in modules/color/color.module
Implementation of hook_form_alter().
drupal_find_theme_templates in includes/theme.inc
Find overridden theme templates. Called by themes and/or theme engines to easily discover templates.
init_theme in includes/theme.inc
Initialize the theme system by loading the theme.

... See full list

File

includes/theme.inc, line 470
The theme system, which controls the output of Drupal.

Code

function list_themes($refresh = FALSE) {
  static $list = array();

  if ($refresh) {
    $list = array();
  }

  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 (db_is_active() && !defined('MAINTENANCE_MODE')) {
      $result = db_query("SELECT * FROM {system} WHERE type = '%s'", 'theme');
      while ($theme = db_fetch_object($result)) {
        if (file_exists($theme->filename)) {
          $theme->info = unserialize($theme->info);
          $themes[] = $theme;
        }
      }
    }
    else {
      // Scan the installation when the database should not be read.
      $themes = _system_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) {
        if (file_exists($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;
}