From 8043cb998f3325731bfab8d82251fa49639aec1d Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 20 Apr 2002 11:52:50 +0000 Subject: - Applied Marco's big patch, including contributions from Moshe: + Changed the db_query() API. + Wrapped all links in l(), lm(), la(), ..., drupal_url() functions. + XHTML-ified some HTML. + Wrapped a lot of text in the administrative pages in a t() function. + Replaced all $REQUEST_URI/$PATH_INFOs by request_uri(). + Small bugfixes (eg. bug in book_export_html() and clean-ups (eg. RSS code). + Fixed some bugs in the taxonomy module (eg. tree making bug), added new functionality (eg. new APIs for use by other modules), included Moshe's taxonomy extensions, and some documentation udpates. + ... --- modules/book.module | 65 +++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 34 deletions(-) (limited to 'modules/book.module') diff --git a/modules/book.module b/modules/book.module index 56203777a..93f23c837 100644 --- a/modules/book.module +++ b/modules/book.module @@ -92,30 +92,30 @@ function book_save($op, $node) { function book_link($type, $node = 0, $main = 0) { if ($type == "page" && user_access("access content")) { - $links[] = "". t("collaborative book") .""; + $links[] = lm(t("collaborative book"), array("mod" => "book"), t("Read and contribute to the collaborative books.")); } if ($type == "menu.create" && user_access("post content")) { - $links[] = "". t("create book page") .""; + $links[] = lm(t("create book page"), array("mod" => "node", "op" => "add", "type" => "book"), t("Add a new book page.")); } if ($type == "admin" && user_access("administer nodes")) { - $links[] = "". t("collaborative book") .""; + $links[] = la(t("collaborative book"), array("mod" => "book")); } if ($type == "node" && $node->type == "book" && book_access("update", $node)) { - $links[] = "nid\" title=\"". t("Suggest an update for this book page.") ."\">". t("edit this page") .""; + $links[] = lm(t("edit this page"), array("mod" => "node", "op" => "edit", "id" => $node->nid), t("Suggest an update for this book page.")); } return $links ? $links : array(); } function book_load($node) { - global $user, $REQUEST_URI; + global $user; $book = db_fetch_object(db_query("SELECT format, parent, weight, log FROM book WHERE nid = '$node->nid'")); - if (strstr($REQUEST_URI, "module.php?mod=node&op=edit")) { + if (strstr(request_uri(), drupal_url(array("mod" => "node", "op" => "edit"), "module"))) { /* ** If a user is about to update a book page, we overload some @@ -219,12 +219,12 @@ function book_node_link($node = 0) { } if ($op == t("Add to book outline")) { - db_query("INSERT INTO book (nid, parent, weight) VALUES ('$node->nid', '". check_query($edit["parent"]) ."', '". check_query($edit["weight"]) ."')"); + db_query("INSERT INTO book (nid, parent, weight) VALUES ('$node->nid', '%s', '%s')", $edit["parent"], $edit["weight"]); $output .= status(t("added the node to the book.")); } if ($op == t("Update book outline")) { - db_query("UPDATE book SET parent = '". check_query($edit["parent"]) ."', weight = '". check_query($edit["weight"]) ."' WHERE nid = '$node->nid'"); + db_query("UPDATE book SET parent = '%s', weight = '%s' WHERE nid = '$node->nid'", $edit["parent"], $edit["weight"]); $output .= status(t("updated the book outline.")); } @@ -256,7 +256,7 @@ function book_node_link($node = 0) { $output .= form_hidden("nid", $node->nid); - return form($output, "post", "admin.php?mod=book&op=outline"); + return form($output, "post", drupal_url(array("mod" => "book", "op" => "outline"), "admin")); } } @@ -384,13 +384,13 @@ function book_view($node, $main = 0) { if ($node->title) { foreach (book_location($node) as $level) { - $location .= "$indent nid\">$level->title
"; + $location .= "$indent ".l($level->title, array("id" => $level->nid))."
"; $indent .= "-"; } $output .= " $location"; $output .= "
"; - $output .= " ". check_output($node->title) ."". ($node->body ? "
". strtr(t("Last updated by %u on %d"), array("%u" => format_name($node), "%d" => format_date($node->created))) ." " : "") .""; + $output .= " ". check_output($node->title) ."". ($node->body ? "
". t("Last updated by %u on %d", array("%u" => format_name($node), "%d" => format_date($node->created))) ." " : "") .""; } if ($node->body) { @@ -406,8 +406,8 @@ function book_view($node, $main = 0) { } $output .= "
"; - $output .= " ". ($prev ? "nid\" title=\"". t("View the previous page in this book.") ."\">". t("previous") ."" : t("previous")) ."index". ($next ? "nid\" title=\"". t("View the next page in this book.") ."\">". t("next") ."" : t("next")) .""; - $output .= " ". ($prev ? "". check_output($prev->title) ."" : " ") ."". ($node->parent ? "parent\" title=\"". t("View this page's parent section.") ."\">". t("up") ."" : t("up")) ."". ($next ? "". check_output($next->title) ."" : " ") .""; + $output .= " ". ($prev ? l(t("previous"), array("id" => $prev->nid), t("View the previous page in this book.")) : t("previous")) ."".lm(t("index"), array("mod" => "book"), t("View this book's table of contents."))."". ($next ? l(t("next"), array("id" => $next->nid), t("View the next page in this book.")) : t("next")) .""; + $output .= " ". ($prev ? "". check_output($prev->title) ."" : " ") ."". ($node->parent ? l(t("up"), array("id" => $node->parent), t("View this page's parent section.")) : t("up")) ."". ($next ? "". check_output($next->title) ."" : " ") .""; $output .= "
"; $output .= "
". $theme->links(link_node($node, $main)) ."
"; $output .= ""; @@ -462,7 +462,7 @@ function book_tree_recurse($nid, $depth, $children) { if ($depth > 0) { if ($children[$nid]) { foreach ($children[$nid] as $foo => $node) { - $output .= "
  • nid\">". check_output($node->title) ."
  • "; + $output .= "
  • ".l(check_output($node->title), array("id" => $node->nid))."
  • "; if ($tree = book_tree_recurse($node->nid, $depth - 1, $children)) { $output .= ""; @@ -508,7 +508,7 @@ function book_render() { if ($node) { // output the content: - $output .= "
    nid\">". check_output($node->title) ."
    ". book_body($node) ."

    "; + $output .= "
    ".l(check_output($node->title), array("id" => $node->nid))."
    ". book_body($node) ."

    "; } } @@ -537,7 +537,7 @@ function book_page() { } function book_export_html($id = "", $depth = 1) { - $result = db_query("SELECT n.nid FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.status = 1 AND n.nid = '". check_input($id) ." AND (n.moderate = 0 OR n.revisions != '')'"); + $result = db_query("SELECT n.nid FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.status = 1 AND n.nid = '%s' AND (n.moderate = 0 OR n.revisions != '')", $id); while ($page = db_fetch_object($result)) { // load the node: @@ -608,12 +608,12 @@ function book_admin_view_line($node, $depth = 0) { */ $output .= ""; - $output .= "
    nid\">". check_output($node->title) ."
    "; + $output .= "
    ".l(check_output($node->title), array("id" => $node->nid))."
    "; $output .= " $revision"; - $output .= " nid\">". t("edit node") .""; + $output .= " ".la(t("edit node"), array("mod" => "node", "op" => "edit", "id" => $node->nid)).""; //TODO: get this link to work. Must pass $nid along so it is received by book_node_link() - //$output .= " nid&op=Edit+book+outline\">". t("edit book outline") .""; - $output .= " nid\">". t("delete node") .""; + //$output .= " ".la(t("edit book outline"), array("mod" => "book", "nid" => $node->nid, "op" => "Edit+book+outline")).""; + $output .= " ".la(t("delete node"), array("mod" => "node", "op" => "delete", "id" => $node->nid)).""; $output .= ""; return $output; @@ -660,7 +660,7 @@ function book_admin_orphan() { $output .= " titleoperations"; foreach ($pages as $nid => $node) { if ($node->parent && empty($pages[$node->parent])) { - $output .= "nid\">". check_output($node->title) ."nid\">". t("edit page") ."nid\">". t("delete page") .""; + $output .= "".l(check_output($node->title), array("id" => $node->nid))."".la(t("edit page"), array("mod" => "node", "op" => "edit", "id" => $node->nid))."".la(t("delete page"), array("mod" => "node", "op" => "delete", "id" => $node->nid)).""; } } $output .= ""; @@ -672,11 +672,11 @@ function book_admin_links() { $result = db_query("SELECT n.nid, n.title FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE b.parent = 0 ORDER BY b.weight, n.title"); while ($book = db_fetch_object($result)) { - $links[] = "nid\">". t("book") .": ". check_output($book->title) .""; + $links[] = la(t("book") .": ". check_output($book->title) ."", array("mod" => "book", "op" => "view", "id" => $book->nid)); } - $links[] = "". t("orphan pages") .""; - $links[] = "" . t("export to HTML") . ""; - $links[] = "" . t("help") . ""; + $links[] = la(t("orphan pages"), array("mod" => "book", "op" => "orphan")); + $links[] = lm(t("export to HTML"), array("mod" => "book", "op" => "feed"), t("display all books in a single HTML page")); + $links[] = la(t("help"), array("mod" => "book", "op" => "help")); return $links; } @@ -719,7 +719,7 @@ function book_help() {

    The Collaborative Book is a magnificient mechanism for organizing content authored by many users. You may use it to organize a Manual (e.g. Drupal Handbook), -to maintain an FAQ, or to manage any outline-like content. Books can have +to maintain a FAQ, or to manage any outline-like content. Books can have Chapters, Sections, etc. In fact, books can have an arbitrarily deep nesting strucuture.

    Under the covers, a Book is only an organization of nodes. These nodes are often of type book page, @@ -735,17 +735,15 @@ page is usually stored as a new revision of a node. This capability makes it eas should that become desirable.

    Like other node types, Book submissions and edits may be subject to moderation, depending on your configuration. -Similarly, Books use permissions to determine who may +Similarly, Books use "user", "op" => "permission")) ?> to determine who may read and write to them. Only Administrators are allowed to create new books, which are really just nodes whose Parent is <root>. To include an existing node in your book, click on the Administer link in that node. At the bottom of this Admin page, click on the Edit Book Outline button. This enables you to place the node wherever you'd like within the book hierarchy. To add a new node into your book, use the create book page link.

    -

    Administrators may review the hierarchy of their books by clicking on the Collaborative Book link -in the Admin center. There, nodes may be edited, reorganized, removed from book, and deleted. This behavior may change in the future. When a Parent node is deleted, he may leave behind child nodes. -These nodes are now orphans. Administrators should periodically -review their books for orphans and reaffiliate those pages as desired. Finally, administrators may also -export their books to a single, flat HTML page which is suitable for printing.

    +

    Administrators may review the hierarchy of their books by clicking on the "book")) ?> in the Admin center. There, nodes may be edited, reorganized, removed from book, and deleted. This behavior may change in the future. When a Parent node is deleted, he may leave behind child nodes. +These nodes are now orphans. Administrators should periodically "book", "op" => "orphan")) ?> and reaffiliate those pages as desired. Finally, administrators may also + "book", "op" => "feed")) ?> to a single, flat HTML page which is suitable for printing.

    Maintain an FAQ with Collaborative Book

    @@ -788,8 +786,7 @@ seek. you are creating a post solely for inclusion in your book, then use the Create book page link.
  • If you don't see the administer link, then you probably have -insufficient permissions.
  • +insufficient "user", "op" => "permission")) ?>.
  • If you want to get really fancy, note that Books are one of the few content types which allow raw PHP in their body. So you've got lots of geeky possibilities there.
  • -- cgit v1.2.3