View source
<?php
require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'themekey_css') . '/themekey_css_build.inc';
require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'themekey') . '/themekey_admin.inc';
function themekey_css_rule_chain_form($form, &$form_state) {
$css_group_options = array(
'CSS_DEFAULT' => 'default',
'CSS_THEME' => 'theme',
'CSS_SYSTEM' => 'system',
);
$css_weight_options = drupal_map_assoc(range(-50, 50));
return themekey_abstract_rule_chain_form($form, $form_state, array(
'load_rules_callback' => 'themekey_css_load_rules',
'themes' => themekey_css_options(),
'rule_delete_path' => 'admin/config/user-interface/themekey/css/delete/',
'additional_fields' => array(
'css_group' => array(
'#type' => 'select',
'#default_value' => 'CSS_DEFAULT',
'#options' => $css_group_options,
),
'css_weight' => array(
'#type' => 'select',
'#default_value' => 0,
'#options' => $css_weight_options,
),
),
));
}
function themekey_css_rule_chain_form_validate(&$form, $form_state) {
themekey_abstract_rule_chain_form_validate($form, $form_state, array(
'check_enabled_callback' => 'themekey_check_css_exists',
'not_enabled_message' => t('CSS file does not exist.'),
));
}
function themekey_css_rule_chain_form_submit($form, &$form_state) {
themekey_abstract_rule_chain_form_submit($form, $form_state, array(
'rule_set_callback' => 'themekey_css_rule_set',
));
}
function themekey_css_admin_delete_rule_confirm($form, &$form_state, $arg, $themekey_property_id) {
$form['themekey_property_id'] = array(
'#type' => 'value',
'#value' => $themekey_property_id,
);
$title = themekey_css_format_rule_as_string($themekey_property_id);
return confirm_form($form, t('Are you sure you want to delete the ThemeKey rule, %title?', array(
'%title' => $title,
)), 'admin/config/user-interface/themekey/css', t('This action cannot be undone.'), t('Delete'), t('Cancel'));
}
function themekey_css_admin_delete_rule_confirm_submit($form, &$form_state) {
if ($form_state['values']['confirm']) {
themekey_css_rule_del($form_state['values']['themekey_property_id']);
}
$form_state['redirect'] = 'admin/config/user-interface/themekey/css';
}
function theme_themekey_css_rule_chain_form($variables) {
return theme_themekey_abstract_rule_chain_form($variables, array(
'header' => array(
t('Adding CSS Rule Chain'),
t('CSS file'),
t('CSS group'),
t('CSS weight'),
t('Enabled'),
t('Operation'),
t('Parent'),
t('Weight'),
t('Page<br />Cache'),
),
'additional_fields' => array(
'css_group',
'css_weight',
),
));
}