You are here

function themekey_get_global_parameters in ThemeKey 6.2

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

Assigns global parameters' values to ThemeKey properties. Therefor it calls hook_themekey_global()

Return value

associative array containing some ThemeKey properties and their values

2 calls to themekey_get_global_parameters()
themekey_debug_properties in ./themekey_debug.module
Iterates over all ThemeKey Properties and prints out their current values.
themekey_match_rules in ./themekey_base.inc
This function steps through the rule chain and returns a theme.

File

./themekey_base.inc, line 168
The functions in this file are the back end of ThemeKey.

Code

function themekey_get_global_parameters() {
  static $global_parameters = NULL;
  if (is_null($global_parameters)) {
    $global_parameters = module_invoke_all('themekey_global');

    // TODO don't store paths in database. maybe use a variable.
    if ($result = db_query('SELECT * FROM {themekey_paths} ORDER BY fit DESC, weight DESC')) {
      $get_q_parts = explode('/', themekey_get_q());
      while ($item = db_fetch_array($result)) {
        $item_parts = explode('/', $item['path']);
        $wildcards = themekey_match_path_parts($get_q_parts, $item_parts);
        if (!empty($wildcards)) {
          $item_wildcards = unserialize($item['wildcards']);
          foreach ($item_wildcards as $index => $item_wildcard) {
            $global_parameters[$item_wildcard] = $wildcards[$index];
          }
          $callbacks = unserialize($item['callbacks']);
          if (count($callbacks)) {
            foreach ($callbacks as $callback) {
              $callback($item, $global_parameters);
            }
          }
        }
      }
    }
  }
  return $global_parameters;
}