You are here

function panels_render_panes in Panels 5.2

Same name and namespace in other branches
  1. 6.2 includes/display-render.inc \panels_render_panes()

Render all the panes in a display into a $content array to be used by the display theme function.

1 call to panels_render_panes()
panels_render_layout in ./panels.module
Given a full layout structure and a content array, render a panel display.

File

./panels.module, line 1002
panels.module Core API for Panels. Provides display editing and rendering capabilities.

Code

function panels_render_panes($display) {

  // Safety check.
  if (empty($display->content)) {
    return array();
  }

  // First, render all the panes into little boxes. We do this here because
  // some panes request to be rendered after other panes (primarily so they
  // can do the leftovers of forms).
  $panes = array();
  $later = array();
  foreach ($display->content as $pid => $pane) {
    $pane->shown = isset($pane->shown) ? $pane->shown : TRUE;

    // TODO Really ought to design a method for creating a quick-access set of content_type (and other plugin) data to help optimize render performance
    // If the user can't see this pane, do not render it.
    if (!$pane->shown || !panels_pane_access($pane, $display)) {
      continue;
    }

    // If this pane wants to render last, add it to the $later array.
    $content_type = panels_get_content_type($pane->type);
    if (!empty($content_type['render last'])) {
      $later[$pid] = $pane;
      continue;
    }
    $panes[$pid] = panels_render_pane_content($display, $pane);
  }
  foreach ($later as $pid => $pane) {
    $panes[$pid] = panels_render_pane_content($display, $pane);
  }

  // Loop through all panels, put all panes that belong to the current panel
  // in an array, then render the panel. Primarily this ensures that the
  // panes are in the proper order.
  $content = array();
  foreach ($display->panels as $panel_name => $pids) {
    $panel = array();
    foreach ($pids as $pid) {
      if (!empty($panes[$pid])) {
        $panel[$pid] = $panes[$pid];
      }
    }
    $content[$panel_name] = panels_render_panel($display, $panel_name, $panel);
  }
  return $content;
}