function themekey_match_rule_childs in ThemeKey 6.3
Same name and namespace in other branches
- 6.4 themekey_base.inc \themekey_match_rule_childs()
- 6.2 themekey_base.inc \themekey_match_rule_childs()
- 7.3 themekey_base.inc \themekey_match_rule_childs()
- 7 themekey_base.inc \themekey_match_rule_childs()
- 7.2 themekey_base.inc \themekey_match_rule_childs()
Helper function of
Parameters
$parameters: reference to an array containing all ThemeKey properties and their values
$parent: id of parent rule
Return value
NULL in case of an error string name of the theme if child rule matched FALSE if no child rule matches TRUE if no child properties in the chain
See also
1 call to themekey_match_rule_childs()
- themekey_match_rules in ./
themekey_base.inc - This function steps through the rule chain and returns a theme.
File
- ./
themekey_base.inc, line 241 - The functions in this file are the back end of ThemeKey.
Code
function themekey_match_rule_childs(&$parameters, $parent = 0) {
static $child_lookups = array();
if (isset($child_lookups[$parent])) {
// prevent endless recursion in case of malformated data in database
return $child_lookups[$parent];
}
if ($result = db_query("SELECT * FROM {themekey_properties} WHERE enabled = 1 AND parent = %d AND value <> '' ORDER BY weight", $parent)) {
$num_childs = 0;
while ($item = db_fetch_array($result)) {
$num_childs++;
if (themekey_match_condition($item, $parameters)) {
if ('drupal:path' == $item['property'] && !empty($parameters['internal:temp_wildcards'])) {
$wildcards = unserialize($item['wildcards']);
if (!empty($wildcards)) {
foreach ($wildcards as $index => $wildcard) {
$parameters[$wildcard] = $parameters['internal:temp_wildcards'][$index];
}
}
}
if (variable_get('themekey_debug_trace_rule_switching', FALSE)) {
themekey_set_debug_message('Match: %rule', array(
'%rule' => themekey_format_rule_as_string($item['id']),
));
}
$child_lookups[$parent] = themekey_match_rule_childs($parameters, $item['id']);
if (FALSE === $child_lookups[$parent]) {
continue;
}
elseif (TRUE === $child_lookups[$parent]) {
if (!themekey_check_theme_enabled($item['theme'])) {
if (variable_get('themekey_debug_trace_rule_switching', FALSE)) {
themekey_set_debug_message('Theme disabled: %theme', array(
'%theme' => $item['theme'],
));
}
continue;
}
$child_lookups[$parent] = $item['theme'];
}
// return own theme or theme from child property or NULL in case of a database error
return $child_lookups[$parent];
}
elseif (variable_get('themekey_debug_trace_rule_switching', FALSE)) {
themekey_set_debug_message('No match: %rule', array(
'%rule' => themekey_format_rule_as_string($item['id']),
));
}
}
$child_lookups[$parent] = !$num_childs;
return $child_lookups[$parent];
}
$child_lookups[$parent] = NULL;
return $child_lookups[$parent];
}