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() ) {
|
if ( $title && $title->exists() ) {
|
||||||
$revision = Revision::newFromTitle( $title );
|
$revision = Revision::newFromTitle( $title );
|
||||||
$content = $revision->getContent();
|
$content = $revision->getContent();
|
||||||
$text = ContentHandler::getContentText( $content );
|
$parserOptions = ParserOptions::newFromUser( $wgUser );
|
||||||
return self::transform( $text );
|
$transformed = $content->preloadTransform( $title, $parserOptions );
|
||||||
|
return ContentHandler::getContentText( $transformed );
|
||||||
} else {
|
} else {
|
||||||
return false;
|
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