drupal_theme_initialize

Versions
7
drupal_theme_initialize()

Initialize the theme system by loading the theme.

▾ 11 functions call drupal_theme_initialize()

batch_process in includes/form.inc
Processes the batch.
block_admin_display in modules/block/block.admin.inc
Menu callback for admin/structure/block.
block_page_build in modules/block/block.module
Implement hook_page_build().
dashboard_show_block_content in modules/dashboard/dashboard.module
AJAX callback to display the rendered contents of a specific block.
dashboard_update in modules/dashboard/dashboard.module
Set the new weight of each region according to the drag-and-drop order.
drupal_build_form in includes/form.inc
Build and process a form based on a form id.
l in includes/common.inc
Format an internal Drupal link.
menu_test_theme_page_callback in modules/simpletest/tests/menu_test.module
Page callback to use when testing the theme callback functionality.
path_to_theme in includes/theme.inc
Return the path to the current themed element.
theme in includes/theme.inc
Generate the themed output.
_block_rehash in modules/block/block.module
Update the 'block' DB table with the blocks currently exported by modules.

Code

includes/theme.inc, line 56

<?php
function drupal_theme_initialize() {
  global $theme, $user, $theme_key;

  // If $theme is already set, assume the others are set, too, and do nothing
  if (isset($theme)) {
    return;
  }

  drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
  $themes = list_themes();

  // Only select the user selected theme if it is available in the
  // list of themes that can be accessed.
  $theme = !empty($user->theme) && isset($themes[$user->theme]) && drupal_theme_access($themes[$user->theme]) ? $user->theme : variable_get('theme_default', 'garland');

  // Allow modules to override the present theme... only select custom theme
  // if it is available in the list of themes that can be accessed.
  $custom_theme = menu_get_custom_theme();
  $theme = $custom_theme && isset($themes[$custom_theme]) && drupal_theme_access($themes[$custom_theme]) ? $custom_theme : $theme;

  // Store the identifier for retrieving theme settings with.
  $theme_key = $theme;

  // Find all our ancestor themes and put them in an array.
  $base_theme = array();
  $ancestor = $theme;
  while ($ancestor && isset($themes[$ancestor]->base_theme)) {
    $base_theme[] = $new_base_theme = $themes[$themes[$ancestor]->base_theme];
    $ancestor = $themes[$ancestor]->base_theme;
  }
  _drupal_theme_initialize($themes[$theme], array_reverse($base_theme));

  // Themes can have alter functions, so reset the drupal_alter() cache.
  drupal_static_reset('drupal_alter');
}
?>
Login or register to post comments
 
 

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.