summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2001-12-01 15:20:48 +0000
committerDries Buytaert <dries@buytaert.net>2001-12-01 15:20:48 +0000
commitd852a999dea8fc1570930f7d29c677dd2fbb89b6 (patch)
treed8141554730cd1be58f0d7c6bc30bffc1e46889c /modules
parent5ecedf72cfa346269e5e172c968993825b464945 (diff)
downloadbrdo-d852a999dea8fc1570930f7d29c677dd2fbb89b6.tar.gz
brdo-d852a999dea8fc1570930f7d29c677dd2fbb89b6.tar.bz2
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.
Diffstat (limited to 'modules')
-rw-r--r--modules/book.module56
-rw-r--r--modules/book/book.module56
-rw-r--r--modules/node.module12
-rw-r--r--modules/node/node.module12
4 files changed, 102 insertions, 34 deletions
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 .= "<tr>";
+ $output .= " <td><div style=\"padding-left: ". (25 * $depth) ."px;\"><a href=\"node.php?id=$node->nid\">". check_output($node->title) ."</a></div></td>";
+ $output .= " <td align=\"center\">$revision</td>";
+ $output .= " <td><a href=\"admin.php?mod=node&op=edit&id=$node->nid\">". t("edit page") ."</td>";
+ $output .= " <td><a href=\"admin.php?mod=node&op=delete&id=$node->nid\">". t("delete page") ."</td>";
+ $output .= "</tr>";
+
+ 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 .= "<tr>";
- $output .= " <td><div style=\"padding-left: ". (25 * $depth) ."px;\">$node->title</div></td>";
- $output .= " <td align=\"center\">". ($rev = end(node_revision_list($node)) ? $rev : 0) ."</td>";
- $output .= " <td><a href=\"admin.php?mod=node&op=edit&id=$node->nid\">". t("edit page") ."</td>";
- $output .= " <td><a href=\"admin.php?mod=node&op=delete&id=$node->nid\">". t("delete page") ."</td>";
- $output .= "</tr>";
- $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 .= "<h3>". check_output($node->title) ."</h3>";
$output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">";
$output .= " <tr><th>title</th><th>rev</th><th colspan=\"2\">operations</th></tr>";
- $output .= book_admin_page($nid);
+ $output .= book_admin_view_line($node);
+ $output .= book_admin_view_book($nid);
$output .= "</table>";
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 .= "<tr>";
+ $output .= " <td><div style=\"padding-left: ". (25 * $depth) ."px;\"><a href=\"node.php?id=$node->nid\">". check_output($node->title) ."</a></div></td>";
+ $output .= " <td align=\"center\">$revision</td>";
+ $output .= " <td><a href=\"admin.php?mod=node&op=edit&id=$node->nid\">". t("edit page") ."</td>";
+ $output .= " <td><a href=\"admin.php?mod=node&op=delete&id=$node->nid\">". t("delete page") ."</td>";
+ $output .= "</tr>";
+
+ 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 .= "<tr>";
- $output .= " <td><div style=\"padding-left: ". (25 * $depth) ."px;\">$node->title</div></td>";
- $output .= " <td align=\"center\">". ($rev = end(node_revision_list($node)) ? $rev : 0) ."</td>";
- $output .= " <td><a href=\"admin.php?mod=node&op=edit&id=$node->nid\">". t("edit page") ."</td>";
- $output .= " <td><a href=\"admin.php?mod=node&op=delete&id=$node->nid\">". t("delete page") ."</td>";
- $output .= "</tr>";
- $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 .= "<h3>". check_output($node->title) ."</h3>";
$output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">";
$output .= " <tr><th>title</th><th>rev</th><th colspan=\"2\">operations</th></tr>";
- $output .= book_admin_page($nid);
+ $output .= book_admin_view_line($node);
+ $output .= book_admin_view_book($nid);
$output .= "</table>";
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);
@@ -544,6 +543,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 .= "<p><a href=\"$referer\">". t("return") ."</a></p>";
+ }
}
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);
@@ -544,6 +543,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 .= "<p><a href=\"$referer\">". t("return") ."</a></p>";
+ }
}
else {
$output = message_access();