summaryrefslogtreecommitdiff
path: root/modules/book.module
diff options
context:
space:
mode:
Diffstat (limited to 'modules/book.module')
-rw-r--r--modules/book.module38
1 files changed, 28 insertions, 10 deletions
diff --git a/modules/book.module b/modules/book.module
index 85f69d059..daf314d1c 100644
--- a/modules/book.module
+++ b/modules/book.module
@@ -182,39 +182,57 @@ function book_tree($parent = "", $depth = 0) {
return $output;
}
-function book_list() {
- return node_overview("type = 'book'");
+function book_list($query = array()) {
+ return node_overview($query);
}
+function book_query($type = "") {
+ global $status;
+ $queries = array(0 => array("active book pages", "WHERE n.type = 'book' ORDER BY n.timestamp DESC"), 1 => array("posted book pages", "WHERE n.type = 'book' AND n.status = '$status[posted]' ORDER BY n.timestamp DESC"), 2 => array("queued book pages", "WHERE n.type = 'book' AND n.status = '$status[queued]' ORDER BY n.timestamp DESC"), 3 => array("dumped book pages", "WHERE n.type = 'book' AND n.status = '$status[dumped]' ORDER BY n.timestamp DESC"));
+ return ($queries[$type] ? $queries[$type] : $queries);
+}
+
+function book_listing() {
+ foreach (book_query() as $key=>$array) {
+ $output .= "<LI><A HREF=\"admin.php?mod=book&type=$key\">$array[0]</A></LI>\n";
+ }
+ return "<OL>$output</OL>\n";
+}
+
+
function book_admin() {
- global $op, $id, $edit, $mod, $keys, $user;
+ global $op, $id, $edit, $mod, $keys, $type, $user;
+
+ print "<SMALL><A HREF=\"admin.php?mod=book&op=add\">add new page</A> | <A HREF=\"admin.php?mod=book&op=listing\">book listing</A> | <A HREF=\"admin.php?mod=book&op=search\">search book</A> | <A HREF=\"admin.php?mod=book\">list overview</A> | <A HREF=\"admin.php?mod=book&op=tree\">tree overview</A></SMALL><HR>\n";
- print "<SMALL><A HREF=\"admin.php?mod=book&op=add\">add new page</A> | <A HREF=\"admin.php?mod=book&op=search\">search book</A> | <A HREF=\"admin.php?mod=book&op=list\">list overview</A> | <A HREF=\"admin.php?mod=book\">tree overview</A></SMALL><HR>\n";
+ $type = $type ? $type : 0;
switch ($op) {
case "add":
print book_form();
break;
- case "list":
- print book_list();
- break;
case "edit":
print book_form(node_get_array(nid, $id));
break;
+ case "listing":
+ print book_listing();
+ break;
case "search":
print search_form($keys);
print search_data($keys, $mod);
break;
+ case "tree":
+ print book_tree();
+ break;
case t("Preview"):
book_view(new Book(($edit[nid] ? $edit[nid] : -1), ($edit[userid] ? $edit[userid] : $user->userid), $edit[title], $edit[body], $edit[parent], $edit[weight], ($edit[timestamp] ? $edit[timestamp] : time())), 0);
print book_form($edit);
break;
case t("Submit"):
book_save($edit);
- print book_tree();
- break;
+ // fall through:
default:
- print book_tree();
+ print book_list(book_query($type));
}
}