r107328 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107327‎ | r107328 | r107329 >
Date:16:20, 26 December 2011
Author:ialex
Status:resolved (Comments)
Tags:
Comment:
* Use local context to get messages
* Pass the context to ContribsPager
Modified paths:
  • /trunk/phase3/includes/api/ApiFeedContributions.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialContributions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiFeedContributions.php
@@ -74,7 +74,7 @@
7575 $feedUrl
7676 );
7777
78 - $pager = new ContribsPager( array(
 78+ $pager = new ContribsPager( $this->getContext(), array(
7979 'target' => $target,
8080 'namespace' => $params['namespace'],
8181 'year' => $params['year'],
Index: trunk/phase3/includes/specials/SpecialContributions.php
@@ -85,11 +85,11 @@
8686 if ( $this->opts['contribs'] != 'newbie' ) {
8787 $target = $nt->getText();
8888 $out->addSubtitle( $this->contributionsSub( $userObj ) );
89 - $out->setHTMLTitle( $this->msg( 'pagetitle', wfMsgExt( 'contributions-title', array( 'parsemag' ), $target ) ) );
 89+ $out->setHTMLTitle( $this->msg( 'pagetitle', $this->msg( 'contributions-title', $target )->plain() ) );
9090 $this->getSkin()->setRelevantUser( $userObj );
9191 } else {
9292 $out->addSubtitle( $this->msg( 'sp-contributions-newbies-sub' ) );
93 - $out->setHTMLTitle( $this->msg( 'pagetitle', wfMsg( 'sp-contributions-newbies-title' ) ) );
 93+ $out->setHTMLTitle( $this->msg( 'pagetitle', $this->msg( 'sp-contributions-newbies-title' )->plain() ) );
9494 }
9595
9696 if ( ( $ns = $request->getVal( 'namespace', null ) ) !== null && $ns !== '' ) {
@@ -161,7 +161,7 @@
162162
163163 $out->addHTML( $this->getForm() );
164164
165 - $pager = new ContribsPager( array(
 165+ $pager = new ContribsPager( $this->getContext(), array(
166166 'target' => $target,
167167 'contribs' => $this->opts['contribs'],
168168 'namespace' => $this->opts['namespace'],
@@ -200,7 +200,7 @@
201201 }
202202 }
203203
204 - if ( !wfMessage( $message, $target )->isDisabled() ) {
 204+ if ( !$this->msg( $message, $target )->isDisabled() ) {
205205 $out->wrapWikiMsg(
206206 "<div class='mw-contributions-footer'>\n$1\n</div>",
207207 array( $message, $target ) );
@@ -275,30 +275,30 @@
276276 $id = $target->getId();
277277 $username = $target->getName();
278278
279 - $tools[] = Linker::link( $talkpage, wfMsgHtml( 'sp-contributions-talk' ) );
 279+ $tools[] = Linker::link( $talkpage, $this->msg( 'sp-contributions-talk' )->escaped() );
280280
281281 if ( ( $id !== null ) || ( $id === null && IP::isIPAddress( $username ) ) ) {
282282 if ( $subject->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
283283 if ( $target->isBlocked() ) {
284284 $tools[] = Linker::linkKnown( # Change block link
285285 SpecialPage::getTitleFor( 'Block', $username ),
286 - wfMsgHtml( 'change-blocklink' )
 286+ $this->msg( 'change-blocklink' )->escaped()
287287 );
288288 $tools[] = Linker::linkKnown( # Unblock link
289289 SpecialPage::getTitleFor( 'Unblock', $username ),
290 - wfMsgHtml( 'unblocklink' )
 290+ $this->msg( 'unblocklink' )->escaped()
291291 );
292292 } else { # User is not blocked
293293 $tools[] = Linker::linkKnown( # Block link
294294 SpecialPage::getTitleFor( 'Block', $username ),
295 - wfMsgHtml( 'blocklink' )
 295+ $this->msg( 'blocklink' )->escaped()
296296 );
297297 }
298298 }
299299 # Block log link
300300 $tools[] = Linker::linkKnown(
301301 SpecialPage::getTitleFor( 'Log', 'block' ),
302 - wfMsgHtml( 'sp-contributions-blocklog' ),
 302+ $this->msg( 'sp-contributions-blocklog' )->escaped(),
303303 array(),
304304 array(
305305 'page' => $userpage->getPrefixedText()
@@ -308,20 +308,20 @@
309309 # Uploads
310310 $tools[] = Linker::linkKnown(
311311 SpecialPage::getTitleFor( 'Listfiles', $username ),
312 - wfMsgHtml( 'sp-contributions-uploads' )
 312+ $this->msg( 'sp-contributions-uploads' )->escaped()
313313 );
314314
315315 # Other logs link
316316 $tools[] = Linker::linkKnown(
317317 SpecialPage::getTitleFor( 'Log', $username ),
318 - wfMsgHtml( 'sp-contributions-logs' )
 318+ $this->msg( 'sp-contributions-logs' )->escaped()
319319 );
320320
321321 # Add link to deleted user contributions for priviledged users
322322 if ( $subject->isAllowed( 'deletedhistory' ) ) {
323323 $tools[] = Linker::linkKnown(
324324 SpecialPage::getTitleFor( 'DeletedContributions', $username ),
325 - wfMsgHtml( 'sp-contributions-deleted' )
 325+ $this->msg( 'sp-contributions-deleted' )->escaped()
326326 );
327327 }
328328
@@ -331,7 +331,7 @@
332332 if ( $id !== null && $userrightsPage->userCanChangeRights( $target ) ) {
333333 $tools[] = Linker::linkKnown(
334334 SpecialPage::getTitleFor( 'Userrights', $username ),
335 - wfMsgHtml( 'sp-contributions-userrights' )
 335+ $this->msg( 'sp-contributions-userrights' )->escaped()
336336 );
337337 }
338338
@@ -412,7 +412,7 @@
413413
414414 $targetSelection = Xml::tags( 'td', array( 'colspan' => 2 ),
415415 Xml::radioLabel(
416 - wfMsgExt( 'sp-contributions-newbies', array( 'parsemag' ) ),
 416+ $this->msg( 'sp-contributions-newbies' )->text(),
417417 'contribs',
418418 'newbie' ,
419419 'newbie',
@@ -420,7 +420,7 @@
421421 array( 'class' => 'mw-input' )
422422 ) . '<br />' .
423423 Xml::radioLabel(
424 - wfMsgExt( 'sp-contributions-username', array( 'parsemag' ) ),
 424+ $this->msg( 'sp-contributions-username' )->text(),
425425 'contribs',
426426 'user',
427427 'user',
@@ -440,7 +440,7 @@
441441 $namespaceSelection =
442442 Xml::tags( 'td', array( 'class' => 'mw-label' ),
443443 Xml::label(
444 - wfMsg( 'namespace' ),
 444+ $this->msg( 'namespace' )->text(),
445445 'namespace',
446446 ''
447447 )
@@ -449,20 +449,20 @@
450450 Xml::namespaceSelector( $this->opts['namespace'], '' ) . '&#160;' .
451451 Html::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
452452 Xml::checkLabel(
453 - wfMsg( 'invert' ),
 453+ $this->msg( 'invert' )->text(),
454454 'nsInvert',
455455 'nsInvert',
456456 $this->opts['nsInvert'],
457 - array( 'title' => wfMsg( 'tooltip-invert' ), 'class' => 'mw-input' )
 457+ array( 'title' => $this->msg( 'tooltip-invert' )->text(), 'class' => 'mw-input' )
458458 ) . '&#160;'
459459 ) .
460460 Html::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
461461 Xml::checkLabel(
462 - wfMsg( 'namespace_association' ),
 462+ $this->msg( 'namespace_association' )->text(),
463463 'associated',
464464 'associated',
465465 $this->opts['associated'],
466 - array( 'title' => wfMsg( 'tooltip-namespace_association' ), 'class' => 'mw-input' )
 466+ array( 'title' => $this->msg( 'tooltip-namespace_association' )->text(), 'class' => 'mw-input' )
467467 ) . '&#160;'
468468 )
469469 ) ;
@@ -470,7 +470,7 @@
471471 $extraOptions = Xml::tags( 'td', array( 'colspan' => 2 ),
472472 Html::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
473473 Xml::checkLabel(
474 - wfMsg( 'history-show-deleted' ),
 474+ $this->msg( 'history-show-deleted' )->text(),
475475 'deletedOnly',
476476 'mw-show-deleted-only',
477477 $this->opts['deletedOnly'],
@@ -479,7 +479,7 @@
480480 ) .
481481 Html::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
482482 Xml::checkLabel(
483 - wfMsg( 'sp-contributions-toponly' ),
 483+ $this->msg( 'sp-contributions-toponly' )->text(),
484484 'topOnly',
485485 'mw-show-top-only',
486486 $this->opts['topOnly'],
@@ -494,13 +494,13 @@
495495 $this->opts['month']
496496 ) . ' ' .
497497 Xml::submitButton(
498 - wfMsg( 'sp-contributions-submit' ),
 498+ $this->msg( 'sp-contributions-submit' )->text(),
499499 array( 'class' => 'mw-submit' )
500500 )
501501 ) ;
502502
503503 $form .=
504 - Xml::fieldset( wfMsg( 'sp-contributions-search' ) ) .
 504+ Xml::fieldset( $this->msg( 'sp-contributions-search' )->text() ) .
505505 Xml::openElement( 'table', array( 'class' => 'mw-contributions-table' ) ) .
506506 Xml::openElement( 'tr' ) .
507507 $targetSelection .
@@ -519,7 +519,7 @@
520520 Xml::closeElement( 'tr' ) .
521521 Xml::closeElement( 'table' );
522522
523 - $explain = wfMessage( 'sp-contributions-explain' );
 523+ $explain = $this->msg( 'sp-contributions-explain' );
524524 if ( $explain->exists() ) {
525525 $form .= "<p id='mw-sp-contributions-explain'>{$explain}</p>";
526526 }
@@ -539,13 +539,13 @@
540540 var $namespace = '', $mDb;
541541 var $preventClickjacking = false;
542542
543 - function __construct( $options ) {
544 - parent::__construct();
 543+ function __construct( IContextSource $context, array $options ) {
 544+ parent::__construct( $context );
545545
546546 $msgs = array( 'uctop', 'diff', 'newarticle', 'rollbacklink', 'diff', 'hist', 'rev-delundel', 'pipe-separator' );
547547
548548 foreach ( $msgs as $msg ) {
549 - $this->messages[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) );
 549+ $this->messages[$msg] = $this->msg( $msg )->escaped();
550550 }
551551
552552 $this->target = isset( $options['target'] ) ? $options['target'] : '';
@@ -795,8 +795,9 @@
796796 $chardiff = ' ';
797797 }
798798
799 - $comment = $this->getLanguage()->getDirMark() . Linker::revComment( $rev, false, true );
800 - $date = $this->getLanguage()->timeanddate( wfTimestamp( TS_MW, $row->rev_timestamp ), true );
 799+ $lang = $this->getLanguage();
 800+ $comment = $lang->getDirMark() . Linker::revComment( $rev, false, true );
 801+ $date = $lang->userTimeAndDate( $row->rev_timestamp, $user );
801802 if ( $rev->userCan( Revision::DELETED_TEXT, $user ) ) {
802803 $d = Linker::linkKnown(
803804 $page,
@@ -815,8 +816,8 @@
816817 # Note that we already excluded rows with hidden user names.
817818 if ( $this->contribs == 'newbie' ) {
818819 $userlink = ' . . ' . Linker::userLink( $rev->getUser(), $rev->getUserText() );
819 - $userlink .= ' ' . wfMsg( 'parentheses',
820 - Linker::userTalkLink( $rev->getUser(), $rev->getUserText() ) ) . ' ';
 820+ $userlink .= ' ' . $this->msg( 'parentheses' )->rawParams(
 821+ Linker::userTalkLink( $rev->getUser(), $rev->getUserText() ) )->escaped() . ' ';
821822 } else {
822823 $userlink = '';
823824 }
@@ -857,7 +858,7 @@
858859
859860 # Denote if username is redacted for this edit
860861 if ( $rev->isDeleted( Revision::DELETED_USER ) ) {
861 - $ret .= " <strong>" . wfMsgHtml( 'rev-deleted-user-contribs' ) . "</strong>";
 862+ $ret .= " <strong>" . $this->msg( 'rev-deleted-user-contribs' )->escaped() . "</strong>";
862863 }
863864
864865 # Tags, if any.

Follow-up revisions

RevisionCommit summaryAuthorDate
r107341Fix fixme on r107328, attempting to use $this in a static method...reedy21:03, 26 December 2011

Comments

#Comment by Siebrand (talk | contribs)   21:01, 26 December 2011

https://translatewiki.net/wiki/Special:Contributions/Olli

[26-Dec-2011 20:59:34] PHP Fatal error: Using $this when not in object context in /www/w/includes/specials/SpecialContributions.php on line 278

Status & tagging log