Commit f2aa485d authored by alexpott's avatar alexpott

Issue #1898050 by duellj, Cottser, meeli, dsdart, Fabianx | c4rl: book.module...

Issue #1898050 by duellj, Cottser, meeli, dsdart, Fabianx | c4rl: book.module - Convert PHPTemplate templates to Twig.
parent 3d24449a
...@@ -957,7 +957,9 @@ function book_preprocess_block(&$variables) { ...@@ -957,7 +957,9 @@ function book_preprocess_block(&$variables) {
} }
/** /**
* Processes variables for book-all-books-block.tpl.php. * Prepares variables for book listing block templates.
*
* Default template: book-all-books-block.html.twig.
* *
* All non-renderable elements are removed so that the template has full access * All non-renderable elements are removed so that the template has full access
* to the structured data but can also simply iterate over all elements and * to the structured data but can also simply iterate over all elements and
...@@ -965,9 +967,8 @@ function book_preprocess_block(&$variables) { ...@@ -965,9 +967,8 @@ function book_preprocess_block(&$variables) {
* *
* @param array $variables * @param array $variables
* An associative array containing the following key: * An associative array containing the following key:
* - book_menus * - book_menus: An associative array containing renderable menu links for all
* * book menus.
* @see book-all-books-block.tpl.php
*/ */
function template_preprocess_book_all_books_block(&$variables) { function template_preprocess_book_all_books_block(&$variables) {
// Remove all non-renderable elements. // Remove all non-renderable elements.
...@@ -979,13 +980,14 @@ function template_preprocess_book_all_books_block(&$variables) { ...@@ -979,13 +980,14 @@ function template_preprocess_book_all_books_block(&$variables) {
} }
/** /**
* Processes variables for book-navigation.tpl.php. * Prepares variables for book navigation templates.
*
* Default template: book-navigation.html.twig.
* *
* @param array $variables * @param array $variables
* An associative array containing the following key: * An associative array containing the following key:
* - book_link * - book_link: An associative array of book link properties.
* * Properties used: bid, link_title, depth, plid, mlid.
* @see book-navigation.tpl.php
*/ */
function template_preprocess_book_navigation(&$variables) { function template_preprocess_book_navigation(&$variables) {
drupal_add_css(drupal_get_path('module', 'book') . '/book.theme.css'); drupal_add_css(drupal_get_path('module', 'book') . '/book.theme.css');
...@@ -1101,15 +1103,15 @@ function book_toc($bid, $depth_limit, $exclude = array()) { ...@@ -1101,15 +1103,15 @@ function book_toc($bid, $depth_limit, $exclude = array()) {
} }
/** /**
* Preprocesses variables for book-export-html.tpl.php. * Prepares variables for book export templates.
* *
* @param array $variables * Default template: book-export-html.html.twig.
* An associative array containing the following keys:
* - title
* - contents
* - depth
* *
* @see book-export-html.tpl.php * @param array $variables
* An associative array containing:
* - title: The title of the book.
* - contents: Output of each book page.
* - depth: The max depth of the book.
*/ */
function template_preprocess_book_export_html(&$variables) { function template_preprocess_book_export_html(&$variables) {
global $base_url; global $base_url;
...@@ -1191,14 +1193,15 @@ function book_node_export(EntityInterface $node, $children = '') { ...@@ -1191,14 +1193,15 @@ function book_node_export(EntityInterface $node, $children = '') {
} }
/** /**
* Processes variables for book-node-export-html.tpl.php. * Prepares variables for single node export templates.
*
* Default template: book-node-export-html.html.twig.
* *
* @param array $variables * @param array $variables
* An associative array containing the following keys: * An associative array containing the following keys:
* - node * - node: The node that will be output.
* - children * - children: All the rendered child nodes within the current node. Defaults
* * to an empty string.
* @see book-node-export-html.tpl.php
*/ */
function template_preprocess_book_node_export_html(&$variables) { function template_preprocess_book_node_export_html(&$variables) {
$variables['depth'] = $variables['node']->book['depth']; $variables['depth'] = $variables['node']->book['depth'];
......
<?php {#
/** /**
* @file * @file
* Default theme implementation for rendering book outlines within a block. * Default theme implementation for rendering book outlines within a block.
...@@ -8,16 +7,18 @@ ...@@ -8,16 +7,18 @@
* pages", which presents multiple independent books on all pages. * pages", which presents multiple independent books on all pages.
* *
* Available variables: * Available variables:
* - $book_menus: Array of book outlines keyed to the parent book ID. Call * - book_menus: Book outlines.
* render() on each to print it as an unordered list. * - book_id: The parent book ID.
* - menu: The top-level book links.
* *
* @see template_preprocess()
* @see template_preprocess_book_all_books_block() * @see template_preprocess_book_all_books_block()
* *
* @ingroup themeable * @ingroup themeable
*/ */
?> #}
<?php foreach ($book_menus as $book_id => $menu): ?> {% for book_id, menu in book_menus %}
<nav id="book-block-menu-<?php print $book_id; ?>" class="book-block-menu"> <nav id="book-block-menu-{{ book_id }}" class="book-block-menu">
<?php print render($menu); ?> {{ menu }}
</nav> </nav>
<?php endforeach; ?> {% endfor %}
{#
/**
* @file
* Default theme implementation for printed version of book outline.
*
* Available variables:
* - title: Top level node title.
* - head: Header tags.
* - language: Language object.
* - language_rtl: A flag indicating whether the current display language is a
* right to left language.
* - base_url: URL to the home page.
* - contents: Nodes within the current outline rendered through
* book-node-export-html.html.twig.
*
* @see template_preprocess()
* @see template_preprocess_book_export_html()
*
* @ingroup themeable
*/
#}
<!DOCTYPE html>
<html{{ html_attributes }}>
<head>
<title>{{ title }}></title>
{{ head }}
<base href="{{ base_url }}" />
<link type="text/css" rel="stylesheet" href="misc/print.css" />
{% if language_rtl %}
<link type="text/css" rel="stylesheet" href="misc/print-rtl.css" />
{% endif %}
</head>
<body>
{#
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) div 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.
#}
{% for i in 1..depth-1 if depth > 1 %}
<div class="section-{{ i }}">
{% endfor %}
{{ contents }}
{% for i in 1..depth-1 if depth > 1 %}
</div>
{% endfor %}
</body>
</html>
<?php
/**
* @file
* Default theme implementation for printed version of book outline.
*
* Available variables:
* - $title: Top level node title.
* - $head: Header tags.
* - $language: Language object.
* - $language_rtl: TRUE or FALSE depending on right to left language scripts.
* - $base_url: URL to home page.
* - $contents: Nodes within the current outline rendered through
* book-node-export-html.tpl.php.
*
* @see template_preprocess_book_export_html()
*
* @ingroup themeable
*/
?>
<!DOCTYPE html >
<html<?php print $html_attributes; ?>>
<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>
{#
/**
* @file
* 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()
* @see template_preprocess_book_navigation()
*
* @ingroup themeable
*/
#}
{% if tree or has_links %}
<nav id="book-navigation-{{ book_id }}" class="book-navigation">
{{ tree }}
{% if has_links %}
<h2 class="element-invisible">{{ 'Book Navigation'|t }}</h2>
<ul class="book-pager">
{% if prev_url %}
<li class="previous">
<a href="{{ prev_url }}" rel="prev" title="{{ 'Go to previous page'|t }}"><b>{{ '‹'|t }}</b> {{ prev_title }}</a>
</li>
{% endif %}
{% if parent_url %}
<li class="up">
<a href="{{ parent_url }}" title="{{ 'Go to parent page'|t }}">{{ 'Up'|t }}</a>
</li>
{% endif %}
{% if next_url %}
<li class="next">
<a href="{{ next_url }}" rel="next" title="{{ 'Go to next page'|t }}">{{ next_title }} <b>{{ '›'|t }}</b></a>
</li>
{% endif %}
</ul>
{% endif %}
</nav>
{% endif %}
<?php
/**
* @file
* 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()
*
* @ingroup themeable
*/
?>
<?php if ($tree || $has_links): ?>
<nav id="book-navigation-<?php print $book_id; ?>" class="book-navigation">
<?php print $tree; ?>
<?php if ($has_links): ?>
<h2 class="element-invisible"><?php print t('Book Navigation'); ?></h2>
<ul class="book-pager">
<?php if ($prev_url): ?>
<li class="previous">
<a href="<?php print $prev_url; ?>" rel="prev" title="<?php print t('Go to previous page'); ?>"><b><?php print t('‹'); ?></b> <?php print $prev_title; ?></a>
</li>
<?php endif; ?>
<?php if ($parent_url): ?>
<li class="up">
<a href="<?php print $parent_url; ?>" title="<?php print t('Go to parent page'); ?>"><?php print t('Up'); ?></a>
</li>
<?php endif; ?>
<?php if ($next_url): ?>
<li class="next">
<a href="<?php print $next_url; ?>" rel="next" title="<?php print t('Go to next page'); ?>"><?php print $next_title;?> <b><?php print t('›'); ?></b></a>
</li>
<?php endif; ?>
</ul>
<?php endif; ?>
</nav>
<?php endif; ?>
<?php {#
/** /**
* @file * @file
* Default theme implementation for a single node in a printer-friendly outline. * Default theme implementation for a single node in a printer-friendly outline.
* *
* @see book-node-export-html.tpl.php
* Where it is collected and printed out.
*
* Available variables: * Available variables:
* - $depth: Depth of the current node inside the outline. * - node: Fully loaded node.
* - $title: Node title. * - depth: Depth of the current node inside the outline.
* - $content: Node content. * - title: Node title.
* - $children: All the child nodes recursively rendered through this file. * - content: Node content.
* - children: All the child nodes recursively rendered through this file.
* *
* @see template_preprocess()
* @see template_preprocess_book_node_export_html() * @see template_preprocess_book_node_export_html()
* *
* @ingroup themeable * @ingroup themeable
*/ */
?> #}
<article id="node-<?php print $node->nid; ?>" class="section-<?php print $depth; ?>"> <article id="node-{{ node.nid }}" class="section-{{ depth }}">
<h1 class="book-heading"><?php print $title; ?></h1> <h1 class="book-heading">{{ title }}</h1>
<?php print $content; ?> {{ content }}
<?php print $children; ?> {{ children }}
</article> </article>
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