From 23357e25e5b7c59bdc69de039cc6e38cab1437a3 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Mon, 10 Jun 2013 13:21:46 +0100 Subject: [PATCH] Issue #1987408 by chrisjlee, jstoller, gnuget, Cottser: Overlay.module - Convert theme_ functions to Twig. --- core/modules/overlay/overlay.module | 24 +++++++------------ .../overlay-disable-message.html.twig | 19 +++++++++++++++ 2 files changed, 27 insertions(+), 16 deletions(-) create mode 100644 core/modules/overlay/templates/overlay-disable-message.html.twig diff --git a/core/modules/overlay/overlay.module b/core/modules/overlay/overlay.module index 14c6c21b08b..07218db5cfa 100644 --- a/core/modules/overlay/overlay.module +++ b/core/modules/overlay/overlay.module @@ -79,6 +79,7 @@ function overlay_theme() { ), 'overlay_disable_message' => array( 'render element' => 'element', + 'template' => 'overlay-disable-message', ), ); } @@ -362,17 +363,17 @@ function overlay_disable_message() { } /** - * Returns the HTML for the message about how to disable the overlay. + * Prepares variables for overlay disable message templates. * - * @param $variables + * Default template: overlay-disable-message.html.twig. + * + * @param array $variables * An associative array with an 'element' element, which itself is an * associative array containing: * - profile_link: The link to this user's account. * - dismiss_message_link: The link to dismiss the overlay. - * - * @ingroup themeable */ -function theme_overlay_disable_message($variables) { +function template_preprocess_overlay_disable_message(&$variables) { $element = $variables['element']; // Add CSS classes to hide the links from most sighted users, while keeping @@ -386,17 +387,8 @@ function theme_overlay_disable_message($variables) { } } - // Render the links. - $output = drupal_render($element['profile_link']) . ' ' . drupal_render($element['dismiss_message_link']); - - // Add a heading for screen-reader users. The heading doesn't need to be seen - // by sighted users. - $output = '

' . t('Options for the administrative overlay') . '

' . $output; - - // Wrap in a container for styling. - $output = '
' . $output . '
'; - - return $output; + $variables['profile_link'] = $element['profile_link']; + $variables['dismiss_link'] = $element['dismiss_message_link']; } /** diff --git a/core/modules/overlay/templates/overlay-disable-message.html.twig b/core/modules/overlay/templates/overlay-disable-message.html.twig new file mode 100644 index 00000000000..e752da5415a --- /dev/null +++ b/core/modules/overlay/templates/overlay-disable-message.html.twig @@ -0,0 +1,19 @@ +{# +/** + * @file + * Default theme implementation for the message about disabling the overlay. + * + * Available variables: + * - profile_link: The link to this user's account. + * - dismiss_link: The link to dismiss the overlay. + * + * @see template_preprocess() + * @see template_preprocess_overlay_disable_message() + * + * @ingroup themeable + */ +#} +
+

{{ 'Options for the administrative overlay'|t }}

+ {{ profile_link }} {{ dismiss_link }} +