You are here

function themekey_features_load_rule_childs in ThemeKey 7

Same name and namespace in other branches
  1. 6.4 themekey_features.module \themekey_features_load_rule_childs()
  2. 6.3 themekey_features.module \themekey_features_load_rule_childs()
  3. 7.3 themekey_features.module \themekey_features_load_rule_childs()
  4. 7.2 themekey_features.module \themekey_features_load_rule_childs()

Loads current ThemeKey Rule Chain as array.

Parameters

$parent: internal use in recursion

Return value

serialized ThemeKey Rule Chain as array

2 calls to themekey_features_load_rule_childs()
themekey_features_rule_chain_features_export_options in ./themekey_features.module
Implements hook_features_export_options().
themekey_features_rule_chain_features_export_render in ./themekey_features.module
Implements hook_features_export_render().

File

./themekey_features.module, line 114

Code

function themekey_features_load_rule_childs($parent = 0) {
  module_load_include('inc', 'themekey', 'themekey_base');
  module_load_include('inc', 'themekey', 'themekey_build');
  $rules = array();
  if ($result = db_select('themekey_properties', 'tp')
    ->fields('tp', array(
    'id',
  ))
    ->condition('parent', $parent)
    ->orderBy('weight', 'ASC')
    ->execute()) {
    foreach ($result as $record) {

      // we have to load the rule again using themekey_rule_get() which applies some transformations
      $rule = themekey_rule_get($record->id);
      if ('drupal:path' != $rule->property) {
        themekey_complete_path($rule);
      }
      unset($rule->id);
      unset($rule->parent);
      unset($rule->weight);
      $rules[] = array(
        'rule' => $rule,
        'string' => themekey_format_rule_as_string($record->id),
        'childs' => themekey_features_load_rule_childs($record->id),
      );
    }
  }
  return $rules;
}