*
* @param $text String: text extension wants to have parsed
* @param $frame PPFrame: The frame to use for expanding any template variables
+ *
+ * @return string
*/
function recursiveTagParse( $text, $frame=false ) {
wfProfileIn( __METHOD__ );
if ( $target !== null ) {
return $target;
} else {
- return $this->mOptions->getInterfaceMessage() ? $wgLang : $wgContLang;
+ return $this->mOptions->getInterfaceMessage() ? $wgLang : $this->mTitle->getPageLanguage();
}
}
if ( $attributes !== '' ) {
$table['attributes'] = $attributes;
}
- } else if ( !isset( $tables[0] ) ) {
+ } elseif ( !isset( $tables[0] ) ) {
// we're outside the table
$out .= $outLine . "\n";
- } else if ( $firstChars === '|}' ) {
+ } elseif ( $firstChars === '|}' ) {
// trim the |} code from the line
$line = substr ( $line , 2 );
$output .= $o;
- } else if ( $firstChars === '|-' ) {
+ } elseif ( $firstChars === '|-' ) {
// start a new row element
// but only when we haven't started one already
if ( count( $currentRow ) != 0 ) {
$currentRow['attributes'] = $attributes;
}
- } else if ( $firstChars === '|+' ) {
+ } elseif ( $firstChars === '|+' ) {
// a table caption, but only proceed if there isn't one already
if ( !isset ( $table['caption'] ) ) {
$line = substr ( $line , 2 );
unset( $c );
$output =& $table['caption']['content'];
}
- } else if ( $firstChars === '|' || $firstChars === '!' || $firstChars === '!+' ) {
+ } elseif ( $firstChars === '|' || $firstChars === '!' || $firstChars === '!+' ) {
// Which kind of cells are we dealing with
$currentTag = 'td';
$line = substr ( $line , 1 );
// decide whether thead to tbody
if ( !array_key_exists( 'type', $currentRow ) ) {
$currentRow['type'] = ( $firstChars === '!' ) ? 'thead' : 'tbody' ;
- } else if ( $firstChars === '|' ) {
+ } elseif ( $firstChars === '|' ) {
$currentRow['type'] = 'tbody';
}
if ( strpos( $cellData[0], '[[' ) !== false ) {
$content = trim ( $cell );
}
- else if ( count ( $cellData ) == 1 ) {
+ elseif ( count ( $cellData ) == 1 ) {
$content = trim ( $cellData[0] );
} else {
$attributes = $this->mStripState->unstripBoth( $cellData[0] );
*
* @private
*/
- function generateTableHTML ( &$table ) {
+ function generateTableHTML( &$table ) {
$return = "";
$return .= str_repeat( '<dl><dd>' , $table['indent'] );
$return .= '<table';
// If we only have tbodies, mark table as simple
for ( $i = 0; isset( $table[$i] ); $i++ ) {
if ( !count( $table[$i] ) ) continue;
- if ( !isset( $table[$i]['type'] ) ) $table[$i]['type'] = 'tbody';
+ if ( !isset( $table[$i]['type'] ) ) {
+ $table[$i]['type'] = 'tbody';
+ }
if ( !$lastSection ) {
$lastSection = $table[$i]['type'];
- } else if ( $lastSection != $table[$i]['type'] ) {
+ } elseif ( $lastSection != $table[$i]['type'] ) {
$simple = false;
- break;
}
}
$lastSection = '';
for ( $i = 0; isset( $table[$i] ); $i++ ) {
- // Check for empty tables
- if ( count( $table[$i] ) ) {
- $empty = false;
- } else {
- continue;
- }
+ if ( !count( $table[$i] ) ) continue;
+ $empty = false; // check for empty tables
+
if ( $table[$i]['type'] != $lastSection && !$simple ) {
$return .= "\n<" . $table[$i]['type'] . '>';
}
(?: [0-9] [\ \-]? ){9} # 9 digits with opt. delimiters
[0-9Xx] # check digit
\b)
- )!xS', array( &$this, 'magicLinkCallback' ), $text );
+ )!x', array( &$this, 'magicLinkCallback' ), $text );
wfProfileOut( __METHOD__ );
return $text;
}
$args = ( null == $piece['parts'] ) ? array() : $piece['parts'];
wfProfileOut( __METHOD__.'-setup' );
wfProfileIn( __METHOD__."-title-$originalTitle" );
-
+
# SUBST
wfProfileIn( __METHOD__.'-modifiers' );
if ( !$found ) {
if ( $dot ) {
$numbering .= '.';
}
- $numbering .= $wgContLang->formatNum( $sublevelCount[$i] );
+ $numbering .= $this->getFunctionLang()->formatNum( $sublevelCount[$i] );
$dot = 1;
}
}
# If we're still here, make it a link to the user page
$userText = wfEscapeWikiText( $username );
$nickText = wfEscapeWikiText( $nickname );
- if ( $user->isAnon() ) {
- return wfMsgExt( 'signature-anon', array( 'content', 'parsemag' ), $userText, $nickText );
- } else {
- return wfMsgExt( 'signature', array( 'content', 'parsemag' ), $userText, $nickText );
- }
+ $msgName = $user->isAnon() ? 'signature-anon' : 'signature';
+
+ return wfMessage( $msgName, $userText, $nickText )->inContentLanguage()->title( $this->getTitle() )->text();
}
/**
$matches = array();
$elements = array_keys( $this->mTransparentTagHooks );
$text = self::extractTagsAndParams( $elements, $text, $matches, $this->mUniqPrefix );
+ $replacements = array();
foreach ( $matches as $marker => $data ) {
list( $element, $content, $params, $tag ) = $data;
} else {
$output = $tag;
}
- $this->mStripState->addGeneral( $marker, $output );
+ $replacements[$marker] = $output;
}
- return $text;
+ return strtr( $text, $replacements );
}
/**
* @param $newText String: replacement text for section data.
* @return String: for "get", the extracted section text.
* for "replace", the whole page with the section replaced.
+ * If the page is empty and section 0 is requested, $text (as '')
+ * is returned
*/
private function extractSections( $text, $section, $mode, $newText='' ) {
global $wgTitle; # not generally used but removes an ugly failure mode
*
* @return string
*/
- function testSrvus( $text, $title, ParserOptions $options, $outputType = self::OT_HTML ) {
+ function testSrvus( $text, Title $title, ParserOptions $options, $outputType = self::OT_HTML ) {
$this->startParse( $title, $options, $outputType, true );
$text = $this->replaceVariables( $text );
return $text;
}
- function testPst( $text, $title, $options ) {
+ function testPst( $text, Title $title, ParserOptions $options ) {
return $this->preSaveTransform( $text, $title, $options->getUser(), $options );
}
- function testPreprocess( $text, $title, $options ) {
+ function testPreprocess( $text, Title $title, ParserOptions $options ) {
return $this->testSrvus( $text, $title, $options, self::OT_PREPROCESS );
}