You are here

function _cache_actions_get_panels_handlers in Cache Actions 7.2

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

Get all existing handlers from page manager.

This is the ugliest function in the whole module =)

Return value

array The handlers.

1 call to _cache_actions_get_panels_handlers()
_cache_actions_get_panes in ./cache_actions.rules.inc
Get Panel Panes.

File

./cache_actions.rules.inc, line 146
This file provides the rules integration for this module.

Code

function _cache_actions_get_panels_handlers() {
  $available_handlers = array();

  // First, get all tasks. This corresponds to all types of page manager pages
  // that can be used, for for instance pages, node view, node edit...
  $tasks = page_manager_get_tasks();
  foreach ($tasks as $task) {

    // Subtasks are tasks that are created under the primary tasks, for instance
    // a custom page the user has created.
    $subtasks = page_manager_get_task_subtasks($task);

    // If we have subtasks, then that's what we're after.
    if (count($subtasks)) {
      foreach ($subtasks as $subtask) {

        // Subtasks have handlers. These can for instance correspond to a panel
        // variant.
        $handlers = page_manager_load_task_handlers($task, $subtask['name']);
        foreach ($handlers as $handler) {

          // Handlers have plugins, in this case we need to get the plugin for
          // this handler.
          $plugin = page_manager_get_task_handler($handler->handler);
          $title = page_manager_get_handler_title($plugin, $handler, $task, $subtask['name']);
          $key = 'task:' . $handler->name . ':' . $handler->task;

          // Fetch available panes.
          $handler_panes = _cache_actions_load_panes($handler, $title);
          foreach ($handler_panes as $pane_key => $handler_pane) {
            $available_handlers[$title][$pane_key] = $handler_pane;
          }
        }
      }
    }
    else {

      // Otherwise let's use the task.
      $handlers = page_manager_load_task_handlers($task);
      if (count($handlers)) {
        foreach ($handlers as $handler) {
          $plugin = page_manager_get_task_handler($handler->handler);
          $title = page_manager_get_handler_title($plugin, $handler, $task, $task['name']);

          // If not, then we have an in-code display. Save off the name, so we
          // can get it.
          // Fetch available panes.
          $handler_panes = _cache_actions_load_panes($handler, $title);
          foreach ($handler_panes as $pane_key => $handler_pane) {
            $available_handlers[$handler->task . ': ' . $title][$pane_key] = $handler_pane;
          }
        }
      }
    }
  }

  // Otherwise just return the handlers.
  return $available_handlers;
}