function ctools_context_create_node_edit_form
It's important to remember that $conf is optional here, because contexts are not always created from the UI.
1 string reference to 'ctools_context_create_node_edit_form'
- node_edit_form.inc in plugins/
contexts/ node_edit_form.inc - Plugin to provide a node_edit_form context.
File
-
plugins/
contexts/ node_edit_form.inc, line 32
Code
function ctools_context_create_node_edit_form($empty, $node = NULL, $conf = FALSE) {
static $creating = FALSE;
$context = new ctools_context(array(
'form',
'node_edit',
'node_form',
'node_edit_form',
'node',
'entity:node',
));
$context->plugin = 'node_edit_form';
if ($empty || $creating) {
return $context;
}
$creating = TRUE;
if ($conf) {
// In this case, $node is actually our $conf array.
$nid = is_array($node) && isset($node['nid']) ? $node['nid'] : (is_object($node) ? $node->nid : 0);
if (module_exists('translation')) {
if ($translation = module_invoke('translation', 'node_nid', $nid, $GLOBALS['language']->language)) {
$nid = $translation;
$reload = TRUE;
}
}
if (is_array($node) || !empty($reload)) {
$node = node_load($nid);
}
}
if (!empty($node)) {
$form_id = $node->type . '_node_form';
$form_state = array(
'want form' => TRUE,
'build_info' => array(
'args' => array(
$node,
),
),
);
$file = drupal_get_path('module', 'node') . '/node.pages.inc';
require_once DRUPAL_ROOT . '/' . $file;
// This piece of information can let other modules know that more files
// need to be included if this form is loaded from cache:
$form_state['build_info']['files'] = array(
$file,
);
$form = drupal_build_form($form_id, $form_state);
// Fill in the 'node' portion of the context.
$context->data = $node;
$context->title = isset($node->title) ? $node->title : '';
$context->argument = isset($node->nid) ? $node->nid : $node->type;
$context->form = $form;
$context->form_state =& $form_state;
$context->form_id = $form_id;
$context->form_title = isset($node->title) ? $node->title : '';
$context->node_type = $node->type;
$context->restrictions['type'] = array(
$node->type,
);
$context->restrictions['form'] = array(
'form',
);
$creating = FALSE;
return $context;
}
$creating = FALSE;
}