You are here

function fusion_apply_rule_add in Fusion Accelerator 7

Same name in this branch
  1. 7 fusion_apply/fusion_apply_ui.rules.inc \fusion_apply_rule_add()
  2. 7 fusion_apply/fusion_apply_rules.inc \fusion_apply_rule_add()
Same name and namespace in other branches
  1. 7.2 fusion_apply/fusion_apply_ui.rules.inc \fusion_apply_rule_add()

Menu callback; displays the edit form for a Fusion Apply rule.

1 string reference to 'fusion_apply_rule_add'
fusion_apply_ui_menu in fusion_apply/fusion_apply_ui.module
Implements hook_menu().

File

fusion_apply/fusion_apply_rules.inc, line 59
Admin page callbacks for Fusion Apply module's rules.

Code

function fusion_apply_rule_add($form, &$form_state) {
  $form = array();
  $form['#tree'] = TRUE;
  $form['rule']['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#default_value' => !empty($form_state['values']['rule']['title']) ? $form_state['values']['rule']['title'] : '',
    '#description' => t('Descriptive title for this rule; used by administrators.'),
    '#required' => TRUE,
  );
  $options = array(
    'page' => t('Page'),
  );
  foreach (list_themes() as $theme_name => $theme) {
    if (empty($theme->status)) {
      continue;
    }

    // Create a list options containing visible regions of this theme.
    $regions = array();
    foreach (system_region_list($theme_name, REGIONS_VISIBLE) as $region_name => $region) {
      $regions['region__' . $region_name] = $region;
    }

    // Group the list of options by theme.
    $key = t('@name Regions', array(
      '@name' => $theme->info['name'],
    ));
    $options[$key] = $regions;
  }
  $form['rule']['rule_type'] = array(
    '#type' => 'select',
    '#title' => t('Type'),
    '#options' => $options,
    '#default_value' => !empty($form_state['values']['rule']['rule_type']) ? $form_state['values']['rule']['rule_type'] : '',
    '#description' => t('Type of element the rule is applied to.'),
    '#required' => TRUE,
  );
  $form['buttons']['save'] = array(
    '#type' => 'submit',
    '#value' => t('Add'),
  );
  return $form;
}