diff options
Diffstat (limited to 'modules/book.module')
-rw-r--r-- | modules/book.module | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/modules/book.module b/modules/book.module index 909542a15..cec2b08c8 100644 --- a/modules/book.module +++ b/modules/book.module @@ -86,7 +86,7 @@ function book_link($type, $node = 0, $main = 0) { menu("admin/node/book/orphan", "orphan pages", "book_admin", $help["orphan"], 8); menu("admin/node/book/help", "help", "book_help", NULL, 9); - $result = db_query("SELECT n.nid, n.title FROM node n INNER JOIN book b ON n.nid = b.nid WHERE b.parent = 0 ORDER BY b.weight, n.title"); + $result = db_query("SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = 0 ORDER BY b.weight, n.title"); while ($book = db_fetch_object($result)) { menu("admin/node/book/$book->nid", "'$book->title' book", "book_admin"); } @@ -98,7 +98,7 @@ function book_link($type, $node = 0, $main = 0) { function book_load($node) { global $user; - $book = db_fetch_object(db_query("SELECT format, parent, weight, log FROM book WHERE nid = %d", $node->nid)); + $book = db_fetch_object(db_query("SELECT format, parent, weight, log FROM {book} WHERE nid = %d", $node->nid)); if (strstr(request_uri(), "node/edit")) { @@ -131,15 +131,15 @@ function book_load($node) { } function book_insert($node) { - db_query("INSERT INTO book (nid, format, parent, weight, log) VALUES (%d, %d, %d, %d, '%s')", $node->nid, $node->format, $node->parent, $node->weight, $node->log); + db_query("INSERT INTO {book} (nid, format, parent, weight, log) VALUES (%d, %d, %d, %d, '%s')", $node->nid, $node->format, $node->parent, $node->weight, $node->log); } function book_update($node) { - db_query("UPDATE book SET format = %d, parent = %d, weight = %d, log = '%s' WHERE nid = %d", $node->format, $node->parent, $node->weight, $node->log, $node->nid); + db_query("UPDATE {book} SET format = %d, parent = %d, weight = %d, log = '%s' WHERE nid = %d", $node->format, $node->parent, $node->weight, $node->log, $node->nid); } function book_delete(&$node) { - db_query("DELETE FROM book WHERE nid = %d", $node->nid); + db_query("DELETE FROM {book} WHERE nid = %d", $node->nid); } function book_validate(&$node) { @@ -210,24 +210,24 @@ function book_node_link($node = 0) { } if ($op == t("Add to book outline")) { - db_query("INSERT INTO book (nid, parent, weight) VALUES (%d, %d, %d)", $node->nid, $edit["parent"], $edit["weight"]); + db_query("INSERT INTO {book} (nid, parent, weight) VALUES (%d, %d, %d)", $node->nid, $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 = %d, weight = %d WHERE nid = %d", $edit["parent"], $edit["weight"], $node->nid); + db_query("UPDATE {book} SET parent = %d, weight = %d WHERE nid = %d", $edit["parent"], $edit["weight"], $node->nid); $output .= status(t("updated the book outline.")); } if ($op == t("Remove from book outline")) { - db_query("DELETE FROM book WHERE nid = %d", $node->nid); + db_query("DELETE FROM {book} WHERE nid = %d", $node->nid); $output .= status(t("removed the node form the book.")); } $output .= "<h3>". t("Edit book outline for node <i>%booktitle</i>", array("%booktitle" => $node->title)) ."</h3>"; if ($edit["nid"]) { - $page = db_fetch_object(db_query("SELECT * FROM book WHERE nid = %d", $node->nid)); + $page = db_fetch_object(db_query("SELECT * FROM {book} WHERE nid = %d", $node->nid)); $output .= form_select(t("Parent"), "parent", $page->parent, book_toc(), t("The parent subject or category the page belongs in.")); $output .= form_weight(t("Weight"), "weight", $node->weight, 15, t("The heavier pages will sink and the lighter pages will be positioned nearer the top.")); @@ -290,7 +290,7 @@ function book_revision_load($page, $conditions = array()) { ** Return the path (call stack) to a certain book page. */ function book_location($node, $nodes = array()) { - $parent = db_fetch_object(db_query("SELECT n.nid, n.title, b.parent FROM node n INNER JOIN book b ON n.nid = b.nid WHERE n.nid = %d", $node->parent)); + $parent = db_fetch_object(db_query("SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.nid = %d", $node->parent)); if ($parent->title) { $nodes = book_location($parent, $nodes); array_push($nodes, $parent); @@ -299,7 +299,7 @@ function book_location($node, $nodes = array()) { } function book_location_down($node, $nodes = array()) { - $last_direct_child = db_fetch_object(db_query("SELECT n.nid, n.title, b.parent FROM node n INNER JOIN book b ON n.nid = b.nid WHERE b.parent = %d ORDER BY b.weight DESC, n.title DESC", $node->nid)); + $last_direct_child = db_fetch_object(db_query("SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = %d ORDER BY b.weight DESC, n.title DESC", $node->nid)); if ($last_direct_child) { array_push($nodes, $last_direct_child); $nodes = book_location_down($last_direct_child, $nodes); @@ -314,7 +314,7 @@ function book_prev($node) { } // previous on the same level - $direct_above = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n INNER JOIN book b ON n.nid = b.nid WHERE b.parent = %d AND n.status = 1 AND (n.moderate = 0 OR n.revisions != '') AND (b.weight < %d OR (b.weight = %d AND n.title < '%s')) ORDER BY b.weight DESC, n.title DESC", $node->parent, $node->weight, $node->weight, $node->title)); + $direct_above = db_fetch_object(db_query("SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = %d AND n.status = 1 AND (n.moderate = 0 OR n.revisions != '') AND (b.weight < %d OR (b.weight = %d AND n.title < '%s')) ORDER BY b.weight DESC, n.title DESC", $node->parent, $node->weight, $node->weight, $node->title)); if ($direct_above) { // get last leaf of $above $path = book_location_down($direct_above); @@ -323,14 +323,14 @@ function book_prev($node) { } else { // direct parent - $prev = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n INNER JOIN book b ON n.nid = b.nid WHERE n.nid = %d AND n.status = 1 AND (n.moderate = 0 OR n.revisions != '')", $node->parent)); + $prev = db_fetch_object(db_query("SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.nid = %d AND n.status = 1 AND (n.moderate = 0 OR n.revisions != '')", $node->parent)); return $prev; } } function book_next($node) { // get first direct child - $child = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n INNER JOIN book b ON n.nid = b.nid WHERE b.parent = %d AND n.status = 1 AND (n.moderate = 0 OR n.revisions != '') ORDER BY b.weight ASC, n.title ASC", $node->nid)); + $child = db_fetch_object(db_query("SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = %d AND n.status = 1 AND (n.moderate = 0 OR n.revisions != '') ORDER BY b.weight ASC, n.title ASC", $node->nid)); if ($child) { return $child; } @@ -339,7 +339,7 @@ function book_next($node) { array_push($path = book_location($node), $node); // path to root node including this one // loop through nodes to book root, starting with this node while (($leaf = array_pop($path)) && count($path)) { - $next = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n INNER JOIN book b ON n.nid = b.nid WHERE b.parent = %d AND n.status = 1 AND (n.moderate = 0 OR n.revisions != '') AND (b.weight > %d OR (b.weight = %d AND n.title > '%s')) ORDER BY b.weight ASC, n.title ASC", $leaf->parent, $leaf->weight, $leaf->weight, $leaf->title)); + $next = db_fetch_object(db_query("SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = %d AND n.status = 1 AND (n.moderate = 0 OR n.revisions != '') AND (b.weight > %d OR (b.weight = %d AND n.title > '%s')) ORDER BY b.weight ASC, n.title ASC", $leaf->parent, $leaf->weight, $leaf->weight, $leaf->title)); if ($next) { return $next; } @@ -477,7 +477,7 @@ function book_toc_recurse($nid, $indent, $toc, $children) { function book_toc($parent = 0, $indent = "", $toc = array()) { - $result = db_query("SELECT n.nid, n.title, b.parent FROM node n INNER JOIN book b ON n.nid = b.nid WHERE n.status = '1' ORDER BY b.weight, n.title"); + $result = db_query("SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.status = '1' ORDER BY b.weight, n.title"); while ($node = db_fetch_object($result)) { $list = $children[$node->parent] ? $children[$node->parent] : array(); @@ -525,7 +525,7 @@ function book_tree_recurse($nid, $depth, $children) { function book_tree($parent = 0, $depth = 3) { - $result = db_query("SELECT n.nid, n.title, b.parent FROM node n INNER JOIN book b ON n.nid = b.nid WHERE n.status = '1' AND n.moderate = '0' ORDER BY b.weight, n.title"); + $result = db_query("SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.status = '1' AND n.moderate = '0' ORDER BY b.weight, n.title"); while ($node = db_fetch_object($result)) { $list = $children[$node->parent] ? $children[$node->parent] : array(); @@ -542,7 +542,7 @@ function book_tree($parent = 0, $depth = 3) { function book_render() { - $result = db_query("SELECT n.nid FROM node n INNER JOIN book b ON n.nid = b.nid WHERE b.parent = 0 AND n.status = 1 AND (n.moderate = 0 OR n.revisions IS NOT NULL) ORDER BY b.weight, n.title"); + $result = db_query("SELECT n.nid FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = 0 AND n.status = 1 AND (n.moderate = 0 OR n.revisions IS NOT NULL) ORDER BY b.weight, n.title"); while ($page = db_fetch_object($result)) { // load the node: @@ -588,7 +588,7 @@ function book_page() { function book_print($id = "", $depth = 1) { global $base_url; - $result = db_query("SELECT n.nid FROM node n INNER JOIN book b ON n.nid = b.nid WHERE n.status = 1 AND n.nid = %d AND (n.moderate = 0 OR n.revisions IS NOT NULL) ORDER BY b.weight, n.title", $id); + $result = db_query("SELECT n.nid FROM {node} n INNER JOIN book b ON n.nid = b.nid WHERE n.status = 1 AND n.nid = %d AND (n.moderate = 0 OR n.revisions IS NOT NULL) ORDER BY b.weight, n.title", $id); while ($page = db_fetch_object($result)) { // load the node: @@ -620,7 +620,7 @@ function book_print($id = "", $depth = 1) { } function book_print_recurse($parent = "", $depth = 1) { - $result = db_query("SELECT n.nid FROM node n INNER JOIN book b ON n.nid = b.nid WHERE n.status = 1 AND b.parent = '$parent' AND (n.moderate = 0 OR n.revisions IS NOT NULL) ORDER BY b.weight, n.title"); + $result = db_query("SELECT n.nid FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.status = 1 AND b.parent = '$parent' AND (n.moderate = 0 OR n.revisions IS NOT NULL) ORDER BY b.weight, n.title"); while ($page = db_fetch_object($result)) { // load the node: @@ -654,7 +654,7 @@ function book_admin_view_line($node, $depth = 0) { } function book_admin_view_book($nid, $depth = 1) { - $result = db_query("SELECT n.nid FROM node n INNER JOIN book b ON n.nid = b.nid WHERE b.parent = %d ORDER BY b.weight, n.title", $nid); + $result = db_query("SELECT n.nid FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = %d ORDER BY b.weight, n.title", $nid); while ($node = db_fetch_object($result)) { $node = node_load(array("nid" => $node->nid)); @@ -693,18 +693,18 @@ function book_admin_save($nid, $edit = array()) { ** Check to see whether the title needs updating: */ - $title = db_result(db_query("SELECT title FROM node WHERE nid = %d", $nid)); + $title = db_result(db_query("SELECT title FROM {node} WHERE nid = %d", $nid)); if ($title != $value["title"]) { - db_query("UPDATE node SET title = '%s' WHERE nid = %d", $value["title"], $nid); + db_query("UPDATE {node} SET title = '%s' WHERE nid = %d", $value["title"], $nid); } /* ** Check to see whether the weight needs updating: */ - $weight = db_result(db_query("SELECT weight FROM book WHERE nid = %d", $nid)); + $weight = db_result(db_query("SELECT weight FROM {book} WHERE nid = %d", $nid)); if ($weight != $value["weight"]) { - db_query("UPDATE book SET weight = %d WHERE nid = %d", $value["weight"], $nid); + db_query("UPDATE {book} SET weight = %d WHERE nid = %d", $value["weight"], $nid); } } @@ -717,7 +717,7 @@ function book_admin_save($nid, $edit = array()) { function book_admin_orphan() { - $result = db_query("SELECT n.nid, n.title, n.status, b.parent FROM node n INNER JOIN book b ON n.nid = b.nid WHERE n.type = 'book'"); + $result = db_query("SELECT n.nid, n.title, n.status, b.parent FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.type = 'book'"); while ($page = db_fetch_object($result)) { $pages[$page->nid] = $page; |