You are here

function themekey_load_rules in ThemeKey 7

Same name and namespace in other branches
  1. 6.4 themekey_build.inc \themekey_load_rules()
  2. 6.2 themekey_build.inc \themekey_load_rules()
  3. 6.3 themekey_build.inc \themekey_load_rules()
  4. 7.3 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 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

2 calls to themekey_load_rules()
ThemekeyMultipleNodePropertiesTestCase::testMultipleProperties in tests/ThemekeyMultipleNodePropertiesTestCase.test
themekey_rule_chain_form in ./themekey_admin.inc
Form builder for the rule chain.

File

./themekey_build.inc, line 286
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 malformated data in database
    return $properties;
  }
  $result = db_select('themekey_properties', 'tp')
    ->fields('tp')
    ->condition('parent', $parent)
    ->orderBy('weight', 'asc')
    ->execute();
  foreach ($result as $item) {
    if ('drupal:path' == $item->property) {
      themekey_complete_path($item);
    }
    $item->depth = $depth;
    $properties[$item->id] = get_object_vars($item);
    themekey_load_rules($item->id, $depth + 1);
    $parent_lookups[$item->id] = TRUE;
  }
  return $properties;
}