You are here

function themekey_load_rules in ThemeKey 6.4

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

Loads all ThemeKey Rules from the database. Therefore, it uses a recursion to build the rule chains.

Parameters

$parent: id of the parent rule. Default is '0'. During the recursion this parameter changes.

$depth: Integer that represents the 'indentation' in current rule chain. Default is '0'. During the recursion, this parameter changes.

Return value

sorted array containing all ThemeKey rules

1 call to themekey_load_rules()
themekey_rule_chain_form in ./themekey_admin.inc
Form builder for the rule chain.

File

./themekey_build.inc, line 281
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_load_rules($parent = 0, $depth = 0) {
  static $properties = array();
  static $parent_lookups = array();
  if (isset($parent_lookups[$parent])) {

    // prevent endless recursion in case of malformatted data in database
    return $properties;
  }
  $query = 'SELECT * FROM {themekey_properties} WHERE parent = %d ORDER BY weight';
  $result = db_query($query, $parent);
  while ($item = db_fetch_array($result)) {
    if ('drupal:path' == $item['property']) {
      themekey_complete_path($item);
    }
    $item['depth'] = $depth;
    $properties[$item['id']] = $item;
    themekey_load_rules($item['id'], $depth + 1);
    $parent_lookups[$item['id']] = TRUE;
  }
  return $properties;
}