You are here

function themekey_rebuild in ThemeKey 6.2

Same name and namespace in other branches
  1. 6.4 themekey_build.inc \themekey_rebuild()
  2. 6.3 themekey_build.inc \themekey_rebuild()
  3. 7.3 themekey_build.inc \themekey_rebuild()
  4. 7 themekey_build.inc \themekey_rebuild()
  5. 7.2 themekey_build.inc \themekey_rebuild()

Rebuilds all ThemeKey related drupal variables by calling ThemeKey's hooks:

  • hook_themekey_properties()
  • hook_themekey_paths()
1 call to themekey_rebuild()
themekey_settings_form in ./themekey_admin.inc
Form builder for the ThemeKey settings form.

File

./themekey_build.inc, line 63
The functions in this file are the back end of ThemeKey which should be used only if you configure something but not when ThemeKey switches themes.

Code

function themekey_rebuild() {

  // includes all modules in the themekey/modules subfolder (internal modules)
  themekey_scan_modules();

  // Get property definitions (from internal and other modules)
  $properties = module_invoke_all('themekey_properties');

  // Attributes
  $attributes = isset($properties['attributes']) ? $properties['attributes'] : array();
  ksort($attributes);
  variable_set('themekey_attributes', $attributes);
  $property_names = array();
  foreach ($attributes as $property_name => $attribute) {
    if (empty($attribute['static'])) {
      $property_names[$property_name] = $property_name;
    }
  }
  variable_set('themekey_properties', $property_names);

  // Property maps
  $maps = isset($properties['maps']) ? $properties['maps'] : array();
  variable_set('themekey_maps', $maps);

  // Find all previous registered paths
  $obsolete_paths = array();
  $result = db_query('SELECT id, path FROM {themekey_paths}');
  while ($item = db_fetch_array($result)) {
    $obsolete_paths[$item['id']] = $item['path'];
  }

  // Get (and register) paths from themekey modules
  $paths = module_invoke_all('themekey_paths');
  foreach ($paths as $item) {
    themekey_path_set($item);
    if (isset($item['id'])) {
      unset($obsolete_paths[$item['id']]);
    }
  }

  // Unregister obsolete paths
  foreach (array_keys($obsolete_paths) as $id) {
    themekey_path_del($id);
  }
}