You are here

public function views_content_plugin_display_ctools_context::options_form in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 views_content/plugins/views/views_content_plugin_display_ctools_context.inc \views_content_plugin_display_ctools_context::options_form()

Provide the default form for setting options.

Overrides views_plugin_display::options_form

File

views_content/plugins/views/views_content_plugin_display_ctools_context.inc, line 145
Contains the block display plugin.

Class

views_content_plugin_display_ctools_context
The plugin that handles a block.

Code

public function options_form(&$form, &$form_state) {

  // It is very important to call the parent function here:
  parent::options_form($form, $form_state);
  switch ($form_state['section']) {
    case 'row_plugin':

      // This just overwrites the existing row_plugin which is using the wrong options.
      $form['row_plugin']['#options'] = views_fetch_plugin_names('row', 'normal', array(
        $this->view->base_table,
      ));
      break;
    case 'admin_title':
      $form['#title'] .= t('Administrative title');
      $form['admin_title'] = array(
        '#type' => 'textfield',
        '#default_value' => $this
          ->get_option('admin_title'),
        '#description' => t('This is the title that will appear for this view context in the configure context dialog. If left blank, the view name will be used.'),
      );
      break;
    case 'inherit_panels_path':
      $form['#title'] .= t('Inherit path from panel display');
      $form['inherit_panels_path'] = array(
        '#type' => 'select',
        '#options' => array(
          1 => t('Yes'),
          0 => t('No'),
        ),
        '#default_value' => $this
          ->get_option('inherit_panels_path'),
        '#description' => t('If yes, all links generated by Views, such as more links, summary links, and exposed input links will go to the panels display path, not the view, if the display has a path.'),
      );
      break;
    case 'argument_input':
      $form['#title'] .= t('Choose the data source for view arguments');
      $argument_input = $this
        ->get_argument_input();
      ctools_include('context');
      ctools_include('dependent');
      $form['argument_input']['#tree'] = TRUE;
      $converters = ctools_context_get_all_converters();
      ksort($converters);
      foreach ($argument_input as $id => $argument) {
        $form['argument_input'][$id] = array(
          '#tree' => TRUE,
        );
        $safe = str_replace(array(
          '][',
          '_',
          ' ',
          ':',
        ), '-', $id);
        $type_id = 'edit-argument-input-' . $safe;
        $form['argument_input'][$id]['type'] = array(
          '#type' => 'select',
          '#options' => array(
            'none' => t('No argument'),
            'context' => t('From context'),
          ),
          '#id' => $type_id,
          '#title' => t('@arg source', array(
            '@arg' => $argument['name'],
          )),
          '#default_value' => $argument['type'],
        );
        $form['argument_input'][$id]['context'] = array(
          '#type' => 'select',
          '#title' => t('Required context'),
          '#description' => t('If "From context" is selected, which type of context to use.'),
          '#default_value' => $argument['context'],
          '#options' => $converters,
          '#dependency' => array(
            $type_id => array(
              'context',
            ),
          ),
        );
        $form['argument_input'][$id]['context_optional'] = array(
          '#type' => 'checkbox',
          '#title' => t('Context is optional'),
          '#description' => t('This context need not be present for the pane to function. If you plan to use this, ensure that the argument handler can handle empty values gracefully.'),
          '#default_value' => $argument['context_optional'],
          '#dependency' => array(
            $type_id => array(
              'context',
            ),
          ),
        );
      }
      break;
  }
}