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

---
 core/includes/common.inc                           |  2 +-
 core/includes/theme.inc                            | 27 ++++++++++++++--------
 core/modules/comment/comment.module                |  2 +-
 core/modules/comment/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 +---
 core/themes/seven/reset.css                        |  3 +--
 12 files changed, 39 insertions(+), 28 deletions(-)

diff --git a/core/includes/common.inc b/core/includes/common.inc
index 17e1363..d796eea 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -6598,7 +6598,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/includes/theme.inc b/core/includes/theme.inc
index f807979..934c7d7 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -649,7 +649,7 @@ function _theme_build_registry($theme, $base_theme, $theme_engine) {
  *     their base theme), direct sub-themes of sub-themes, etc. The keys are
  *     the themes' machine names, and the values are the themes' human-readable
  *     names. This element is not set if there are no themes on the system that
- *     declare this theme as their base theme. 
+ *     declare this theme as their base theme.
 */
 function list_themes($refresh = FALSE) {
   $list = &drupal_static(__FUNCTION__, array());
@@ -1982,24 +1982,31 @@ 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.
+ *   - type (optional): An integer representing the marker type to display. See
+ *     MARK_NEW and MARK_UPDATED.
+ *   - content (optional): A string containing the text to mark.
+ *   - attributes: The attributes applied to the mark element.
  */
 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' . drupal_attributes($variables['attributes']) . '>' . $content . '</mark>';
 }
 
 /**
diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index 39faf90..034149d 100644
--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -2130,7 +2130,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/comment.tpl.php b/core/modules/comment/comment.tpl.php
index 72d7847..233c6e5 100644
--- a/core/modules/comment/comment.tpl.php
+++ b/core/modules/comment/comment.tpl.php
@@ -56,9 +56,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 d425232..d629c1d 100644
--- a/core/modules/node/node.admin.inc
+++ b/core/modules/node/node.admin.inc
@@ -488,7 +488,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_type_get_name($node)),
@@ -496,6 +495,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 be15dee..a725141 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -2295,7 +2295,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 d5f41e1..6b35a16 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.
@@ -110,7 +109,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 f012264..ae8865d 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_type_get_name($node->type)),
         // 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 a409150..0418a2f 100644
--- a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php
+++ b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php
@@ -124,7 +124,7 @@ class TranslationTest extends WebTestBase {
 
     // Check to make sure that interface shows translation as outdated.
     $this->drupalGet('node/' . $node->nid . '/translate');
-    $this->assertRaw('<span class="marker">' . t('outdated') . '</span>', t('Translation marked as outdated.'));
+    $this->assertRaw('<mark class="outdated">' . t('outdated') . '</mark>', t('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 a501870..984c84b 100644
--- a/core/modules/translation/translation.pages.inc
+++ b/core/modules/translation/translation.pages.inc
@@ -52,7 +52,7 @@ function translation_node_overview(Node $node) {
         $options[] = empty($links->links[$langcode]['href']) ? l($text, $path) : l($text, $links->links[$langcode]['href'], $links->links[$langcode]);
       }
       $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 04aa8e5..08c6d05 100644
--- a/core/themes/bartik/templates/comment.tpl.php
+++ b/core/themes/bartik/templates/comment.tpl.php
@@ -77,10 +77,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); ?>
diff --git a/core/themes/seven/reset.css b/core/themes/seven/reset.css
index de53f28..edcf52f 100644
--- a/core/themes/seven/reset.css
+++ b/core/themes/seven/reset.css
@@ -1,4 +1,3 @@
-
 /**
  * Reset CSS styles.
  *
@@ -59,6 +58,7 @@ li,
 fieldset,
 form,
 input,
+mark,
 select,
 textarea,
 label,
@@ -102,7 +102,6 @@ tr.even .form-item,
 .form-radios,
 .form-checkboxes .form-item,
 .form-radios .form-item,
-.marker,
 .form-required,
 .more-link,
 .more-help-link,
-- 
1.7.11.4


From 459e38a41c712a48ade245d19fe36a9cead1e749 Mon Sep 17 00:00:00 2001
From: JohnAlbin <virtually.johnalbin@gmail.com>
Date: Sun, 19 Aug 2012 18:54:11 +0200
Subject: [PATCH 2/2] Fix docs

---
 core/includes/theme.inc | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 934c7d7..e20af19 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -1986,10 +1986,11 @@ function theme_tablesort_indicator($variables) {
  *
  * @param $variables
  *   An associative array containing:
- *   - type (optional): An integer representing the marker type to display. See
- *     MARK_NEW and MARK_UPDATED.
- *   - content (optional): A string containing the text to mark.
+ *   - 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'];
-- 
1.7.11.4

