You are here

function page_manager_node_edit in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 page_manager/plugins/tasks/node_edit.inc \page_manager_node_edit()

Entry point for our overridden node edit.

This function asks its assigned handlers who, if anyone, would like to run with it. If no one does, it passes through to Drupal core's node edit, which is node_page_edit().

1 call to page_manager_node_edit()
page_manager_node_add in page_manager/plugins/tasks/node_edit.inc
Callback to handle the process of adding a node.
1 string reference to 'page_manager_node_edit'
page_manager_node_edit_menu_alter in page_manager/plugins/tasks/node_edit.inc
Callback defined by page_manager_node_edit_page_manager_tasks().

File

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

Code

function page_manager_node_edit($node) {

  // Load my task plugin.
  $task = page_manager_get_task('node_edit');

  // Load the node into a context.
  ctools_include('context');
  ctools_include('context-task-handler');
  $contexts = ctools_context_handler_get_task_contexts($task, '', array(
    $node,
  ));

  // Set the default title for the node add/edit form. If the page has a custom
  // title it'll override this.
  $types = node_type_get_types();
  $context = reset($contexts);
  if (empty($context->data->nid)) {
    drupal_set_title(t('Create @name', array(
      '@name' => $types[$context->data->type]->name,
    )), PASS_THROUGH);
  }
  else {
    drupal_set_title(t('<em>Edit @type</em> @title', array(
      '@type' => $types[$context->node_type]->name,
      '@title' => $context->data->title,
    )), PASS_THROUGH);
  }
  $arg = array(
    isset($node->nid) ? $node->nid : $node->type,
  );
  $output = ctools_context_handler_render($task, '', $contexts, $arg);
  if ($output === FALSE) {

    // Fall back!
    // We've already built the form with the context, so we can't build it again, or
    // form_clean_id will mess up our ids. But we don't really need to, either:
    $output = $context->form;
  }
  return $output;
}