r77608 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77607‎ | r77608 | r77609 >
Date:21:51, 2 December 2010
Author:vyznev
Status:deferred
Tags:
Comment:
Add creationdateformat and lasteditformat parameters for customizing the date/time formats.
Modified paths:
  • /trunk/extensions/DPLforum/DPLforum_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DPLforum/DPLforum_body.php
@@ -60,6 +60,8 @@
6161 var $sInput;
6262 var $sOmit;
6363 var $vMarkNew;
 64+ var $sCreationDateFormat;
 65+ var $sLastEditFormat;
6466
6567 function cat( &$parser, $name ) {
6668 $cats = array();
@@ -141,6 +143,16 @@
142144 return htmlspecialchars( wfMsg( $type ) );
143145 }
144146
 147+ function date( $ts, $type = 'date', $df = false ) { // based on Language::date()
 148+ global $wgLang;
 149+ $ts = wfTimestamp( TS_MW, $ts );
 150+ $ts = $wgLang->userAdjust( $ts );
 151+ if ( $df === false ) {
 152+ $df = $wgLang->getDateFormatString( $type, $wgLang->dateFormat( true ) );
 153+ }
 154+ return $wgLang->sprintfDate( $df, $ts );
 155+ }
 156+
145157 function parse( &$input, &$parser ) {
146158 global $wgContLang;
147159
@@ -150,8 +162,10 @@
151163 $this->bAddAuthor = ( $this->get( 'addauthor' ) == 'true' );
152164 $this->bTimestamp = ( $this->get( 'timestamp' ) != 'false' );
153165 $this->bAddLastEdit = ( $this->get( 'addlastedit' ) != 'false' );
 166+ $this->sLastEditFormat = $this->get( 'lasteditformat', false );
154167 $this->bAddLastEditor = ( $this->get( 'addlasteditor' ) == 'true' );
155168 $this->bAddCreationDate = ( $this->get( 'addcreationdate' ) == 'true' );
 169+ $this->sCreationDateFormat = $this->get( 'creationdateformat', false );
156170
157171 switch( $this->get( 'historylink' ) ) {
158172 case 'embed':
@@ -374,7 +388,7 @@
375389
376390 // Generates a single line of output.
377391 function buildOutput( $page, $title, $time, $user = '', $author = '', $made = '' ) {
378 - global $wgLang, $wgUser;
 392+ global $wgUser;
379393
380394 $sk = $wgUser->getSkin();
381395 $tm =& $this->bTableMode;
@@ -382,7 +396,7 @@
383397
384398 if ( $this->bAddCreationDate ) {
385399 if ( is_numeric( $made ) ) {
386 - $made = $wgLang->date( $made, true );
 400+ $made = $this->date( $made, 'date', $this->sCreationDateFormat );
387401 }
388402
389403 if ( $page && $this->bLinkHistory && !$this->bAddLastEdit ) {
@@ -456,7 +470,7 @@
457471
458472 if ( $this->bAddLastEdit ) {
459473 if ( is_numeric( $time ) ) {
460 - $time = $wgLang->timeanddate( $time, true );
 474+ $time = $this->date( $time, 'both', $this->sLastEditFormat );
461475 }
462476
463477 if ( $page && $this->bLinkHistory ) {

Status & tagging log