You are here

function themekey_rebuild in ThemeKey 6.4

Same name and namespace in other branches
  1. 6.2 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()
3 calls to themekey_rebuild()
themekey_features_rule_chain_features_rebuild in ./themekey_features.module
Implementation of hook_features_rebuild().
themekey_rule_chain_form in ./themekey_admin.inc
Form builder for the rule chain.
themekey_update_6302 in ./themekey.install
Implements hook_update_N().

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 = 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 wight 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);
}