You are here

function themekey_features_load_rule_childs in ThemeKey 7.3

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 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. The difference compared to themekey_load_rules() is, that database stuff like ids, parent ids and weights are stripped for export.

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 157

Code

function themekey_features_load_rule_childs($module_name = '', $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)
    ->condition('enabled', 1)
    ->orderBy('weight', 'ASC')
    ->execute()) {
    foreach ($result as $record) {

      // we have to load the rule again using themekey_rule_get() which applies some transformations
      // like themekey_complete_path()
      $rule = themekey_rule_get($record->id);
      if (!empty($module_name)) {
        $rule->module = $module_name;
      }

      // remove the database specific stuff for export
      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($module_name, $record->id),
      );
    }
  }
  return $rules;
}