function themekey_abstract_rule_set in ThemeKey 7.3
4 calls to themekey_abstract_rule_set()
- themekey_abstract_update_static_rule in ./themekey_build.inc
- themekey_css_rule_set in themekey_css/themekey_css_build.inc
- Stores ThemeKey rules in database.
It creates a new dataset or updates an existing one.
- themekey_redirect_rule_set in themekey_redirect/themekey_redirect_build.inc
- Stores ThemeKey rules in database.
It creates a new dataset or updates an existing one.
- themekey_rule_set in ./themekey_build.inc
- Stores ThemeKey rules in database.
It creates a new dataset or updates an existing one.
File
- ./themekey_build.inc, line 349
- 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_abstract_rule_set($table, &$item, $module = 'themekey') {
if ('drupal:path' == $item['property']) {
list($item['value'], $item['wildcards']) = themekey_prepare_custom_path($item['value']);
}
else {
$item['wildcards'] = array();
}
if (empty($item['module'])) {
$item['module'] = trim($module);
}
$txn = db_transaction();
if (empty($item['id'])) {
if ($item['enabled']) {
$id = db_select($table, 'tp')
->fields('tp', array(
'id',
))
->condition('property', $item['property'])
->condition('operator', $item['operator'])
->condition('value', $item['value'])
->condition('parent', $item['parent'])
->condition('enabled', 1)
->execute()
->fetchField();
if ($id) {
throw new ThemeKeyRuleConflictException(t('New rule conflicts with an existing rule on the same level.'), $id);
}
}
$result = db_select($table, 'tp');
$result
->addExpression('MAX(weight)', 'weight');
$weight = $result
->execute()
->fetchField();
$item['weight'] = 1 + $weight;
drupal_write_record($table, $item, array());
}
else {
if ($item['enabled']) {
$id = db_select($table, 'tp')
->fields('tp', array(
'id',
))
->condition('property', $item['property'])
->condition('operator', $item['operator'])
->condition('value', $item['value'])
->condition('parent', $item['parent'])
->condition('enabled', 1)
->condition('id', $item['id'], '<>')
->execute()
->fetchField();
if ($id) {
throw new ThemeKeyRuleConflictException(t('Updated rule conflicts with an existing rule on the same level.'), $id);
}
}
drupal_write_record($table, $item, 'id');
}
}