mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-07-13 09:49:31 +02:00
Use GetDoubleUnderscoreIDs hook to remove magic words.
Prevously, the magic words were removed by hooking onto ParserBeforeTidy. Since the Parser class provides its own mechanism for removing magic words that are surrounded by double underscores, we now use this (undocumented) hook.
This commit is contained in:
@ -56,7 +56,7 @@
|
||||
$wgHooks['ArticleAfterFetchContentObject'][] =
|
||||
'LinkTitles::onArticleAfterFetchContentObject';
|
||||
};
|
||||
$wgHooks['ParserBeforeTidy'][] = 'LinkTitles::removeMagicWord';
|
||||
$wgHooks['GetDoubleUnderscoreIDs'][] = 'LinkTitles::onGetDoubleUnderscoreIDs';
|
||||
}
|
||||
|
||||
/// Event handler that is hooked to the ArticleSave event.
|
||||
@ -269,18 +269,14 @@
|
||||
);
|
||||
}
|
||||
|
||||
/// Remove the magic words that this extension introduces from the
|
||||
/// $text, so that they do not appear on the rendered page.
|
||||
/// @param $parser Parser object
|
||||
/// @param $text String that contains the page content.
|
||||
/// Adds the two magic words defined by this extension to the list of
|
||||
/// 'double-underscore' terms that are automatically removed before a
|
||||
/// page is displayed.
|
||||
/// @param $doubleUnderscoreIDs Array of magic word IDs.
|
||||
/// @returns true
|
||||
static function removeMagicWord( &$parser, &$text ) {
|
||||
$mwa = new MagicWordArray(array(
|
||||
'MAG_LINKTITLES_NOAUTOLINKS',
|
||||
'MAG_LINKTITLES_NOTARGET'
|
||||
)
|
||||
);
|
||||
$mwa->matchAndRemove( $text );
|
||||
public static function onGetDoubleUnderscoreIDs( &$doubleUnderscoreIDs ) {
|
||||
$doubleUnderscoreIDs[] = 'MAG_LINKTITLES_NOTARGET';
|
||||
$doubleUnderscoreIDs[] = 'MAG_LINKTITLES_NOAUTOLINKS';
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user