/**
* Get the target language for the content being parsed. This is usually the
* language that the content is in.
+ *
+ * @since 1.19
+ *
+ * @return Language|null
*/
- function getTargetLanguage() {
+ public function getTargetLanguage() {
$target = $this->mOptions->getTargetLanguage();
+
if ( $target !== null ) {
return $target;
} elseif( $this->mOptions->getInterfaceMessage() ) {
return $this->mOptions->getUserLangObj();
} elseif( is_null( $this->mTitle ) ) {
- throw new MWException( __METHOD__.': $this->mTitle is null' );
+ throw new MWException( __METHOD__ . ': $this->mTitle is null' );
}
+
return $this->mTitle->getPageLanguage();
}
throw new MWException( __METHOD__.': unrecognised match type "' .
substr( $m[0], 0, 20 ) . '"' );
}
- $url = wfMsgForContent( $urlmsg, $id );
+ $url = wfMessage( $urlmsg, $id )->inContentLanguage()->text();
return Linker::makeExternalLink( $url, "{$keyword} {$id}", true, $CssClass );
} elseif ( isset( $m[5] ) && $m[5] !== '' ) {
# ISBN
}
if ( !$text && $this->mOptions->getEnableImageWhitelist()
&& preg_match( self::EXT_IMAGE_REGEX, $url ) ) {
- $whitelist = explode( "\n", wfMsgForContent( 'external_image_whitelist' ) );
+ $whitelist = explode( "\n", wfMessage( 'external_image_whitelist' )->inContentLanguage()->text() );
foreach ( $whitelist as $entry ) {
# Sanitize the regex fragment, make it case-insensitive, ignore blank entries/comments
if ( strpos( $entry, '#' ) === 0 || $entry === '' ) {
if ( $useLinkPrefixExtension ) {
# Match the end of a line for a word that's not followed by whitespace,
# e.g. in the case of 'The Arab al[[Razi]]', 'al' will be matched
- $e2 = wfMsgForContent( 'linkprefix' );
+ $e2 = wfMessage( 'linkprefix' )->inContentLanguage()->text();
}
if ( is_null( $this->mTitle ) ) {
*/
function limitationWarn( $limitationType, $current = null, $max = null) {
# does no harm if $current and $max are present but are unnecessary for the message
- $warning = wfMsgExt( "$limitationType-warning", array( 'parsemag', 'escape' ), $current, $max );
+ $warning = wfMessage( "$limitationType-warning" )->numParams( $current, $max )
+ ->inContentLanguage()->escaped();
$this->mOutput->addWarning( $warning );
$this->addTrackingCategory( "$limitationType-category" );
}
if ( $frame->depth >= $limit ) {
$found = true;
$text = '<span class="error">'
- . wfMsgForContent( 'parser-template-recursion-depth-warning', $limit )
+ . wfMessage( 'parser-template-recursion-depth-warning' )
+ ->numParams( $limit )->inContentLanguage()->text()
. '</span>';
}
}
# This has to be done after redirect resolution to avoid infinite loops via redirects
if ( !$frame->loopCheck( $title ) ) {
$found = true;
- $text = '<span class="error">' . wfMsgForContent( 'parser-template-loop-warning', $titleText ) . '</span>';
+ $text = '<span class="error">'
+ . wfMessage( 'parser-template-loop-warning', $titleText )->inContentLanguage()->text()
+ . '</span>';
wfDebug( __METHOD__.": template loop broken at '$titleText'\n" );
}
wfProfileOut( __METHOD__ . '-loadtpl' );
# Get the revision
$rev = $id
? Revision::newFromId( $id )
- : Revision::newFromTitle( $title );
+ : Revision::newFromTitle( $title, 0, Revision::READ_NORMAL );
$rev_id = $rev ? $rev->getId() : 0;
# If there is no current revision, there is no page
if ( $id === false && !$rev ) {
global $wgEnableScaryTranscluding;
if ( !$wgEnableScaryTranscluding ) {
- return wfMsgForContent('scarytranscludedisabled');
+ return wfMessage('scarytranscludedisabled')->inContentLanguage()->text();
}
$url = $title->getFullUrl( "action=$action" );
if ( strlen( $url ) > 255 ) {
- return wfMsgForContent( 'scarytranscludetoolong' );
+ return wfMessage( 'scarytranscludetoolong' )->inContentLanguage()->text();
}
return $this->fetchScaryTemplateMaybeFromCache( $url );
}
$text = Http::get( $url );
if ( !$text ) {
- return wfMsgForContent( 'scarytranscludefailed', $url );
+ return wfMessage( 'scarytranscludefailed', $url )->inContentLanguage()->text();
}
$dbw = wfGetDB( DB_MASTER );
$text = $this->replaceVariables( $text );
# This works almost by chance, as the replaceVariables are done before the getUserSig(),
- # which may corrupt this parser instance via its wfMsgExt( parsemag ) call-
+ # which may corrupt this parser instance via its wfMessage()->text() call-
# Signatures
$sigText = $this->getUserSig( $user );
'vertAlign' => array( 'baseline', 'sub', 'super', 'top', 'text-top', 'middle',
'bottom', 'text-bottom' ),
'frame' => array( 'thumbnail', 'manualthumb', 'framed', 'frameless',
- 'upright', 'border', 'link', 'alt' ),
+ 'upright', 'border', 'link', 'alt', 'class' ),
);
static $internalParamMap;
if ( !$internalParamMap ) {
# * upright reduce width for upright images, rounded to full __0 px
# * border draw a 1px border around the image
# * alt Text for HTML alt attribute (defaults to empty)
+ # * class Set a class for img node
# * link Set the target of the image link. Can be external, interwiki, or local
# vertical-align values (no % or length right now):
# * baseline
switch( $paramName ) {
case 'manualthumb':
case 'alt':
+ case 'class':
# @todo FIXME: Possibly check validity here for
# manualthumb? downstream behavior seems odd with
# missing manual thumbs.
# Linker does the rest
$time = isset( $options['time'] ) ? $options['time'] : false;
- $ret = Linker::makeImageLink2( $title, $file, $params['frame'], $params['handler'],
+ $ret = Linker::makeImageLink( $this, $title, $file, $params['frame'], $params['handler'],
$time, $descQuery, $this->mOptions->getThumbSize() );
# Give the handler a chance to modify the parser object