summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2013-05-24 16:54:30 (GMT)
committerAlex Pott2013-05-24 16:54:30 (GMT)
commitf2aa485dfc47e1d0a278b6a66ffe3a71a315c977 (patch)
tree311f67ab26804722ecb130904b9dc31bf836d77f
parent3d24449a97d855d0d51f85f2ff5d6182bed5849f (diff)
Issue #1898050 by duellj, Cottser, meeli, dsdart, Fabianx | c4rl: book.module - Convert PHPTemplate templates to Twig.
-rw-r--r--core/modules/book/book.module43
-rw-r--r--core/modules/book/templates/book-all-books-block.html.twig (renamed from core/modules/book/templates/book-all-books-block.tpl.php)19
-rw-r--r--core/modules/book/templates/book-export-html.html.twig51
-rw-r--r--core/modules/book/templates/book-export-html.tpl.php52
-rw-r--r--core/modules/book/templates/book-navigation.html.twig59
-rw-r--r--core/modules/book/templates/book-navigation.tpl.php58
-rw-r--r--core/modules/book/templates/book-node-export-html.html.twig23
-rw-r--r--core/modules/book/templates/book-node-export-html.tpl.php25
8 files changed, 166 insertions, 164 deletions
diff --git a/core/modules/book/book.module b/core/modules/book/book.module
index 3ac47f4..4ae3740 100644
--- a/core/modules/book/book.module
+++ b/core/modules/book/book.module
@@ -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
* to the structured data but can also simply iterate over all elements and
@@ -965,9 +967,8 @@ function book_preprocess_block(&$variables) {
*
* @param array $variables
* An associative array containing the following key:
- * - book_menus
- *
- * @see book-all-books-block.tpl.php
+ * - book_menus: An associative array containing renderable menu links for all
+ * book menus.
*/
function template_preprocess_book_all_books_block(&$variables) {
// Remove all non-renderable elements.
@@ -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
* An associative array containing the following key:
- * - book_link
- *
- * @see book-navigation.tpl.php
+ * - book_link: An associative array of book link properties.
+ * Properties used: bid, link_title, depth, plid, mlid.
*/
function template_preprocess_book_navigation(&$variables) {
drupal_add_css(drupal_get_path('module', 'book') . '/book.theme.css');
@@ -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
- * An associative array containing the following keys:
- * - title
- * - contents
- * - depth
+ * Default template: book-export-html.html.twig.
*
- * @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) {
global $base_url;
@@ -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
* An associative array containing the following keys:
- * - node
- * - children
- *
- * @see book-node-export-html.tpl.php
+ * - node: The node that will be output.
+ * - children: All the rendered child nodes within the current node. Defaults
+ * to an empty string.
*/
function template_preprocess_book_node_export_html(&$variables) {
$variables['depth'] = $variables['node']->book['depth'];
diff --git a/core/modules/book/templates/book-all-books-block.tpl.php b/core/modules/book/templates/book-all-books-block.html.twig
index 8e5343b..518c1e1 100644
--- a/core/modules/book/templates/book-all-books-block.tpl.php
+++ b/core/modules/book/templates/book-all-books-block.html.twig
@@ -1,5 +1,4 @@
-<?php
-
+{#
/**
* @file
* Default theme implementation for rendering book outlines within a block.
@@ -8,16 +7,18 @@
* pages", which presents multiple independent books on all pages.
*
* Available variables:
- * - $book_menus: Array of book outlines keyed to the parent book ID. Call
- * render() on each to print it as an unordered list.
+ * - book_menus: Book outlines.
+ * - book_id: The parent book ID.
+ * - menu: The top-level book links.
*
+ * @see template_preprocess()
* @see template_preprocess_book_all_books_block()
*
* @ingroup themeable
*/
-?>
-<?php foreach ($book_menus as $book_id => $menu): ?>
- <nav id="book-block-menu-<?php print $book_id; ?>" class="book-block-menu">
- <?php print render($menu); ?>
+#}
+{% for book_id, menu in book_menus %}
+ <nav id="book-block-menu-{{ book_id }}" class="book-block-menu">
+ {{ menu }}
</nav>
-<?php endforeach; ?>
+{% endfor %}
diff --git a/core/modules/book/templates/book-export-html.html.twig b/core/modules/book/templates/book-export-html.html.twig
new file mode 100644
index 0000000..95d5de3
--- /dev/null
+++ b/core/modules/book/templates/book-export-html.html.twig
@@ -0,0 +1,51 @@
+{#
+/**
+ * @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>
diff --git a/core/modules/book/templates/book-export-html.tpl.php b/core/modules/book/templates/book-export-html.tpl.php
deleted file mode 100644
index df04dab..0000000
--- a/core/modules/book/templates/book-export-html.tpl.php
+++ /dev/null
@@ -1,52 +0,0 @@
-<?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>
diff --git a/core/modules/book/templates/book-navigation.html.twig b/core/modules/book/templates/book-navigation.html.twig
new file mode 100644
index 0000000..82e02fd
--- /dev/null
+++ b/core/modules/book/templates/book-navigation.html.twig
@@ -0,0 +1,59 @@
+{#
+/**
+ * @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 %}
diff --git a/core/modules/book/templates/book-navigation.tpl.php b/core/modules/book/templates/book-navigation.tpl.php
deleted file mode 100644
index cdc1278..0000000
--- a/core/modules/book/templates/book-navigation.tpl.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<?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; ?>
diff --git a/core/modules/book/templates/book-node-export-html.html.twig b/core/modules/book/templates/book-node-export-html.html.twig
new file mode 100644
index 0000000..7168de6
--- /dev/null
+++ b/core/modules/book/templates/book-node-export-html.html.twig
@@ -0,0 +1,23 @@
+{#
+/**
+ * @file
+ * Default theme implementation for a single node in a printer-friendly outline.
+ *
+ * Available variables:
+ * - node: Fully loaded node.
+ * - 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()
+ * @see template_preprocess_book_node_export_html()
+ *
+ * @ingroup themeable
+ */
+#}
+<article id="node-{{ node.nid }}" class="section-{{ depth }}">
+ <h1 class="book-heading">{{ title }}</h1>
+ {{ content }}
+ {{ children }}
+</article>
diff --git a/core/modules/book/templates/book-node-export-html.tpl.php b/core/modules/book/templates/book-node-export-html.tpl.php
deleted file mode 100644
index 50c878f..0000000
--- a/core/modules/book/templates/book-node-export-html.tpl.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-
-/**
- * @file
- * 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:
- * - $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()
- *
- * @ingroup themeable
- */
-?>
-<article 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; ?>
-</article>