diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-12-30 16:16:38 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-12-30 16:16:38 +0000 |
commit | a95c2a68aaededb5538da3df4d40c88879c4c45d (patch) | |
tree | f44d23eeab210cbad48d002f85f5ca1bd4272b38 /modules/book.module | |
parent | 7a673ac3cc2729fc4f01a3ede470b85cbf5fd6d6 (diff) | |
download | brdo-a95c2a68aaededb5538da3df4d40c88879c4c45d.tar.gz brdo-a95c2a68aaededb5538da3df4d40c88879c4c45d.tar.bz2 |
- import.module:
+ Improved input filtering; this should make the news items look
more consistent in terms of mark-up.
+ Quoted all array indices: converted all instances of $foo[bar]
to $foo["bar"]. Made various other changes to make the import
module compliant with the coding style.
- theme.inc:
+ Fixed small XHTML glitch
- comment system:
+ Made it possible for users to edit their comments (when certain
criteria are matched).
+ Renamed the SQL table field "lid" to "nid" and updated the code
to reflect this change: this is a rather /annoying/ change that
has been asked for a few times. It will impact the contributed
BBS/forum modules and requires a tiny SQL update:
sql> ALTER TABLE comments CHANGE lid nid int(10) NOT NULL;
+ Moved most (all?) of the comment related logic from node.php to
comment.module where it belongs. This also marks a first step
towards removing/reducing "node.php".
+ Added a delete button to the comment admin form and made it so
that Drupal prompts for confirmation prior to deleting a comment
from the database. This behavior is similar to that of deleting
nodes.
+ Disabled comment moderation for now.
+ Some of the above changes will make it easier to integrate the
upcomcing mail-to-web and web-to-mail gateways. They are part
of a bigger plan. ;)
- node system:
+ Made it so that updating nodes (like for instance updating blog
entries) won't trigger the submission rate throttle.
+ Fixed a small glitch where a node's title wasn't always passed
to the $theme->header() function.
+ Made "node_array()" and "node_object()" more generic and named
them "object2array()" and "array2object()".
+ Moved most (all?) of the comment related logic from node.php to
comment.module where it belongs. This also marks a first step
towards removing/reducing "node.php".
- misc:
+ Applied three patches by Foxen. One to improve performance of
the book module, and two other patches to fix small glitches in
common.inc. Thanks Foxen!
Diffstat (limited to 'modules/book.module')
-rw-r--r-- | modules/book.module | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/modules/book.module b/modules/book.module index b463dd43f..37b9a2352 100644 --- a/modules/book.module +++ b/modules/book.module @@ -423,7 +423,7 @@ function book_toc_recurse($nid, $indent, $toc, $children) { return $toc; } -function book_toc($parent = "", $indent = "", $toc = array()) { +function book_toc($parent = 0, $indent = "", $toc = array()) { $result = db_query("SELECT n.nid, n.title, b.parent FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.type = 'book' AND n.status = '1' ORDER BY b.weight, n.title"); @@ -446,46 +446,43 @@ function book_toc($parent = "", $indent = "", $toc = array()) { ** Iterate root book nodes: */ - $toc = book_toc_recurse(0, $indent, $toc, $children, $titles); + $toc = book_toc_recurse($parent, $indent, $toc, $children); return $toc; } -function book_tree($parent = "", $depth = 0) { - if ($depth < 3) { +function book_tree_recurse($nid, $depth, $children) { - /* - ** Select all child nodes and render them into a table of contents: - */ - - $result = db_query("SELECT n.nid FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE b.parent = '$parent' AND (n.moderate = 0 OR n.revisions != '') ORDER BY b.weight, n.title"); - - while ($page = db_fetch_object($result)) { - // load the node: - $node = node_load(array("nid" => $page->nid)); - - // take the most recent approved revision: - if ($node->moderate) { - $node = book_revision_load($node, array("moderate" => 0, "status" => 1)); - } - - if ($node) { - // output the content: + if ($depth > 1) { + if ($children[$nid]) { + foreach ($children[$nid] as $foo => $node) { $output .= "<li><a href=\"node.php?id=$node->nid\">". check_output($node->title) ."</a></li>"; - - // build the sub-tree of each child: - $output .= book_tree($node->nid, $depth + 1); + $output .= book_tree_recurse($node->nid, $depth - 1, $children); } } + } + + return $output; +} + - $output = "<ul>$output</ul>"; +function book_tree($parent = 0, $depth = 3) { + + $result = db_query("SELECT n.nid, n.title, b.parent FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.type = 'book' AND n.status = '1' ORDER BY b.weight, n.title"); + while ($node = db_fetch_object($result)) { + $list = $children[$node->parent] ? $children[$node->parent] : array(); + array_push($list, $node); + $children[$node->parent] = $list; } + $output = book_tree_recurse($parent, $depth, $children); + $output = "<ul>$output</ul>"; return $output; } + function book_render() { global $theme; |