From 1d47e0a030b3dbf1a9753cef7b3de5182bc13eeb Mon Sep 17 00:00:00 2001 From: webchick <drupal@webchick.net> Date: Thu, 12 Jun 2014 20:43:12 -0700 Subject: [PATCH] Issue #1939092 by mgifford, dbazuin, jenlampton, azinoman, pwieck, Cottser, joelpittet, larowlan: Convert theme_mark() to Twig. --- core/includes/theme.inc | 21 +------------------ core/modules/system/templates/mark.html.twig | 22 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 20 deletions(-) create mode 100644 core/modules/system/templates/mark.html.twig diff --git a/core/includes/theme.inc b/core/includes/theme.inc index e338fd15906e..03d0df0c2cb5 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1672,26 +1672,6 @@ function template_preprocess_table(&$variables) { } } -/** - * Returns HTML for a marker for new or updated content. - * - * @param $variables - * An associative array containing: - * - type: Number representing the marker type to display. See MARK_NEW, - * MARK_UPDATED, MARK_READ. - */ -function theme_mark($variables) { - $type = $variables['status']; - if (\Drupal::currentUser()->isAuthenticated()) { - if ($type == MARK_NEW) { - return ' <span class="marker">' . t('new') . '</span>'; - } - elseif ($type == MARK_UPDATED) { - return ' <span class="marker">' . t('updated') . '</span>'; - } - } -} - /** * Prepares variables for item list templates. * @@ -2570,6 +2550,7 @@ function drupal_common_theme() { ), 'mark' => array( 'variables' => array('status' => MARK_NEW), + 'template' => 'mark', ), 'item_list' => array( 'variables' => array('items' => array(), 'title' => '', 'list_type' => 'ul', 'attributes' => array(), 'empty' => NULL), diff --git a/core/modules/system/templates/mark.html.twig b/core/modules/system/templates/mark.html.twig new file mode 100644 index 000000000000..2798bb00828d --- /dev/null +++ b/core/modules/system/templates/mark.html.twig @@ -0,0 +1,22 @@ +{# +/** + * @file + * Default theme implementation for a marker for new or updated content. + * + * Available variables: + * - status: Number representing the marker status to display. Use the constants + * below for comparison: + * - MARK_NEW + * - MARK_UPDATED + * - MARK_READ + * + * @ingroup themeable + */ +#} +{% if logged_in %} + {% if status is constant('MARK_NEW') %} + <span class="marker">{{ 'new'|t }}</span> + {% elseif status is constant('MARK_UPDATED') %} + <span class="marker">{{ 'updated'|t }}</span> + {% endif %} +{% endif %} -- GitLab