You are here

function panels_mini_load in Panels 6.2

Same name and namespace in other branches
  1. 5.2 panels_mini/panels_mini.module \panels_mini_load()
  2. 6.3 panels_mini/panels_mini.module \panels_mini_load()
  3. 7.3 panels_mini/panels_mini.module \panels_mini_load()

Load a mini panel.

10 calls to panels_mini_load()
panels_mini_admin_load in panels_mini/panels_mini.module
Menu callback to check to see if a mini panel is valid as part of a path, and if it is, return the mini.
panels_mini_block in panels_mini/panels_mini.module
Implementation of hook_block().
panels_mini_content in panels_mini/panels_mini.module
Render a mini panel called from a panels display.
panels_mini_delete_confirm in panels_mini/panels_mini.admin.inc
Provide a form to confirm deletion of a mini panel.
panels_mini_edit in panels_mini/panels_mini.admin.inc
Edit a mini panel.

... See full list

File

panels_mini/panels_mini.module, line 277
panels_mini.module

Code

function panels_mini_load($pid) {
  static $cache = array();
  if (array_key_exists($pid, $cache)) {
    return $cache[$pid];
  }
  $where = is_numeric($pid) ? 'pid = %d' : "name = '%s'";
  $panel_mini = db_fetch_object(db_query("SELECT * FROM {panels_mini} WHERE {$where}", $pid));
  if (!$panel_mini) {
    $defaults = panels_mini_default_panels();
    if (isset($defaults[$pid])) {
      $panel_mini = $defaults[$pid];
      $status = variable_get('panel_mini_defaults', array());

      // Determine if default panel is enabled or disabled.
      if (isset($status[$panel_mini->name])) {
        $panel_mini->disabled = $status[$panel_mini->name];
      }
      $cache[$pid] = $panel_mini;
      return $panel_mini;
    }
    return;
  }
  $panel_mini->contexts = !empty($panel_mini->contexts) ? unserialize($panel_mini->contexts) : array();
  $panel_mini->requiredcontexts = !empty($panel_mini->requiredcontexts) ? unserialize($panel_mini->requiredcontexts) : array();
  $panel_mini->relationships = !empty($panel_mini->relationships) ? unserialize($panel_mini->relationships) : array();
  $cache[$pid] = panels_mini_sanitize($panel_mini);
  $cache[$pid]->display = panels_load_display($cache[$pid]->did);
  return $cache[$pid];
}