r48247 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48246‎ | r48247 | r48248 >
Date:23:51, 9 March 2009
Author:werdna
Status:resolved (Comments)
Tags:
Comment:
Surround dynamic dates with a <span>. Bug 17785.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/parser/DateFormatter.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/DateFormatter.php
@@ -155,12 +155,22 @@
156156 $bits[$key{$p}] = $matches[$p+1];
157157 }
158158 }
159 -
 159+
 160+ return $this->formatDate( $bits );
 161+ }
 162+
 163+ function formatDate( $bits ) {
160164 $format = $this->targets[$this->mTarget];
161165
162166 # Construct new date
163167 $text = '';
164168 $fail = false;
 169+
 170+ // Pre-generate y/Y stuff because we need the year for the <span> title.
 171+ if ( !isset( $bits['y'] ) )
 172+ $bits['y'] = $this->makeIsoYear( $bits['Y'] );
 173+ if ( !isset( $bits['Y'] ) )
 174+ $bits['Y'] = $this->makeNormalYear( $bits['y'] );
165175
166176 for ( $p=0; $p < strlen( $format ); $p++ ) {
167177 $char = $format{$p};
@@ -185,11 +195,7 @@
186196 }
187197 break;
188198 case 'y': # ISO year
189 - if ( !isset( $bits['y'] ) ) {
190 - $text .= $this->makeIsoYear( $bits['Y'] );
191 - } else {
192 - $text .= $bits['y'];
193 - }
 199+ $text .= $bits['y'];
194200 break;
195201 case 'j': # ordinary day of month
196202 if ( !isset($bits['j']) ) {
@@ -212,11 +218,7 @@
213219 }
214220 break;
215221 case 'Y': # ordinary (optional BC) year
216 - if ( !isset( $bits['Y'] ) ) {
217 - $text .= $this->makeNormalYear( $bits['y'] );
218 - } else {
219 - $text .= $bits['Y'];
220 - }
 222+ $text .= $bits['Y'];
221223 break;
222224 default:
223225 $text .= $char;
@@ -225,6 +227,13 @@
226228 if ( $fail ) {
227229 $text = $matches[0];
228230 }
 231+
 232+ $isoDate = $bits['y'].$bits['m'].$bits['d'];
 233+
 234+ // Output is not strictly HTML (it's wikitext), but <span> is whitelisted.
 235+ $text = Xml::tags( 'span',
 236+ array( 'class' => 'mw-formatted-date', 'title' => $isoDate ), $text );
 237+
229238 return $text;
230239 }
231240
Index: trunk/phase3/RELEASE-NOTES
@@ -136,6 +136,8 @@
137137 name of the last user to edit the page
138138 * LinkerMakeExternalLink now has an $attribs parameter for link attributes and
139139 a $linkType parameter for the type of external link being made
 140+* (bug 17785) Dynamic dates surrounded with a <span> tag, fixing sortable tables with
 141+ dynamic dates.
140142
141143 === Bug fixes in 1.15 ===
142144 * (bug 16968) Special:Upload no longer throws useless warnings.

Comments

#Comment by Brion VIBBER (talk | contribs)   23:30, 18 March 2009

Needs parser tests

Status & tagging log