function themekey_rule_chain_form in ThemeKey 6.4
Same name and namespace in other branches
- 6.2 themekey_admin.inc \themekey_rule_chain_form()
- 6.3 themekey_admin.inc \themekey_rule_chain_form()
- 7.3 themekey_admin.inc \themekey_rule_chain_form()
- 7 themekey_admin.inc \themekey_rule_chain_form()
- 7.2 themekey_admin.inc \themekey_rule_chain_form()
Form builder for the rule chain.
The form will not be validated. All changes will be saved immediately. Validation will happen when the form displays the stored configuration. Otherwise all the drag'n'drop stuff will not work.
See also
themekey_rule_chain_form_submit()
themekey_rule_chain_form_set_error()
2 string references to 'themekey_rule_chain_form'
- themekey_form_alter in ./
themekey_admin.inc - Implements hook_form_alter().
- themekey_menu in ./
themekey.module - Implements hook_menu().
File
- ./
themekey_admin.inc, line 31
Code
function themekey_rule_chain_form() {
// scan for new properties provided by other modules
themekey_rebuild();
$properties = variable_get('themekey_properties', array());
if (empty($properties)) {
drupal_goto('admin/settings/themekey/settings');
}
$themes = themekey_theme_options(TRUE, TRUE);
$attributes = variable_get('themekey_attributes', array());
$operators = array(
'=' => '=',
'!' => '!',
'*' => '*',
'!*' => '!*',
'<' => '<',
'<=' => '<=',
'>' => '>',
'>=' => '>=',
'~' => '~',
'!~' => '!~',
);
$form = array(
'#tree' => TRUE,
);
$items = themekey_load_rules();
$parent_options = array_merge(array(
0,
), array_keys($items));
$parent_options = array_combine($parent_options, $parent_options);
foreach ($items as $item) {
$form['old_items'][$item['id']]['depth'] = array(
'#type' => 'value',
'#value' => $item['depth'],
);
$form['old_items'][$item['id']]['id'] = array(
'#type' => 'hidden',
'#value' => $item['id'],
);
$property = $item['property'];
$wildcard = '';
$static = FALSE;
if (!in_array($property, $properties)) {
if (!empty($attributes[$property]['static'])) {
$static = TRUE;
$form['old_items'][$item['id']]['property'] = array(
'#type' => 'hidden',
'#default_value' => $property,
'#value' => $property,
'#prefix' => '<span class="themekey-fadeable">' . $property . '</span>',
);
$form['old_items'][$item['id']]['operator'] = array(
'#type' => 'hidden',
'#default_value' => '=',
'#value' => '=',
);
$form['old_items'][$item['id']]['value'] = array(
'#type' => 'hidden',
'#default_value' => 'static',
'#value' => 'static',
);
$form['old_items'][$item['id']]['theme'] = array(
'#type' => 'select',
'#default_value' => 'default',
'#options' => array(
'default' => t('Triggered'),
),
);
}
else {
$property = 'drupal:path:wildcard';
$wildcard = $item['property'];
}
}
if (!isset($form['old_items'][$item['id']]['property'])) {
$form['old_items'][$item['id']]['property'] = array(
'#type' => 'select',
'#default_value' => $property,
'#options' => $properties,
);
}
$form['old_items'][$item['id']]['wildcard'] = array(
'#type' => 'textfield',
'#default_value' => $wildcard,
'#size' => 10,
'#maxlength' => 255,
);
if (!isset($form['old_items'][$item['id']]['operator'])) {
$form['old_items'][$item['id']]['operator'] = array(
'#type' => 'select',
'#default_value' => $item['operator'],
'#options' => $operators,
);
}
if (!isset($form['old_items'][$item['id']]['value'])) {
$form['old_items'][$item['id']]['value'] = array(
'#type' => 'textfield',
'#default_value' => $item['value'],
'#size' => 20,
'#maxlength' => 255,
);
}
$form['old_items'][$item['id']]['parent'] = array(
'#type' => 'select',
'#default_value' => $item['parent'],
'#options' => $parent_options,
);
if (!isset($form['old_items'][$item['id']]['theme'])) {
$form['old_items'][$item['id']]['theme'] = array(
'#type' => 'select',
'#default_value' => $item['theme'],
'#options' => $themes,
);
}
$form['old_items'][$item['id']]['enabled'] = array(
'#type' => 'checkbox',
'#default_value' => $item['enabled'],
);
$form['old_items'][$item['id']]['weight'] = array(
'#type' => 'weight',
'#delta' => 50,
'#default_value' => $item['weight'],
);
$form['old_items'][$item['id']]['delete'] = array(
'#value' => $static ? '' : l(t('delete'), 'admin/settings/themekey/properties/delete/' . $item['id']),
);
}
$form['new_item']['property'] = array(
'#type' => 'select',
'#default_value' => !empty($_GET['property']) ? check_plain($_GET['property']) : '',
'#options' => $properties,
);
$form['new_item']['wildcard'] = array(
'#type' => 'textfield',
'#default_value' => '',
'#size' => 10,
'#maxlength' => 255,
);
$form['new_item']['operator'] = array(
'#type' => 'select',
'#default_value' => '=',
'#options' => $operators,
);
$form['new_item']['value'] = array(
'#type' => 'textfield',
'#default_value' => !empty($_GET['value']) ? check_plain($_GET['value']) : '',
'#size' => 25,
'#maxlength' => 255,
);
$form['new_item']['theme'] = array(
'#type' => 'select',
'#default_value' => 'default',
'#options' => $themes,
);
$form['new_item']['enabled'] = array(
'#type' => 'checkbox',
'#default_value' => TRUE,
);
$form['buttons']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
);
return $form;
}