Merge branch 'nornagon-master-patch-72881' into 'master'
Use Content::preloadTransform to transform preload text Closes #6 See merge request troyengel/Preloader!7
This commit is contained in:
commit
faaf288414
1 changed files with 4 additions and 14 deletions
|
|
@ -41,21 +41,11 @@ class Preloader {
|
|||
if ( $title && $title->exists() ) {
|
||||
$revision = Revision::newFromTitle( $title );
|
||||
$content = $revision->getContent();
|
||||
$text = ContentHandler::getContentText( $content );
|
||||
return self::transform( $text );
|
||||
$parserOptions = ParserOptions::newFromUser( $wgUser );
|
||||
$transformed = $content->preloadTransform( $title, $parserOptions );
|
||||
return ContentHandler::getContentText( $transformed );
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove sections from the text and trim whitespace
|
||||
*
|
||||
* @param $text
|
||||
* @return string
|
||||
*/
|
||||
static function transform( $text ) {
|
||||
$text = trim( preg_replace( '/<\/?includeonly>/s', '', $text ) );
|
||||
return trim( preg_replace( '/<noinclude>.*<\/noinclude>/s', '', $text ) );
|
||||
}
|
||||
}
|
||||
Reference in a new issue