You are here

function panels_common_edit_context_form in Panels 5.2

Same name and namespace in other branches
  1. 6.2 includes/common-context.inc \panels_common_edit_context_form()

Form (for ajax use) to add a context

File

includes/common.inc, line 1061
Functions used by more than one panels client module.

Code

function panels_common_edit_context_form($object, $context, $position, $contexts) {
  $ctext = $object->contexts[$position];
  $form['position'] = array(
    '#type' => 'hidden',
    '#value' => $position,
  );
  $form['start_form'] = array(
    '#value' => '<div class="modal-form clear-block">',
  );
  $form['description'] = array(
    '#prefix' => '<div class="description">',
    '#suffix' => '</div>',
    '#value' => check_plain($context['description']),
  );

  // Basic context values
  $form['context']['#tree'] = TRUE;
  $form['context']['name'] = array(
    '#type' => 'hidden',
    '#value' => $context['name'],
  );
  $form['context']['id'] = array(
    '#type' => 'value',
    '#value' => $ctext['id'],
  );
  $form['context']['identifier'] = array(
    '#type' => 'textfield',
    '#title' => t('Identifier'),
    '#description' => t('Enter a name to identify this !type on administrative screens.', array(
      '!type' => t('context'),
    )),
    '#default_value' => $ctext['identifier'],
  );
  $form['context']['keyword'] = array(
    '#type' => 'textfield',
    '#title' => t('Keyword'),
    '#description' => t('Enter a keyword to use for substitution in titles.'),
    '#default_value' => $ctext['keyword'],
  );

  // Settings particular to this context
  $context_settings = array();
  if (isset($ctext['context_settings'])) {
    $context_settings = $ctext['context_settings'];
  }
  if (isset($context['settings form']) && function_exists($context['settings form'])) {
    $form['context']['context_settings'] = $context['settings form']($context_settings);
    $form['context']['context_settings']['#tree'] = TRUE;
  }
  $form['context_info'] = array(
    '#type' => 'value',
    '#value' => $context,
  );
  $form['end_form'] = array(
    '#value' => '</div>',
  );
  $form['next'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}