You are here

function panels_mini_load in Panels 5.2

Same name and namespace in other branches
  1. 6.3 panels_mini/panels_mini.module \panels_mini_load()
  2. 6.2 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_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.module
Provide a form to confirm deletion of a mini panel.
panels_mini_edit in panels_mini/panels_mini.module
Edit a mini panel.
panels_mini_edit_content in panels_mini/panels_mini.module
Pass through to the panels content editor.

... See full list

File

panels_mini/panels_mini.module, line 1055
panels_mini.module

Code

function panels_mini_load($pid) {
  static $cache = array();
  if (array_key_exists($pid, $cache)) {
    return $cache[$pid];
  }
  if (!is_numeric($pid)) {
    $where = "name = '%s'";
  }
  else {
    $where = 'pid = %d';
  }
  $panel_mini = db_fetch_object(db_query("SELECT m.*, d.hide_title FROM {panels_mini} AS m INNER JOIN {panels_display} AS d ON m.did = d.did 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();

  // $panel_mini->hide_title = ((bool) db_result(db_query('SELECT hide_title FROM {panels_display} WHERE did = %d', $panel_mini->did)));
  $cache[$pid] = panels_mini_sanitize($panel_mini);
  $cache[$pid]->display = panels_load_display($cache[$pid]->did);
  return $cache[$pid];
}