mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-15 11:59:56 +00:00
DAT-2876 switch to internal parsing to prevent hooks errors
This commit is contained in:
parent
7cbfad1d19
commit
0396b38175
|
@ -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,15 +25,19 @@ class MediaWikiParserService implements ExternalParser {
|
|||
//fix for first item list elements
|
||||
$wikitext = "\n" . $wikitext;
|
||||
}
|
||||
$parsedText = $this->parser->parse( $wikitext, $this->getParserTitle(), $this->getParserOptions(),
|
||||
false, false )->getText();
|
||||
$output = $this->parser->internalParse( $wikitext, false, $this->frame );
|
||||
$this->parser->replaceLinkHolders( $output );
|
||||
|
||||
wfProfileOut( __METHOD__ );
|
||||
return $parsedText;
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used for parsing wikitext provided in infobox that might contain variables
|
||||
*
|
||||
* @param $wikitext
|
||||
*
|
||||
* @return string HTML outcome
|
||||
*/
|
||||
public function parseRecursive( $wikitext ) {
|
||||
|
@ -42,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 ) {
|
||||
|
@ -68,6 +77,7 @@ class MediaWikiParserService implements ExternalParser {
|
|||
private function getParserOptions() {
|
||||
$options = $this->parser->getOptions();
|
||||
$options->enableLimitReport( false );
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue