mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-07-13 17:59:29 +02:00
Use typed parameters in functions.
This commit is contained in:
@ -88,7 +88,7 @@
|
|||||||
/// @param $article Article object
|
/// @param $article Article object
|
||||||
/// @param $content Content object that holds the article content
|
/// @param $content Content object that holds the article content
|
||||||
/// @returns true
|
/// @returns true
|
||||||
static function parseContent( &$article, &$content ) {
|
static function parseContent( WikiPage &$wikiPage, Content &$content ) {
|
||||||
// If the page contains the magic word '__NOAUTOLINKS__', do not parse
|
// If the page contains the magic word '__NOAUTOLINKS__', do not parse
|
||||||
// the content.
|
// the content.
|
||||||
if ( $content->matchMagicWord(
|
if ( $content->matchMagicWord(
|
||||||
@ -121,7 +121,7 @@
|
|||||||
$templatesDelimiter = '{{[^|]+?}}|{{.+\||';
|
$templatesDelimiter = '{{[^|]+?}}|{{.+\||';
|
||||||
};
|
};
|
||||||
|
|
||||||
LinkTitles::$currentTitle = $article->getTitle();
|
LinkTitles::$currentTitle = $wikiPage->getTitle();
|
||||||
$text = $content->getContentHandler()->serializeContent($content);
|
$text = $content->getContentHandler()->serializeContent($content);
|
||||||
$newText = $text;
|
$newText = $text;
|
||||||
|
|
||||||
@ -250,18 +250,17 @@
|
|||||||
/// Automatically processes a single page, given a $title Title object.
|
/// Automatically processes a single page, given a $title Title object.
|
||||||
/// This function is called by the SpecialLinkTitles class and the
|
/// This function is called by the SpecialLinkTitles class and the
|
||||||
/// LinkTitlesJob class.
|
/// LinkTitlesJob class.
|
||||||
/// @param $title `Title` object that identifies the page.
|
/// @param string $title Page title.
|
||||||
/// @param $context Object that implements IContextProvider.
|
/// @param IContextProvider $context Object that implements IContextProvider.
|
||||||
/// If in doubt, call MediaWiki's `RequestContext::getMain()`
|
/// If in doubt, call MediaWiki's `RequestContext::getMain()`
|
||||||
/// to obtain such an object.
|
/// to obtain such an object.
|
||||||
/// @returns undefined
|
/// @returns undefined
|
||||||
public static function processPage($title, $context) {
|
public static function processPage($title, IContextProvider $context) {
|
||||||
// TODO: make this namespace-aware
|
// TODO: make this namespace-aware
|
||||||
$titleObj = Title::makeTitle(0, $title);
|
$titleObj = Title::makeTitle(0, $title);
|
||||||
$page = WikiPage::factory($titleObj);
|
$page = WikiPage::factory($titleObj);
|
||||||
$content = $page->getContent();
|
$content = $page->getContent();
|
||||||
$article = Article::newFromWikiPage($page, $context);
|
LinkTitles::parseContent($page, $content);
|
||||||
LinkTitles::parseContent($article, $content);
|
|
||||||
$page->doQuickEditContent($content,
|
$page->doQuickEditContent($content,
|
||||||
$context->getUser(),
|
$context->getUser(),
|
||||||
"Links to existing pages added by LinkTitles bot.",
|
"Links to existing pages added by LinkTitles bot.",
|
||||||
@ -274,14 +273,14 @@
|
|||||||
/// page is displayed.
|
/// page is displayed.
|
||||||
/// @param $doubleUnderscoreIDs Array of magic word IDs.
|
/// @param $doubleUnderscoreIDs Array of magic word IDs.
|
||||||
/// @returns true
|
/// @returns true
|
||||||
public static function onGetDoubleUnderscoreIDs( &$doubleUnderscoreIDs ) {
|
public static function onGetDoubleUnderscoreIDs( array &$doubleUnderscoreIDs ) {
|
||||||
$doubleUnderscoreIDs[] = 'MAG_LINKTITLES_NOTARGET';
|
$doubleUnderscoreIDs[] = 'MAG_LINKTITLES_NOTARGET';
|
||||||
$doubleUnderscoreIDs[] = 'MAG_LINKTITLES_NOAUTOLINKS';
|
$doubleUnderscoreIDs[] = 'MAG_LINKTITLES_NOAUTOLINKS';
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build an anonymous callback function to be used in simple mode.
|
// Build an anonymous callback function to be used in simple mode.
|
||||||
private static function simpleModeCallback( $matches ) {
|
private static function simpleModeCallback( array $matches ) {
|
||||||
if ( LinkTitles::checkTargetPage() ) {
|
if ( LinkTitles::checkTargetPage() ) {
|
||||||
return '[[' . $matches[0] . ']]';
|
return '[[' . $matches[0] . ']]';
|
||||||
}
|
}
|
||||||
@ -298,7 +297,7 @@
|
|||||||
// If $wgCapitalLinks is set to true, the case of the first
|
// If $wgCapitalLinks is set to true, the case of the first
|
||||||
// letter is ignored by MediaWiki and we don't need to build a
|
// letter is ignored by MediaWiki and we don't need to build a
|
||||||
// piped link if only the case of the first letter is different.
|
// piped link if only the case of the first letter is different.
|
||||||
private static function smartModeCallback( $matches ) {
|
private static function smartModeCallback( array $matches ) {
|
||||||
global $wgCapitalLinks;
|
global $wgCapitalLinks;
|
||||||
|
|
||||||
if ( $wgCapitalLinks ) {
|
if ( $wgCapitalLinks ) {
|
||||||
@ -339,9 +338,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Sets member variables for the current target page.
|
/// Sets member variables for the current target page.
|
||||||
private static function newTarget( $titleString ) {
|
private static function newTarget( $title ) {
|
||||||
// @todo Make this wiki namespace aware.
|
// @todo Make this wiki namespace aware.
|
||||||
LinkTitles::$targetTitle = Title::makeTitle( NS_MAIN, $titleString );
|
LinkTitles::$targetTitle = Title::makeTitle( NS_MAIN, $title);
|
||||||
LinkTitles::$targetContent = null;
|
LinkTitles::$targetContent = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,10 +74,10 @@ class SpecialLinkTitles extends SpecialPage {
|
|||||||
/// Processes wiki articles, starting at the page indicated by
|
/// Processes wiki articles, starting at the page indicated by
|
||||||
/// $startTitle. If $wgLinkTitlesTimeLimit is reached before all pages are
|
/// $startTitle. If $wgLinkTitlesTimeLimit is reached before all pages are
|
||||||
/// processed, returns the title of the next page that needs processing.
|
/// processed, returns the title of the next page that needs processing.
|
||||||
/// @param $request WebRequest object that is associated with the special
|
/// @param WebRequest $request WebRequest object that is associated with the special
|
||||||
/// page.
|
/// page.
|
||||||
/// @param $output Output object that the special page is equipped with.
|
/// @param Output $output Output object that the special page is equipped with.
|
||||||
private function process(&$request, &$output) {
|
private function process( WebRequest &$request, Output &$output) {
|
||||||
global $wgLinkTitlesTimeLimit;
|
global $wgLinkTitlesTimeLimit;
|
||||||
|
|
||||||
// Start the stopwatch
|
// Start the stopwatch
|
||||||
|
Reference in New Issue
Block a user