You are here

function _themekey_rebuild in ThemeKey 6

Function _themekey_rebuild().

1 call to _themekey_rebuild()
_themekey_settings_form in ./themekey_admin.inc
Function _themekey_settings_form().

File

./themekey_build.inc, line 25

Code

function _themekey_rebuild() {

  // Create a list of modules in the /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();
  drupal_alter('themekey_attributes', $attributes);
  variable_set('themekey_attributes', $attributes);

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

  // Find all previous registered paths
  $obsolete_paths = array();
  $result = db_query('SELECT id, path FROM {themekey_paths} WHERE custom = 0');
  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');
  drupal_alter('themekey_paths', $paths);
  foreach ($paths as $item) {
    _themekey_path_set($item, FALSE);
    if (isset($item['id'])) {
      unset($obsolete_paths[$item['id']]);
    }
  }

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