function context_ui_form

cis7 context_export_ui.class.php context_ui_form(&$form, &$form_state)
cle7 context_export_ui.class.php context_ui_form(&$form, &$form_state)
elmsmedia7 context_export_ui.class.php context_ui_form(&$form, &$form_state)
icor7 context_export_ui.class.php context_ui_form(&$form, &$form_state)
meedjum_blog7 context_export_ui.class.php context_ui_form(&$form, &$form_state)
mooc7 context_export_ui.class.php context_ui_form(&$form, &$form_state)

Generates the omnibus context definition editing form.

Parameters

$form: Form array to populate.

$form_state: Form state array

2 string references to 'context_ui_form'
context.inc in sites/all/modules/ulmus/context/context_ui/export_ui/context.inc
context_ui_theme in sites/all/modules/ulmus/context/context_ui/context_ui.module
Implementation of hook_theme().

File

sites/all/modules/ulmus/context/context_ui/export_ui/context_export_ui.class.php, line 107

Code

function context_ui_form(&$form, &$form_state) {
  $conditions = array_keys(context_conditions());
  sort($conditions);
  $reactions = array_keys(context_reactions());
  sort($reactions);

  $context = $form_state['item'];
  if (!empty($form_state['input'])) {
    $context = _context_ui_rebuild_from_input($context, $form_state['input'], $conditions, $reactions);
  }

  $form['#base'] = 'context_ui_form';
  $form['#theme'] = 'context_ui_form';

  // Core context definition
  $form['info']['#type'] = 'fieldset';
  $form['info']['#tree'] = FALSE;


  $form['info']['name']['#element_validate'] = array('context_ui_edit_name_validate');

  $form['info']['tag'] = array(
    '#title' => t('Tag'),
    '#type' => 'textfield',
    '#required' => FALSE,
    '#maxlength' => 255,
    '#default_value' => isset($context->tag) ? $context->tag : '',
    '#description' => t('Example: <code>theme</code>') . '<br/>' . t('A tag to group this context with others.'),
  );

  $form['info']['description'] = array(
    '#title' => t('Description'),
    '#type' => 'textfield',
    '#required' => FALSE,
    '#maxlength' => 255,
    '#default_value' => isset($context->description) ? $context->description : '',
    '#description' => t('The description of this context definition.'),
  );

  // Condition mode
  $form['condition_mode'] = array(
    '#type' => 'checkbox',
    '#default_value' => isset($context->condition_mode) ? $context->condition_mode : FALSE,
    '#title' => t('Require all conditions'),
    '#description' => t('If checked, all conditions must be met for this context to be active. Otherwise, the first condition that is met will activate this context.'),
  );

  // Condition plugin forms
  $form['conditions'] = array(
    '#theme' => 'context_ui_plugins',
    '#title' => t('Conditions'),
    '#description' => t('Trigger the activation of this context'),
    '#tree' => TRUE,
    'selector' => array(
      '#type' => 'select',
      '#options' => array(0 => '<' . t('Add a condition') . '>'),
      '#default_value' => 0,
    ),
    'state' => array(
      '#attributes' => array('class' => array('context-plugins-state')),
      '#type' => 'hidden',
    ),
    'plugins' => array('#tree' => TRUE),
  );
  foreach ($conditions as $condition) {
    if ($plugin = context_get_plugin('condition', $condition)) {
      $form['conditions']['plugins'][$condition] = array(
        '#tree' => TRUE,
        '#plugin' => $plugin,
        '#context_enabled' => isset($context->conditions[$condition]), // This flag is used at the theme layer.
        'values' => $plugin->condition_form($context),
        'options' => $plugin->options_form($context),
      );
      $form['conditions']['selector']['#options'][$condition] = $plugin->title;
    }
  }

  // Reaction plugin forms
  $form['reactions'] = array(
    '#theme' => 'context_ui_plugins',
    '#title' => t('Reactions'),
    '#description' => t('Actions to take when this context is active'),
    '#tree' => TRUE,
    'selector' => array(
      '#type' => 'select',
      '#options' => array(0 => '<' . t('Add a reaction') . '>'),
      '#default_value' => 0,
    ),
    'state' => array(
      '#attributes' => array('class' => array('context-plugins-state')),
      '#type' => 'hidden',
    ),
    'plugins' => array('#tree' => TRUE),
  );
  foreach ($reactions as $reaction) {
    if ($plugin = context_get_plugin('reaction', $reaction)) {
      $form['reactions']['plugins'][$reaction] = $plugin->options_form($context) + array(
        '#plugin' => $plugin,
        '#context_enabled' => isset($context->reactions[$reaction]), // This flag is used at the theme layer.
      );
      $form['reactions']['selector']['#options'][$reaction] = $plugin->title;
    }
  }
}