/**
  * Test if a pane (or ESI tag) should be rendered. Normal panes are checked
  * for visibility and access-control rules. Panes rendered by ESI are just
  * checked for visibility.
  */
 function pane_should_be_rendered($pane)
 {
     if (!$pane->shown) {
         return FALSE;
     } elseif (!empty($pane->cache) && $pane->cache['method'] == 'esi') {
         // ESI panes are always rendered (access callbacks)
         return TRUE;
     }
     return panels_pane_access($pane, $this->display);
 }
Ejemplo n.º 2
0
 function render_pane_content(&$pane)
 {
     if (!empty($pane->shown) && panels_pane_access($pane, $this->display)) {
         $content = parent::render_pane_content($pane);
     }
     // Ensure that empty panes have some content.
     if (empty($content) || empty($content->content)) {
         if (empty($content)) {
             $content = new stdClass();
         }
         // Get the administrative title.
         $content_type = ctools_get_content_type($pane->type);
         $title = ctools_content_admin_title($content_type, $pane->subtype, $pane->configuration, $this->display->context);
         $content->content = t('Placeholder for empty or inaccessible "@title"', array('@title' => html_entity_decode($title, ENT_QUOTES)));
         // Add these to prevent notices.
         $content->type = 'panels_ipe';
         $content->subtype = 'panels_ipe';
         $pane->IPE_empty = TRUE;
     }
     return $content;
 }
 /**
  * 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.
  *
  * @param array $panes
  *  An associative array of pane data (stdClass objects), keyed on pane id.
  * @return array
  *  An associative array of panes to be rendered, keyed on pane id and sorted
  *  into proper rendering order.
  */
 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'];
 }
 /**
  * Render all panes in the attached display into their panel regions, then
  * render those regions.
  *
  * @return array $content
  *    An array of rendered panel regions, keyed on the region name.
  */
 function render_regions()
 {
     ctools_include('content');
     // 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 = $first = $normal = $last = array();
     foreach ($this->display->content as $pid => $pane) {
         $pane->shown = !empty($pane->shown);
         // guarantee this field exists.
         // If the user can't see this pane, do not render it.
         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;
             }
         }
     }
     foreach ($first + $normal + $last as $pid => $pane) {
         $panes[$pid] = $this->render_pane($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 ($this->display->panels as $panel_name => $pids) {
         $panel_panes = array();
         foreach ($pids as $pid) {
             if (!empty($panes[$pid])) {
                 $panel_panes[$pid] = $panes[$pid];
             }
         }
         $content[$panel_name] = $this->render_region($panel_name, $panel_panes);
     }
     // Prevent notices by making sure that all panels at least have an entry:
     $panels = panels_get_regions($this->plugins['layout'], $this->display);
     foreach ($panels as $id => $panel) {
         if (!isset($content[$id])) {
             $content[$id] = NULL;
         }
     }
     return $content;
 }