r48561 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48560‎ | r48561 | r48562 >
Date:01:06, 19 March 2009
Author:nad
Status:deferred
Tags:
Comment:
can't use user pref format with sortable table
Modified paths:
  • /trunk/extensions/RecordAdmin/RecordAdmin_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/RecordAdmin/RecordAdmin_body.php
@@ -296,7 +296,7 @@
297297 * Render a set of records returned by getRecords() as an HTML table
298298 */
299299 function renderRecords( $records, $cols = false, $sortable = true ) {
300 - global $wgUser, $wgLang;
 300+ global $wgUser;
301301 if ( count( $records ) < 1 ) return wfMsg( 'recordadmin-nomatch' );
302302
303303 $special = Title::makeTitle( NS_SPECIAL, 'RecordAdmin' );
@@ -323,8 +323,8 @@
324324
325325 $stripe = '';
326326 foreach ( $records as $r ) {
327 - $tsc = $wgLang->date( $r['created'], true, true ) . ', ' . $wgLang->time( $r['created'], true, true );
328 - $tsm = $wgLang->date( $r['modified'], true, true ) . ', ' . $wgLang->time( $r['modified'], true, true );
 327+ $tsc = $this->formatDate( $r['created'] );
 328+ $tsm = $this->formatDate( $r['modified'] );
329329 $t = $r[0];
330330 $u = $t->getLocalURL();
331331 $col = $r['title'];
@@ -352,6 +352,15 @@
353353 }
354354
355355 /**
 356+ * Take a MediaWiki timestamp and return a formatted date appropriate for sortable table
 357+ */
 358+ function formatDate( $ts ) {
 359+ global $wgLang;
 360+ $ts = preg_replace( "|^(....)(..)(..)(..)(..)(..)|", "$1-$2-$3 $4:$5:$6", $wgLang->userAdjust( $ts ) );
 361+ return date( 'd M Y, H:i', strtotime( $ts ) );
 362+ }
 363+
 364+ /**
356365 * Read in and prepare the form (for use as a search filter) for passed record type
357366 * - we're using the record's own form as a filter for searching for records
358367 * - extract only the content from between the form tags and remove any submit inputs

Status & tagging log