function page_manager_node_edit_menu_alter

Callback defined by page_manager_node_edit_page_manager_tasks().

Alter the node edit input so that node edit comes to us rather than the normal node edit process.

1 string reference to 'page_manager_node_edit_menu_alter'
page_manager_node_edit_page_manager_tasks in page_manager/plugins/tasks/node_edit.inc
Specialized implementation of hook_page_manager_task_tasks(). See api-task.html for more information.

File

page_manager/plugins/tasks/node_edit.inc, line 44

Code

function page_manager_node_edit_menu_alter(&$items, $task) {
    if (variable_get('page_manager_node_edit_disabled', TRUE)) {
        return;
    }
    $callback = $items['node/%node/edit']['page callback'];
    // Override the node edit handler for our purpose.
    if ($callback == 'node_page_edit' || variable_get('page_manager_override_anyway', FALSE)) {
        $items['node/%node/edit']['page callback'] = 'page_manager_node_edit';
        $items['node/%node/edit']['file path'] = $task['path'];
        $items['node/%node/edit']['file'] = $task['file'];
    }
    else {
        variable_set('page_manager_node_edit_disabled', TRUE);
        if (!empty($GLOBALS['page_manager_enabling_node_edit'])) {
            drupal_set_message(t('Page manager module is unable to enable node/%node/edit because some other module already has overridden with %callback.', array(
                '%callback' => $callback,
            )), 'warning');
        }
        return;
    }
    // Also catch node/add handling:
    foreach (node_type_get_types() as $type) {
        $path = 'node/add/' . str_replace('_', '-', $type->type);
        if ($items[$path]['page callback'] != 'node_add') {
            if (!empty($GLOBALS['page_manager_enabling_node_edit'])) {
                drupal_set_message(t('Page manager module is unable to override @path because some other module already has overridden with %callback. Node edit will be enabled but that edit path will not be overridden.', array(
                    '@path' => $path,
                    '%callback' => $items[$path]['page callback'],
                )), 'warning');
            }
            continue;
        }
        $items[$path]['page callback'] = 'page_manager_node_add';
        $items[$path]['file path'] = $task['path'];
        $items[$path]['file'] = $task['file'];
        // Why str_replace things back?
        $items[$path]['page arguments'] = array(
            $type->type,
        );
    }
}