Commit 8dc1fab2 authored by alexpott's avatar alexpott

Issue #1938840 by chrisjlee, duellj, Cottser, shanethehat, idflood,...

Issue #1938840 by chrisjlee, duellj, Cottser, shanethehat, idflood, tlattimore: Bartik.theme - Convert PHPTemplate templates to Twig.
parent 624f9e62
......@@ -92,7 +92,7 @@ function bartik_process_page(&$variables) {
}
/**
* Implements hook_preprocess_HOOK() for maintenance-page.tpl.php.
* Implements hook_preprocess_HOOK() for maintenance-page.html.twig.
*/
function bartik_preprocess_maintenance_page(&$variables) {
// By default, site_name is set to Drupal if no db connection is available
......@@ -106,7 +106,7 @@ function bartik_preprocess_maintenance_page(&$variables) {
}
/**
* Implements hook_process_HOOK() for maintenance-page.tpl.php.
* Implements hook_process_HOOK() for maintenance-page.html.twig.
*/
function bartik_process_maintenance_page(&$variables) {
$site_config = config('system.site');
......@@ -124,6 +124,17 @@ function bartik_process_maintenance_page(&$variables) {
}
}
/**
* Implements hook_preprocess_HOOK() for node.html.twig.
*/
function bartik_preprocess_node(&$variables) {
// Remove the "Add new comment" link on teasers or when the comment form is
// displayed on the page.
if ($variables['teaser'] || !empty($variables['content']['comments']['comment_form'])) {
unset($variables['content']['links']['comment']['#links']['comment-add']);
}
}
/**
* Implements theme_menu_tree().
*/
......
<?php
/**
* @file
* Bartik's theme implementation to provide an HTML container for comments.
*
* Available variables:
* - $content: The array of content-related elements for the node. Use
* render($content) to print them all, or
* print a subset such as render($content['comment_form']).
* - $attributes: An instance of Attributes class that can be manipulated as an
* array and printed as a string.
* It includes the 'class' information, which includes:
* - comment-wrapper: The current template type, i.e., "theming hook".
* - $title_prefix (array): An array containing additional output populated by
* modules, intended to be displayed in front of the main title tag that
* appears in the template.
* - $title_suffix (array): An array containing additional output populated by
* modules, intended to be displayed after the main title tag that appears in
* the template.
*
* The following variables are provided for contextual information.
* - $node: Node entity the comments are attached to.
* The constants below the variables show the possible values and should be
* used for comparison.
* - $display_mode
* - COMMENT_MODE_FLAT
* - COMMENT_MODE_THREADED
*
* @see template_preprocess_comment_wrapper()
*
* @ingroup themeable
*/
?>
<section id="comments" <?php print $attributes; ?>>
<?php if ($content['comments'] && $node->type != 'forum'): ?>
<?php print render($title_prefix); ?>
<h2 class="title"><?php print t('Comments'); ?></h2>
<?php print render($title_suffix); ?>
<?php endif; ?>
<?php print render($content['comments']); ?>
<?php if ($content['comment_form']): ?>
<h2 class="title comment-form"><?php print t('Add new comment'); ?></h2>
<?php print render($content['comment_form']); ?>
<?php endif; ?>
</section>
<?php
{#
/**
* @file
* Bartik's theme implementation for comments.
*
* Available variables:
* - $author: Comment author. Can be a link or plain text.
* - $content: An array of comment items. Use render($content) to print them
* all, or print a subset such as render($content['field_example']). Use
* hide($content['field_example']) to temporarily suppress the printing of a
* given element.
* - $created: Formatted date and time for when the comment was created.
* - author: Comment author. Can be a link or plain text.
* - content: The content-related items for the comment display. Use
* {{ content }} to print them all, or print a subset such as
* {{ content.field_example }}. Use hide(content.field_example) to temporarily
* suppress the printing of a given element.
* - created: Formatted date and time for when the comment was created.
* Preprocess functions can reformat it by calling format_date() with the
* desired parameters on the $comment->created variable.
* - $changed: Formatted date and time for when the comment was last changed.
* desired parameters on the 'comment.created' variable.
* - changed: Formatted date and time for when the comment was last changed.
* Preprocess functions can reformat it by calling format_date() with the
* desired parameters on the $comment->changed variable.
* - $new: New comment marker.
* - $permalink: Comment permalink.
* - $submitted: Submission information created from $author and $created
* desired parameters on the 'comment.changed' variable.
* - new: New comment marker.
* - permalink: Comment permalink.
* - submitted: Submission information created from author and created
* during template_preprocess_comment().
* - $signature: Authors signature.
* - $status: Comment status. Possible values are:
* - user_picture: The comment author's profile picture.
* - signature: The comment author's signature.
* - status: Comment status. Possible values are:
* unpublished, published, or preview.
* - $title: Linked title.
* - $attributes: An instance of Attributes class that can be manipulated as an
* array and printed as a string.
* It includes the 'class' information, which includes:
* - title: Comment title, linked to the comment.
* - attributes.class: List of classes that can be used to style contextually
* through CSS. The default values can be one or more of the following:
* - comment: The current template type; e.g., 'theming hook'.
* - by-anonymous: Comment by an unregistered user.
* - by-node-author: Comment by the author of the parent node.
......@@ -35,100 +34,96 @@
* - unpublished: An unpublished comment visible only to administrators.
* - by-viewer: Comment by the user currently viewing the page.
* - new: New comment since the last visit.
* - $title_prefix (array): An array containing additional output populated by
* modules, intended to be displayed in front of the main title tag that
* appears in the template.
* - $title_suffix (array): An array containing additional output populated by
* modules, intended to be displayed after the main title tag that appears in
* the template.
* - title_prefix: Additional output populated by modules, intended to be
* displayed in front of the main title tag that appears in the template.
* - title_suffix: Additional output populated by modules, intended to be
* displayed after the main title tag that appears in the template.
* - content_attributes: List of classes for the styling of the comment content.
*
* These variables are provided to give context about the parent comment (if
* any):
* - $comment_parent: Full parent comment object (if any).
* - $parent_author: Equivalent to $author for the parent comment.
* - $parent_created: Equivalent to $created for the parent comment.
* - $parent_changed: Equivalent to $changed for the parent comment.
* - $parent_title: Equivalent to $title for the parent comment.
* - $parent_permalink: Equivalent to $permalink for the parent comment.
* - $parent: A text string of parent comment submission information created
* from $parent_author and $parent_created during
* template_preprocess_comment(). This information is presented to help
* screen readers follow lengthy discussion threads. You can hide this from
* sighted users using the class element-invisible.
* - comment_parent: Full parent comment entity (if any).
* - parent_author: Equivalent to author for the parent comment.
* - parent_created: Equivalent to created for the parent comment.
* - parent_changed: Equivalent to changed for the parent comment.
* - parent_title: Equivalent to title for the parent comment.
* - parent_permalink: Equivalent to permalink for the parent comment.
* - parent: A text string of parent comment submission information created from
* 'parent_author' and 'parent_created' during template_preprocess_comment().
* This information is presented to help screen readers follow lengthy
* discussion threads. You can hide this from sighted users using the class
* element-invisible.
*
* These two variables are provided for context:
* - $comment: Full comment object.
* - $node: Node entity the comments are attached to.
* - comment: Full comment object.
* - node: Node entity the comments are attached to.
*
* @see template_preprocess()
* @see template_preprocess_comment()
* @see template_process()
* @see theme_comment()
*
* @ingroup themeable
*/
?>
<article class="<?php print $attributes['class']; ?> clearfix"<?php print $attributes; ?> role="article">
#}
<article class="{{ attributes.class }} clearfix"{{ attributes }} role="article">
<header class="comment-header">
<div class="attribution">
<?php print render($user_picture); ?>
{{ user_picture }}
<div class="submitted">
<p class="commenter-name">
<?php print $author; ?>
{{ author }}
</p>
<p class="comment-time">
<?php print $created; ?>
{{ created }}
</p>
<p class="comment-permalink">
<?php print $permalink; ?>
{{ permalink }}
</p>
<?php
{#
// Indicate the semantic relationship between parent and child comments
// for accessibility. The list is difficult to navigate in a screen
// reader without this information.
if ($parent):
?>
#}
{% if parent %}
<p class="comment-parent element-invisible">
<?php print $parent; ?>
{{ parent }}
</p>
<?php endif; ?>
{% endif %}
</div>
</div> <!-- /.attribution -->
<div class="comment-text">
<div class="comment-arrow"></div>
<?php if ($new): ?>
<span class="new"><?php print $new; ?></span>
<?php endif; ?>
{% if new %}
<span class="new">{{ new }}</span>
{% endif %}
<?php print render($title_prefix); ?>
<h3<?php print $title_attributes; ?>><?php print $title; ?></h3>
<?php print render($title_suffix); ?>
{{ title_prefix }}
<h3{{ title_attributes }}>{{ title }}</h3>
{{ title_suffix }}
</div> <!-- /.comment-text -->
</header> <!-- /.comment-header -->
<div class="content"<?php print $content_attributes; ?>>
<?php
// We hide the comments and links now so that we can render them later.
hide($content['links']);
print render($content);
?>
<div{{ content_attributes }}>
{# We hide the links now so that we can render them later. #}
{% hide(content.links) %}
{{ content }}
</div> <!-- /.content -->
<footer class="comment-footer">
<?php if ($signature): ?>
<div class="user-signature clearfix">
<?php print $signature; ?>
</div>
<?php endif; ?>
{% if signature %}
<div class="user-signature clearfix">
{{ signature }}
</div>
{% endif %}
<nav>
<?php print render($content['links']); ?>
{{ content.links }}
</nav>
</footer> <!-- /.comment-footer -->
......
<?php
{#
/**
* @file
* Bartik's theme implementation to display a single Drupal page while offline.
*
* All of the available variables are mirrored in page.tpl.php.
* All of the available variables are mirrored in page.html.twig.
*
* @see template_preprocess()
* @see template_preprocess_maintenance_page()
......@@ -12,52 +11,52 @@
*
* @ingroup themeable
*/
?>
#}
<!DOCTYPE html>
<html lang="<?php print $language->langcode; ?>" dir="<?php print $language->dir; ?>">
<html lang="{{ language.langcode }}" dir="{{ language.dir }}">
<head>
<?php print $head; ?>
<title><?php print $head_title; ?></title>
<?php print $styles; ?>
<?php print $scripts; ?>
{{ head }}
<title>{{ head_title }}</title>
{{ styles }}
{{ scripts }}
</head>
<body class="<?php print $attributes['class']; ?>" <?php print $attributes;?>>
<body class="{{ attributes.class }}"{{ attributes }}>
<div id="skip-link">
<a href="#main-content" class="element-invisible element-focusable"><?php print t('Skip to main content'); ?></a>
<a href="#main-content" class="element-invisible element-focusable">{{ 'Skip to main content'|t }}</a>
</div>
<div id="page-wrapper"><div id="page">
<header id="header" role="banner"><div class="section clearfix">
<?php if ($site_name || $site_slogan): ?>
<div id="name-and-slogan"<?php if ($hide_site_name && $hide_site_slogan) { print ' class="element-invisible"'; } ?>>
<?php if ($site_name): ?>
<div id="site-name"<?php if ($hide_site_name) { print ' class="element-invisible"'; } ?>>
{% if site_name or site_slogan %}
<div id="name-and-slogan"{{ hide_site_name and hide_site_slogan ? ' class="element-invisible"' }}>
{% if site_name %}
<div id="site-name"{{ hide_site_name ? ' class="element-invisible"' }}>
<strong>
<a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
<a href="{{ front_page }}" title="{{ 'Home'|t }}" rel="home"><span>{{ site_name }}</span></a>
</strong>
</div>
<?php endif; ?>
<?php if ($site_slogan): ?>
<div id="site-slogan"<?php if ($hide_site_slogan) { print ' class="element-invisible"'; } ?>>
<?php print $site_slogan; ?>
{% endif %}
{% if site_slogan %}
<div id="site-slogan"{{ hide_site_slogan ? ' class="element-invisible"' }}>
{{ site_slogan }}
</div>
<?php endif; ?>
{% endif %}
</div> <!-- /#name-and-slogan -->
<?php endif; ?>
{% endif %}
</div></header> <!-- /.section, /#header -->
<div id="main-wrapper"><div id="main" class="clearfix">
<main id="content" class="column" role="main"><section class="section">
<a id="main-content"></a>
<?php if ($title): ?><h1 class="title" id="page-title"><?php print $title; ?></h1><?php endif; ?>
<?php print $content; ?>
<?php if ($messages): ?>
{% if title %}<h1 class="title" id="page-title">{{ title }}</h1>{% endif %}
{{ content }}
{% if messages %}
<div id="messages"><div class="section clearfix">
<?php print $messages; ?>
{{ messages }}
</div></div> <!-- /.section, /#messages -->
<?php endif; ?>
{% endif %}
</section></main> <!-- /.section, /#content -->
</div></div> <!-- /#main, /#main-wrapper -->
......
{#
/**
* @file
* Bartik's theme implementation to display a node.
*
* Available variables:
* - node: Full node entity.
* - type: The type of the node, for example, "page" or "article".
* - uid: The user ID of the node author.
* - created: Formatted creation date. Preprocess functions can reformat it by
* calling format_date() with the desired parameters on
* $variables['node']->created.
* - promote: Whether the node is promoted to the front page.
* - sticky: Whether the node is 'sticky'. Sticky nodes are ordered above
* other non-sticky nodes in teaser listings
* - status: Whether the node is published.
* - comment: A value representing the comment status of the current node. May
* be one of the following:
* - 0: The comment form and any existing comments are hidden.
* - 1: Comments are closed. No new comments may be posted, but existing
* comments are displayed.
* - 2: Comments are open on this node.
* - comment_count: Number of comments attached to the node.
* - label: The title of the node.
* - content: All node items. Use {{ content }} to print them all,
* or print a subset such as {{ content.field_example }}. Use
* {% hide(content.field_example) %} to temporarily suppress the printing
* of a given element.
* - user_picture: The node author's picture from user-picture.html.twig.
* - date: Formatted creation date. Preprocess functions can reformat it by
* calling format_date() with the desired parameters on
* $variables['created'].
* - name: Themed username of node author output from theme_username().
* - node_url: Direct URL of the current node.
* - display_submitted: Whether submission information should be displayed.
* - submitted: Submission information created from name and date during
* template_preprocess_node().
* - attributes: HTML attributes for the containing element.
* The attributes.class element may contain one or more of the following
* classes:
* - node: The current template type (also known as a "theming hook").
* - node-[type]: The current node type. For example, if the node is a
* "Article" it would result in "node-article". Note that the machine
* name will often be in a short form of the human readable label.
* - view-mode-[view_mode]: The View Mode of the node; for example, a teaser
* would result in: "view-mode-teaser", and full: "view-mode-full".
* - preview: Whether a node is in preview mode.
* The following are controlled through the node publishing options.
* - promoted: Appears on nodes promoted to the front page.
* - sticky: Appears on nodes ordered above other non-sticky nodes in teaser
* listings.
* - unpublished: Appears on unpublished nodes visible only to site admins.
* - title_prefix: Additional output populated by modules, intended to be
* displayed in front of the main title tag that appears in the template.
* - title_suffix: Additional output populated by modules, intended to be
* displayed after the main title tag that appears in the template.
* - view_mode: View mode; for example, "teaser" or "full".
* - teaser: Flag for the teaser state. Will be true if view_mode is 'teaser'.
* - page: Flag for the full page state. Will be true if view_mode is 'full'.
* - readmore: Flag for more state. Will be true if the teaser content of the
* node cannot hold the main body content.
* - is_front: Flag for front. Will be true when presented on the front page.
* - logged_in: Flag for authenticated user status. Will be true when the
* current user is a logged-in member.
* - is_admin: Flag for admin user status. Will be true when the current user
* is an administrator.
*
* In field variables, each field instance attached to the node a corresponding
* variable is defined; for example, 'node.body' becomes 'body'. When needing to
* access a field's raw values, developers/themers are strongly encouraged to
* use these variables. Otherwise they will have to explicitly specify the
* desired field language; for example, 'node.body.en', thus overriding any
* language negotiation rule that may have been applied previously.
*
* @see template_preprocess()
* @see template_preprocess_node()
*
* @ingroup themeable
*/
#}
<article id="node-{{ node.nid }}" class="{{ attributes.class}} clearfix"{{ attributes }} role="article">
<header>
{{ title_prefix }}
{% if not page %}
<h2{{ title_attributes }}>
<a href="{{ node_url }}">{{ label }}</a>
</h2>
{% endif %}
{{ title_suffix }}
{% if display_submitted %}
<div class="meta submitted">
{{ user_picture }}
{{ submitted }}
</div>
{% endif %}
</header>
<div class="content clearfix"{{ content_attributes }}>
{# We hide the comments and links now so that we can render them later. #}
{% hide(content.comments) %}
{% hide(content.links) %}
{{ content }}
</div>
{% if content.links %}
<footer class="link-wrapper">
{{ content.links }}
</footer>
{% endif %}
{{ content.comments }}
</article>
<?php
/**
* @file
* Bartik's theme implementation to display a node.
*
* Available variables:
* - $label: the (sanitized) title of the node.
* - $content: An array of node items. Use render($content) to print them all,
* or print a subset such as render($content['field_example']). Use
* hide($content['field_example']) to temporarily suppress the printing of a
* given element.
* - $user_picture: The node author's picture. Use render() when printing.
* - $date: Formatted creation date. Preprocess functions can reformat it by
* calling format_date() with the desired parameters on the $created variable.
* - $name: Themed username of node author output from theme_username().
* - $node_url: Direct URL of the current node.
* - $display_submitted: Whether submission information should be displayed.
* - $submitted: Submission information created from $name and $date during
* template_preprocess_node().
* - $attributes: An instance of Attributes class that can be manipulated as an
* array and printed as a string.
* It includes the 'class' information, which includes:
* - node: The current template type; for example, "theming hook".
* - node-[type]: The current node type. For example, if the node is a
* "Article" it would result in "node-article". Note that the machine
* name will often be in a short form of the human readable label.
* - view-mode-[view_mode]: The View Mode of the node; for example, "teaser"
* or "full".
* - preview: Nodes in preview mode.
* The following are controlled through the node publishing options.
* - promoted: Nodes promoted to the front page.
* - sticky: Nodes ordered above other non-sticky nodes in teaser
* listings.
* - unpublished: Unpublished nodes visible only to administrators.
* - $title_prefix (array): An array containing additional output populated by
* modules, intended to be displayed in front of the main title tag that
* appears in the template.
* - $title_suffix (array): An array containing additional output populated by
* modules, intended to be displayed after the main title tag that appears in
* the template.
*
* Other variables:
* - $node: Full node entity. Contains data that may not be safe.
* - $type: Node type; for example, page, article, etc.
* - $comment_count: Number of comments attached to the node.
* - $uid: User ID of the node author.
* - $created: Time the node was published formatted in Unix timestamp.
*
* Node status variables:
* - $view_mode: View mode; for example, "teaser" or "full".
* - $teaser: Flag for the teaser state (shortcut for $view_mode == 'teaser').
* - $page: Flag for the full page state.
* - $promote: Flag for front page promotion state.
* - $sticky: Flags for sticky post setting.
* - $status: Flag for published status.
* - $comment: State of comment settings for the node.
* - $is_front: Flags true when presented in the front page.
* - $logged_in: Flags true when the current user is a logged-in member.
* - $is_admin: Flags true when the current user is an administrator.
*
* Field variables: For each field instance attached to the node a
* corresponding variable is defined; for example, $node->body becomes $body.
* When needing to access a field's raw values, developers/themers are strongly
* encouraged to use these variables. Otherwise they will have to explicitly
* specify the desired field language; for example, $node->body['en'], thus
* overriding any language negotiation rule that was previously applied.
*
* @see template_preprocess()
* @see template_preprocess_node()
* @see template_process()
*
* @ingroup themeable
*/
?>
<article id="node-<?php print $node->nid; ?>" class="<?php print $attributes['class']; ?> clearfix"<?php print $attributes; ?> role="article">
<header>
<?php print render($title_prefix); ?>
<?php if (!$page): ?>
<h2<?php print $title_attributes; ?>>
<a href="<?php print $node_url; ?>"><?php print $label; ?></a>
</h2>
<?php endif; ?>
<?php print render($title_suffix); ?>
<?php if ($display_submitted): ?>
<div class="meta submitted">
<?php print render($user_picture); ?>
<?php print $submitted; ?>
</div>
<?php endif; ?>
</header>
<div class="content clearfix"<?php print $content_attributes; ?>>
<?php
// We hide the comments and links now so that we can render them later.
hide($content['comments']);
hide($content['links']);
print render($content);
?>
</div>
<?php
// Remove the "Add new comment" link on the teaser page or if the comment
// form is being displayed on the same page.
if ($teaser || !empty($content['comments']['comment_form'])) {
unset($content['links']['comment']['#links']['comment-add']);
}
// Only display the footer if there are links.
$links = render($content['links']);
if ($links):
?>
<footer class="link-wrapper">
<?php print $links; ?>
</footer>
<?php endif; ?>
<?php print render($content['comments']); ?>
</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