From bcc1a5a36a0b324f7b71facd087adb1891a33b53 Mon Sep 17 00:00:00 2001 From: JohnAlbin Date: Mon, 13 Aug 2012 12:22:20 +0800 Subject: [PATCH] Issue #1311372: theme_mark() should use the element, not --- 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..30b653b 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 ' ' . t('new') . ''; + $content = $variables['content']; + if ($type == MARK_NEW) { + $variables['attributes']['class'][] = 'new'; + if (!$content) { + $content = t('new'); } - elseif ($type == MARK_UPDATED) { - return ' ' . t('updated') . ''; + } + elseif ($type == MARK_UPDATED) { + $variables['attributes']['class'][] = 'updated'; + if (!$content) { + $content = t('updated'); } } + return '' . $content . ''; } /** 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 @@
> - - - + > 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 = '
'; $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 .= '
'; $output .= theme('username', array('account' => user_load($node->uid))); $output .= '
'; 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('' . t('outdated') . '', t('Translation marked as outdated.')); + $this->assertRaw('' . t('outdated') . '', 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 ? ' - ' . t('outdated') . '' : ''; + $status .= $translation_node->translate ? ' - ' . theme('mark', array('content' => t('outdated'), 'attributes' => array('class' => array('outdated')))) : ''; if ($translation_node->nid == $tnid) { $language_name = t('@language_name (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 @@
- - - - + > 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