Same name and namespace in other branches
- 4.7.x modules/node.module \node_preview()
- 5.x modules/node/node.module \node_preview()
- 6.x modules/node/node.pages.inc \node_preview()
- 7.x modules/node/node.pages.inc \node_preview()
Generate a node preview, including a form for further edits.
1 string reference to 'node_preview'
- node_configure in modules/
node.module - Menu callback; presents general node configuration options.
File
- modules/
node.module, line 1487 - The core that allows content to be submitted to the site.
Code
function node_preview($node) {
// Convert the array to an object:
$node = array2object($node);
if (node_access('create', $node) || node_access('update', $node)) {
// Load the user's name when needed:
if (isset($node->name)) {
// The use of isset() is mandatory in the context of user IDs, because
// user ID 0 denotes the anonymous user.
if ($user = user_load(array(
'name' => $node->name,
))) {
$node->uid = $user->uid;
}
else {
$node->uid = 0;
// anonymous user
}
}
else {
if ($node->uid) {
$user = user_load(array(
'uid' => $node->uid,
));
$node->name = $user->name;
}
}
// Set the created time when needed:
if (empty($node->created)) {
$node->created = time();
}
// Extract a teaser, if it hasn't been set (e.g. by a module-provided
// 'teaser' form item).
if (!isset($node->teaser)) {
$node->teaser = node_teaser($node->body, $node->format);
}
// Display a preview of the node:
// Previewing alters $node so it needs to be cloned.
if (!form_get_errors()) {
$output = theme('node_preview', clone $node);
}
$output .= node_form($node);
$name = node_invoke($node, 'node_name');
drupal_set_breadcrumb(array(
l(t('Home'), NULL),
l(t('create content'), 'node/add'),
l(t('Submit %name', array(
'%name' => $name,
)), 'node/add/' . $node->type),
));
return $output;
}
}