You are here

function panels_page_load in Panels 6.2

Same name and namespace in other branches
  1. 5.2 panels_page/panels_page.module \panels_page_load()

Load a panel page.

5 calls to panels_page_load()
panels_page_admin_cache_load in panels_page/panels_page.module
Menu loader for some panels_page admin screens. Loads the panels_page specified by the name arg from the edit cache, or induces a 404 when a bad arg is provided.
panels_page_admin_load in panels_page/panels_page.module
Menu loader for some panels_page admin screens. Loads the panels_page specified by the name arg, induces a 404 when a bad arg is provided.
panels_page_edit_alternate in panels_page/panels_page.admin.inc
_panels_page_check_switchers in panels_page/panels_page.render.inc
_panels_page_master_loader in panels_page/panels_page.module
Determine the render-time behavior of panels_page.

File

panels_page/panels_page.read.inc, line 68
panels_page.write.inc

Code

function panels_page_load($id, $load_display = FALSE) {
  $cache = panels_page_loaded_cache($id);
  if ($cache) {

    // TODO This is deprecated. The fetcher should always be called directly
    if ($load_display && empty($cache->primary)) {
      panels_page_fetch_primary_display($cache);
    }
    return $cache;
  }
  $where = is_numeric($id) ? 'pid = %d' : "name = '%s'";
  $page = db_fetch_object(db_query("SELECT * FROM {panels_page} WHERE {$where}", $id));
  $defaults = panels_page_default_panels();
  if (!$page) {
    if (isset($defaults[$id])) {

      // Default panel pages will always only be identified by name, so no need
      // for the both-ids-point-to-same-object trick.
      $page = $defaults[$id];
      $page->type = t('Default');

      // move the 'display' to the new 'primary' location.
      $page->primary = $page->display;
      unset($page->display);
      panels_page_loaded_cache($id, $page);
      return $page;
    }
    return;
  }
  else {
    $page->type = isset($defaults[$id]) ? t('Overridden') : t('Local');
  }
  $page->access = $page->access ? explode(', ', $page->access) : array();
  $page->arguments = !empty($page->arguments) ? unserialize($page->arguments) : array();
  $page->displays = !empty($page->displays) ? unserialize($page->displays) : array();
  $page->contexts = !empty($page->contexts) ? unserialize($page->contexts) : array();
  $page->relationships = !empty($page->relationships) ? unserialize($page->relationships) : array();
  $page->switcher_options = !empty($page->switcher_options) ? unserialize($page->switcher_options) : array();
  $page->load_flags = (int) $page->load_flags;
  if ($load_display) {
    $page->primary = panels_load_display($page->did);

    // By default, we set the primary display as the current display.
    $page->display =& $page->primary;
  }
  panels_page_loaded_cache($id, $page);
  return $page;
}