You are here

function panels_renderer_standard::prepare_panes in Panels 6.3

Same name and namespace in other branches
  1. 7.3 plugins/display_renderers/panels_renderer_standard.class.php \panels_renderer_standard::prepare_panes()

Prepare the list of panes to be rendered, accounting for visibility/access settings and rendering order.

This method represents the standard approach for determining the list of panes to be rendered that is compatible with all parts of the Panels architecture. It first applies visibility & access checks, then sorts panes into their proper rendering order, and returns the result as an array.

Inheriting classes should override this method if that renderer needs to regularly make additions to the set of panes that will be rendered.

Parameters

array $panes: An associative array of pane data (stdClass objects), keyed on pane id.

Return value

array An associative array of panes to be rendered, keyed on pane id and sorted into proper rendering order.

1 call to panels_renderer_standard::prepare_panes()
panels_renderer_standard::prepare in plugins/display_renderers/panels_renderer_standard.class.php
Prepare the attached display for rendering.

File

plugins/display_renderers/panels_renderer_standard.class.php, line 218

Class

panels_renderer_standard
The standard render pipeline for a Panels display object.

Code

function prepare_panes($panes) {
  ctools_include('content');

  // Use local variables as writing to them is very slightly faster
  $first = $normal = $last = array();

  // Prepare the list of panes to be rendered
  foreach ($panes as $pid => $pane) {
    if (empty($this->admin)) {

      // TODO remove in 7.x and ensure the upgrade path weeds out any stragglers; it's been long enough
      $pane->shown = !empty($pane->shown);

      // guarantee this field exists.
      // If this pane is not visible to the user, skip out and do the next one
      if (!$pane->shown || !panels_pane_access($pane, $this->display)) {
        continue;
      }
    }
    $content_type = ctools_get_content_type($pane->type);

    // If this pane wants to render last, add it to the $last array. We allow
    // this because some panes need to be rendered after other panes,
    // primarily so they can do things like the leftovers of forms.
    if (!empty($content_type['render last'])) {
      $last[$pid] = $pane;
    }
    else {
      if (!empty($content_type['render first'])) {
        $first[$pid] = $pane;
      }
      else {
        $normal[$pid] = $pane;
      }
    }
  }
  $this->prepared['panes'] = $first + $normal + $last;
  return $this->prepared['panes'];
}