Revision: 48561
Author:   nad
Date:     2009-03-19 01:06:55 +0000 (Thu, 19 Mar 2009)

Log Message:
-----------
can't use user pref format with sortable table

Modified Paths:
--------------
    trunk/extensions/RecordAdmin/RecordAdmin_body.php

Modified: trunk/extensions/RecordAdmin/RecordAdmin_body.php
===================================================================
--- trunk/extensions/RecordAdmin/RecordAdmin_body.php   2009-03-19 00:57:57 UTC 
(rev 48560)
+++ trunk/extensions/RecordAdmin/RecordAdmin_body.php   2009-03-19 01:06:55 UTC 
(rev 48561)
@@ -296,7 +296,7 @@
         * Render a set of records returned by getRecords() as an HTML table
         */
        function renderRecords( $records, $cols = false, $sortable = true ) {
-               global $wgUser, $wgLang;
+               global $wgUser;
                if ( count( $records ) < 1 ) return wfMsg( 
'recordadmin-nomatch' );
 
                $special  = Title::makeTitle( NS_SPECIAL, 'RecordAdmin' );
@@ -323,8 +323,8 @@
 
                $stripe = '';
                foreach ( $records as $r ) {
-                       $tsc = $wgLang->date( $r['created'], true, true ) . ', 
' . $wgLang->time( $r['created'], true, true );
-                       $tsm = $wgLang->date( $r['modified'], true, true ) . ', 
' . $wgLang->time( $r['modified'], true, true );
+                       $tsc = $this->formatDate( $r['created'] );
+                       $tsm = $this->formatDate( $r['modified'] );
                        $t   = $r[0];
                        $u   = $t->getLocalURL();
                        $col = $r['title'];
@@ -352,6 +352,15 @@
        }
 
        /**
+        * Take a MediaWiki timestamp and return a formatted date appropriate 
for sortable table
+        */
+       function formatDate( $ts ) {
+               global $wgLang;
+               $ts = preg_replace( "|^(....)(..)(..)(..)(..)(..)|", "$1-$2-$3 
$4:$5:$6", $wgLang->userAdjust( $ts ) );
+               return date( 'd M Y, H:i', strtotime( $ts ) );
+       }
+
+       /**
         * Read in and prepare the form (for use as a search filter) for passed 
record type
         * - we're using the record's own form as a filter for searching for 
records
         * - extract only the content from between the form tags and remove any 
submit inputs



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to