From c47d2fcb460ad41b3a08d44e5f4d7114ca6ac8f1 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 23 Oct 2005 18:08:06 +0000 Subject: - Patch #33220 by Tobias: improved themeability of book module. --- modules/book.module | 53 +++++++++++++++++++++++++++--------------------- modules/book/book.module | 53 +++++++++++++++++++++++++++--------------------- 2 files changed, 60 insertions(+), 46 deletions(-) (limited to 'modules') diff --git a/modules/book.module b/modules/book.module index 207675c3c..6c48aaf80 100644 --- a/modules/book.module +++ b/modules/book.module @@ -444,7 +444,17 @@ function book_nodeapi(&$node, $op, $teaser, $page) { foreach ($book as $key => $value) { $node->$key = $value; } - $node = theme('book_navigation', $node); + + $path = book_location($node); + // Construct the breadcrumb: + $node->breadcrumb = array(); // Overwrite the trail with a book trail. + foreach ($path as $level) { + $node->breadcrumb[] = array('path' => 'node/'. $level->nid, 'title' => $level->title); + } + $node->breadcrumb[] = array('path' => 'node/'. $node->nid); + + $node->body .= theme('book_navigation', $node); + if ($page) { menu_set_location($node->breadcrumb); } @@ -461,16 +471,6 @@ function book_nodeapi(&$node, $op, $teaser, $page) { * @ingroup themeable */ function theme_book_navigation($node) { - $path = book_location($node); - - // Construct the breadcrumb: - - $node->breadcrumb = array(); // Overwrite the trail with a book trail. - foreach ($path as $level) { - $node->breadcrumb[] = array('path' => 'node/'. $level->nid, 'title' => $level->title); - } - $node->breadcrumb[] = array('path' => 'node/'. $node->nid); - if ($node->nid) { $output .= '
'; @@ -509,9 +509,7 @@ function theme_book_navigation($node) { $output .= '
'; } - $node->body = $node->body.$output; - - return $node; + return $output; } /** @@ -657,7 +655,6 @@ function book_render() { * */ function book_export($type = 'html', $nid = FALSE) { - global $base_url; $type = drupal_strtolower($type); $node = node_load($nid); if ($node) { @@ -684,14 +681,7 @@ function book_export($type = 'html', $nid = FALSE) { for ($i = 1; $i < $depth; $i++) { $output .= "\n"; } - $html = "\n"; - $html .= ''; - $html .= "\n". check_plain($node->title) ."\n"; - $html .= ''; - $html .= '' . "\n"; - $html .= "\n"; - $html .= "\n\n". $output . "\n\n\n"; - print $html; + print theme('book_export_html', check_plain($node->title), $output); } else { drupal_access_denied(); @@ -720,6 +710,23 @@ function book_export($type = 'html', $nid = FALSE) { } } +/** + * How the book's HTML export should be themed + * + * @ingroup themeable + */ +function theme_book_export_html($title, $content) { + global $base_url; + $html = "\n"; + $html .= ''; + $html .= "\n". $title ."\n"; + $html .= ''; + $html .= '' . "\n"; + $html .= "\n"; + $html .= "\n\n". $content . "\n\n\n"; + return $html; +} + /** * Given a node, this function returns the depth of the node in its hierarchy. * A root node has depth 1, and children of a node of depth n have depth (n+1). diff --git a/modules/book/book.module b/modules/book/book.module index 207675c3c..6c48aaf80 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -444,7 +444,17 @@ function book_nodeapi(&$node, $op, $teaser, $page) { foreach ($book as $key => $value) { $node->$key = $value; } - $node = theme('book_navigation', $node); + + $path = book_location($node); + // Construct the breadcrumb: + $node->breadcrumb = array(); // Overwrite the trail with a book trail. + foreach ($path as $level) { + $node->breadcrumb[] = array('path' => 'node/'. $level->nid, 'title' => $level->title); + } + $node->breadcrumb[] = array('path' => 'node/'. $node->nid); + + $node->body .= theme('book_navigation', $node); + if ($page) { menu_set_location($node->breadcrumb); } @@ -461,16 +471,6 @@ function book_nodeapi(&$node, $op, $teaser, $page) { * @ingroup themeable */ function theme_book_navigation($node) { - $path = book_location($node); - - // Construct the breadcrumb: - - $node->breadcrumb = array(); // Overwrite the trail with a book trail. - foreach ($path as $level) { - $node->breadcrumb[] = array('path' => 'node/'. $level->nid, 'title' => $level->title); - } - $node->breadcrumb[] = array('path' => 'node/'. $node->nid); - if ($node->nid) { $output .= '
'; @@ -509,9 +509,7 @@ function theme_book_navigation($node) { $output .= '
'; } - $node->body = $node->body.$output; - - return $node; + return $output; } /** @@ -657,7 +655,6 @@ function book_render() { * */ function book_export($type = 'html', $nid = FALSE) { - global $base_url; $type = drupal_strtolower($type); $node = node_load($nid); if ($node) { @@ -684,14 +681,7 @@ function book_export($type = 'html', $nid = FALSE) { for ($i = 1; $i < $depth; $i++) { $output .= "\n"; } - $html = "\n"; - $html .= ''; - $html .= "\n". check_plain($node->title) ."\n"; - $html .= ''; - $html .= '' . "\n"; - $html .= "\n"; - $html .= "\n\n". $output . "\n\n\n"; - print $html; + print theme('book_export_html', check_plain($node->title), $output); } else { drupal_access_denied(); @@ -720,6 +710,23 @@ function book_export($type = 'html', $nid = FALSE) { } } +/** + * How the book's HTML export should be themed + * + * @ingroup themeable + */ +function theme_book_export_html($title, $content) { + global $base_url; + $html = "\n"; + $html .= ''; + $html .= "\n". $title ."\n"; + $html .= ''; + $html .= '' . "\n"; + $html .= "\n"; + $html .= "\n\n". $content . "\n\n\n"; + return $html; +} + /** * Given a node, this function returns the depth of the node in its hierarchy. * A root node has depth 1, and children of a node of depth n have depth (n+1). -- cgit v1.2.3