You are here

function themekey_rebuild in ThemeKey 7.3

Same name and namespace in other branches
  1. 6.4 themekey_build.inc \themekey_rebuild()
  2. 6.2 themekey_build.inc \themekey_rebuild()
  3. 6.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 the hooks:

6 calls to themekey_rebuild()
themekey_abstract_rule_chain_form in ./themekey_admin.inc
themekey_compat_settings_form_submit in ./themekey_compat_admin.inc
Form submission handler for themekey_compat_settings_form().
themekey_flush_caches in ./themekey.module
Implements hook_flush_caches().
themekey_modules_enabled in ./themekey.module
Implements hook_modules_enabled().
themekey_ui_update_7301 in ./themekey_ui.install
Remove variable themekey_ui_blog_author.

... See full list

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();
  module_load_include('inc', 'themekey', 'themekey_base');

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

  // Attributes
  $attributes = isset($properties['attributes']) ? $properties['attributes'] : array();
  ksort($attributes);
  $property_names = array();
  foreach ($attributes as $property_name => $attribute) {
    if (empty($attribute['static'])) {
      if (preg_match("/^[\\w-]+:[:\\w-]+\$/", $property_name)) {
        $property_names[$property_name] = $property_name;
      }
      else {
        drupal_set_message(t('%property is not a valid ThemeKey property name.', array(
          '%property' => $property_name,
        )), 'error');
      }
    }
    if (!isset($attribute['page cache'])) {
      $attributes[$property_name]['page cache'] = THEMEKEY_PAGECACHE_UNSUPPORTED;
    }
  }
  variable_set('themekey_attributes', $attributes);
  variable_set('themekey_properties', $property_names);

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

  // Get (and register) paths from themekey modules
  $paths = array_merge_recursive(themekey_invoke_modules('themekey_paths'), module_invoke_all('themekey_paths'));

  // assign fit factor and weight to this item
  array_walk($paths, 'themekey_path_set');
  $paths_sort = array();
  foreach ($paths as $item) {
    $paths_sort[$item['fit']][$item['weight']][] = $item;
  }
  ksort($paths_sort, SORT_NUMERIC);
  $paths = array();
  foreach (array_reverse($paths_sort) as $same_fit) {
    ksort($same_fit, SORT_NUMERIC);
    foreach (array_reverse($same_fit) as $same_weight) {
      foreach ($same_weight as $item) {
        $paths[] = $item;
      }
    }
  }
  variable_set('themekey_paths', $paths);
  module_invoke_all('themekey_rebuild');
}