function themekey_features_save_rule_childs in ThemeKey 7.2
Same name and namespace in other branches
- 6.4 themekey_features.module \themekey_features_save_rule_childs()
- 6.3 themekey_features.module \themekey_features_save_rule_childs()
- 7.3 themekey_features.module \themekey_features_save_rule_childs()
- 7 themekey_features.module \themekey_features_save_rule_childs()
Takes a serialized ThemeKey Rule Chain as created by themekey_features_load_rule_childs() and adds it to the current one in the database with it. Conflicting rules will be stored as well, but disabled.
Parameters
string $module: The name of the feature module whose components should be reverted.
$childs: serialized ThemeKey Rule Chain as array
$parent: internal use in recursion
2 calls to themekey_features_save_rule_childs()
File
- ./
themekey_features.module, line 210
Code
function themekey_features_save_rule_childs($module, $childs, $force = FALSE, $parent = 0, $enabled = 1) {
module_load_include('inc', 'themekey', 'themekey_build');
foreach ($childs as $child) {
$child['rule']['parent'] = $parent;
$id = db_select('themekey_properties', 'tp')
->fields('tp', array(
'id',
))
->condition('property', $child['rule']['property'])
->condition('operator', $child['rule']['operator'])
->condition('value', $child['rule']['value'])
->condition('parent', $child['rule']['parent'])
->condition('module', $module)
->condition('enabled', 0)
->execute()
->fetchField();
if ($id) {
// re-enable a disabled rule
$child['rule']['id'] = $id;
}
try {
themekey_rule_set($child['rule'], $module);
} catch (ThemeKeyRuleConflictException $e) {
// disable a conflicting rule
if ($force) {
themekey_rule_disable($e
->getCode());
}
else {
$child['rule']['enabled'] = 0;
}
themekey_rule_set($child['rule'], $module);
drupal_set_message(t('ThemeKey rule %rule has been disabled because it conflicts with an existing one.', array(
'%rule' => $child['string'],
)), 'warning');
}
themekey_features_save_rule_childs($module, $child['childs'], $force, $child['rule']['id'], $child['rule']['enabled']);
}
}