mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-07-13 17:59:29 +02:00
Move the page processing function to LinkTitles class.
A public static function was created to DRY things up.
This commit is contained in:
@ -299,6 +299,23 @@
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Automatically processes a single page, given a $title Title object.
|
||||||
|
/// This function is called by the SpecialLinkTitles class and the
|
||||||
|
/// LinkTitlesJob class.
|
||||||
|
public static function processPage($title, $context) {
|
||||||
|
// TODO: make this namespace-aware
|
||||||
|
$titleObj = Title::makeTitle(0, $title);
|
||||||
|
$page = WikiPage::factory($titleObj);
|
||||||
|
$article = Article::newFromWikiPage($page, $context);
|
||||||
|
$text = $article->getContent();
|
||||||
|
LinkTitles::parseContent($article, $text);
|
||||||
|
$content = new WikitextContent($text);
|
||||||
|
$page->doEditContent($content,
|
||||||
|
"Parsed for page titles by LinkTitles bot.",
|
||||||
|
EDIT_MINOR | EDIT_FORCE_BOT
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// Remove the magic words that this extension introduces from the
|
/// Remove the magic words that this extension introduces from the
|
||||||
/// $text, so that they do not appear on the rendered page.
|
/// $text, so that they do not appear on the rendered page.
|
||||||
static function removeMagicWord( &$parser, &$text ) {
|
static function removeMagicWord( &$parser, &$text ) {
|
||||||
|
@ -119,7 +119,7 @@ class SpecialLinkTitles extends SpecialPage {
|
|||||||
// Iterate through the pages; break if a time limit is exceeded.
|
// Iterate through the pages; break if a time limit is exceeded.
|
||||||
foreach ( $res as $row ) {
|
foreach ( $res as $row ) {
|
||||||
$curTitle = $row->page_title;
|
$curTitle = $row->page_title;
|
||||||
$this->processPage($curTitle);
|
LinkTitles::processPage($curTitle, $this->getContext());
|
||||||
$start += 1;
|
$start += 1;
|
||||||
|
|
||||||
// Check if the time limit is exceeded
|
// Check if the time limit is exceeded
|
||||||
@ -147,21 +147,6 @@ class SpecialLinkTitles extends SpecialPage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Processes a single page, given a $title Title object.
|
|
||||||
private function processPage($title) {
|
|
||||||
// TODO: make this namespace-aware
|
|
||||||
$titleObj = Title::makeTitle(0, $title);
|
|
||||||
$page = WikiPage::factory($titleObj);
|
|
||||||
$article = Article::newFromWikiPage($page, $this->getContext());
|
|
||||||
$text = $article->getContent();
|
|
||||||
LinkTitles::parseContent($article, $text);
|
|
||||||
$content = new WikitextContent($text);
|
|
||||||
$page->doEditContent($content,
|
|
||||||
"Parsed for page titles by LinkTitles bot.",
|
|
||||||
EDIT_MINOR | EDIT_FORCE_BOT
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Adds WikiText to the output containing information about the extension
|
/// Adds WikiText to the output containing information about the extension
|
||||||
/// and a form and button to start linking.
|
/// and a form and button to start linking.
|
||||||
|
Reference in New Issue
Block a user