You are here

function views_handler_area_link::options_form in Views link area 6

Same name and namespace in other branches
  1. 7 views_handler_area_link.inc \views_handler_area_link::options_form()

Default options form that provides the label widget that all fields should have.

Overrides views_handler_area::options_form

File

./views_handler_area_link.inc, line 15

Class

views_handler_area_link

Code

function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);
  $form['text'] = array(
    '#type' => 'textfield',
    '#title' => t('Link text'),
    '#default_value' => $this->options['text'],
    '#description' => t('The text of the link'),
  );
  $form['path'] = array(
    '#type' => 'textfield',
    '#title' => t('Link path'),
    '#default_value' => $this->options['path'],
    '#description' => t('The Drupal path or full URL to which to link'),
  );
  $form['query'] = array(
    '#type' => 'textfield',
    '#title' => t('Link querystring'),
    '#default_value' => $this->options['query'],
    '#description' => t('The query parameters that follow the full path'),
  );
  $form['anchor'] = array(
    '#type' => 'textfield',
    '#title' => t('Link anchor'),
    '#default_value' => $this->options['anchor'],
    '#description' => t('The anchor data that follows the full path and query parameters'),
  );
  $form['class'] = array(
    '#type' => 'textfield',
    '#title' => t('Link CSS class'),
    '#default_value' => $this->options['class'],
    '#description' => t('A custom CSS class to add to the link'),
  );
  $count = 0;

  // This lets us prepare the key as we want it printed.
  foreach ($this->view->display_handler
    ->get_handlers('argument') as $arg => $handler) {
    $options[t('Arguments')]['%' . ++$count] = t('@argument title', array(
      '@argument' => $handler
        ->ui_name(),
    ));
    $options[t('Arguments')]['!' . $count] = t('@argument input', array(
      '@argument' => $handler
        ->ui_name(),
    ));
  }
  if (!empty($options)) {
    $output = t('<p>The following substitution patterns are available for this display based on the arguments for this view. Use the pattern shown on the left to display the value indicated on the right.</p>');
    foreach (array_keys($options) as $type) {
      if (!empty($options[$type])) {
        $items = array();
        foreach ($options[$type] as $key => $value) {
          $items[] = $key . ' == ' . $value;
        }
        $output .= theme('item_list', $items, $type);
      }
    }

    // This construct uses 'hidden' and not markup because process doesn't
    // run. It also has an extra div because the dependency wants to hide
    // the parent in situations like this, so we need a second div to
    // make this work.
    $form['help'] = array(
      '#type' => 'hidden',
      '#id' => 'views-tokens-help',
      '#prefix' => '<div><fieldset id="views-tokens-help"><legend>' . t('Replacement patterns') . '</legend>' . $output . '</fieldset></div>',
      '#process' => array(
        'views_process_dependency',
      ),
    );
  }
}