function page_manager_page_menu
Delegated implementation of hook_menu().
1 string reference to 'page_manager_page_menu'
- page_manager_page_page_manager_tasks in page_manager/
plugins/ tasks/ page.inc - Specialized implementation of hook_page_manager_task_tasks(). See api-task.html for more information.
File
-
page_manager/
plugins/ tasks/ page.admin.inc, line 15
Code
function page_manager_page_menu(&$items, $task) {
// Set up access permissions.
$access_callback = isset($task['admin access callback']) ? $task['admin access callback'] : 'user_access';
$access_arguments = isset($task['admin access arguments']) ? $task['admin access arguments'] : array(
'administer page manager',
);
$base = array(
'access callback' => $access_callback,
'access arguments' => $access_arguments,
'file' => 'plugins/tasks/page.admin.inc',
);
$items['admin/structure/pages/add'] = array(
'title' => 'Add custom page',
'page callback' => 'page_manager_page_add_subtask',
'page arguments' => array(),
'type' => MENU_LOCAL_ACTION,
) + $base;
$items['admin/structure/pages/import'] = array(
'title' => 'Import page',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'page_manager_page_import_subtask',
'page',
),
'type' => MENU_LOCAL_ACTION,
) + $base;
if ($access_callback == 'user_access') {
$items['admin/structure/pages/import']['access callback'] = 'ctools_access_multiperm';
$items['admin/structure/pages/import']['access arguments'][] = 'use ctools import';
}
// AJAX callbacks for argument modal.
$items['admin/structure/pages/argument'] = array(
'page callback' => 'page_manager_page_subtask_argument_ajax',
'type' => MENU_CALLBACK,
) + $base;
// Add menu entries for each subtask.
foreach (page_manager_page_load_all() as $subtask_id => $subtask) {
if (!empty($subtask->disabled)) {
continue;
}
if (!isset($subtask->access['type'])) {
$subtask->access['type'] = 'none';
}
if (!isset($subtask->access['settings'])) {
$subtask->access['settings'] = NULL;
}
$path = array();
$page_arguments = array(
(string) $subtask_id,
);
$access_arguments = array(
$subtask->access,
);
$load_arguments = array(
$subtask_id,
'%index',
'%map',
);
// Replace named placeholders with our own placeholder to load contexts.
$position = 0;
foreach (explode('/', $subtask->path) as $bit) {
// Remove things like double slashes completely.
if (!isset($bit) || $bit === '') {
continue;
}
if ($bit[0] == '%' && $bit != '%') {
$placeholder = '%pm_arg';
// Chop off that %.
$name = substr($bit, 1);
// Check to see if the argument plugin wants to use a different
// placholder. This will allow to_args.
if (!empty($subtask->arguments[$name])) {
ctools_include('context');
if (!empty($subtask->arguments[$name]['name'])) {
$plugin = ctools_get_argument($subtask->arguments[$name]['name']);
if (isset($plugin['path placeholder'])) {
if (function_exists($plugin['path placeholder'])) {
$placeholder = $plugin['path placeholder']($subtask->arguments[$name]);
}
else {
$placeholder = $plugin['path placeholder'];
}
}
}
}
// If an argument, swap it out with our argument loader and make sure
// the argument gets passed through to the page callback.
$path[] = $placeholder;
$page_arguments[] = $position;
$access_arguments[] = $position;
}
elseif ($bit[0] != '!') {
$path[] = $bit;
}
// Increment position. We do it like this to skip empty items that
// could happen from erroneous paths like: this///that.
$position++;
}
$menu_path = implode('/', $path);
$items[$menu_path] = page_manager_page_menu_item($task, $subtask->menu, $access_arguments, $page_arguments, $load_arguments);
// Add a parent menu item if one is configured.
if (isset($subtask->menu['type']) && $subtask->menu['type'] == 'default tab') {
array_pop($path);
$parent_path = implode('/', $path);
$items[$parent_path] = page_manager_page_menu_item($task, $subtask->menu['parent'], $access_arguments, $page_arguments, $load_arguments);
}
}
}