diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-03-25 16:42:52 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-03-25 16:42:52 +0000 |
commit | 5fb307f5bf4d39a4492671ac6223bd65492a1b16 (patch) | |
tree | 257bbb055b59144d1ad86feb6a92dce7d8ba7693 /modules/book/book.module | |
parent | 5b92e9099f45a779359cdf85f27874619bb8358f (diff) | |
download | brdo-5fb307f5bf4d39a4492671ac6223bd65492a1b16.tar.gz brdo-5fb307f5bf4d39a4492671ac6223bd65492a1b16.tar.bz2 |
- refactoring, refactoring, refactoring
Diffstat (limited to 'modules/book/book.module')
-rw-r--r-- | modules/book/book.module | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/modules/book/book.module b/modules/book/book.module index 66bedfec9..78199557f 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -75,6 +75,16 @@ function book_search() { print search_data($keys, $mod); } +function book_toc($parent = 0, $offset = 0, $toc = array()) { + global $status; + $result = db_query("SELECT n.*, b.* FROM nodes n LEFT JOIN book b ON n.nid = b.node WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight"); + while ($node = db_fetch_object($result)) { + $toc[$node->nid] = ($offset ? $offset : "") ."". ++$number .". $node->title"; + $toc = book_toc($node->nid, ($offset ? "$offset." : "") ."$number.", $toc); + } + return $toc; +} + function book_form($edit = array()) { global $allowed_html, $PHP_SELF, $REQUEST_URI, $status, $theme, $user; @@ -92,8 +102,7 @@ function book_form($edit = array()) { } else { $output .= "<B>". t("Parent") .":</B><BR>\n"; - $result = db_query("SELECT nid, title FROM nodes WHERE type = 'book' AND status = '$status[posted]'"); - while ($node = db_fetch_object($result)) $options2 .= "<OPTION VALUE=\"$node->nid\"". ($edit[parent] == $node->nid ? " SELECTED" : "") .">". check_select($node->title) ."</OPTION>"; + foreach (book_toc() as $key=>$value) $options2 .= "<OPTION VALUE=\"$key\"". ($edit[parent] == $key ? " SELECTED" : "") .">". check_select($value) ."</OPTION>"; if (user_access($user, "book")) $options2 .= "<OPTION VALUE=\"0\"". ($edit[parent] == 0 ? " SELECTED" : "") ."> </OPTION>"; $output .= "<SELECT NAME=\"edit[parent]\">$options2</SELECT><BR>\n"; $output .= "<SMALL><I>". t("The parent subject or category the new page belongs in.") ."</I></SMALL><P>\n"; |