Merge branch 'release-302-dat-2861' into DAT-2875-refactor

This commit is contained in:
idradm 2015-06-10 14:44:59 +02:00
commit ed16bffd63

View file

@ -14,7 +14,9 @@ class MediaWikiParserService implements ExternalParser {
/**
* Method used for parsing wikitext provided through variable
*
* @param $wikitext
*
* @return mixed
*/
public function parse( $wikitext ) {
@ -23,22 +25,19 @@ class MediaWikiParserService implements ExternalParser {
//fix for first item list elements
$wikitext = "\n" . $wikitext;
}
//save current options state, as it'll be overridden by new instance when parse is invoked
$options = $this->getParserOptions();
$tmpOptions = clone $options;
$tmpOptions->setIsPartialParse( true );
$output = $this->parser->parse( $wikitext, $this->getParserTitle(), $tmpOptions, false, false )->getText();
//restore options state
$this->parser->Options( $options );
$output = $this->parser->internalParse( $wikitext, false, $this->frame );
$this->parser->replaceLinkHolders( $output );
wfProfileOut( __METHOD__ );
return $output;
}
/**
* Method used for parsing wikitext provided in infobox that might contain variables
*
* @param $wikitext
*
* @return string HTML outcome
*/
public function parseRecursive( $wikitext ) {
@ -49,16 +48,19 @@ class MediaWikiParserService implements ExternalParser {
$newlinesstripped = preg_replace( '|[\n\r]|Us', '', $ready );
$marksstripped = preg_replace( '|{{{.*}}}|Us', '', $newlinesstripped );
wfProfileOut( __METHOD__ );
return $marksstripped;
}
public function replaceVariables( $wikitext ) {
$output = $this->parser->replaceVariables( $wikitext, $this->frame );
return $output;
}
/**
* Add image to parser output for later usage
*
* @param string $title
*/
public function addImage( $title ) {
@ -75,6 +77,7 @@ class MediaWikiParserService implements ExternalParser {
private function getParserOptions() {
$options = $this->parser->getOptions();
$options->enableLimitReport( false );
return $options;
}
}