From d852a999dea8fc1570930f7d29c677dd2fbb89b6 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 1 Dec 2001 15:20:48 +0000 Subject: Node and book updates: - Fixed a glitch in the book overview in the admin section. - When updating a book page through the admin section, no new revision is created unless explictely specified. - Improved the usability of the node and book pages a little. --- modules/book.module | 56 ++++++++++++++++++++++++++++++++++-------------- modules/book/book.module | 56 ++++++++++++++++++++++++++++++++++-------------- modules/node.module | 12 ++++++++++- modules/node/node.module | 12 ++++++++++- 4 files changed, 102 insertions(+), 34 deletions(-) (limited to 'modules') diff --git a/modules/book.module b/modules/book.module index 99d3f2d24..342a03136 100644 --- a/modules/book.module +++ b/modules/book.module @@ -98,6 +98,7 @@ function book_load($node) { $book = db_fetch_object(db_query("SELECT parent, weight FROM book WHERE nid = '$node->nid'")); if (strstr($REQUEST_URI, "module.php?mod=node&op=edit")) { + /* ** If a user is about to update a book page, we overload some ** fields to reflect the changes. We use the $REQUEST_URI to @@ -113,14 +114,15 @@ function book_load($node) { $book->uid = 0; $book->name = ""; } - } - /* - ** We set the revision field to indicate that we have to create - ** a new revision when updating this book page. - */ + /* + ** We set the revision field to indicate that we have to create + ** a new revision when updating this book page. + */ - $book->revision = 1; + $book->revision = 1; + + } return $book; } @@ -435,21 +437,42 @@ function book_export_html_recursive($parent = "", $depth = 1) { return $output; } -function book_admin_page($nid, $depth = 0) { +function book_admin_view_line($node, $depth = 0) { + + /* + ** Extract the revision number: + */ + + if ($list = node_revision_list($node)) { + $revision = end($list); + } + else { + $revision = 0; + } + + /* + ** Diplay the book page: + */ + + $output .= ""; + $output .= "
nid\">". check_output($node->title) ."
"; + $output .= " $revision"; + $output .= " nid\">". t("edit page") .""; + $output .= " nid\">". t("delete page") .""; + $output .= ""; + + return $output; +} + +function book_admin_view_book($nid, $depth = 1) { $weight = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30); $result = db_query("SELECT n.nid FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.type = 'book' AND b.parent = '$nid' ORDER BY b.weight, n.title"); while ($node = db_fetch_object($result)) { $node = node_load(array("nid" => $node->nid)); - - $output .= ""; - $output .= "
$node->title
"; - $output .= " ". ($rev = end(node_revision_list($node)) ? $rev : 0) .""; - $output .= "
nid\">". t("edit page") .""; - $output .= " nid\">". t("delete page") .""; - $output .= ""; - $output .= book_admin_page($node->nid, $depth + 1); + $output .= book_admin_view_line($node, $depth); + $output .= book_admin_view_book($node->nid, $depth + 1); } return $output; @@ -462,7 +485,8 @@ function book_admin_view($nid, $depth = 0) { $output .= "

". check_output($node->title) ."

"; $output .= ""; $output .= " "; - $output .= book_admin_page($nid); + $output .= book_admin_view_line($node); + $output .= book_admin_view_book($nid); $output .= "
titlerevoperations
"; return $output; diff --git a/modules/book/book.module b/modules/book/book.module index 99d3f2d24..342a03136 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -98,6 +98,7 @@ function book_load($node) { $book = db_fetch_object(db_query("SELECT parent, weight FROM book WHERE nid = '$node->nid'")); if (strstr($REQUEST_URI, "module.php?mod=node&op=edit")) { + /* ** If a user is about to update a book page, we overload some ** fields to reflect the changes. We use the $REQUEST_URI to @@ -113,14 +114,15 @@ function book_load($node) { $book->uid = 0; $book->name = ""; } - } - /* - ** We set the revision field to indicate that we have to create - ** a new revision when updating this book page. - */ + /* + ** We set the revision field to indicate that we have to create + ** a new revision when updating this book page. + */ - $book->revision = 1; + $book->revision = 1; + + } return $book; } @@ -435,21 +437,42 @@ function book_export_html_recursive($parent = "", $depth = 1) { return $output; } -function book_admin_page($nid, $depth = 0) { +function book_admin_view_line($node, $depth = 0) { + + /* + ** Extract the revision number: + */ + + if ($list = node_revision_list($node)) { + $revision = end($list); + } + else { + $revision = 0; + } + + /* + ** Diplay the book page: + */ + + $output .= ""; + $output .= "
nid\">". check_output($node->title) ."
"; + $output .= " $revision"; + $output .= " nid\">". t("edit page") .""; + $output .= " nid\">". t("delete page") .""; + $output .= ""; + + return $output; +} + +function book_admin_view_book($nid, $depth = 1) { $weight = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30); $result = db_query("SELECT n.nid FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.type = 'book' AND b.parent = '$nid' ORDER BY b.weight, n.title"); while ($node = db_fetch_object($result)) { $node = node_load(array("nid" => $node->nid)); - - $output .= ""; - $output .= "
$node->title
"; - $output .= " ". ($rev = end(node_revision_list($node)) ? $rev : 0) .""; - $output .= "
nid\">". t("edit page") .""; - $output .= " nid\">". t("delete page") .""; - $output .= ""; - $output .= book_admin_page($node->nid, $depth + 1); + $output .= book_admin_view_line($node, $depth); + $output .= book_admin_view_book($node->nid, $depth + 1); } return $output; @@ -462,7 +485,8 @@ function book_admin_view($nid, $depth = 0) { $output .= "

". check_output($node->title) ."

"; $output .= ""; $output .= " "; - $output .= book_admin_page($nid); + $output .= book_admin_view_line($node); + $output .= book_admin_view_book($nid); $output .= "
titlerevoperations
"; return $output; diff --git a/modules/node.module b/modules/node.module index 0b719a3b4..fc0743677 100644 --- a/modules/node.module +++ b/modules/node.module @@ -415,7 +415,6 @@ function node_admin() { break; case t("Submit"): print node_submit($edit); - print node_admin_nodes(); break; case t("Delete"): print node_delete($edit); @@ -543,6 +542,13 @@ function node_validate($node, &$error) { function node_form($edit) { + /* + ** Save the referer. We record where the user came from such that we + ** can redirect him after having completed the node forms. + */ + + referer_save(); + /* ** Validate the node: */ @@ -835,6 +841,10 @@ function node_submit($node) { $output = t("You are not authorized to create this node."); } } + + if ($referer = referer_load()) { + $output .= "

". t("return") ."

"; + } } else { $output = message_access(); diff --git a/modules/node/node.module b/modules/node/node.module index 0b719a3b4..fc0743677 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -415,7 +415,6 @@ function node_admin() { break; case t("Submit"): print node_submit($edit); - print node_admin_nodes(); break; case t("Delete"): print node_delete($edit); @@ -543,6 +542,13 @@ function node_validate($node, &$error) { function node_form($edit) { + /* + ** Save the referer. We record where the user came from such that we + ** can redirect him after having completed the node forms. + */ + + referer_save(); + /* ** Validate the node: */ @@ -835,6 +841,10 @@ function node_submit($node) { $output = t("You are not authorized to create this node."); } } + + if ($referer = referer_load()) { + $output .= "

". t("return") ."

"; + } } else { $output = message_access(); -- cgit v1.2.3