r92376 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92375‎ | r92376 | r92377 >
Date:19:19, 16 July 2011
Author:ialex
Status:ok
Tags:
Comment:
* Use wfMessage() instead of OutputPage::addWikiMsgArray() with the third parameter
* In EditPage.php: call Linker methods statically
Modified paths:
  • /trunk/phase3/includes/EditPage.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/actions/RollbackAction.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/EditPage.php
@@ -1324,8 +1324,6 @@
13251325
13261326 wfProfileIn( __METHOD__ );
13271327
1328 - $sk = $wgUser->getSkin();
1329 -
13301328 #need to parse the preview early so that we know which templates are used,
13311329 #otherwise users with "show preview after edit box" will get a blank list
13321330 #we parse this near the beginning so that setHeaders can do the title
@@ -1366,10 +1364,10 @@
13671365 $wgOut->addHTML( $this->editFormTextTop );
13681366
13691367 $templates = $this->getTemplates();
1370 - $formattedtemplates = $sk->formatTemplates( $templates, $this->preview, $this->section != '');
 1368+ $formattedtemplates = Linker::formatTemplates( $templates, $this->preview, $this->section != '');
13711369
13721370 $hiddencats = $this->mArticle->getHiddenCategories();
1373 - $formattedhiddencats = $sk->formatHiddenCategories( $hiddencats );
 1371+ $formattedhiddencats = Linker::formatHiddenCategories( $hiddencats );
13741372
13751373 if ( $this->wasDeletedSinceLastEdit() && 'save' != $this->formtype ) {
13761374 $wgOut->wrapWikiMsg(
@@ -1408,7 +1406,7 @@
14091407 '<div class="mw-confirm-recreate">' .
14101408 wfMsgExt( $key, 'parseinline', $username, "<nowiki>$comment</nowiki>" ) .
14111409 Xml::checkLabel( wfMsg( 'recreate' ), 'wpRecreate', 'wpRecreate', false,
1412 - array( 'title' => $sk->titleAttrib( 'recreate' ), 'tabindex' => 1, 'id' => 'wpRecreate' )
 1410+ array( 'title' => Linker::titleAttrib( 'recreate' ), 'tabindex' => 1, 'id' => 'wpRecreate' )
14131411 ) .
14141412 '</div>'
14151413 );
@@ -1696,15 +1694,14 @@
16971695 if ( !$summary || ( !$this->preview && !$this->diff ) )
16981696 return "";
16991697
1700 - global $wgParser, $wgUser;
1701 - $sk = $wgUser->getSkin();
 1698+ global $wgParser;
17021699
17031700 if ( $isSubjectPreview )
17041701 $summary = wfMsgForContent( 'newsectionsummary', $wgParser->stripSectionName( $summary ) );
17051702
17061703 $message = $isSubjectPreview ? 'subject-preview' : 'summary-preview';
17071704
1708 - $summary = wfMsgExt( $message, 'parseinline' ) . $sk->commentBlock( $summary, $this->mTitle, $isSubjectPreview );
 1705+ $summary = wfMsgExt( $message, 'parseinline' ) . Linker::commentBlock( $summary, $this->mTitle, $isSubjectPreview );
17091706 return Xml::tags( 'div', array( 'class' => 'mw-summary-preview' ), $summary );
17101707 }
17111708
@@ -1879,16 +1876,16 @@
18801877 if( !wfMessage( $msg )->isDisabled() ) {
18811878 global $wgOut;
18821879 $wgOut->addHTML( '<div class="mw-tos-summary">' );
1883 - $wgOut->addWikiMsgArray( $msg, array() );
 1880+ $wgOut->addWikiMsg( $msg );
18841881 $wgOut->addHTML( '</div>' );
18851882 }
18861883 }
18871884
18881885 protected function showEditTools() {
18891886 global $wgOut;
1890 - $wgOut->addHTML( '<div class="mw-editTools">' );
1891 - $wgOut->addWikiMsgArray( 'edittools', array(), array( 'content' ) );
1892 - $wgOut->addHTML( '</div>' );
 1887+ $wgOut->addHTML( '<div class="mw-editTools">' .
 1888+ wfMessage( 'edittools' )->inContentLanguage()->parse() .
 1889+ '</div>' );
18931890 }
18941891
18951892 protected function getCopywarn() {
@@ -1909,7 +1906,7 @@
19101907 }
19111908
19121909 protected function showStandardInputs( &$tabindex = 2 ) {
1913 - global $wgOut, $wgUser;
 1910+ global $wgOut;
19141911 $wgOut->addHTML( "<div class='editOptions'>\n" );
19151912
19161913 if ( $this->section != 'new' ) {
@@ -1917,7 +1914,7 @@
19181915 $wgOut->addHTML( $this->getSummaryPreview( false, $this->summary ) );
19191916 }
19201917
1921 - $checkboxes = $this->getCheckboxes( $tabindex, $wgUser->getSkin(),
 1918+ $checkboxes = $this->getCheckboxes( $tabindex,
19221919 array( 'minor' => $this->minoredit, 'watch' => $this->watchthis ) );
19231920 $wgOut->addHTML( "<div class='editCheckboxes'>" . implode( $checkboxes, "\n" ) . "</div>\n" );
19241921 $wgOut->addHTML( "<div class='editButtons'>\n" );
@@ -2151,23 +2148,21 @@
21522149 * Produce the stock "please login to edit pages" page
21532150 */
21542151 function userNotLoggedInPage() {
2155 - global $wgUser, $wgOut;
2156 - $skin = $wgUser->getSkin();
 2152+ global $wgOut;
21572153
21582154 $loginTitle = SpecialPage::getTitleFor( 'Userlogin' );
2159 - $loginLink = $skin->link(
 2155+ $loginLink = Linker::linkKnown(
21602156 $loginTitle,
21612157 wfMsgHtml( 'loginreqlink' ),
21622158 array(),
2163 - array( 'returnto' => $this->getContextTitle()->getPrefixedText() ),
2164 - array( 'known', 'noclasses' )
 2159+ array( 'returnto' => $this->getContextTitle()->getPrefixedText() )
21652160 );
21662161
21672162 $wgOut->setPageTitle( wfMsg( 'whitelistedittitle' ) );
21682163 $wgOut->setRobotPolicy( 'noindex,nofollow' );
21692164 $wgOut->setArticleRelated( false );
21702165
2171 - $wgOut->addWikiMsgArray( 'whitelistedittext', array( $loginLink ), array( 'replaceafter' ) );
 2166+ $wgOut->addHTML( wfMessage( 'whitelistedittext' )->rawParams( $loginLink )->parse() );
21722167 $wgOut->returnToMain( false, $this->getContextTitle() );
21732168 }
21742169
@@ -2492,13 +2487,12 @@
24932488 * minor and watch
24942489 *
24952490 * @param $tabindex Current tabindex
2496 - * @param $skin Skin object
24972491 * @param $checked Array of checkbox => bool, where bool indicates the checked
24982492 * status of the checkbox
24992493 *
25002494 * @return array
25012495 */
2502 - public function getCheckboxes( &$tabindex, $skin, $checked ) {
 2496+ public function getCheckboxes( &$tabindex, $checked ) {
25032497 global $wgUser;
25042498
25052499 $checkboxes = array();
@@ -2516,7 +2510,7 @@
25172511 $checkboxes['minor'] =
25182512 Xml::check( 'wpMinoredit', $checked['minor'], $attribs ) .
25192513 "&#160;<label for='wpMinoredit' id='mw-editpage-minoredit'" .
2520 - Xml::expandAttributes( array( 'title' => $skin->titleAttrib( 'minoredit', 'withaccess' ) ) ) .
 2514+ Xml::expandAttributes( array( 'title' => Linker::titleAttrib( 'minoredit', 'withaccess' ) ) ) .
25212515 ">{$minorLabel}</label>";
25222516 }
25232517 }
@@ -2532,7 +2526,7 @@
25332527 $checkboxes['watch'] =
25342528 Xml::check( 'wpWatchthis', $checked['watch'], $attribs ) .
25352529 "&#160;<label for='wpWatchthis' id='mw-editpage-watch'" .
2536 - Xml::expandAttributes( array( 'title' => $skin->titleAttrib( 'watch', 'withaccess' ) ) ) .
 2530+ Xml::expandAttributes( array( 'title' => Linker::titleAttrib( 'watch', 'withaccess' ) ) ) .
25372531 ">{$watchLabel}</label>";
25382532 }
25392533 wfRunHooks( 'EditPageBeforeEditChecks', array( &$this, &$checkboxes, &$tabindex ) );
@@ -2623,19 +2617,16 @@
26242618 * @return string
26252619 */
26262620 public function getCancelLink() {
2627 - global $wgUser;
2628 -
26292621 $cancelParams = array();
26302622 if ( !$this->isConflict && $this->mArticle->getOldID() > 0 ) {
26312623 $cancelParams['oldid'] = $this->mArticle->getOldID();
26322624 }
26332625
2634 - return $wgUser->getSkin()->link(
 2626+ return Linker::linkKnown(
26352627 $this->getContextTitle(),
26362628 wfMsgExt( 'cancel', array( 'parseinline' ) ),
26372629 array( 'id' => 'mw-editform-cancel' ),
2638 - $cancelParams,
2639 - array( 'known', 'noclasses' )
 2630+ $cancelParams
26402631 );
26412632 }
26422633
Index: trunk/phase3/includes/OutputPage.php
@@ -2019,15 +2019,14 @@
20202020 $this->setArticleRelated( false );
20212021
20222022 $loginTitle = SpecialPage::getTitleFor( 'Userlogin' );
2023 - $loginLink = Linker::link(
 2023+ $loginLink = Linker::linkKnown(
20242024 $loginTitle,
20252025 wfMsgHtml( 'loginreqlink' ),
20262026 array(),
2027 - array( 'returnto' => $this->getTitle()->getPrefixedText() ),
2028 - array( 'known', 'noclasses' )
 2027+ array( 'returnto' => $this->getTitle()->getPrefixedText() )
20292028 );
2030 - $this->addWikiMsgArray( 'loginreqpagetext', array( $loginLink ), array( 'replaceafter' ) );
2031 - $this->addHTML( "\n<!--" . $this->getTitle()->getPrefixedUrl() . '-->' );
 2029+ $this->addHTML( wfMessage( 'loginreqpagetext' )->rawParams( $loginLink )->parse() .
 2030+ "\n<!--" . $this->getTitle()->getPrefixedUrl() . '-->' );
20322031
20332032 # Don't return to the main page if the user can't read it
20342033 # otherwise we'll end up in a pointless loop
Index: trunk/phase3/includes/actions/RollbackAction.php
@@ -63,8 +63,8 @@
6464 $current = $details['current'];
6565
6666 if ( $current->getComment() != '' ) {
67 - $this->getOutput()->addWikiMsgArray( 'editcomment', array(
68 - Linker::formatComment( $current->getComment() ) ), array( 'replaceafter' ) );
 67+ $this->getOutput()->addHTML( wfMessage( 'editcomment' )->rawParams(
 68+ Linker::formatComment( $current->getComment() ) )->parse() );
6969 }
7070 }
7171

Status & tagging log