You are here

function system_theme_data in Drupal 6

Same name and namespace in other branches
  1. 4 modules/system.module \system_theme_data()
  2. 5 modules/system/system.module \system_theme_data()

Collect data about all currently available themes.

Return value

Array of all available themes and their data.

8 calls to system_theme_data()
drupal_flush_all_caches in includes/common.inc
Flush all cached data on the site.
system_admin_theme_settings in modules/system/system.admin.inc
Form builder; This function allows selection of the theme to show in administration sections.
system_install in modules/system/system.install
Implementation of hook_install().
system_themes_form in modules/system/system.admin.inc
Menu callback; displays a listing of all themes.
system_theme_settings in modules/system/system.admin.inc
Form builder; display theme configuration for entire site and individual themes.

... See full list

File

modules/system/system.module, line 807
Configuration system that lets administrators modify the workings of the site.

Code

function system_theme_data() {
  $write_database = TRUE;

  // If lock not acquired, return $files data without writing to database.
  if (!lock_acquire('system_theme_data')) {
    $write_database = FALSE;

    // Wait for the parallel thread to be done so we are more likely
    // to get updated and consistent data.
    lock_wait('system_theme_data');
  }

  // Scan the installation theme .info files and their engines.
  $themes = _system_theme_data();
  foreach ($themes as $key => $theme) {
    if (!isset($theme->owner)) {
      $themes[$key]->owner = '';
    }
  }

  // Extract current files from database.
  system_get_files_database($themes, 'theme');

  // If lock not acquired, return $themes data without writing to database.
  if ($write_database) {
    $filenames = array();
    foreach ($themes as $theme) {

      // Record the filename of each theme that was found.
      $filenames[] = $theme->filename;

      // Existing themes will always have $theme->status set, since it's a
      // property that is only stored in the database.
      if (isset($theme->status)) {
        db_query("UPDATE {system} SET owner = '%s', info = '%s', filename = '%s' WHERE name = '%s' AND type = '%s'", $theme->owner, serialize($theme->info), $theme->filename, $theme->name, 'theme');
      }
      else {
        $theme->status = $theme->name == variable_get('theme_default', 'garland');
        db_query("INSERT INTO {system} (name, owner, info, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', '%s', '%s', %d, %d, %d)", $theme->name, $theme->owner, serialize($theme->info), 'theme', $theme->filename, $theme->status, 0, 0);
      }
    }

    // Delete from the system table any themes missing from the file system.
    if ($filenames) {
      db_query("DELETE FROM {system} WHERE type = 'theme' AND filename NOT IN (" . db_placeholders($filenames, 'varchar') . ")", $filenames);
    }
    lock_release('system_theme_data');
  }
  return $themes;
}