list_themes

includes/theme.inc, line 435

Versions
4.6 – 7
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 functions call 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.
system_menu in modules/system/system.module
Implementation of hook_menu().
system_themes_form_submit in modules/system/system.admin.inc
Process system_themes_form form submissions.
system_theme_select_form in modules/system/system.module
Returns a fieldset containing the theme select form.
system_update_6042 in modules/system/system.install
Upgrade recolored theme stylesheets to new array structure.
theme_get_setting in includes/theme.inc
Retrieve a setting for the current theme. This function is designed for use from within themes & engines to determine theme settings made in the admin interface.
_color_rewrite_stylesheet in modules/color/color.module
Rewrite the stylesheet to match the colors in the palette.
_drupal_maintenance_theme in includes/theme.maintenance.inc
Sets up the theming system for site installs, updates and when the site is in off-line mode. It also applies when the database is unavailable.

Code

<?php
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;
}
?>
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.