remove nopreload hook entirely, use noinclude instead
This commit is contained in:
parent
78e42f0e2e
commit
2a07e8002a
1 changed files with 7 additions and 20 deletions
|
|
@ -2,10 +2,8 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension allows preloading of custom content into all edit forms
|
* Extension allows preloading of custom content into all edit forms
|
||||||
* when creating an article
|
* when creating an article. <includeonly> and <noinclude> are respected
|
||||||
*
|
* and stripped during new article population.
|
||||||
* Also adds a new tag <nopreload> which is used to mark sections which
|
|
||||||
* shouldn't be preloaded, ever; has no effect on the rendering of pages
|
|
||||||
*
|
*
|
||||||
* @file
|
* @file
|
||||||
* @ingroup Extensions
|
* @ingroup Extensions
|
||||||
|
|
@ -20,8 +18,8 @@ if( !defined( 'MEDIAWIKI' ) ) {
|
||||||
$wgExtensionCredits['other'][] = array(
|
$wgExtensionCredits['other'][] = array(
|
||||||
'path' => __FILE__,
|
'path' => __FILE__,
|
||||||
'name' => 'Preloader',
|
'name' => 'Preloader',
|
||||||
'author' => 'Rob Church',
|
'author' => 'Rob Church, Troy Engel',
|
||||||
'version' => '1.1.1',
|
'version' => '1.1.2',
|
||||||
'url' => 'https://www.mediawiki.org/wiki/Extension:Preloader',
|
'url' => 'https://www.mediawiki.org/wiki/Extension:Preloader',
|
||||||
'descriptionmsg' => 'preloader-desc',
|
'descriptionmsg' => 'preloader-desc',
|
||||||
);
|
);
|
||||||
|
|
@ -33,15 +31,9 @@ $wgExtensionMessagesFiles['Preloader'] = dirname(__FILE__) . '/Preloader.i18n.p
|
||||||
$wgPreloaderSource[ NS_MAIN ] = 'Template:Preload';
|
$wgPreloaderSource[ NS_MAIN ] = 'Template:Preload';
|
||||||
|
|
||||||
$wgHooks['EditFormPreloadText'][] = 'Preloader::mainHook';
|
$wgHooks['EditFormPreloadText'][] = 'Preloader::mainHook';
|
||||||
$wgHooks['ParserFirstCallInit'][] = 'Preloader::setParserHook';
|
|
||||||
|
|
||||||
class Preloader {
|
class Preloader {
|
||||||
|
|
||||||
public static function setParserHook( $parser ) {
|
|
||||||
$parser->setHook( 'nopreload', array( __CLASS__, 'parserHook' ) );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Hook function for the preloading */
|
/** Hook function for the preloading */
|
||||||
public static function mainHook( &$text, &$title ) {
|
public static function mainHook( &$text, &$title ) {
|
||||||
$src = self::preloadSource( $title->getNamespace() );
|
$src = self::preloadSource( $title->getNamespace() );
|
||||||
|
|
@ -53,12 +45,6 @@ class Preloader {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Hook function for the parser */
|
|
||||||
public static function parserHook( $input, $args, &$parser ) {
|
|
||||||
$output = $parser->parse( $input, $parser->getTitle(), $parser->getOptions(), false, false );
|
|
||||||
return $output->getText();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine what page should be used as the source of preloaded text
|
* Determine what page should be used as the source of preloaded text
|
||||||
* for a given namespace and return the title (in text form)
|
* for a given namespace and return the title (in text form)
|
||||||
|
|
@ -92,12 +78,13 @@ class Preloader {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove <nopreload> sections from the text and trim whitespace
|
* Remove sections from the text and trim whitespace
|
||||||
*
|
*
|
||||||
* @param $text
|
* @param $text
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
static function transform( $text ) {
|
static function transform( $text ) {
|
||||||
return trim( preg_replace( '/<nopreload>.*<\/nopreload>/s', '', $text ) );
|
$text = trim( preg_replace( '/<\/?includeonly>/s', '', $text ) );
|
||||||
|
return trim( preg_replace( '/<noinclude>.*<\/noinclude>/s', '', $text ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in a new issue