From 5fb307f5bf4d39a4492671ac6223bd65492a1b16 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 25 Mar 2001 16:42:52 +0000 Subject: - refactoring, refactoring, refactoring --- modules/book.module | 13 +++++++++++-- modules/book/book.module | 13 +++++++++++-- modules/headline.module | 2 +- modules/moderation.module | 2 +- 4 files changed, 24 insertions(+), 6 deletions(-) (limited to 'modules') diff --git a/modules/book.module b/modules/book.module index 66bedfec9..78199557f 100644 --- a/modules/book.module +++ b/modules/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 .= "". t("Parent") .":
\n"; - $result = db_query("SELECT nid, title FROM nodes WHERE type = 'book' AND status = '$status[posted]'"); - while ($node = db_fetch_object($result)) $options2 .= ""; + foreach (book_toc() as $key=>$value) $options2 .= ""; if (user_access($user, "book")) $options2 .= ""; $output .= "
\n"; $output .= "". t("The parent subject or category the new page belongs in.") ."

\n"; 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 .= "". t("Parent") .":
\n"; - $result = db_query("SELECT nid, title FROM nodes WHERE type = 'book' AND status = '$status[posted]'"); - while ($node = db_fetch_object($result)) $options2 .= ""; + foreach (book_toc() as $key=>$value) $options2 .= ""; if (user_access($user, "book")) $options2 .= ""; $output .= "
\n"; $output .= "". t("The parent subject or category the new page belongs in.") ."

\n"; diff --git a/modules/headline.module b/modules/headline.module index 4234d33ef..e4393195b 100644 --- a/modules/headline.module +++ b/modules/headline.module @@ -212,7 +212,7 @@ function headline_export($uri) { while ($node = db_fetch_object($result)) { print "\n"; print " ". check_export($node->title) ."\n"; - print " ". $site_url ."node.php?id=$node->id\n"; + print " ". $site_url ."node.php?id=$node->nid\n"; print "\n"; } diff --git a/modules/moderation.module b/modules/moderation.module index e9380db5f..4b63f0274 100644 --- a/modules/moderation.module +++ b/modules/moderation.module @@ -77,7 +77,7 @@ function moderation_node($id) { else { if ($node->pid && $n = node_get_object("nid", $node->pid)) { if ($node->pid) $output .= " ". t("The above node is a suggested update for an existing node:") ." \"nid\">". check_output($n->title) ."\"."; - if ($node->log) $output .= " ". t("The log message to accompany this update is given below:") ."

". check_output($node->log, 1) ."

"; + if ($node->log) $output .= " ". t("The log message to accompany this update is given below:") ."

". check_output($node->log, 1) ."

"; } // moderation form: -- cgit v1.2.3