From db47bac35ec035388cfdab0a9fb27e97f8099742 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Mon, 5 Nov 2001 22:59:11 +0000 Subject: - node.module: + Changed node_form() to use good ol' tables instead of div/CSS-tags. + Revised the "revision API": I think we have both an easy and powerful API now that should make everyone happy. + Improved the usability of the rollback functionality a bit. + Removed the "view node" link from the "node overview" page in the admin section and added a "delete node" link instead. + Added a few missing translations; there might be missing more translations though. - book.module: + Made the book module use the "revision API" instead of having it poke and use the innards and underlying details of the revision system. - queue.module: + Made the queue module use the improved revision number. - module.inc: + Applied Moshe's patch: added more arguments to module_invoke() - mail-to-sql.pl: + Added support for more header fields and for folded fields Notes: - no database updates required --- modules/node.module | 65 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 18 deletions(-) (limited to 'modules/node.module') diff --git a/modules/node.module b/modules/node.module index 26d40dc08..2c1b6d3b1 100644 --- a/modules/node.module +++ b/modules/node.module @@ -234,6 +234,18 @@ function node_admin_nodes() { return $output; } +/* +** Return the revision with the specified revision number. +*/ + +function node_revision_load($node, $revision) { + return $node->revisions[$revision]["node"]; +} + +/* +** Create and return a new revision of the given node. +*/ + function node_revision_create($node) { global $user; @@ -252,14 +264,12 @@ function node_revision_create($node) { return $node; } -function node_revision_rollback($nid, $revision) { - global $user; +/* +** Roll-back to the revision with the specified revision number. +*/ - /* - ** Load the original/current node: - */ - - $node = node_load(array("nid" => $nid)); +function node_revision_rollback($node, $revision) { + global $user; /* ** Extract the specified revision: @@ -298,8 +308,11 @@ function node_revision_rollback($nid, $revision) { watchdog("special", "node: rollbacked to revision #$revision of '$node->title'"); } -function node_revision_delete($nid, $revision) { - $node = node_load(array("nid" => $nid)); +/* +** Delete the revision with specified revision number. +*/ + +function node_revision_delete($node, $revision) { unset($node->revisions[$revision]); @@ -308,8 +321,17 @@ function node_revision_delete($nid, $revision) { watchdog("special", "node: removed revision #$revision of '$node->title'"); } -function node_revision_previous($node) { - return end(array_keys($node->revisions)); +/* +** Return a list of all the existing revision numbers. +*/ + +function node_revision_list($node) { + if (is_array($node->revisions)) { + return array_keys($node->revisions); + } + else { + return array(); + } } function node_admin() { @@ -344,10 +366,12 @@ function node_admin() { print node_admin_edit($id); break; case "rollback revision": - print node_revision_rollback($id, $revision); + print node_revision_rollback(node_load(array("nid" => $id)), $revision); + print node_admin_edit($id); break; case "delete revision": - print node_revision_delete($id, $revision); + print node_revision_delete(node_load(array("nid" => $id)), $revision); + print node_admin_edit($id); break; case t("Preview"): print node_preview($edit); @@ -492,7 +516,6 @@ function node_form($edit) { $form .= $function(&$edit, &$help, &$error); } - $output .= "
"; /* ** Add the help text: @@ -502,6 +525,10 @@ function node_form($edit) { $output .= "

$help

"; } + $output .= ""; + $output .= " "; + $output .= " "; + $output .= " "; + $output .= "
"; + /* ** Add the default fields: */ @@ -554,14 +581,13 @@ function node_form($edit) { $output .= form_submit(t("Delete")); } - $output .= ""; - /* ** Add the admin specific parts: */ if (user_access("administer nodes")) { - $output .= "
"; + $output .= "
"; + $output .= form_textfield(t("Authored by"), "name", $edit->name, 20, 25, $error["name"]); $output .= form_textfield(t("Authored on"), "date", $edit->date, 20, 25, $error["date"]); $output .= "
"; @@ -569,9 +595,12 @@ function node_form($edit) { $output .= form_select(t("Allow users comments"), "comment", $edit->comment, array("Disabled", "Enabled")); $output .= form_select(t("Promote to front page"), "promote", $edit->promote, array("Disabled", "Enabled")); $output .= form_select(t("Create new revision"), "revision", $edit->revision, array("Disabled", "Enabled")); - $output .= ""; } + $output .= "
"; + return form($output); } -- cgit v1.2.3