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
|
* Method used for parsing wikitext provided through variable
|
||||||
|
*
|
||||||
* @param $wikitext
|
* @param $wikitext
|
||||||
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function parse( $wikitext ) {
|
public function parse( $wikitext ) {
|
||||||
|
@ -23,15 +25,19 @@ class MediaWikiParserService implements ExternalParser {
|
||||||
//fix for first item list elements
|
//fix for first item list elements
|
||||||
$wikitext = "\n" . $wikitext;
|
$wikitext = "\n" . $wikitext;
|
||||||
}
|
}
|
||||||
$parsedText = $this->parser->parse( $wikitext, $this->getParserTitle(), $this->getParserOptions(),
|
$output = $this->parser->internalParse( $wikitext, false, $this->frame );
|
||||||
false, false )->getText();
|
$this->parser->replaceLinkHolders( $output );
|
||||||
|
|
||||||
wfProfileOut( __METHOD__ );
|
wfProfileOut( __METHOD__ );
|
||||||
return $parsedText;
|
|
||||||
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method used for parsing wikitext provided in infobox that might contain variables
|
* Method used for parsing wikitext provided in infobox that might contain variables
|
||||||
|
*
|
||||||
* @param $wikitext
|
* @param $wikitext
|
||||||
|
*
|
||||||
* @return string HTML outcome
|
* @return string HTML outcome
|
||||||
*/
|
*/
|
||||||
public function parseRecursive( $wikitext ) {
|
public function parseRecursive( $wikitext ) {
|
||||||
|
@ -42,16 +48,19 @@ class MediaWikiParserService implements ExternalParser {
|
||||||
$newlinesstripped = preg_replace( '|[\n\r]|Us', '', $ready );
|
$newlinesstripped = preg_replace( '|[\n\r]|Us', '', $ready );
|
||||||
$marksstripped = preg_replace( '|{{{.*}}}|Us', '', $newlinesstripped );
|
$marksstripped = preg_replace( '|{{{.*}}}|Us', '', $newlinesstripped );
|
||||||
wfProfileOut( __METHOD__ );
|
wfProfileOut( __METHOD__ );
|
||||||
|
|
||||||
return $marksstripped;
|
return $marksstripped;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function replaceVariables( $wikitext ) {
|
public function replaceVariables( $wikitext ) {
|
||||||
$output = $this->parser->replaceVariables( $wikitext, $this->frame );
|
$output = $this->parser->replaceVariables( $wikitext, $this->frame );
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add image to parser output for later usage
|
* Add image to parser output for later usage
|
||||||
|
*
|
||||||
* @param string $title
|
* @param string $title
|
||||||
*/
|
*/
|
||||||
public function addImage( $title ) {
|
public function addImage( $title ) {
|
||||||
|
@ -68,6 +77,7 @@ class MediaWikiParserService implements ExternalParser {
|
||||||
private function getParserOptions() {
|
private function getParserOptions() {
|
||||||
$options = $this->parser->getOptions();
|
$options = $this->parser->getOptions();
|
||||||
$options->enableLimitReport( false );
|
$options->enableLimitReport( false );
|
||||||
|
|
||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue