function views_plugin_style::options_form

Overrides views_plugin::options_form

7 calls to views_plugin_style::options_form()
views_plugin_style_default::options_form in plugins/views_plugin_style_default.inc
Provide a form to edit options for this plugin.
views_plugin_style_grid::options_form in plugins/views_plugin_style_grid.inc
Render the given style.
views_plugin_style_jump_menu::options_form in plugins/views_plugin_style_jump_menu.inc
Render the given style.
views_plugin_style_list::options_form in plugins/views_plugin_style_list.inc
Render the given style.
views_plugin_style_mapping::options_form in plugins/views_plugin_style_mapping.inc
Provide a form to edit options for this plugin.

... See full list

9 methods override views_plugin_style::options_form()
views_plugin_style_default::options_form in plugins/views_plugin_style_default.inc
Provide a form to edit options for this plugin.
views_plugin_style_grid::options_form in plugins/views_plugin_style_grid.inc
Render the given style.
views_plugin_style_jump_menu::options_form in plugins/views_plugin_style_jump_menu.inc
Render the given style.
views_plugin_style_list::options_form in plugins/views_plugin_style_list.inc
Render the given style.
views_plugin_style_mapping::options_form in plugins/views_plugin_style_mapping.inc
Provide a form to edit options for this plugin.

... See full list

File

plugins/views_plugin_style.inc, line 203

Class

views_plugin_style
Base class to define a style plugin handler.

Code

public function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
    // Only fields-based views can handle grouping. Style plugins can also
    // exclude themselves from being groupable by setting their "use grouping"
    // definition key to FALSE.
    // @todo Document "uses grouping" in docs.php when docs.php is written.
    if ($this->uses_fields() && $this->definition['uses grouping']) {
        $options = array(
            '' => t('- None -'),
        );
        $field_labels = $this->display->handler
            ->get_field_labels(TRUE);
        $options += $field_labels;
        // If there are no fields, we can't group on them.
        if (count($options) > 1) {
            // This is for backward compatibility, when there was just a single
            // select form.
            if (is_string($this->options['grouping'])) {
                $grouping = $this->options['grouping'];
                $this->options['grouping'] = array();
                $this->options['grouping'][0]['field'] = $grouping;
            }
            if (isset($this->options['group_rendered']) && is_string($this->options['group_rendered'])) {
                $this->options['grouping'][0]['rendered'] = $this->options['group_rendered'];
                unset($this->options['group_rendered']);
            }
            $c = count($this->options['grouping']);
            // Add a form for every grouping, plus one.
            for ($i = 0; $i <= $c; $i++) {
                $grouping = !empty($this->options['grouping'][$i]) ? $this->options['grouping'][$i] : array();
                $grouping += array(
                    'field' => '',
                    'rendered' => TRUE,
                    'rendered_strip' => FALSE,
                );
                $form['grouping'][$i]['field'] = array(
                    '#type' => 'select',
                    '#title' => t('Grouping field Nr.@number', array(
                        '@number' => $i + 1,
                    )),
                    '#options' => $options,
                    '#default_value' => $grouping['field'],
                    '#description' => t('You may optionally specify a field by which to group the records. Leave blank to not group.'),
                );
                $form['grouping'][$i]['rendered'] = array(
                    '#type' => 'checkbox',
                    '#title' => t('Use rendered output to group rows'),
                    '#default_value' => $grouping['rendered'],
                    '#description' => t('If enabled the rendered output of the grouping field is used to group the rows.'),
                    '#dependency' => array(
                        'edit-style-options-grouping-' . $i . '-field' => array_keys($field_labels),
                    ),
                );
                $form['grouping'][$i]['rendered_strip'] = array(
                    '#type' => 'checkbox',
                    '#title' => t('Remove tags from rendered output'),
                    '#default_value' => $grouping['rendered_strip'],
                    '#description' => t('Some modules add HTML to the rendered output and prevent the rows from grouping correctly. Stripping the HTML tags should correct this.'),
                    '#dependency' => array(
                        'edit-style-options-grouping-' . $i . '-field' => array_keys($field_labels),
                    ),
                );
            }
        }
    }
    if ($this->uses_row_class()) {
        $form['row_class'] = array(
            '#title' => t('Row class'),
            '#description' => t('The class to provide on each row.'),
            '#type' => 'textfield',
            '#default_value' => $this->options['row_class'],
        );
        if ($this->uses_fields()) {
            $form['row_class']['#description'] .= ' ' . t('You may use field tokens from as per the "Replacement patterns" used in "Rewrite the output of this field" for all fields.');
        }
        $form['default_row_class'] = array(
            '#title' => t('Add views row classes'),
            '#description' => t('Add the default row classes like views-row-1 to the output. You can use this to quickly reduce the amount of markup the view provides by default, at the cost of making it more difficult to apply CSS.'),
            '#type' => 'checkbox',
            '#default_value' => $this->options['default_row_class'],
        );
        $form['row_class_special'] = array(
            '#title' => t('Add striping (odd/even), first/last row classes'),
            '#description' => t('Add css classes to the first and last line, as well as odd/even classes for striping.'),
            '#type' => 'checkbox',
            '#default_value' => $this->options['row_class_special'],
        );
    }
    if (!$this->uses_fields() || !empty($this->options['uses_fields'])) {
        $form['uses_fields'] = array(
            '#type' => 'checkbox',
            '#title' => t('Force using fields'),
            '#description' => t('If neither the row nor the style plugin supports fields, this field allows to enable them, so you can for example use groupby.'),
            '#default_value' => $this->options['uses_fields'],
        );
    }
}