You are here

function views_idle_filter_handler::options_form in Views Idle Filter 7

Provide the basic form which calls through to subforms.

If overridden, it is best to call through to the parent, or to at least make sure all of the functions in this form are called.

Overrides views_handler_filter::options_form

File

./views_idle_filter_handler.inc, line 27
Definition of views_idle_filter_handler.

Class

views_idle_filter_handler
Views Idle Filter handler.

Code

function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);

  // Lock the exposed checkbox.
  $form['expose_button']['checkbox']['checkbox']['#disabled'] = TRUE;
  $form['expose_button']['checkbox']['#attributes']['class'][] = 'element-invisible';
  $form['content'] = array(
    '#type' => 'text_format',
    '#title' => t('Additional description'),
    '#default_value' => $this->options['content'],
    '#rows' => 2,
    '#format' => isset($this->options['format']) ? $this->options['format'] : filter_default_format(),
    '#wysiwyg' => FALSE,
  );
  $form['tokenize'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use replacement tokens in additional description'),
    '#default_value' => $this->options['tokenize'],
  );
  $options = array();
  $count = 0;

  // Get a list of the available arguments for token replacement.
  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(),
    ));
  }
  $options[t('Arguments')]['!' . $count] = t('@argument input', array(
    '@argument' => 'ww',
  ));
  $options[t('Global tokens')][t('global tokens')] = t('any global Drupal tokens such as [site:name]');
  $output = '<p>' . t('The following tokens are available. If you would like to have the characters \'[\' and \']\' please use the html entity codes \'%5B\' or  \'%5D\' or they will get replaced with empty space.' . '</p>');
  foreach (array_keys($options) as $type) {
    if (!empty($options[$type])) {
      $items = array();
      foreach ($options[$type] as $key => $value) {
        $items[] = $key . ' == ' . check_plain($value);
      }
      $output .= theme('item_list', array(
        'items' => $items,
        'title' => $type,
        'type' => 'ul',
      ));
    }
  }
  $form['token_help'] = array(
    '#type' => 'fieldset',
    '#title' => t('Replacement patterns'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#value' => $output,
    '#id' => 'edit-options-token-help',
    '#dependency' => array(
      'edit-options-tokenize' => array(
        1,
      ),
    ),
    '#prefix' => '<div>',
    '#suffix' => '</div>',
  );
}