1.20.x views_plugin_display.inc views_plugin_display::set_override($section, $new_state = NULL)

Flip the override setting for the given section.

Parameters

string $section: Which option should be marked as overridden, for example "filters".

bool $new_state: Select the new state of the option.

  • TRUE: Revert to default.
  • FALSE: Mark it as overridden.

File

modules/views/plugins/views_plugin_display.inc, line 2518
Contains the base display plugin.

Class

views_plugin_display
The default display plugin handler. Display plugins handle options and basic mechanisms for different output methods.

Code

function set_override($section, $new_state = NULL) {
  $options = $this->defaultable_sections($section);
  if (!$options) {
    return;
  }

  if (!isset($new_state)) {
    $new_state = empty($this->options['defaults'][$section]);
  }

  // For each option that is part of this group, fix our settings.
  foreach ($options as $option) {
    if ($new_state) {
      // Revert to defaults.
      unset($this->options[$option]);
      unset($this->display->display_options[$option]);
    }
    else {
      // copy existing values into our display.
      $this->options[$option] = $this->get_option($option);
      $this->display->display_options[$option] = $this->options[$option];
    }
    $this->options['defaults'][$option] = $new_state;
    $this->display->display_options['defaults'][$option] = $new_state;
  }
}