$this->dfltNamespace = NS_MAIN;
$this->indexTag = 'l';
$this->description = 'Enumerate all links that point to a given namespace';
- $this->descriptionLink = 'link';
- $this->descriptionLinked = 'linked';
+ $this->descriptionWhat = 'link';
+ $this->descriptionTargets = 'linked titles';
$this->descriptionLinking = 'linking';
break;
case 'alltransclusions':
$this->dfltNamespace = NS_TEMPLATE;
$this->indexTag = 't';
$this->description = 'List all transclusions (pages embedded using {{x}}), including non-existing';
- $this->descriptionLink = 'transclusion';
- $this->descriptionLinked = 'transcluded';
+ $this->descriptionWhat = 'transclusion';
+ $this->descriptionTargets = 'transcluded titles';
$this->descriptionLinking = 'transcluding';
break;
default:
if ( $params['unique'] ) {
if ( $fld_ids ) {
$this->dieUsage(
- "{$this->getModuleName()} cannot return corresponding page ids in unique {$this->descriptionLink}s mode",
+ "{$this->getModuleName()} cannot return corresponding page ids in unique {$this->descriptionWhat}s mode",
'params' );
}
$this->addOption( 'DISTINCT' );
$continueArr = explode( '|', $params['continue'] );
$op = $params['dir'] == 'descending' ? '<' : '>';
if ( $params['unique'] ) {
- if ( count( $continueArr ) != 1 ) {
- $this->dieUsage( 'Invalid continue parameter', 'badcontinue' );
- }
+ $this->dieContinueUsageIf( count( $continueArr ) != 1 );
$continueTitle = $db->addQuotes( $continueArr[0] );
$this->addWhere( "{$pfx}title $op= $continueTitle" );
} else {
- if ( count( $continueArr ) != 2 ) {
- $this->dieUsage( 'Invalid continue parameter', 'badcontinue' );
- }
+ $this->dieContinueUsageIf( count( $continueArr ) != 2 );
$continueTitle = $db->addQuotes( $continueArr[0] );
$continueFrom = intval( $continueArr[1] );
$this->addWhere(
if ( $params['unique'] ) {
$this->setContinueEnumParameter( 'continue', $row->pl_title );
} else {
- $this->setContinueEnumParameter( 'continue', $row->pl_title . "|" . $row->pl_from );
+ $this->setContinueEnumParameter( 'continue', $row->pl_title . '|' . $row->pl_from );
}
break;
}
if ( $params['unique'] ) {
$this->setContinueEnumParameter( 'continue', $row->pl_title );
} else {
- $this->setContinueEnumParameter( 'continue', $row->pl_title . "|" . $row->pl_from );
+ $this->setContinueEnumParameter( 'continue', $row->pl_title . '|' . $row->pl_from );
}
break;
}
public function getParamDescription() {
$p = $this->getModulePrefix();
- $link = $this->descriptionLink;
+ $what = $this->descriptionWhat;
+ $targets = $this->descriptionTargets;
$linking = $this->descriptionLinking;
return array(
- 'from' => "The title of the $link to start enumerating from",
- 'to' => "The title of the $link to stop enumerating at",
- 'prefix' => "Search for all $link titles that begin with this value",
+ 'from' => "The title of the $what to start enumerating from",
+ 'to' => "The title of the $what to stop enumerating at",
+ 'prefix' => "Search for all $targets that begin with this value",
'unique' => array(
- "Only show distinct $link titles. Cannot be used with {$p}prop=ids.",
- 'When used as a generator, yields target pages instead of source pages.',
+ "Only show distinct $targets. Cannot be used with {$p}prop=ids.",
+ 'When used as a generator, yields target pages instead of source pages.',
),
'prop' => array(
'What pieces of information to include',
" ids - Adds the pageid of the $linking page (Cannot be used with {$p}unique)",
- " title - Adds the title of the $link",
+ " title - Adds the title of the $what",
),
'namespace' => 'The namespace to enumerate',
- 'limit' => "How many total items to return",
+ 'limit' => 'How many total items to return',
'continue' => 'When more results are available, use this to continue',
'dir' => 'The direction in which to list',
);
public function getPossibleErrors() {
$m = $this->getModuleName();
- $link = $this->descriptionLink;
+ $what = $this->descriptionWhat;
return array_merge( parent::getPossibleErrors(), array(
- array( 'code' => 'params', 'info' => "{$m} cannot return corresponding page ids in unique {$link}s mode" ),
- array( 'code' => 'badcontinue', 'info' => 'Invalid continue parameter' ),
+ array( 'code' => 'params', 'info' => "{$m} cannot return corresponding page ids in unique {$what}s mode" ),
) );
}
public function getExamples() {
$p = $this->getModulePrefix();
- $link = $this->descriptionLink;
- $linked = $this->descriptionLinked;
+ $name = $this->getModuleName();
+ $what = $this->descriptionWhat;
+ $targets = $this->descriptionTargets;
return array(
- "api.php?action=query&list=all{$link}s&{$p}from=B&{$p}prop=ids|title"
- => "List $linked titles with page ids they are from, including missing ones. Start at B",
- "api.php?action=query&list=all{$link}s&{$p}unique=&{$p}from=B"
- => "List unique $linked titles",
- "api.php?action=query&generator=all{$link}s&g{$p}unique=&g{$p}from=B"
- => "Gets all $link targets, marking the missing ones",
- "api.php?action=query&generator=all{$link}s&g{$p}from=B"
- => "Gets pages containing the {$link}s",
+ "api.php?action=query&list={$name}&{$p}from=B&{$p}prop=ids|title"
+ => "List $targets with page ids they are from, including missing ones. Start at B",
+ "api.php?action=query&list={$name}&{$p}unique=&{$p}from=B"
+ => "List unique $targets",
+ "api.php?action=query&generator={$name}&g{$p}unique=&g{$p}from=B"
+ => "Gets all $targets, marking the missing ones",
+ "api.php?action=query&generator={$name}&g{$p}from=B"
+ => "Gets pages containing the {$what}s",
);
}
public function getHelpUrls() {
- return "https://www.mediawiki.org/wiki/API:All{$this->descriptionLink}s";
- }
-
- public function getVersion() {
- return __CLASS__ . ': $Id$';
+ $name = ucfirst( $this->getModuleName() );
+ return "https://www.mediawiki.org/wiki/API:{$name}";
}
}