You are here

function panels_load_displays in Panels 5.2

Same name and namespace in other branches
  1. 8.3 panels.module \panels_load_displays()
  2. 6.3 panels.module \panels_load_displays()
  3. 6.2 panels.module \panels_load_displays()
  4. 7.3 panels.module \panels_load_displays()

Load and fill the requested $display object(s).

Helper function primarily for for panels_load_display().

Parameters

array $dids: An indexed array of dids to be loaded from the database.

Return value

$displays An array of displays, keyed by their display dids.

3 calls to panels_load_displays()
panels_load_display in ./panels.module
Load a single display.
panels_mini_list_page in panels_mini/panels_mini.module
Provide a list of mini panels, with links to edit or delete them.
panels_page_list_page in panels_page/panels_page.admin.inc
Provide a list of panels, with links to edit or delete them.

File

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

Code

function panels_load_displays($dids) {
  $displays = array();
  if (empty($dids) || !is_array($dids)) {
    return $displays;
  }
  $subs = implode(', ', array_fill(0, count($dids), '%d'));
  $result = db_query("SELECT * FROM {panels_display} WHERE did IN ({$subs})", $dids);
  while ($obj = db_fetch_array($result)) {
    $display = new panels_display();
    foreach ($obj as $key => $value) {
      $display->{$key} = $value;

      // unserialize important bits
      if (in_array($key, array(
        'layout_settings',
        'panel_settings',
        'cache',
      ))) {
        $display->{$key} = empty($display->{$key}) ? array() : unserialize($display->{$key});
      }
    }
    $display->panels = $display->content = array();
    $displays[$display->did] = $display;
  }
  foreach (module_implements('panels_layout_content_alter') as $module) {
    $function = $module . '_panels_layout_content_alter';
    $function($content, $layout, $settings);
  }
  $result = db_query("SELECT * FROM {panels_pane} WHERE did IN ({$subs}) ORDER BY did, panel, position", $dids);
  while ($pane = db_fetch_object($result)) {
    $pane->configuration = unserialize($pane->configuration);
    $pane->cache = empty($pane->cache) ? array() : unserialize($pane->cache);
    $pane->access = $pane->access ? explode(', ', $pane->access) : array();

    // Old panels may not have shown property, so enable by default when loading.
    $pane->shown = isset($pane->shown) ? $pane->shown : TRUE;
    $displays[$pane->did]->panels[$pane->panel][] = $pane->pid;
    $displays[$pane->did]->content[$pane->pid] = $pane;
  }
  return $displays;
}