You are here

function _cache_actions_get_display_from_key in Cache Actions 7.2

Same name and namespace in other branches
  1. 6.2 cache_actions.rules.inc \_cache_actions_get_display_from_key()
  2. 7 cache_actions.rules.inc \_cache_actions_get_display_from_key()

Get a display out of a key specified in the UI.

Parameters

string $key: The key.

Return value

panels_display The related display.

1 call to _cache_actions_get_display_from_key()
cache_actions_update_7201 in ./cache_actions.install
Upgrade all old panels rules to the new format.

File

./cache_actions.install, line 77
Installation tasks for cache actions.

Code

function _cache_actions_get_display_from_key($key) {
  static $displays = array();
  $info = explode(':', $key);
  if (count($info) == 1) {
    return FALSE;
  }
  if ($info[0] == 'task') {
    list(, $handler, $task) = $info;
    $subtask = $task;
  }
  else {
    list(, $handler, $task, $subtask) = $info;
  }
  $key = $task . ':' . $handler . ':' . $subtask;
  if (isset($displays[$key])) {
    return $displays[$key];
  }
  $task = page_manager_get_task($task);
  $handler = page_manager_load_task_handler($task, $subtask, $handler);

  // Save the task handler to be sure we have this handler in the database.
  page_manager_save_task_handler($handler);

  // In-code handlers have the displays attached to them.
  if (isset($handler->conf['display'])) {
    $display = $handler->conf['display'];
  }
  elseif (isset($handler->conf['did'])) {

    // Otherwise we're dealing with a database display.
    $display = panels_load_display($handler->conf['did']);
  }
  $displays[$key] = $display;
  return $display;
}