Commit 75a6f4de authored by Gábor Hojtsy's avatar Gábor Hojtsy

#160200 by dvessel and chx: better theming support for book module

parent 98a5fb14
<?php
// $Id$
/**
* @file book-all-books-block.tpl.php
* Default theme implementation for rendering book outlines within a block.
* This template is used only when the block is configured to "show block on
* all pages" which presents Multiple independent books on all pages.
*
* Available variables:
* - $book_menus: Array of book outlines rendered as an unordered list. It is
* keyed to the parent book ID which is also the ID of the parent node
* containing an entire outline.
*
* @see template_preprocess_book_all_books_block()
*/
?>
<?php foreach ($book_menus as $book_id => $menu) : ?>
<div id="book-block-menu-<?php print $book_id; ?>" class="book-block-menu">
<?php print $menu; ?>
</div>
<?php endforeach; ?>
<?php
// $Id$
/**
* @file book-export-html.tpl.php
* Default theme implementation for printed version of book outline.
*
* Available variables:
* - $title: Top level node title.
* - $head: Header tags.
* - $language: Language code. e.g. "en" for english.
* - $language_rtl: TRUE or FALSE depending on right to left language scripts.
* - $base_url: URL to home page.
* - $content: Nodes within the current outline rendered through
* book-node-export-html.tpl.php.
*
* @see template_preprocess_book_export_html()
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="<?php print $language->language; ?>" xml:lang="<?php print $language->language; ?>">
<head>
<title><?php print $title; ?></title>
<?php print $head; ?>
<base href="<?php print $base_url; ?>" />
<link type="text/css" rel="stylesheet" href="misc/print.css" />
<?php if ($language_rtl): ?>
<link type="text/css" rel="stylesheet" href="misc/print-rtl.css" />
<?php endif; ?>
</head>
<body>
<?php
/**
* The given node is /embedded to its absolute depth in a top level
* section/. For example, a child node with depth 2 in the hierarchy is
* contained in (otherwise empty) &lt;div&gt; elements corresponding to
* depth 0 and depth 1. This is intended to support WYSIWYG output - e.g.,
* level 3 sections always look like level 3 sections, no matter their
* depth relative to the node selected to be exported as printer-friendly
* HTML.
*/
$div_close = '';
?>
<?php for ($i = 1; $i < $depth; $i++) : ?>
<div class="section-<?php print $i; ?>">
<?php $div_close .= '</div>'; ?>
<?php endfor; ?>
<?php print $contents; ?>
<?php print $div_close; ?>
</body>
</html>
<?php
// $Id$
/**
* @file book-navigation.tpl.php
* Default theme implementation to navigate books. Presented under nodes that
* are a part of book outlines.
*
* Available variables:
* - $tree: The immediate children of the current node rendered as an
* unordered list.
* - $current_depth: Depth of the current node within the book outline.
* Provided for context.
* - $prev_url: URL to the previous node.
* - $prev_title: Title of the previous node.
* - $parent_url: URL to the parent node.
* - $parent_title: Title of the parent node. Not printed by default. Provided
* as an option.
* - $next_url: URL to the next node.
* - $next_title: Title of the next node.
* - $has_links: Flags TRUE whenever the previous, parent or next data has a
* value.
* - $book_id: The book ID of the current outline being viewed. Same as the
* node ID containing the entire outline. Provided for context.
* - $book_url: The book/node URL of the current outline being viewed.
* Provided as an option. Not used by default.
* - $book_title: The book/node title of the current outline being viewed.
* Provided as an option. Not used by default.
*
* @see template_preprocess_book_navigation()
*/
?>
<?php if ($tree || $has_links): ?>
<div id="book-navigation-<?php print $book_id; ?>" class="book-navigation">
<?php print $tree; ?>
<?php if ($has_links): ?>
<div class="page-links clear-block">
<?php if ($prev_url) : ?>
<a href="<?php print $prev_url; ?>" class="page-previous" title="<?php print t('Go to previous page'); ?>"><?php print t('‹ ') . $prev_title; ?></a>
<?php endif; ?>
<?php if ($parent_url) : ?>
<a href="<?php print $parent_url; ?>" class="page-up" title="<?php print t('Go to parent page'); ?>"><?php print t('up'); ?></a>
<?php endif; ?>
<?php if ($next_url) : ?>
<a href="<?php print $next_url; ?>" class="page-next" title="<?php print t('Go to next page'); ?>"><?php print $next_title . t(' ›'); ?></a>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php
// $Id$
/**
* @file book-node-export-html.tpl.php
* Default theme implementation for rendering a single node in a printer
* friendly outline.
*
* @see book-node-export-html.tpl.php
* Where it is collected and printed out.
*
* Available variables:
* - $depth: Depth of the current node inside the outline.
* - $title: Node title.
* - $content: Node content.
* - $children: All the child nodes recursively rendered through this file.
*
* @see template_preprocess_book_node_export_html()
*/
?>
<div id="node-<?php print $node->nid; ?>" class="section-<?php print $depth; ?>">
<h1 class="book-heading"><?php print $title; ?></h1>
<?php print $content; ?>
<?php print $children; ?>
</div>
This diff is collapsed.
......@@ -73,47 +73,19 @@ function book_export($type, $nid) {
*/
function book_export_html($nid) {
if (user_access('access printer-friendly version')) {
$content = '';
$export_data = array();
$node = node_load($nid);
if (isset($node->book)) {
$depth = $node->book['depth'];
for ($i = 1; $i < $depth; $i++) {
$content .= "<div class=\"section-$i\">\n";
}
$tree = book_menu_subtree_data($node->book);
$content .= book_export_traverse($tree, 'book_node_visitor_html_pre', 'book_node_visitor_html_post');
for ($i = 1; $i < $depth; $i++) {
$content .= "</div>\n";
}
$contents = book_export_traverse($tree, 'book_node_export');
}
return theme('book_export_html', check_plain($node->title), $content);
return theme('book_export_html', $node->title, $contents, $node->book['depth']);
}
else {
drupal_access_denied();
}
}
/**
* How the book's HTML export should be themed
*
* @ingroup themeable
*/
function theme_book_export_html($title, $content) {
global $base_url, $language;
$html = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
$html .= '<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">';
$html .= "<head>\n<title>". $title ."</title>\n";
$html .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
$html .= '<base href="'. $base_url .'/" />'."\n";
$html .= '<link type="text/css" rel="stylesheet" href="misc/print.css" />';
if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) {
$html .= '<link type="text/css" rel="stylesheet" href="misc/print-rtl.css" />';
}
$html .= "</head>\n<body>\n". $content ."\n</body>\n</html>\n";
return $html;
}
/**
* Menu callback; show the outline form for a single node.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment