function _cache_actions_get_panels_handlers in Cache Actions 6.2
Same name and namespace in other branches
- 7.2 cache_actions.rules.inc \_cache_actions_get_panels_handlers()
- 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 =)
Parameters
bool $panes set this to true if you want the function to return: an array consisting of the panels and the panes.
Return value
the handlers.
2 calls to _cache_actions_get_panels_handlers()
- cache_actions_action_clear_panels_page_cache_form in ./
cache_actions.rules.inc - The form for the clear panel page action
- cache_actions_action_clear_panels_pane_cache_form in ./
cache_actions.rules.inc
File
- ./
cache_actions.rules.inc, line 192 - This file provides the rules integration for this module.
Code
function _cache_actions_get_panels_handlers($panes = FALSE) {
$available_handlers = array();
$available_panes = array();
$js_structure = 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']);
$available_handlers[$subtask['admin title']][$handler->name . ':' . $handler->task . ':' . $handler->subtask] = $title;
// If we want to fetch the panes as well, then go ahead.
if ($panes) {
list($handler_panes, $pane_js) = _cache_actions_load_panes($handler, $title, TRUE);
$available_panes += $handler_panes;
$js_structure += $pane_js;
}
}
}
}
else {
$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, $subtask['name']);
// If not, then we have an in-code display. Save off the name, so we can get it.
$available_handlers[$task['admin title']][$handler->name . ':' . $handler->task] = $title;
if ($panes) {
list($handler_panes, $pane_js) = _cache_actions_load_panes($handler, $title, TRUE);
$available_panes += $handler_panes;
$js_structure += $pane_js;
}
}
}
}
}
// Return an array if we want the panes.
if ($panes) {
return array(
$available_handlers,
$available_panes,
$js_structure,
);
}
// Otherwise just return the handlers.
return $available_handlers;
}