From 07eb4f34d75d77ce0e8b6e41ad77adce6d33ccf2 Mon Sep 17 00:00:00 2001
From: JohnAlbin <virtually.johnalbin@gmail.com>
Date: Mon, 13 Aug 2012 12:22:20 +0800
Subject: [PATCH] Issue #1311372: theme_mark() should use the <mark> element,
 not <span>

---
 core/includes/theme.inc                            | 28 ++++++++++++++--------
 core/modules/comment/comment.module                |  2 +-
 core/modules/comment/templates/comment.tpl.php     |  4 +---
 core/modules/node/node.admin.inc                   |  4 +++-
 core/modules/node/node.module                      |  4 +++-
 core/modules/system/system.theme.css               |  7 ++++--
 core/modules/tracker/tracker.pages.inc             |  5 +++-
 .../Drupal/translation/Tests/TranslationTest.php   |  2 +-
 core/modules/translation/translation.pages.inc     |  2 +-
 core/themes/bartik/templates/comment.tpl.php       |  5 +---
 10 files changed, 38 insertions(+), 25 deletions(-)

diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index d2fe902..23ea152 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -2101,24 +2101,32 @@ function theme_tablesort_indicator($variables) {
 }
 
 /**
- * Returns HTML for a marker for new or updated content.
+ * Returns HTML for marked content; often used 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.
+ *   - content: A string containing the text to mark.
+ *   - attributes: The attributes applied to the mark element.
+ *   - type: An optional integer representing the marker type to display; see
+ *     MARK_NEW and MARK_UPDATED. If type is specified, the "content" does not
+ *     need to be set since a default value will be provided for it.
  */
 function theme_mark($variables) {
   $type = $variables['type'];
-  global $user;
-  if ($user->uid) {
-    if ($type == MARK_NEW) {
-      return ' <span class="marker">' . t('new') . '</span>';
+  $content = $variables['content'];
+  if ($type == MARK_NEW) {
+    $variables['attributes']['class'][] = 'new';
+    if (!$content) {
+      $content = t('new');
     }
-    elseif ($type == MARK_UPDATED) {
-      return ' <span class="marker">' . t('updated') . '</span>';
+  }
+  elseif ($type == MARK_UPDATED) {
+    $variables['attributes']['class'][] = 'updated';
+    if (!$content) {
+      $content = t('updated');
     }
   }
+  return '<mark' . $variables['attributes'] . '>' . $content . '</mark>';
 }
 
 /**
@@ -3006,7 +3014,7 @@ function drupal_common_theme() {
       'variables' => array('style' => NULL),
     ),
     'mark' => array(
-      'variables' => array('type' => MARK_NEW),
+      'variables' => array('type' => MARK_READ, 'content' => NULL, 'attributes' => array()),
     ),
     'item_list' => array(
       'variables' => array('items' => array(), 'title' => '', 'type' => 'ul', 'attributes' => array()),
diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index 7b6eda4..6837a2a 100644
--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -1654,7 +1654,7 @@ function template_preprocess_comment(&$variables) {
   $variables['created'] = format_date($comment->created);
   $variables['changed'] = format_date($comment->changed);
 
-  $variables['new'] = !empty($comment->new) ? t('new') : '';
+  $variables['new'] = !empty($comment->new) ? theme('mark', array('type' => MARK_NEW)) : '';
   $variables['user_picture'] = theme_get_setting('toggle_comment_user_picture') ? theme('user_picture', array('account' => $comment)) : '';
   $variables['signature'] = $comment->signature;
 
diff --git a/core/modules/comment/templates/comment.tpl.php b/core/modules/comment/templates/comment.tpl.php
index 890e457..2b3924f 100644
--- a/core/modules/comment/templates/comment.tpl.php
+++ b/core/modules/comment/templates/comment.tpl.php
@@ -72,9 +72,7 @@
 <article class="<?php print $attributes['class']; ?> clearfix"<?php print $attributes; ?>>
 
   <?php print render($title_prefix); ?>
-  <?php if ($new): ?>
-    <mark class="new"><?php print $new; ?></mark>
-  <?php endif; ?>
+  <?php print $new; ?>
   <h3<?php print $title_attributes; ?>><?php print $title; ?></h3>
   <?php print render($title_suffix); ?>
 
diff --git a/core/modules/node/node.admin.inc b/core/modules/node/node.admin.inc
index b35e839..516b5bc 100644
--- a/core/modules/node/node.admin.inc
+++ b/core/modules/node/node.admin.inc
@@ -533,7 +533,6 @@ function node_admin_nodes() {
           '#title' => $node->label(),
           '#href' => 'node/' . $node->nid,
           '#options' => $l_options,
-          '#suffix' => ' ' . theme('mark', array('type' => node_mark($node->nid, $node->changed))),
         ),
       ),
       'type' => check_plain(node_get_type_label($node)),
@@ -541,6 +540,9 @@ function node_admin_nodes() {
       'status' => $node->status ? t('published') : t('not published'),
       'changed' => format_date($node->changed, 'short'),
     );
+    if ($type = node_mark($node->nid, $node->changed)) {
+      $options[$node->nid]['title']['data']['#suffix'] = ' ' . theme('mark', array('type' => $type));
+    }
     if ($multilingual) {
       $options[$node->nid]['language_name'] = language_name($node->langcode);
     }
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index 50395b1..adbcf59 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -2085,7 +2085,9 @@ function theme_node_recent_content($variables) {
 
   $output = '<div class="node-title">';
   $output .= l($node->label(), 'node/' . $node->nid);
-  $output .= theme('mark', array('type' => node_mark($node->nid, $node->changed)));
+  if ($type = node_mark($node->nid, $node->changed)) {
+    $output .= ' ' . theme('mark', array('type' => $type));
+  }
   $output .= '</div><div class="node-author">';
   $output .= theme('username', array('account' => user_load($node->uid)));
   $output .= '</div>';
diff --git a/core/modules/system/system.theme.css b/core/modules/system/system.theme.css
index ad901ea..1cfbdc8 100644
--- a/core/modules/system/system.theme.css
+++ b/core/modules/system/system.theme.css
@@ -1,4 +1,3 @@
-
 /**
  * @file
  * Basic styling for common markup.
@@ -114,7 +113,11 @@ input.form-checkbox,
 input.form-radio {
   vertical-align: middle;
 }
-.marker,
+.new,
+.updated {
+  background-color: transparent;
+  color: #f00;
+}
 .form-required {
   color: #f00;
 }
diff --git a/core/modules/tracker/tracker.pages.inc b/core/modules/tracker/tracker.pages.inc
index 853f50d..e80f242 100644
--- a/core/modules/tracker/tracker.pages.inc
+++ b/core/modules/tracker/tracker.pages.inc
@@ -72,11 +72,14 @@ function tracker_page($account = NULL, $set_title = FALSE) {
       $row = array(
         'type' => check_plain(node_get_type_label($node)),
         // Do not use $node->label(), because $node comes from the database.
-        'title' => array('data' => l($node->title, 'node/' . $node->nid) . ' ' . theme('mark', array('type' => node_mark($node->nid, $node->changed)))),
+        'title' => array('data' => l($node->title, 'node/' . $node->nid)),
         'author' => array('data' => theme('username', array('account' => $node))),
         'replies' => array('class' => array('replies'), 'data' => $comments),
         'last updated' => array('data' => t('!time ago', array('!time' => format_interval(REQUEST_TIME - $node->last_activity)))),
       );
+      if ($type = node_mark($node->nid, $node->changed)) {
+        $row['title']['data'] .= ' ' . theme('mark', array('type' => $type));
+      }
 
       // Adds extra RDFa markup to the $row array if the RDF module is enabled.
       if (function_exists('rdf_mapping_load')) {
diff --git a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php
index bc9094d..2c872f6 100644
--- a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php
+++ b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php
@@ -125,7 +125,7 @@ function testContentTranslation() {
 
     // Check to make sure that interface shows translation as outdated.
     $this->drupalGet('node/' . $node->nid . '/translate');
-    $this->assertRaw('<span class="marker">' . t('outdated') . '</span>', 'Translation marked as outdated.');
+    $this->assertRaw('<mark class="outdated">' . t('outdated') . '</mark>', 'Translation marked as outdated.');
 
     // Update translation and mark as updated.
     $edit = array();
diff --git a/core/modules/translation/translation.pages.inc b/core/modules/translation/translation.pages.inc
index 7a9880c..8a3f3c3 100644
--- a/core/modules/translation/translation.pages.inc
+++ b/core/modules/translation/translation.pages.inc
@@ -55,7 +55,7 @@ function translation_node_overview(Node $node) {
         }
       }
       $status = $translation_node->status ? t('Published') : t('Not published');
-      $status .= $translation_node->translate ? ' - <span class="marker">' . t('outdated') . '</span>' : '';
+      $status .= $translation_node->translate ? ' - ' . theme('mark', array('content' => t('outdated'), 'attributes' => array('class' => array('outdated')))) : '';
       if ($translation_node->nid == $tnid) {
         $language_name = t('<strong>@language_name</strong> (source)', array('@language_name' => $language_name));
       }
diff --git a/core/themes/bartik/templates/comment.tpl.php b/core/themes/bartik/templates/comment.tpl.php
index ef525c1..2f73a74 100644
--- a/core/themes/bartik/templates/comment.tpl.php
+++ b/core/themes/bartik/templates/comment.tpl.php
@@ -101,10 +101,7 @@
   <div class="comment-text">
     <div class="comment-arrow"></div>
 
-    <?php if ($new): ?>
-      <span class="new"><?php print $new; ?></span>
-    <?php endif; ?>
-
+    <?php print $new; ?>
     <?php print render($title_prefix); ?>
     <h3<?php print $title_attributes; ?>><?php print $title; ?></h3>
     <?php print render($title_suffix); ?>
-- 
1.8.0

