Commit d852a999 authored by Dries's avatar Dries

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.
parent 5ecedf72
This diff is collapsed.
......@@ -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;
......
......@@ -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;
......
......@@ -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 .= "<p><a href=\"$referer\">". t("return") ."</a></p>";
}
}
else {
$output = message_access();
......
......@@ -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 .= "<p><a href=\"$referer\">". t("return") ."</a></p>";
}
}
else {
$output = message_access();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment