2006-10-25 17:16:37 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Created on Oct 16, 2006
|
|
|
|
|
*
|
|
|
|
|
* API for MediaWiki 1.8+
|
|
|
|
|
*
|
2007-05-20 23:31:44 +00:00
|
|
|
* Copyright (C) 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
|
2006-10-25 17:16:37 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (!defined('MEDIAWIKI')) {
|
|
|
|
|
// Eclipse helper - will be ignored in production
|
|
|
|
|
require_once ("ApiQueryBase.php");
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-20 08:55:14 +00:00
|
|
|
/**
|
2007-05-20 23:31:44 +00:00
|
|
|
* This is three-in-one module to query:
|
|
|
|
|
* * backlinks - links pointing to the given page,
|
|
|
|
|
* * embeddedin - what pages transclude the given page within themselves,
|
|
|
|
|
* * imageusage - what pages use the given image
|
2008-04-14 07:45:50 +00:00
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup API
|
2007-04-20 08:55:14 +00:00
|
|
|
*/
|
2006-10-25 17:16:37 +00:00
|
|
|
class ApiQueryBacklinks extends ApiQueryGeneratorBase {
|
|
|
|
|
|
2008-02-25 14:32:57 +00:00
|
|
|
private $params, $rootTitle, $contRedirs, $contLevel, $contTitle, $contID, $redirID;
|
2006-10-25 17:16:37 +00:00
|
|
|
|
2008-04-14 07:45:50 +00:00
|
|
|
// output element name, database column field prefix, database table
|
2006-10-30 00:18:05 +00:00
|
|
|
private $backlinksSettings = array (
|
|
|
|
|
'backlinks' => array (
|
|
|
|
|
'code' => 'bl',
|
|
|
|
|
'prefix' => 'pl',
|
|
|
|
|
'linktbl' => 'pagelinks'
|
|
|
|
|
),
|
|
|
|
|
'embeddedin' => array (
|
|
|
|
|
'code' => 'ei',
|
|
|
|
|
'prefix' => 'tl',
|
|
|
|
|
'linktbl' => 'templatelinks'
|
|
|
|
|
),
|
2007-05-14 05:28:06 +00:00
|
|
|
'imageusage' => array (
|
|
|
|
|
'code' => 'iu',
|
2006-10-30 00:18:05 +00:00
|
|
|
'prefix' => 'il',
|
|
|
|
|
'linktbl' => 'imagelinks'
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2006-10-25 17:16:37 +00:00
|
|
|
public function __construct($query, $moduleName) {
|
2006-10-30 00:18:05 +00:00
|
|
|
$code = $prefix = $linktbl = null;
|
|
|
|
|
extract($this->backlinksSettings[$moduleName]);
|
|
|
|
|
|
|
|
|
|
parent :: __construct($query, $moduleName, $code);
|
|
|
|
|
$this->bl_ns = $prefix . '_namespace';
|
|
|
|
|
$this->bl_from = $prefix . '_from';
|
2008-02-25 14:32:57 +00:00
|
|
|
$this->bl_table = $linktbl;
|
2006-10-30 00:18:05 +00:00
|
|
|
$this->bl_code = $code;
|
|
|
|
|
|
2007-05-14 05:28:06 +00:00
|
|
|
$this->hasNS = $moduleName !== 'imageusage';
|
2006-10-30 00:18:05 +00:00
|
|
|
if ($this->hasNS) {
|
|
|
|
|
$this->bl_title = $prefix . '_title';
|
|
|
|
|
$this->bl_sort = "{$this->bl_ns}, {$this->bl_title}, {$this->bl_from}";
|
|
|
|
|
$this->bl_fields = array (
|
|
|
|
|
$this->bl_ns,
|
|
|
|
|
$this->bl_title
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
$this->bl_title = $prefix . '_to';
|
|
|
|
|
$this->bl_sort = "{$this->bl_title}, {$this->bl_from}";
|
|
|
|
|
$this->bl_fields = array (
|
|
|
|
|
$this->bl_title
|
|
|
|
|
);
|
|
|
|
|
}
|
2006-10-25 17:16:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function execute() {
|
|
|
|
|
$this->run();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function executeGenerator($resultPageSet) {
|
|
|
|
|
$this->run($resultPageSet);
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-02-25 14:32:57 +00:00
|
|
|
private function prepareFirstQuery($resultPageSet = null) {
|
|
|
|
|
/* SELECT page_id, page_title, page_namespace, page_is_redirect
|
2008-05-10 10:49:26 +00:00
|
|
|
* FROM pagelinks, page WHERE pl_from=page_id
|
|
|
|
|
* AND pl_title='Foo' AND pl_namespace=0
|
2008-02-25 14:32:57 +00:00
|
|
|
* LIMIT 11 ORDER BY pl_from
|
|
|
|
|
*/
|
|
|
|
|
$db = $this->getDb();
|
2008-05-10 10:49:26 +00:00
|
|
|
$this->addTables(array('page', $this->bl_table));
|
|
|
|
|
$this->addWhere("{$this->bl_from}=page_id");
|
2008-02-25 14:32:57 +00:00
|
|
|
if(is_null($resultPageSet))
|
2008-03-18 19:31:02 +00:00
|
|
|
$this->addFields(array('page_id', 'page_title', 'page_namespace'));
|
2006-10-30 00:18:05 +00:00
|
|
|
else
|
2008-02-25 14:32:57 +00:00
|
|
|
$this->addFields($resultPageSet->getPageTableFields());
|
2008-03-18 19:31:02 +00:00
|
|
|
$this->addFields('page_is_redirect');
|
2008-02-25 14:32:57 +00:00
|
|
|
$this->addWhereFld($this->bl_title, $this->rootTitle->getDbKey());
|
|
|
|
|
if($this->hasNS)
|
2006-10-30 00:18:05 +00:00
|
|
|
$this->addWhereFld($this->bl_ns, $this->rootTitle->getNamespace());
|
2007-07-06 07:16:38 +00:00
|
|
|
$this->addWhereFld('page_namespace', $this->params['namespace']);
|
2008-02-25 14:32:57 +00:00
|
|
|
if(!is_null($this->contID))
|
|
|
|
|
$this->addWhere("page_id>={$this->contID}");
|
2007-09-04 14:44:46 +00:00
|
|
|
if($this->params['filterredir'] == 'redirects')
|
|
|
|
|
$this->addWhereFld('page_is_redirect', 1);
|
|
|
|
|
if($this->params['filterredir'] == 'nonredirects')
|
|
|
|
|
$this->addWhereFld('page_is_redirect', 0);
|
2008-02-25 14:32:57 +00:00
|
|
|
$this->addOption('LIMIT', $this->params['limit'] + 1);
|
|
|
|
|
$this->addOption('ORDER BY', $this->bl_from);
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-02-25 14:32:57 +00:00
|
|
|
private function prepareSecondQuery($resultPageSet = null) {
|
|
|
|
|
/* SELECT page_id, page_title, page_namespace, page_is_redirect, pl_title, pl_namespace
|
2008-05-10 10:49:26 +00:00
|
|
|
* FROM pagelinks, page WHERE pl_from=page_id
|
|
|
|
|
* AND (pl_title='Foo' AND pl_namespace=0) OR (pl_title='Bar' AND pl_namespace=1)
|
2008-02-25 14:32:57 +00:00
|
|
|
* LIMIT 11 ORDER BY pl_namespace, pl_title, pl_from
|
|
|
|
|
*/
|
|
|
|
|
$db = $this->getDb();
|
2008-05-10 10:49:26 +00:00
|
|
|
$this->addTables(array('page', $this->bl_table));
|
|
|
|
|
$this->addWhere("{$this->bl_from}=page_id");
|
2008-02-25 14:32:57 +00:00
|
|
|
if(is_null($resultPageSet))
|
|
|
|
|
$this->addFields(array('page_id', 'page_title', 'page_namespace', 'page_is_redirect'));
|
|
|
|
|
else
|
|
|
|
|
$this->addFields($resultPageSet->getPageTableFields());
|
|
|
|
|
$this->addFields($this->bl_title);
|
|
|
|
|
if($this->hasNS)
|
|
|
|
|
$this->addFields($this->bl_ns);
|
|
|
|
|
$titleWhere = '';
|
|
|
|
|
foreach($this->redirTitles as $t)
|
2008-04-14 07:45:50 +00:00
|
|
|
$titleWhere .= ($titleWhere != '' ? " OR " : '') .
|
2008-06-13 13:22:50 +00:00
|
|
|
"({$this->bl_title} = ".$db->addQuotes($t->getDBKey()).
|
2008-02-25 14:32:57 +00:00
|
|
|
($this->hasNS ? " AND {$this->bl_ns} = '{$t->getNamespace()}'" : "") .
|
|
|
|
|
")";
|
|
|
|
|
$this->addWhere($titleWhere);
|
|
|
|
|
$this->addWhereFld('page_namespace', $this->params['namespace']);
|
|
|
|
|
if(!is_null($this->redirID))
|
|
|
|
|
$this->addWhere("page_id>={$this->redirID}");
|
|
|
|
|
if($this->params['filterredir'] == 'redirects')
|
|
|
|
|
$this->addWhereFld('page_is_redirect', 1);
|
|
|
|
|
if($this->params['filterredir'] == 'nonredirects')
|
|
|
|
|
$this->addWhereFld('page_is_redirect', 0);
|
|
|
|
|
$this->addOption('LIMIT', $this->params['limit'] + 1);
|
2006-10-30 00:18:05 +00:00
|
|
|
$this->addOption('ORDER BY', $this->bl_sort);
|
2008-02-25 14:32:57 +00:00
|
|
|
}
|
2006-10-25 17:16:37 +00:00
|
|
|
|
2008-02-25 14:32:57 +00:00
|
|
|
private function run($resultPageSet = null) {
|
|
|
|
|
$this->params = $this->extractRequestParams(false);
|
2008-04-22 18:43:22 +00:00
|
|
|
$this->redirect = isset($this->params['redirect']) && $this->params['redirect'];
|
|
|
|
|
$userMax = ( $this->redirect ? ApiBase::LIMIT_BIG1/2 : ApiBase::LIMIT_BIG1 );
|
|
|
|
|
$botMax = ( $this->redirect ? ApiBase::LIMIT_BIG2/2 : ApiBase::LIMIT_BIG2 );
|
2008-02-25 14:32:57 +00:00
|
|
|
if( $this->params['limit'] == 'max' ) {
|
|
|
|
|
$this->params['limit'] = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
|
|
|
|
|
$this->getResult()->addValue( 'limits', $this->getModuleName(), $this->params['limit'] );
|
2006-10-25 17:16:37 +00:00
|
|
|
}
|
2006-10-27 03:50:34 +00:00
|
|
|
|
2008-02-25 14:32:57 +00:00
|
|
|
$this->processContinue();
|
|
|
|
|
$this->prepareFirstQuery($resultPageSet);
|
|
|
|
|
|
|
|
|
|
$db = $this->getDB();
|
2006-10-25 17:16:37 +00:00
|
|
|
$res = $this->select(__METHOD__);
|
|
|
|
|
|
|
|
|
|
$count = 0;
|
2008-02-25 14:32:57 +00:00
|
|
|
$this->data = array ();
|
|
|
|
|
$this->continueStr = null;
|
|
|
|
|
$this->redirTitles = array();
|
2006-10-25 17:16:37 +00:00
|
|
|
while ($row = $db->fetchObject($res)) {
|
2008-02-25 14:32:57 +00:00
|
|
|
if (++ $count > $this->params['limit']) {
|
2006-10-25 17:16:37 +00:00
|
|
|
// We've reached the one extra which shows that there are additional pages to be had. Stop here...
|
2008-02-25 14:32:57 +00:00
|
|
|
// Continue string preserved in case the redirect query doesn't pass the limit
|
|
|
|
|
$this->continueStr = $this->getContinueStr($row->page_id);
|
2006-10-25 17:16:37 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-25 14:32:57 +00:00
|
|
|
if (is_null($resultPageSet))
|
|
|
|
|
$this->extractRowInfo($row);
|
|
|
|
|
else
|
2008-03-18 19:31:02 +00:00
|
|
|
{
|
|
|
|
|
if($row->page_is_redirect)
|
|
|
|
|
$this->redirTitles[] = Title::makeTitle($row->page_namespace, $row->page_title);
|
2006-10-25 17:16:37 +00:00
|
|
|
$resultPageSet->processDbRow($row);
|
2008-03-18 19:31:02 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
}
|
2008-02-25 14:32:57 +00:00
|
|
|
$db->freeResult($res);
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-22 18:43:22 +00:00
|
|
|
if($this->redirect && !empty($this->redirTitles))
|
2008-02-25 14:32:57 +00:00
|
|
|
{
|
|
|
|
|
$this->resetQueryParams();
|
|
|
|
|
$this->prepareSecondQuery($resultPageSet);
|
|
|
|
|
$res = $this->select(__METHOD__);
|
|
|
|
|
$count = 0;
|
|
|
|
|
while($row = $db->fetchObject($res))
|
|
|
|
|
{
|
|
|
|
|
if(++$count > $this->params['limit'])
|
|
|
|
|
{
|
|
|
|
|
// We've reached the one extra which shows that there are additional pages to be had. Stop here...
|
|
|
|
|
// We need to keep the parent page of this redir in
|
|
|
|
|
if($this->hasNS)
|
|
|
|
|
$contTitle = Title::makeTitle($row->{$this->bl_ns}, $row->{$this->bl_title});
|
|
|
|
|
else
|
|
|
|
|
$contTitle = Title::makeTitle(NS_IMAGE, $row->{$this->bl_title});
|
|
|
|
|
$this->continueStr = $this->getContinueRedirStr($contTitle->getArticleID(), $row->page_id);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-02-25 14:32:57 +00:00
|
|
|
if(is_null($resultPageSet))
|
|
|
|
|
$this->extractRedirRowInfo($row);
|
|
|
|
|
else
|
|
|
|
|
$resultPageSet->processDbRow($row);
|
2006-10-25 17:16:37 +00:00
|
|
|
}
|
2008-02-25 14:32:57 +00:00
|
|
|
$db->freeResult($res);
|
2006-10-25 17:16:37 +00:00
|
|
|
}
|
2008-02-25 14:32:57 +00:00
|
|
|
if(!is_null($this->continueStr))
|
|
|
|
|
$this->setContinueEnumParameter('continue', $this->continueStr);
|
2006-10-25 17:16:37 +00:00
|
|
|
|
2007-11-16 22:50:59 +00:00
|
|
|
if (is_null($resultPageSet)) {
|
2008-02-25 14:32:57 +00:00
|
|
|
$resultData = array();
|
|
|
|
|
foreach($this->data as $ns => $a)
|
|
|
|
|
foreach($a as $title => $arr)
|
|
|
|
|
$resultData[$arr['pageid']] = $arr;
|
2006-10-25 17:16:37 +00:00
|
|
|
$result = $this->getResult();
|
2008-02-25 14:32:57 +00:00
|
|
|
$result->setIndexedTagName($resultData, $this->bl_code);
|
|
|
|
|
$result->addValue('query', $this->getModuleName(), $resultData);
|
2006-10-25 17:16:37 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-21 00:10:01 +00:00
|
|
|
private function extractRowInfo($row) {
|
2008-02-25 14:32:57 +00:00
|
|
|
if(!isset($this->data[$row->page_namespace][$row->page_title])) {
|
|
|
|
|
$this->data[$row->page_namespace][$row->page_title]['pageid'] = $row->page_id;
|
|
|
|
|
ApiQueryBase::addTitleInfo($this->data[$row->page_namespace][$row->page_title], Title::makeTitle($row->page_namespace, $row->page_title));
|
|
|
|
|
if($row->page_is_redirect)
|
|
|
|
|
{
|
|
|
|
|
$this->data[$row->page_namespace][$row->page_title]['redirect'] = '';
|
|
|
|
|
$this->redirTitles[] = Title::makeTitle($row->page_namespace, $row->page_title);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-02-25 14:32:57 +00:00
|
|
|
private function extractRedirRowInfo($row)
|
|
|
|
|
{
|
|
|
|
|
$a['pageid'] = $row->page_id;
|
|
|
|
|
ApiQueryBase::addTitleInfo($a, Title::makeTitle($row->page_namespace, $row->page_title));
|
|
|
|
|
if($row->page_is_redirect)
|
|
|
|
|
$a['redirect'] = '';
|
|
|
|
|
$ns = $this->hasNS ? $row->{$this->bl_ns} : NS_IMAGE;
|
|
|
|
|
$this->data[$ns][$row->{$this->bl_title}]['redirlinks'][] = $a;
|
2008-04-14 07:45:50 +00:00
|
|
|
$this->getResult()->setIndexedTagName($this->data[$ns][$row->{$this->bl_title}]['redirlinks'], $this->bl_code);
|
2007-05-21 00:10:01 +00:00
|
|
|
}
|
|
|
|
|
|
2007-07-06 07:16:38 +00:00
|
|
|
protected function processContinue() {
|
2008-02-25 14:32:57 +00:00
|
|
|
if (!is_null($this->params['continue']))
|
2007-07-06 07:16:38 +00:00
|
|
|
$this->parseContinueParam();
|
2008-02-25 14:32:57 +00:00
|
|
|
else {
|
2008-06-05 00:00:07 +00:00
|
|
|
if ( $this->params['title'] !== "" ) {
|
|
|
|
|
$title = Title::newFromText( $this->params['title'] );
|
|
|
|
|
if ( !$title ) {
|
2008-06-12 11:43:15 +00:00
|
|
|
$this->dieUsageMsg(array('invalidtitle', $this->params['title']));
|
2008-06-05 00:00:07 +00:00
|
|
|
} else {
|
|
|
|
|
$this->rootTitle = $title;
|
|
|
|
|
}
|
2008-05-10 10:49:26 +00:00
|
|
|
} else {
|
|
|
|
|
$this->dieUsageMsg(array('missingparam', 'title'));
|
2007-07-06 07:16:38 +00:00
|
|
|
}
|
2006-10-25 17:16:37 +00:00
|
|
|
}
|
2006-10-30 00:18:05 +00:00
|
|
|
|
2008-02-25 14:32:57 +00:00
|
|
|
// only image titles are allowed for the root in imageinfo mode
|
2006-10-30 00:18:05 +00:00
|
|
|
if (!$this->hasNS && $this->rootTitle->getNamespace() !== NS_IMAGE)
|
|
|
|
|
$this->dieUsage("The title for {$this->getModuleName()} query must be an image", 'bad_image_title');
|
2006-10-25 17:16:37 +00:00
|
|
|
}
|
|
|
|
|
|
2007-07-06 07:16:38 +00:00
|
|
|
protected function parseContinueParam() {
|
|
|
|
|
$continueList = explode('|', $this->params['continue']);
|
2008-02-25 14:32:57 +00:00
|
|
|
// expected format:
|
|
|
|
|
// ns | key | id1 [| id2]
|
|
|
|
|
// ns+key: root title
|
|
|
|
|
// id1: first-level page ID to continue from
|
|
|
|
|
// id2: second-level page ID to continue from
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-02-25 14:32:57 +00:00
|
|
|
// null stuff out now so we know what's set and what isn't
|
|
|
|
|
$this->rootTitle = $this->contID = $this->redirID = null;
|
|
|
|
|
$rootNs = intval($continueList[0]);
|
|
|
|
|
if($rootNs === 0 && $continueList[0] !== '0')
|
|
|
|
|
// Illegal continue parameter
|
|
|
|
|
$this->dieUsage("Invalid continue param. You should pass the original value returned by the previous query", "_badcontinue");
|
|
|
|
|
$this->rootTitle = Title::makeTitleSafe($rootNs, $continueList[1]);
|
|
|
|
|
if(!$this->rootTitle)
|
|
|
|
|
$this->dieUsage("Invalid continue param. You should pass the original value returned by the previous query", "_badcontinue");
|
|
|
|
|
$contID = intval($continueList[2]);
|
|
|
|
|
if($contID === 0 && $continueList[2] !== '0')
|
|
|
|
|
$this->dieUsage("Invalid continue param. You should pass the original value returned by the previous query", "_badcontinue");
|
|
|
|
|
$this->contID = $contID;
|
|
|
|
|
$redirID = intval(@$continueList[3]);
|
|
|
|
|
if($redirID === 0 && @$continueList[3] !== '0')
|
|
|
|
|
// This one isn't required
|
|
|
|
|
return;
|
|
|
|
|
$this->redirID = $redirID;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2006-10-25 17:16:37 +00:00
|
|
|
}
|
|
|
|
|
|
2006-10-30 00:18:05 +00:00
|
|
|
protected function getContinueStr($lastPageID) {
|
|
|
|
|
return $this->rootTitle->getNamespace() .
|
|
|
|
|
'|' . $this->rootTitle->getDBkey() .
|
|
|
|
|
'|' . $lastPageID;
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-25 14:32:57 +00:00
|
|
|
protected function getContinueRedirStr($lastPageID, $lastRedirID) {
|
|
|
|
|
return $this->getContinueStr($lastPageID) . '|' . $lastRedirID;
|
2006-10-30 00:18:05 +00:00
|
|
|
}
|
|
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getAllowedParams() {
|
2008-03-18 19:31:02 +00:00
|
|
|
$retval = array (
|
2007-07-06 07:16:38 +00:00
|
|
|
'title' => null,
|
2006-10-25 17:16:37 +00:00
|
|
|
'continue' => null,
|
|
|
|
|
'namespace' => array (
|
|
|
|
|
ApiBase :: PARAM_ISMULTI => true,
|
2006-11-03 06:53:47 +00:00
|
|
|
ApiBase :: PARAM_TYPE => 'namespace'
|
2006-10-25 17:16:37 +00:00
|
|
|
),
|
2007-09-04 14:44:46 +00:00
|
|
|
'filterredir' => array(
|
|
|
|
|
ApiBase :: PARAM_DFLT => 'all',
|
|
|
|
|
ApiBase :: PARAM_TYPE => array(
|
|
|
|
|
'all',
|
|
|
|
|
'redirects',
|
|
|
|
|
'nonredirects'
|
|
|
|
|
)
|
|
|
|
|
),
|
2006-10-25 17:16:37 +00:00
|
|
|
'limit' => array (
|
|
|
|
|
ApiBase :: PARAM_DFLT => 10,
|
|
|
|
|
ApiBase :: PARAM_TYPE => 'limit',
|
|
|
|
|
ApiBase :: PARAM_MIN => 1,
|
2007-05-19 18:08:36 +00:00
|
|
|
ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1,
|
2006-10-25 17:16:37 +00:00
|
|
|
ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2
|
|
|
|
|
)
|
|
|
|
|
);
|
2008-03-18 19:31:02 +00:00
|
|
|
if($this->getModuleName() == 'embeddedin')
|
|
|
|
|
return $retval;
|
|
|
|
|
$retval['redirect'] = false;
|
|
|
|
|
return $retval;
|
2006-10-25 17:16:37 +00:00
|
|
|
}
|
|
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getParamDescription() {
|
2008-03-18 19:31:02 +00:00
|
|
|
$retval = array (
|
2007-07-06 07:16:38 +00:00
|
|
|
'title' => 'Title to search. If null, titles= parameter will be used instead, but will be obsolete soon.',
|
2006-10-25 17:16:37 +00:00
|
|
|
'continue' => 'When more results are available, use this to continue.',
|
|
|
|
|
'namespace' => 'The namespace to enumerate.',
|
2008-03-18 19:31:02 +00:00
|
|
|
'filterredir' => 'How to filter for redirects'
|
2006-10-25 17:16:37 +00:00
|
|
|
);
|
2008-03-18 19:31:02 +00:00
|
|
|
if($this->getModuleName() != 'embeddedin')
|
|
|
|
|
return array_merge($retval, array(
|
|
|
|
|
'redirect' => 'If linking page is a redirect, find all pages that link to that redirect as well. Maximum limit is halved.',
|
|
|
|
|
'limit' => "How many total pages to return. If {$this->bl_code}redirect is enabled, limit applies to each level separately."
|
|
|
|
|
));
|
|
|
|
|
return array_merge($retval, array(
|
|
|
|
|
'limit' => "How many total pages to return."
|
|
|
|
|
));
|
2006-10-25 17:16:37 +00:00
|
|
|
}
|
|
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getDescription() {
|
2006-11-03 06:53:47 +00:00
|
|
|
switch ($this->getModuleName()) {
|
|
|
|
|
case 'backlinks' :
|
|
|
|
|
return 'Find all pages that link to the given page';
|
|
|
|
|
case 'embeddedin' :
|
|
|
|
|
return 'Find all pages that embed (transclude) the given title';
|
2007-05-14 05:28:06 +00:00
|
|
|
case 'imageusage' :
|
2006-11-03 06:53:47 +00:00
|
|
|
return 'Find all pages that use the given image title.';
|
|
|
|
|
default :
|
|
|
|
|
ApiBase :: dieDebug(__METHOD__, 'Unknown module name');
|
|
|
|
|
}
|
2006-10-25 17:16:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function getExamples() {
|
2006-10-30 00:18:05 +00:00
|
|
|
static $examples = array (
|
|
|
|
|
'backlinks' => array (
|
2007-07-06 07:16:38 +00:00
|
|
|
"api.php?action=query&list=backlinks&bltitle=Main%20Page",
|
|
|
|
|
"api.php?action=query&generator=backlinks&gbltitle=Main%20Page&prop=info"
|
2006-10-30 00:18:05 +00:00
|
|
|
),
|
|
|
|
|
'embeddedin' => array (
|
2007-07-06 07:16:38 +00:00
|
|
|
"api.php?action=query&list=embeddedin&eititle=Template:Stub",
|
|
|
|
|
"api.php?action=query&generator=embeddedin&geititle=Template:Stub&prop=info"
|
2006-10-30 00:18:05 +00:00
|
|
|
),
|
2007-05-14 05:28:06 +00:00
|
|
|
'imageusage' => array (
|
2007-07-06 07:16:38 +00:00
|
|
|
"api.php?action=query&list=imageusage&iutitle=Image:Albert%20Einstein%20Head.jpg",
|
|
|
|
|
"api.php?action=query&generator=imageusage&giutitle=Image:Albert%20Einstein%20Head.jpg&prop=info"
|
2006-10-30 00:18:05 +00:00
|
|
|
)
|
2006-10-25 17:16:37 +00:00
|
|
|
);
|
2006-10-30 00:18:05 +00:00
|
|
|
|
|
|
|
|
return $examples[$this->getModuleName()];
|
2006-10-25 17:16:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getVersion() {
|
2007-12-06 18:33:18 +00:00
|
|
|
return __CLASS__ . ': $Id$';
|
2006-10-25 17:16:37 +00:00
|
|
|
}
|
|
|
|
|
}
|