mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-07-13 17:59:29 +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'][] =
|
$wgHooks['ArticleAfterFetchContentObject'][] =
|
||||||
'LinkTitles::onArticleAfterFetchContentObject';
|
'LinkTitles::onArticleAfterFetchContentObject';
|
||||||
};
|
};
|
||||||
$wgHooks['ParserBeforeTidy'][] = 'LinkTitles::removeMagicWord';
|
$wgHooks['GetDoubleUnderscoreIDs'][] = 'LinkTitles::onGetDoubleUnderscoreIDs';
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Event handler that is hooked to the ArticleSave event.
|
/// Event handler that is hooked to the ArticleSave event.
|
||||||
@ -269,18 +269,14 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove the magic words that this extension introduces from the
|
/// Adds the two magic words defined by this extension to the list of
|
||||||
/// $text, so that they do not appear on the rendered page.
|
/// 'double-underscore' terms that are automatically removed before a
|
||||||
/// @param $parser Parser object
|
/// page is displayed.
|
||||||
/// @param $text String that contains the page content.
|
/// @param $doubleUnderscoreIDs Array of magic word IDs.
|
||||||
/// @returns true
|
/// @returns true
|
||||||
static function removeMagicWord( &$parser, &$text ) {
|
public static function onGetDoubleUnderscoreIDs( &$doubleUnderscoreIDs ) {
|
||||||
$mwa = new MagicWordArray(array(
|
$doubleUnderscoreIDs[] = 'MAG_LINKTITLES_NOTARGET';
|
||||||
'MAG_LINKTITLES_NOAUTOLINKS',
|
$doubleUnderscoreIDs[] = 'MAG_LINKTITLES_NOAUTOLINKS';
|
||||||
'MAG_LINKTITLES_NOTARGET'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$mwa->matchAndRemove( $text );
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user