From 52ca5a1a5a6bb16be9f1cd077315c810ff91ce0d Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Thu, 30 Aug 2012 10:41:27 +0200 Subject: [PATCH] Maintenance for Cite extension. * Update deprecated calls. * Remove superfluous newlines. * Add @todo where uncertain. Change-Id: Ifc79b199fa551c23fafa190664688c8320059338 --- Cite_body.php | 64 +++++++++++++++++++++++--------------------- SpecialCite.php | 2 +- SpecialCite_body.php | 16 +++++------ 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/Cite_body.php b/Cite_body.php index 147ca1440..a53cf7cb9 100644 --- a/Cite_body.php +++ b/Cite_body.php @@ -642,8 +642,8 @@ class Cite { $ent[] = $this->referencesFormatEntry( $k, $v ); } - $prefix = wfMsgForContentNoTrans( 'cite_references_prefix' ); - $suffix = wfMsgForContentNoTrans( 'cite_references_suffix' ); + $prefix = wfMessage( 'cite_references_prefix' )->inContentLanguage()->plain(); + $suffix = wfMessage( 'cite_references_suffix' )->inContentLanguage()->plain(); $content = implode( "\n", $ent ); // Let's try to cache it. @@ -697,69 +697,69 @@ class Cite { function referencesFormatEntry( $key, $val ) { // Anonymous reference if ( !is_array( $val ) ) { - return wfMsgForContentNoTrans( + return wfMessage( 'cite_references_link_one', $this->referencesKey( $key ), $this->refKey( $key ), $this->referenceText( $key, $val ) - ); + )->inContentLanguage()->plain(); } $text = $this->referenceText( $key, $val['text'] ); if ( isset( $val['follow'] ) ) { - return wfMsgForContentNoTrans( + return wfMessage( 'cite_references_no_link', $this->referencesKey( $val['follow'] ), $text - ); + )->inContentLanguage()->plain(); } elseif ( $val['text'] == '' ) { - return wfMsgForContentNoTrans( + return wfMessage( 'cite_references_link_one', $this->referencesKey( $key ), $this->refKey( $key, $val['count'] ), $text - ); + )->inContentLanguage()->plain(); } if ( $val['count'] < 0 ) { - return wfMsgForContentNoTrans( + return wfMessage( 'cite_references_link_one', $this->referencesKey( $val['key'] ), # $this->refKey( $val['key'], $val['count'] ), $this->refKey( $val['key'] ), $text - ); + )->inContentLanguage()->plain(); // Standalone named reference, I want to format this like an // anonymous reference because displaying "1. 1.1 Ref text" is // overkill and users frequently use named references when they // don't need them for convenience } elseif ( $val['count'] === 0 ) { - return wfMsgForContentNoTrans( + return wfMessage( 'cite_references_link_one', $this->referencesKey( $key . "-" . $val['key'] ), # $this->refKey( $key, $val['count'] ), $this->refKey( $key, $val['key'] . "-" . $val['count'] ), $text - ); + )->inContentLanguage()->plain(); // Named references with >1 occurrences } else { $links = array(); // for group handling, we have an extra key here. for ( $i = 0; $i <= $val['count']; ++$i ) { - $links[] = wfMsgForContentNoTrans( + $links[] = wfMessage( 'cite_references_link_many_format', $this->refKey( $key, $val['key'] . "-$i" ), $this->referencesFormatEntryNumericBacklinkLabel( $val['number'], $i, $val['count'] ), $this->referencesFormatEntryAlternateBacklinkLabel( $i ) - ); + )->inContentLanguage()->plain(); } $list = $this->listToText( $links ); - return wfMsgForContentNoTrans( 'cite_references_link_many', + return wfMessage( 'cite_references_link_many', $this->referencesKey( $key . "-" . $val['key'] ), $list, $text - ); + )->inContentLanguage()->plain(); } } @@ -861,10 +861,11 @@ class Cite { * @return string A key for use in wikitext */ function refKey( $key, $num = null ) { - $prefix = wfMsgForContent( 'cite_reference_link_prefix' ); - $suffix = wfMsgForContent( 'cite_reference_link_suffix' ); + $prefix = wfMessage( 'cite_reference_link_prefix' )->inContentLanguage()->text(); + $suffix = wfMessage( 'cite_reference_link_suffix' )->inContentLanguage()->text(); if ( isset( $num ) ) { - $key = wfMsgForContentNoTrans( 'cite_reference_link_key_with_num', $key, $num ); + $key = wfMessage( 'cite_reference_link_key_with_num', $key, $num ) + ->inContentLanguage()->plain(); } return "$prefix$key$suffix"; @@ -882,10 +883,11 @@ class Cite { * @return string A key for use in wikitext */ function referencesKey( $key, $num = null ) { - $prefix = wfMsgForContent( 'cite_references_link_prefix' ); - $suffix = wfMsgForContent( 'cite_references_link_suffix' ); + $prefix = wfMessage( 'cite_references_link_prefix' )->inContentLanguage()->text(); + $suffix = wfMessage( 'cite_references_link_suffix' )->inContentLanguage()->text(); if ( isset( $num ) ) { - $key = wfMsgForContentNoTrans( 'cite_reference_link_key_with_num', $key, $num ); + $key = wfMessage( 'cite_reference_link_key_with_num', $key, $num ) + ->inContentLanguage()->plain(); } return "$prefix$key$suffix"; @@ -912,13 +914,13 @@ class Cite { return $this->parse( - wfMsgForContentNoTrans( + wfMessage( 'cite_reference_link', $this->refKey( $key, $count ), $this->referencesKey( $key . $subkey ), $this->getLinkLabel( $label, $group, ( ( $group == CITE_DEFAULT_GROUP ) ? '' : "$group " ) . $wgContLang->formatNum( $label ) ) - ) + )->inContentLanguage()->plain() ); } @@ -937,8 +939,8 @@ class Cite { function listToText( $arr ) { $cnt = count( $arr ); - $sep = wfMsgForContentNoTrans( 'cite_references_link_many_sep' ); - $and = wfMsgForContentNoTrans( 'cite_references_link_many_and' ); + $sep = wfMessage( 'cite_references_link_many_sep' )->inContentLanguage()->plain(); + $and = wfMessage( 'cite_references_link_many_and' )->inContentLanguage()->plain(); if ( $cnt == 1 ) { // Enforce always returning a string @@ -1010,7 +1012,8 @@ class Cite { */ function genBacklinkLabels() { wfProfileIn( __METHOD__ ); - $text = wfMsgForContentNoTrans( 'cite_references_link_many_format_backlink_labels' ); + $text = wfMessage( 'cite_references_link_many_format_backlink_labels' ) + ->inContentLanguage()->plain(); $this->mBacklinkLabels = preg_split( '#[\n\t ]#', $text ); wfProfileOut( __METHOD__ ); } @@ -1152,10 +1155,10 @@ class Cite { */ function error( $key, $param = null, $parse = 'parse' ) { # We rely on the fact that PHP is okay with passing unused argu- - # ments to functions. If $1 is not used in the message, wfMsg will + # ments to functions. If $1 is not used in the message, wfMessage will # just ignore the extra parameter. $ret = '' . - wfMsgNoTrans( 'cite_error', wfMsgNoTrans( $key, $param ) ) . + wfMessage( 'cite_error', wfMessage( $key, $param )->plain() )->plain() . ''; if ( $parse == 'parse' ) { $ret = $this->parse( $ret ); @@ -1171,7 +1174,8 @@ class Cite { * @param string $data Serialized error data */ function croak( $error, $data ) { - wfDebugDieBacktrace( wfMsgForContent( 'cite_croak', $this->error( $error ), $data ) ); + wfDebugDieBacktrace( wfMessage( 'cite_croak', $this->error( $error ), $data ) + ->inContentLanguage()->text() ); } /**#@-*/ diff --git a/SpecialCite.php b/SpecialCite.php index d1ff7d460..6d9b81381 100644 --- a/SpecialCite.php +++ b/SpecialCite.php @@ -78,7 +78,7 @@ function wfSpecialCiteToolbox( &$skin ) { array( 'id' => 't-cite' ), Linker::link( SpecialPage::getTitleFor( 'Cite' ), - wfMsg( 'cite_article_link' ), + wfMessage( 'cite_article_link' )->text(), // @todo Should be escaped()? # Used message keys: 'tooltip-cite-article', 'accesskey-cite-article' Linker::tooltipAndAccessKeyAttribs( 'cite-article' ), $skin->data['nav_urls']['cite']['args'] diff --git a/SpecialCite_body.php b/SpecialCite_body.php index e43a879f6..0425c8506 100644 --- a/SpecialCite_body.php +++ b/SpecialCite_body.php @@ -1,5 +1,4 @@ tags to // be generated around the output of the CiteOutput @@ -17,14 +16,14 @@ class SpecialCite extends SpecialPage { $this->setHeaders(); $this->outputHeader(); - $page = $par !== null ? $par : $wgRequest->getText( 'page' ); + $page = $par !== null ? $par : $this->getRequest()->getText( 'page' ); $title = Title::newFromText( $page ); $cform = new CiteForm( $title ); $cform->execute(); if ( $title && $title->exists() ) { - $id = $wgRequest->getInt( 'id' ); + $id = $this->getRequest()->getInt( 'id' ); $cout = new CiteOutput( $title, $id ); $cout->execute(); } @@ -32,7 +31,6 @@ class SpecialCite extends SpecialPage { } class CiteForm { - /** * @var Title */ @@ -54,7 +52,7 @@ class CiteForm { ) ) . Html::hidden( 'title', SpecialPage::getTitleFor( 'Cite' )->getPrefixedDBkey() ) . Xml::openElement( 'label' ) . - wfMsgHtml( 'cite_page' ) . ' ' . + wfMessage( 'cite_page' )->escaped() . ' ' . Xml::element( 'input', array( 'type' => 'text', @@ -68,7 +66,7 @@ class CiteForm { Xml::element( 'input', array( 'type' => 'submit', - 'value' => wfMsgHtml( 'cite_submit' ) + 'value' => wfMessage( 'cite_submit' )->escaped() ), '' ) . @@ -76,11 +74,9 @@ class CiteForm { Xml::closeElement( 'form' ) ); } - } class CiteOutput { - /** * @var Title */ @@ -125,7 +121,7 @@ class CiteOutput { $wgHooks['ParserGetVariableValueTs'][] = array( $this, 'timestamp' ); - $msg = wfMsgForContentNoTrans( 'cite_text' ); + $msg = wfMessage( 'cite_text' )->inContentLanguage()->plain(); if ( $msg == '' ) { # With MediaWiki 1.20 the plain text files were deleted and the text moved into SpecialCite.i18n.php # This code is kept for b/c in case an installation has its own file "cite_text-xx"