summaryrefslogtreecommitdiff
path: root/modules/book.module
diff options
context:
space:
mode:
Diffstat (limited to 'modules/book.module')
-rw-r--r--modules/book.module34
1 files changed, 24 insertions, 10 deletions
diff --git a/modules/book.module b/modules/book.module
index 48ce8162b..52260c9cf 100644
--- a/modules/book.module
+++ b/modules/book.module
@@ -61,7 +61,7 @@ function book_view($node, $main = 0) {
$output .= " <TR><TD COLSPAN=\"2\">$location</TD><TD ALIGN=\"right\">". node_control($node) ."</TD></TR>\n";
$output .= " <TR><TD COLSPAN=\"3\"><HR></TD></TR>";
- $output .= " <TR><TD COLSPAN=\"3\"><B><BIG>". check_output($node->title) ."</BIG></B>". ($node->body ? "<BR><SMALL><I>Last updated by ". format_username($node->userid, $node->name) ." on ". format_date($node->timestamp) ."</I></SMALL> " : "") ."</TD></TR>\n";
+ $output .= " <TR><TD COLSPAN=\"3\"><B><BIG>". check_output($node->title) ."</BIG></B>". ($node->body ? "<BR><SMALL><I>Last updated by ". format_name($node->name) ." on ". format_date($node->timestamp) ."</I></SMALL> " : "") ."</TD></TR>\n";
}
if ($node->body) {
@@ -83,9 +83,9 @@ function book_view($node, $main = 0) {
function book_search($keys) {
global $status;
- $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid LEFT JOIN users u ON n.author = u.id WHERE n.type = 'book' AND n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR b.body LIKE '%". check_input($keys) ."%') ORDER BY n.timestamp DESC LIMIT 20");
+ $result = db_query("SELECT n.*, u.name FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid LEFT JOIN users u ON n.author = u.id WHERE n.type = 'book' AND n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR b.body LIKE '%". check_input($keys) ."%') ORDER BY n.timestamp DESC LIMIT 20");
while ($node = db_fetch_object($result)) {
- $find[$i++] = array("title" => check_output($node->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=book&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->userid, "date" => $node->timestamp);
+ $find[$i++] = array("title" => check_output($node->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=book&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->name, "date" => $node->timestamp);
}
return $find;
}
@@ -128,8 +128,8 @@ function book_form($edit = array()) {
$form .= book_view(new Book(node_preview($edit)));
}
- $form .= form_item(t("Author"), format_username(($edit[userid] ? $edit[userid] : $user->userid)));
- $form .= form_hidden(userid, $edit[userid]);
+ $form .= form_item(t("Author"), format_name(($edit[name] ? $edit[name] : $user->name)));
+ $form .= form_hidden(name, $edit[name]);
$form .= form_textfield(t("Subject"), "title", $edit[title], 50, 64);
$form .= form_select(t("Parent"), "parent", $edit[parent], book_toc(), t("The parent subject or category the page belongs in."));
@@ -251,7 +251,7 @@ function book_page() {
switch ($op) {
case "feed":
- print book_export_html($i, $depth = 1);
+ print book_export_html($id, $depth = 1);
break;
default:
book_render();
@@ -301,16 +301,30 @@ function book_user() {
}
}
-function book_export_html($parent = "", $depth = 0) {
+function book_export_html($id = "", $depth = 1) {
+ global $status;
+
+ $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.type = 'book' AND n.status = '$status[posted]' AND n.nid = '". check_input($id) ."'");
+
+ while ($node = db_fetch_object($result)) {
+ $output .= "<H$depth>". check_output($node->title) ."</H$depth>";
+ if ($node->body) $output .= "<blockquote>". check_output($node->body, 1) ."</blockquote>";
+ }
+ $output .= book_export_html_recursive($id, $depth);
+
+ return $output;
+}
+
+function book_export_html_recursive($parent = "", $depth = 1) {
global $status;
$result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight");
while ($node = db_fetch_object($result)) {
$output .= "<H$depth>". check_output($node->title) ."</H$depth>";
- if ($node->body) $output .= check_output($node->body, 1);
- if ($node->pid) $output .= book_export_html($node->pid, $depth + 1);
- $output .= book_export_html($node->nid, $depth + 1);
+ if ($node->body) $output .= "<blockquote>". check_output($node->body, 1) ."</blockquote>";
+ if ($node->pid) $output .= book_export_html_recursive($node->pid, $depth + 1);
+ $output .= book_export_html_recursive($node->nid, $depth + 1);
}
return $output;