mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-07-13 01:39:30 +02:00
Revise Special class.
- Change: The $wgLinkTitlesBatchTimeLimit configuration variable was renamed to $wgLinkTitlesSpecialPageReloadAfter.
This commit is contained in:
@ -27,7 +27,7 @@
|
||||
"LinkTitlesSmartMode": true,
|
||||
"LinkTitlesWordStartOnly": true,
|
||||
"LinkTitlesWordEndOnly": true,
|
||||
"LinkTitlesBatchTimeLimit": 1,
|
||||
"LinkTitlesSpecialPageReloadAfter": 1,
|
||||
"LinkTitlesNamespaces": [
|
||||
0
|
||||
]
|
||||
|
@ -149,6 +149,12 @@ class Config {
|
||||
*/
|
||||
public $enableNoTargetMagicWord;
|
||||
|
||||
/**
|
||||
* Time (in seconds) after which to reload the special page.
|
||||
* @var integer reload interval (in seconds)
|
||||
*/
|
||||
public $specialPageReloadAfter;
|
||||
|
||||
public $enableConsoleOutput;
|
||||
public $enableDebugConsoleOutput;
|
||||
|
||||
@ -174,6 +180,7 @@ class Config {
|
||||
global $wgLinkTitlesParseHeadings;
|
||||
global $wgLinkTitlesEnableNoTargetMagicWord;
|
||||
global $wgLinkTitlesCheckRedirect;
|
||||
global $wgLinkTitlesSpecialPageReloadAfter;
|
||||
$this->parseOnEdit = $wgLinkTitlesParseOnEdit;
|
||||
$this->parseOnRender = $wgLinkTitlesParseOnRender;
|
||||
$this->preferShortTitles = $wgLinkTitlesPreferShortTitles;
|
||||
@ -189,6 +196,7 @@ class Config {
|
||||
$this->parseHeadings = $wgLinkTitlesParseHeadings;
|
||||
$this->enableNoTargetMagicWord = $wgLinkTitlesEnableNoTargetMagicWord;;
|
||||
$this->checkRedirect = $wgLinkTitlesCheckRedirect;;
|
||||
$this->specialPageReloadAfter = $wgLinkTitlesSpecialPageReloadAfter;
|
||||
$this->enableConsoleOutput = false;
|
||||
$this->enableDebugConsoleOutput = false;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ if ( !defined( 'MEDIAWIKI' ) ) {
|
||||
*
|
||||
*/
|
||||
class Special extends \SpecialPage {
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* Constructor. Announces the special page title and required user right to the parent constructor.
|
||||
@ -46,6 +47,7 @@ class Special extends \SpecialPage {
|
||||
// users who have the 'linktitles-batch' right get to see this page (by
|
||||
// default, this are all sysop users).
|
||||
parent::__construct( 'LinkTitles', 'linktitles-batch' );
|
||||
$this->config = new Config();
|
||||
}
|
||||
|
||||
function getGroupName() {
|
||||
@ -94,11 +96,8 @@ class Special extends \SpecialPage {
|
||||
* @param OutputPage $output Output page for the special page.
|
||||
*/
|
||||
private function process( \WebRequest &$request, \OutputPage &$output) {
|
||||
global $wgLinkTitlesTimeLimit;
|
||||
global $wgLinkTitlesNamespaces;
|
||||
|
||||
// get our Namespaces
|
||||
$namespacesClause = str_replace( '_', ' ','(' . implode( ', ',$wgLinkTitlesNamespaces ) . ')' );
|
||||
$namespacesClause = str_replace( '_', ' ','(' . implode( ', ',$this->config->nameSpaces ) . ')' );
|
||||
|
||||
// Start the stopwatch
|
||||
$startTime = microtime( true );
|
||||
@ -147,7 +146,7 @@ class Special extends \SpecialPage {
|
||||
$start += 1;
|
||||
|
||||
// Check if the time limit is exceeded
|
||||
if ( microtime(true)-$startTime > $wgLinkTitlesTimeLimit )
|
||||
if ( microtime( true ) - $startTime > $config->specialPageReloadAfter )
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -244,14 +243,14 @@ EOF
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Generates an HTML form and JavaScript to automatically submit the
|
||||
* form.
|
||||
* @param $url URL to reload with a POST request.
|
||||
* @param $start Index of the next page that shall be processed.
|
||||
* @param $end Index of the last page to be processed.
|
||||
* @param $reloads Counter that holds the number of reloads so far.
|
||||
* @returns String that holds the HTML for a form and a JavaScript command.
|
||||
* @return String that holds the HTML for a form and a JavaScript command.
|
||||
*/
|
||||
private function getReloaderForm( $url, $start, $end, $reloads ) {
|
||||
return
|
||||
@ -268,16 +267,15 @@ EOF
|
||||
;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Adds statistics to the page when all processing is done.
|
||||
* @param $output Output object
|
||||
* @param $start Index of the first page that was processed.
|
||||
* @param $end Index of the last processed page.
|
||||
* @param $reloads Number of reloads of the page.
|
||||
* @returns undefined
|
||||
* @return undefined
|
||||
*/
|
||||
private function addCompletedInfo( &$output, $start, $end, $reloads ) {
|
||||
global $wgLinkTitlesTimeLimit;
|
||||
$pagesPerReload = sprintf('%0.1f', $end / $reloads);
|
||||
$output->addWikiText(
|
||||
<<<EOF
|
||||
@ -286,7 +284,7 @@ EOF
|
||||
|-
|
||||
| total number of pages: || ${end}
|
||||
|-
|
||||
| timeout setting [s]: || ${wgLinkTitlesTimeLimit}
|
||||
| timeout setting [s]: || {$config->specialPageReloadAfter}
|
||||
|-
|
||||
| webpage reloads: || ${reloads}
|
||||
|-
|
||||
@ -296,10 +294,10 @@ EOF
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Counts the number of pages in a read-access wiki database ($dbr).
|
||||
* @param $dbr Read-only `Database` object.
|
||||
* @returns Number of pages in the default namespace (0) of the wiki.
|
||||
* @return Number of pages in the default namespace (0) of the wiki.
|
||||
*/
|
||||
private function countPages( &$dbr, $namespacesClause ) {
|
||||
$res = $dbr->select(
|
||||
|
Reference in New Issue
Block a user