You are here

class panels_display in Panels 7.3

Same name and namespace in other branches
  1. 8.3 panels.module \panels_display
  2. 5.2 panels.module \panels_display
  3. 6.3 panels.module \panels_display
  4. 6.2 panels.module \panels_display

Forms the basis of a panel display.

Hierarchy

Expanded class hierarchy of panels_display

10 string references to 'panels_display'
panels_export_display in ./panels.module
Exports the provided display into portable code.
panels_load_displays in ./panels.module
Load and fill the requested $display object(s).
panels_mini_uninstall in panels_mini/panels_mini.install
Implementation of hook_uninstall().
panels_new_display in ./panels.module
Creates a new display, setting the ID to our magic new id.
panels_save_display in ./panels.module
Save a display object.

... See full list

File

./panels.module, line 769
Core functionality for the Panels engine.

View source
class panels_display {
  public $args = array();
  public $content = array();
  public $panels = array();
  public $incoming_content = NULL;
  public $css_id = NULL;
  public $context = array();
  public $did = 'new';
  public $renderer = 'standard';

  /**
   * Add a pane.
   */
  public function add_pane(&$pane, $location = NULL) {

    // If no location specified, use what's set in the pane.
    if (empty($location)) {
      $location = $pane->panel;
    }
    else {
      $pane->panel = $location;
    }

    // Generate a permanent uuid for this pane, and use
    // it as a temporary pid.
    $pane->uuid = ctools_uuid_generate();
    $pane->pid = 'new-' . $pane->uuid;

    // Add the pane to the appropriate spots.
    $this->content[$pane->pid] =& $pane;
    $this->panels[$location][] = $pane->pid;
  }

  /**
   * Duplicate a pane.
   */
  public function duplicate_pane($pid, $location = FALSE) {
    $pane = $this
      ->clone_pane($pid);
    $this
      ->add_pane($pane, $location);
  }

  /**
   * Clone a pane.
   */
  public function clone_pane($pid) {
    $pane = clone $this->content[$pid];
    $pane->uuid = ctools_uuid_generate();
    return $pane;
  }

  /**
   * Get the title from a display.
   *
   * The display must have already been rendered, or the setting to set the
   * display's title from a pane's title will not have worked.
   *
   * @return mixed
   *   The title to use. If NULL, this means to let any default title that may
   *   be in use pass through. i.e, do not actually set the title.
   */
  public function get_title() {
    switch ($this->hide_title) {
      case PANELS_TITLE_NONE:
        return '';
      case PANELS_TITLE_PANE:
        return isset($this->stored_pane_title) ? $this->stored_pane_title : '';
      case PANELS_TITLE_FIXED:
      case FALSE:

        // For old exported panels that are not in the database.
        if (!empty($this->title)) {
          return filter_xss_admin(ctools_context_keyword_substitute($this->title, array(), $this->context));
        }
        return NULL;
    }
  }

  /**
   * Render this panels display.
   *
   * After checking to ensure the designated layout plugin is valid, a
   * display renderer object is spawned and runs its rendering logic.
   *
   * @param mixed $renderer
   *    An instantiated display renderer object, or the name of a display
   *    renderer plugin+class to be fetched. Defaults to NULL. When NULL, the
   *    predesignated display renderer will be used.
   *
   * @return mixed
   *    NULL or output of render function.
   */
  public function render($renderer = NULL) {
    $layout = panels_get_layout($this->layout);
    if (!$layout) {
      return NULL;
    }

    // If we were not given a renderer object, load it.
    if (!is_object($renderer)) {

      // If the renderer was not specified, default to $this->renderer
      // which is either standard or was already set for us.
      $renderer = panels_get_renderer_handler(!empty($renderer) ? $renderer : $this->renderer, $this);
      if (!$renderer) {
        return NULL;
      }
    }
    $output = '';

    // Let modules act just prior to render.
    foreach (module_implements('panels_pre_render') as $module) {
      $function = $module . '_panels_pre_render';
      $output .= $function($this, $renderer);
    }
    $output .= $renderer
      ->render();

    // Let modules act just after render.
    foreach (module_implements('panels_post_render') as $module) {
      $function = $module . '_panels_post_render';
      $output .= $function($this, $renderer);
    }
    return $output;
  }

  /**
   * Determine if the given user can perform the requested operation.
   *
   * @param string $op
   *   An operation like: create, read, update, or delete.
   * @param object $account
   *   (optional) The account to check access for.
   *
   * @return bool
   *   TRUE if access is granted; otherwise FALSE.
   */
  public function access($op, $account = NULL) {
    global $user;
    if (!$account) {
      $account = $user;
    }

    // Even administrators need to go through the access system. However, to
    // support legacy plugins, user 1 gets full access no matter what.
    if ($account->uid == 1) {
      return TRUE;
    }
    if (!in_array($op, array(
      'create',
      'read',
      'update',
      'delete',
      'change layout',
    ))) {
      return FALSE;
    }
    if (empty($this->storage_type) || empty($this->storage_id)) {
      return FALSE;
    }
    if ($this->storage_type == 'unknown') {
      return FALSE;
    }
    $storage_plugin = panels_get_panels_storage_plugin($this->storage_type);
    if (!$storage_plugin) {
      return FALSE;
    }
    $access_callback = panels_plugin_get_function('panels_storage', $storage_plugin, 'access callback');
    if (!$access_callback) {
      return FALSE;
    }
    return $access_callback($this->storage_type, $this->storage_id, $op, $account);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
panels_display::$args public property
panels_display::$content public property
panels_display::$context public property
panels_display::$css_id public property
panels_display::$did public property
panels_display::$incoming_content public property
panels_display::$panels public property
panels_display::$renderer public property
panels_display::access public function Determine if the given user can perform the requested operation.
panels_display::add_pane public function Add a pane.
panels_display::clone_pane public function Clone a pane.
panels_display::duplicate_pane public function Duplicate a pane.
panels_display::get_title public function Get the title from a display.
panels_display::render public function Render this panels display.