summaryrefslogtreecommitdiff
path: root/modules/book/book.module
diff options
context:
space:
mode:
Diffstat (limited to 'modules/book/book.module')
-rw-r--r--modules/book/book.module13
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" : "") .">&nbsp;</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";