summaryrefslogtreecommitdiff
path: root/modules/book.module
diff options
context:
space:
mode:
Diffstat (limited to 'modules/book.module')
-rw-r--r--modules/book.module56
1 files changed, 40 insertions, 16 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;