You are here

public function view::init_display in Views (for Drupal 7) 7.3

Same name and namespace in other branches
  1. 6.3 includes/view.inc \view::init_display()
  2. 6.2 includes/view.inc \view::init_display()

Set the display for this view and initialize the display handler.

7 calls to view::init_display()
view::access in includes/view.inc
Determine if the given user has access to the view.
view::build_title in includes/view.inc
Force the view to build a title.
view::choose_display in includes/view.inc
Get the first display that is accessible to the user.
view::export in includes/view.inc
Export a view as PHP code.
view::process_locale_strings in includes/view.inc
Process strings for localization, deletion or export to code.

... See full list

File

includes/view.inc, line 481
views_objects Objects that represent a View or part of a view

Class

view
An object to contain all of the data to generate a view.

Code

public function init_display($reset = FALSE) {

  // The default display is always the first one in the list.
  if (isset($this->current_display)) {
    return TRUE;
  }

  // Instantiate all displays.
  foreach (array_keys($this->display) as $id) {

    // Correct for shallow cloning
    // Often we'll have a cloned view so we don't mess up each other's
    // displays, but the clone is pretty shallow and doesn't necessarily
    // clone the displays. We can tell this by looking to see if a handler
    // has already been set; if it has, but $this->current_display is not
    // set, then something is dreadfully wrong.
    if (!empty($this->display[$id]->handler)) {
      $this->display[$id] = clone $this->display[$id];
      unset($this->display[$id]->handler);
    }
    $this->display[$id]->handler = views_get_plugin('display', $this->display[$id]->display_plugin);
    if (!empty($this->display[$id]->handler)) {
      $this->display[$id]->handler->localization_keys = array(
        $id,
      );

      // Initialize the new display handler with data.
      $this->display[$id]->handler
        ->init($this, $this->display[$id]);

      // If this is NOT the default display handler, let it know which is
      // since it may well utilize some data from the default.
      // This assumes that the 'default' handler is always first. It always
      // is. Make sure of it.
      if ($id != 'default') {
        $this->display[$id]->handler->default_display =& $this->display['default']->handler;
      }
    }
  }
  $this->current_display = 'default';
  $this->display_handler =& $this->display['default']->handler;
  return TRUE;
}