function views_handler_argument::default_summary_form

Form for selecting further summary options.

Only used when the default action is set to display one.

File

handlers/views_handler_argument.inc, line 666

Class

views_handler_argument
Base class for arguments.

Code

public function default_summary_form(&$form, &$form_state) {
    $style_plugins = views_fetch_plugin_data('style');
    $summary_plugins = array();
    $format_options = array();
    foreach ($style_plugins as $key => $plugin) {
        if (isset($plugin['type']) && $plugin['type'] == 'summary') {
            $summary_plugins[$key] = $plugin;
            $format_options[$key] = $plugin['title'];
        }
    }
    $form['summary'] = array(
        // Views custom key, moves this element to the appropriate container
        // under the radio button.
'#argument_option' => 'summary',
    );
    $form['summary']['sort_order'] = array(
        '#type' => 'radios',
        '#title' => t('Sort order'),
        '#options' => array(
            'asc' => t('Ascending'),
            'desc' => t('Descending'),
        ),
        '#default_value' => $this->options['summary']['sort_order'],
        '#dependency' => array(
            'radio:options[default_action]' => array(
                'summary',
            ),
        ),
    );
    $form['summary']['number_of_records'] = array(
        '#type' => 'radios',
        '#title' => t('Sort by'),
        '#default_value' => $this->options['summary']['number_of_records'],
        '#options' => array(
            0 => $this->get_sort_name(),
            1 => t('Number of records'),
        ),
        '#dependency' => array(
            'radio:options[default_action]' => array(
                'summary',
            ),
        ),
    );
    $form['summary']['format'] = array(
        '#type' => 'radios',
        '#title' => t('Format'),
        '#options' => $format_options,
        '#default_value' => $this->options['summary']['format'],
        '#dependency' => array(
            'radio:options[default_action]' => array(
                'summary',
            ),
        ),
    );
    foreach ($summary_plugins as $id => $info) {
        if (empty($info['uses options'])) {
            continue;
        }
        $plugin = $this->get_plugin('style', $id);
        if ($plugin) {
            $form['summary']['options'][$id] = array(
                '#prefix' => '<div id="edit-options-summary-options-' . $id . '-wrapper">',
                '#suffix' => '</div>',
                '#id' => 'edit-options-summary-options-' . $id,
                '#type' => 'item',
                // Trick it into checking input to make #process run.
'#input' => TRUE,
                '#dependency' => array(
                    'radio:options[default_action]' => array(
                        'summary',
                    ),
                    'radio:options[summary][format]' => array(
                        $id,
                    ),
                ),
                '#dependency_count' => 2,
            );
            $options[$id] = $info['title'];
            $plugin->options_form($form['summary']['options'][$id], $form_state);
        }
    }
}