node.pages.inc

  1. drupal
    1. 6 modules/node/node.pages.inc
    2. 7 modules/node/node.pages.inc
    3. 8 core/modules/node/node.pages.inc

Page callbacks for adding, editing, deleting, and revisions management for content.

Functions & methods

NameDescription
node_addReturns a node submission form.
node_add_page
node_delete_confirmMenu callback -- ask for confirmation of node deletion
node_delete_confirm_submitExecute node deletion
node_formGenerate the node add/edit form array.
node_form_build_preview
node_form_delete_submitButton submit function: handle the 'Delete' button on the node form.
node_form_submit
node_form_submit_build_nodeUpdates the form state's node entity by processing this submission's values.
node_form_validate
node_page_editMenu callback; presents the node editing form.
node_previewGenerate a node preview.
node_revision_delete_confirm
node_revision_delete_confirm_submit
node_revision_overviewGenerate an overview table of older revisions of a node.
node_revision_revert_confirmAsk for confirmation of the reversion to prevent against CSRF attacks.
node_revision_revert_confirm_submit
theme_node_add_listReturns HTML for a list of available node types for node creation.
theme_node_previewReturns HTML for a node preview for display during node creation and editing.

File

modules/node/node.pages.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Page callbacks for adding, editing, deleting, and revisions management for content.
  5. */
  6. /**
  7. * Menu callback; presents the node editing form.
  8. */
  9. function node_page_edit($node) {
  10. $type_name = node_type_get_name($node);
  11. drupal_set_title(t('<em>Edit @type</em> @title', array('@type' => $type_name, '@title' => $node->title)), PASS_THROUGH);
  12. return drupal_get_form($node->type . '_node_form', $node);
  13. }
  14. function node_add_page() {
  15. $item = menu_get_item();
  16. $content = system_admin_menu_block($item);
  17. // Bypass the node/add listing if only one content type is available.
  18. if (count($content) == 1) {
  19. $item = array_shift($content);
  20. drupal_goto($item['href']);
  21. }
  22. return theme('node_add_list', array('content' => $content));
  23. }
  24. /**
  25. * Returns HTML for a list of available node types for node creation.
  26. *
  27. * @param $variables
  28. * An associative array containing:
  29. * - content: An array of content types.
  30. *
  31. * @ingroup themeable
  32. */
  33. function theme_node_add_list($variables) {
  34. $content = $variables['content'];
  35. $output = '';
  36. if ($content) {
  37. $output = '<dl class="node-type-list">';
  38. foreach ($content as $item) {
  39. $output .= '<dt>' . l($item['title'], $item['href'], $item['localized_options']) . '</dt>';
  40. $output .= '<dd>' . filter_xss_admin($item['description']) . '</dd>';
  41. }
  42. $output .= '</dl>';
  43. }
  44. else {
  45. $output = '<p>' . t('You have not created any content types yet. Go to the <a href="@create-content">content type creation page</a> to add a new content type.', array('@create-content' => url('admin/structure/types/add'))) . '</p>';
  46. }
  47. return $output;
  48. }
  49. /**
  50. * Returns a node submission form.
  51. */
  52. function node_add($type) {
  53. global $user;
  54. $types = node_type_get_types();
  55. $node = (object) array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => $type, 'language' => LANGUAGE_NONE);
  56. drupal_set_title(t('Create @name', array('@name' => $types[$type]->name)), PASS_THROUGH);
  57. $output = drupal_get_form($type . '_node_form', $node);
  58. return $output;
  59. }
  60. function node_form_validate($form, &$form_state) {
  61. // $form_state['node'] contains the actual entity being edited, but we must
  62. // not update it with form values that have not yet been validated, so we
  63. // create a pseudo-entity to use during validation.
  64. $node = (object) $form_state['values'];
  65. node_validate($node, $form, $form_state);
  66. entity_form_field_validate('node', $form, $form_state);
  67. }
  68. /**
  69. * Generate the node add/edit form array.
  70. */
  71. function node_form($form, &$form_state, $node) {
  72. global $user;
  73. // During initial form build, add the node entity to the form state for use
  74. // during form building and processing. During a rebuild, use what is in the
  75. // form state.
  76. if (!isset($form_state['node'])) {
  77. if (!isset($node->title)) {
  78. $node->title = NULL;
  79. }
  80. node_object_prepare($node);
  81. $form_state['node'] = $node;
  82. }
  83. else {
  84. $node = $form_state['node'];
  85. }
  86. // Some special stuff when previewing a node.
  87. if (isset($form_state['node_preview'])) {
  88. $form['#prefix'] = $form_state['node_preview'];
  89. $node->in_preview = TRUE;
  90. }
  91. else {
  92. unset($node->in_preview);
  93. }
  94. // Identify this as a node edit form.
  95. // @todo D8: Remove. Modules can implement hook_form_BASE_FORM_ID_alter() now.
  96. $form['#node_edit_form'] = TRUE;
  97. $form['#attributes']['class'][] = 'node-form';
  98. if (!empty($node->type)) {
  99. $form['#attributes']['class'][] = 'node-' . $node->type . '-form';
  100. }
  101. // Basic node information.
  102. // These elements are just values so they are not even sent to the client.
  103. foreach (array('nid', 'vid', 'uid', 'created', 'type', 'language') as $key) {
  104. $form[$key] = array(
  105. '#type' => 'value',
  106. '#value' => isset($node->$key) ? $node->$key : NULL,
  107. );
  108. }
  109. // Changed must be sent to the client, for later overwrite error checking.
  110. $form['changed'] = array(
  111. '#type' => 'hidden',
  112. '#default_value' => isset($node->changed) ? $node->changed : NULL,
  113. );
  114. // Invoke hook_form() to get the node-specific bits. Can't use node_invoke(),
  115. // because hook_form() needs to be able to receive $form_state by reference.
  116. // @todo hook_form() implementations are unable to add #validate or #submit
  117. // handlers to the form buttons below. Remove hook_form() entirely.
  118. $function = node_type_get_base($node) . '_form';
  119. if (function_exists($function) && ($extra = $function($node, $form_state))) {
  120. $form = array_merge_recursive($form, $extra);
  121. }
  122. // If the node type has a title, and the node type form defined no special
  123. // weight for it, we default to a weight of -5 for consistency.
  124. if (isset($form['title']) && !isset($form['title']['#weight'])) {
  125. $form['title']['#weight'] = -5;
  126. }
  127. // @todo D8: Remove. Modules should access the node using $form_state['node'].
  128. $form['#node'] = $node;
  129. $form['additional_settings'] = array(
  130. '#type' => 'vertical_tabs',
  131. '#weight' => 99,
  132. );
  133. // Add a log field if the "Create new revision" option is checked, or if the
  134. // current user has the ability to check that option.
  135. $form['revision_information'] = array(
  136. '#type' => 'fieldset',
  137. '#title' => t('Revision information'),
  138. '#collapsible' => TRUE,
  139. // Collapsed by default when "Create new revision" is unchecked
  140. '#collapsed' => !$node->revision,
  141. '#group' => 'additional_settings',
  142. '#attributes' => array(
  143. 'class' => array('node-form-revision-information'),
  144. ),
  145. '#attached' => array(
  146. 'js' => array(drupal_get_path('module', 'node') . '/node.js'),
  147. ),
  148. '#weight' => 20,
  149. '#access' => $node->revision || user_access('administer nodes'),
  150. );
  151. $form['revision_information']['revision'] = array(
  152. '#type' => 'checkbox',
  153. '#title' => t('Create new revision'),
  154. '#default_value' => $node->revision,
  155. '#access' => user_access('administer nodes'),
  156. );
  157. // Check the revision log checkbox when the log textarea is filled in.
  158. // This must not happen if "Create new revision" is enabled by default, since
  159. // the state would auto-disable the checkbox otherwise.
  160. if (!$node->revision) {
  161. $form['revision_information']['revision']['#states'] = array(
  162. 'checked' => array(
  163. 'textarea[name="log"]' => array('empty' => FALSE),
  164. ),
  165. );
  166. }
  167. $form['revision_information']['log'] = array(
  168. '#type' => 'textarea',
  169. '#title' => t('Revision log message'),
  170. '#rows' => 4,
  171. '#default_value' => !empty($node->log) ? $node->log : '',
  172. '#description' => t('Provide an explanation of the changes you are making. This will help other authors understand your motivations.'),
  173. );
  174. // Node author information for administrators
  175. $form['author'] = array(
  176. '#type' => 'fieldset',
  177. '#access' => user_access('administer nodes'),
  178. '#title' => t('Authoring information'),
  179. '#collapsible' => TRUE,
  180. '#collapsed' => TRUE,
  181. '#group' => 'additional_settings',
  182. '#attributes' => array(
  183. 'class' => array('node-form-author'),
  184. ),
  185. '#attached' => array(
  186. 'js' => array(
  187. drupal_get_path('module', 'node') . '/node.js',
  188. array(
  189. 'type' => 'setting',
  190. 'data' => array('anonymous' => variable_get('anonymous', t('Anonymous'))),
  191. ),
  192. ),
  193. ),
  194. '#weight' => 90,
  195. );
  196. $form['author']['name'] = array(
  197. '#type' => 'textfield',
  198. '#title' => t('Authored by'),
  199. '#maxlength' => 60,
  200. '#autocomplete_path' => 'user/autocomplete',
  201. '#default_value' => !empty($node->name) ? $node->name : '',
  202. '#weight' => -1,
  203. '#description' => t('Leave blank for %anonymous.', array('%anonymous' => variable_get('anonymous', t('Anonymous')))),
  204. );
  205. $form['author']['date'] = array(
  206. '#type' => 'textfield',
  207. '#title' => t('Authored on'),
  208. '#maxlength' => 25,
  209. '#description' => t('Format: %time. The date format is YYYY-MM-DD and %timezone is the time zone offset from UTC. Leave blank to use the time of form submission.', array('%time' => !empty($node->date) ? date_format(date_create($node->date), 'Y-m-d H:i:s O') : format_date($node->created, 'custom', 'Y-m-d H:i:s O'), '%timezone' => !empty($node->date) ? date_format(date_create($node->date), 'O') : format_date($node->created, 'custom', 'O'))),
  210. '#default_value' => !empty($node->date) ? $node->date : '',
  211. );
  212. // Node options for administrators
  213. $form['options'] = array(
  214. '#type' => 'fieldset',
  215. '#access' => user_access('administer nodes'),
  216. '#title' => t('Publishing options'),
  217. '#collapsible' => TRUE,
  218. '#collapsed' => TRUE,
  219. '#group' => 'additional_settings',
  220. '#attributes' => array(
  221. 'class' => array('node-form-options'),
  222. ),
  223. '#attached' => array(
  224. 'js' => array(drupal_get_path('module', 'node') . '/node.js'),
  225. ),
  226. '#weight' => 95,
  227. );
  228. $form['options']['status'] = array(
  229. '#type' => 'checkbox',
  230. '#title' => t('Published'),
  231. '#default_value' => $node->status,
  232. );
  233. $form['options']['promote'] = array(
  234. '#type' => 'checkbox',
  235. '#title' => t('Promoted to front page'),
  236. '#default_value' => $node->promote,
  237. );
  238. $form['options']['sticky'] = array(
  239. '#type' => 'checkbox',
  240. '#title' => t('Sticky at top of lists'),
  241. '#default_value' => $node->sticky,
  242. );
  243. // Add the buttons.
  244. $form['actions'] = array('#type' => 'actions');
  245. $form['actions']['submit'] = array(
  246. '#type' => 'submit',
  247. '#access' => variable_get('node_preview_' . $node->type, DRUPAL_OPTIONAL) != DRUPAL_REQUIRED || (!form_get_errors() && isset($form_state['node_preview'])),
  248. '#value' => t('Save'),
  249. '#weight' => 5,
  250. '#submit' => array('node_form_submit'),
  251. );
  252. $form['actions']['preview'] = array(
  253. '#access' => variable_get('node_preview_' . $node->type, DRUPAL_OPTIONAL) != DRUPAL_DISABLED,
  254. '#type' => 'submit',
  255. '#value' => t('Preview'),
  256. '#weight' => 10,
  257. '#submit' => array('node_form_build_preview'),
  258. );
  259. if (!empty($node->nid) && node_access('delete', $node)) {
  260. $form['actions']['delete'] = array(
  261. '#type' => 'submit',
  262. '#value' => t('Delete'),
  263. '#weight' => 15,
  264. '#submit' => array('node_form_delete_submit'),
  265. );
  266. }
  267. // This form uses a button-level #submit handler for the form's main submit
  268. // action. node_form_submit() manually invokes all form-level #submit handlers
  269. // of the form. Without explicitly setting #submit, Form API would auto-detect
  270. // node_form_submit() as submit handler, but that is the button-level #submit
  271. // handler for the 'Save' action. To maintain backwards compatibility, a
  272. // #submit handler is auto-suggested for custom node type modules.
  273. $form['#validate'][] = 'node_form_validate';
  274. if (!isset($form['#submit']) && function_exists($node->type . '_node_form_submit')) {
  275. $form['#submit'][] = $node->type . '_node_form_submit';
  276. }
  277. $form += array('#submit' => array());
  278. field_attach_form('node', $node, $form, $form_state, $node->language);
  279. return $form;
  280. }
  281. /**
  282. * Button submit function: handle the 'Delete' button on the node form.
  283. */
  284. function node_form_delete_submit($form, &$form_state) {
  285. $destination = array();
  286. if (isset($_GET['destination'])) {
  287. $destination = drupal_get_destination();
  288. unset($_GET['destination']);
  289. }
  290. $node = $form['#node'];
  291. $form_state['redirect'] = array('node/' . $node->nid . '/delete', array('query' => $destination));
  292. }
  293. function node_form_build_preview($form, &$form_state) {
  294. $node = node_form_submit_build_node($form, $form_state);
  295. $form_state['node_preview'] = node_preview($node);
  296. $form_state['rebuild'] = TRUE;
  297. }
  298. /**
  299. * Generate a node preview.
  300. */
  301. function node_preview($node) {
  302. if (node_access('create', $node) || node_access('update', $node)) {
  303. _field_invoke_multiple('load', 'node', array($node->nid => $node));
  304. // Load the user's name when needed.
  305. if (isset($node->name)) {
  306. // The use of isset() is mandatory in the context of user IDs, because
  307. // user ID 0 denotes the anonymous user.
  308. if ($user = user_load_by_name($node->name)) {
  309. $node->uid = $user->uid;
  310. $node->picture = $user->picture;
  311. }
  312. else {
  313. $node->uid = 0; // anonymous user
  314. }
  315. }
  316. elseif ($node->uid) {
  317. $user = user_load($node->uid);
  318. $node->name = $user->name;
  319. $node->picture = $user->picture;
  320. }
  321. $node->changed = REQUEST_TIME;
  322. $nodes = array($node->nid => $node);
  323. field_attach_prepare_view('node', $nodes, 'full');
  324. // Display a preview of the node.
  325. if (!form_get_errors()) {
  326. $node->in_preview = TRUE;
  327. $output = theme('node_preview', array('node' => $node));
  328. unset($node->in_preview);
  329. }
  330. drupal_set_title(t('Preview'), PASS_THROUGH);
  331. return $output;
  332. }
  333. }
  334. /**
  335. * Returns HTML for a node preview for display during node creation and editing.
  336. *
  337. * @param $variables
  338. * An associative array containing:
  339. * - node: The node object which is being previewed.
  340. *
  341. * @ingroup themeable
  342. */
  343. function theme_node_preview($variables) {
  344. $node = $variables['node'];
  345. $output = '<div class="preview">';
  346. $preview_trimmed_version = FALSE;
  347. $elements = node_view(clone $node, 'teaser');
  348. $trimmed = drupal_render($elements);
  349. $elements = node_view($node, 'full');
  350. $full = drupal_render($elements);
  351. // Do we need to preview trimmed version of post as well as full version?
  352. if ($trimmed != $full) {
  353. drupal_set_message(t('The trimmed version of your post shows what your post looks like when promoted to the main page or when exported for syndication.<span class="no-js"> You can insert the delimiter "&lt;!--break--&gt;" (without the quotes) to fine-tune where your post gets split.</span>'));
  354. $output .= '<h3>' . t('Preview trimmed version') . '</h3>';
  355. $output .= $trimmed;
  356. $output .= '<h3>' . t('Preview full version') . '</h3>';
  357. $output .= $full;
  358. }
  359. else {
  360. $output .= $full;
  361. }
  362. $output .= "</div>\n";
  363. return $output;
  364. }
  365. function node_form_submit($form, &$form_state) {
  366. $node = node_form_submit_build_node($form, $form_state);
  367. $insert = empty($node->nid);
  368. node_save($node);
  369. $node_link = l(t('view'), 'node/' . $node->nid);
  370. $watchdog_args = array('@type' => $node->type, '%title' => $node->title);
  371. $t_args = array('@type' => node_type_get_name($node), '%title' => $node->title);
  372. if ($insert) {
  373. watchdog('content', '@type: added %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
  374. drupal_set_message(t('@type %title has been created.', $t_args));
  375. }
  376. else {
  377. watchdog('content', '@type: updated %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
  378. drupal_set_message(t('@type %title has been updated.', $t_args));
  379. }
  380. if ($node->nid) {
  381. $form_state['values']['nid'] = $node->nid;
  382. $form_state['nid'] = $node->nid;
  383. $form_state['redirect'] = 'node/' . $node->nid;
  384. }
  385. else {
  386. // In the unlikely case something went wrong on save, the node will be
  387. // rebuilt and node form redisplayed the same way as in preview.
  388. drupal_set_message(t('The post could not be saved.'), 'error');
  389. $form_state['rebuild'] = TRUE;
  390. }
  391. // Clear the page and block caches.
  392. cache_clear_all();
  393. }
  394. /**
  395. * Updates the form state's node entity by processing this submission's values.
  396. *
  397. * This is the default builder function for the node form. It is called
  398. * during the "Save" and "Preview" submit handlers to retrieve the entity to
  399. * save or preview. This function can also be called by a "Next" button of a
  400. * wizard to update the form state's entity with the current step's values
  401. * before proceeding to the next step.
  402. *
  403. * @see node_form()
  404. */
  405. function node_form_submit_build_node($form, &$form_state) {
  406. // @todo Legacy support for modules that extend the node form with form-level
  407. // submit handlers that adjust $form_state['values'] prior to those values
  408. // being used to update the entity. Module authors are encouraged to instead
  409. // adjust the node directly within a hook_node_submit() implementation. For
  410. // Drupal 8, evaluate whether the pattern of triggering form-level submit
  411. // handlers during button-level submit processing is worth supporting
  412. // properly, and if so, add a Form API function for doing so.
  413. unset($form_state['submit_handlers']);
  414. form_execute_handlers('submit', $form, $form_state);
  415. $node = $form_state['node'];
  416. entity_form_submit_build_entity('node', $node, $form, $form_state);
  417. node_submit($node);
  418. foreach (module_implements('node_submit') as $module) {
  419. $function = $module . '_node_submit';
  420. $function($node, $form, $form_state);
  421. }
  422. return $node;
  423. }
  424. /**
  425. * Menu callback -- ask for confirmation of node deletion
  426. */
  427. function node_delete_confirm($form, &$form_state, $node) {
  428. $form['#node'] = $node;
  429. // Always provide entity id in the same form key as in the entity edit form.
  430. $form['nid'] = array('#type' => 'value', '#value' => $node->nid);
  431. return confirm_form($form,
  432. t('Are you sure you want to delete %title?', array('%title' => $node->title)),
  433. 'node/' . $node->nid,
  434. t('This action cannot be undone.'),
  435. t('Delete'),
  436. t('Cancel')
  437. );
  438. }
  439. /**
  440. * Execute node deletion
  441. */
  442. function node_delete_confirm_submit($form, &$form_state) {
  443. if ($form_state['values']['confirm']) {
  444. $node = node_load($form_state['values']['nid']);
  445. node_delete($form_state['values']['nid']);
  446. watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->title));
  447. drupal_set_message(t('@type %title has been deleted.', array('@type' => node_type_get_name($node), '%title' => $node->title)));
  448. }
  449. $form_state['redirect'] = '<front>';
  450. }
  451. /**
  452. * Generate an overview table of older revisions of a node.
  453. */
  454. function node_revision_overview($node) {
  455. drupal_set_title(t('Revisions for %title', array('%title' => $node->title)), PASS_THROUGH);
  456. $header = array(t('Revision'), array('data' => t('Operations'), 'colspan' => 2));
  457. $revisions = node_revision_list($node);
  458. $rows = array();
  459. $revert_permission = FALSE;
  460. if ((user_access('revert revisions') || user_access('administer nodes')) && node_access('update', $node)) {
  461. $revert_permission = TRUE;
  462. }
  463. $delete_permission = FALSE;
  464. if ((user_access('delete revisions') || user_access('administer nodes')) && node_access('delete', $node)) {
  465. $delete_permission = TRUE;
  466. }
  467. foreach ($revisions as $revision) {
  468. $row = array();
  469. $operations = array();
  470. if ($revision->current_vid > 0) {
  471. $row[] = array('data' => t('!date by !username', array('!date' => l(format_date($revision->timestamp, 'short'), "node/$node->nid"), '!username' => theme('username', array('account' => $revision))))
  472. . (($revision->log != '') ? '<p class="revision-log">' . filter_xss($revision->log) . '</p>' : ''),
  473. 'class' => array('revision-current'));
  474. $operations[] = array('data' => drupal_placeholder(t('current revision')), 'class' => array('revision-current'), 'colspan' => 2);
  475. }
  476. else {
  477. $row[] = t('!date by !username', array('!date' => l(format_date($revision->timestamp, 'short'), "node/$node->nid/revisions/$revision->vid/view"), '!username' => theme('username', array('account' => $revision))))
  478. . (($revision->log != '') ? '<p class="revision-log">' . filter_xss($revision->log) . '</p>' : '');
  479. if ($revert_permission) {
  480. $operations[] = l(t('revert'), "node/$node->nid/revisions/$revision->vid/revert");
  481. }
  482. if ($delete_permission) {
  483. $operations[] = l(t('delete'), "node/$node->nid/revisions/$revision->vid/delete");
  484. }
  485. }
  486. $rows[] = array_merge($row, $operations);
  487. }
  488. $build['node_revisions_table'] = array(
  489. '#theme' => 'table',
  490. '#rows' => $rows,
  491. '#header' => $header,
  492. );
  493. return $build;
  494. }
  495. /**
  496. * Ask for confirmation of the reversion to prevent against CSRF attacks.
  497. */
  498. function node_revision_revert_confirm($form, $form_state, $node_revision) {
  499. $form['#node_revision'] = $node_revision;
  500. return confirm_form($form, t('Are you sure you want to revert to the revision from %revision-date?', array('%revision-date' => format_date($node_revision->revision_timestamp))), 'node/' . $node_revision->nid . '/revisions', '', t('Revert'), t('Cancel'));
  501. }
  502. function node_revision_revert_confirm_submit($form, &$form_state) {
  503. $node_revision = $form['#node_revision'];
  504. $node_revision->revision = 1;
  505. $node_revision->log = t('Copy of the revision from %date.', array('%date' => format_date($node_revision->revision_timestamp)));
  506. node_save($node_revision);
  507. watchdog('content', '@type: reverted %title revision %revision.', array('@type' => $node_revision->type, '%title' => $node_revision->title, '%revision' => $node_revision->vid));
  508. drupal_set_message(t('@type %title has been reverted back to the revision from %revision-date.', array('@type' => node_type_get_name($node_revision), '%title' => $node_revision->title, '%revision-date' => format_date($node_revision->revision_timestamp))));
  509. $form_state['redirect'] = 'node/' . $node_revision->nid . '/revisions';
  510. }
  511. function node_revision_delete_confirm($form, $form_state, $node_revision) {
  512. $form['#node_revision'] = $node_revision;
  513. return confirm_form($form, t('Are you sure you want to delete the revision from %revision-date?', array('%revision-date' => format_date($node_revision->revision_timestamp))), 'node/' . $node_revision->nid . '/revisions', t('This action cannot be undone.'), t('Delete'), t('Cancel'));
  514. }
  515. function node_revision_delete_confirm_submit($form, &$form_state) {
  516. $node_revision = $form['#node_revision'];
  517. node_revision_delete($node_revision->vid);
  518. watchdog('content', '@type: deleted %title revision %revision.', array('@type' => $node_revision->type, '%title' => $node_revision->title, '%revision' => $node_revision->vid));
  519. drupal_set_message(t('Revision from %revision-date of @type %title has been deleted.', array('%revision-date' => format_date($node_revision->revision_timestamp), '@type' => node_type_get_name($node_revision), '%title' => $node_revision->title)));
  520. $form_state['redirect'] = 'node/' . $node_revision->nid;
  521. if (db_query('SELECT COUNT(vid) FROM {node_revision} WHERE nid = :nid', array(':nid' => $node_revision->nid))->fetchField() > 1) {
  522. $form_state['redirect'] .= '/revisions';
  523. }
  524. }
Login or register to post comments