r23044 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23043‎ | r23044 | r23045 >
Date:08:50, 17 June 2007
Author:yurik
Status:old
Tags:
Comment:
API: Added filter by namespace to links & templates query - bug 10275
Patch by Roan Kattouw with minor mod.
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryLinks.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryLinks.php
@@ -73,6 +73,8 @@
7474 if ($this->getPageSet()->getGoodTitleCount() == 0)
7575 return; // nothing to do
7676
 77+ $params = $this->extractRequestParams();
 78+
7779 $this->addFields(array (
7880 $this->prefix . '_from pl_from',
7981 $this->prefix . '_namespace pl_namespace',
@@ -81,6 +83,7 @@
8284
8385 $this->addTables($this->table);
8486 $this->addWhereFld($this->prefix . '_from', array_keys($this->getPageSet()->getGoodTitles()));
 87+ $this->addWhereFld($this->prefix . '_namespace', $params['namespace']);
8588 $this->addOption('ORDER BY', str_replace('pl_', $this->prefix . '_', 'pl_from, pl_namespace, pl_title'));
8689
8790 $db = $this->getDB();
@@ -131,6 +134,23 @@
132135 $data);
133136 }
134137
 138+ protected function getAllowedParams()
 139+ {
 140+ return array(
 141+ 'namespace' => array(
 142+ ApiBase :: PARAM_TYPE => 'namespace',
 143+ ApiBase :: PARAM_ISMULTI => true
 144+ )
 145+ );
 146+ }
 147+
 148+ protected function getParamDescription()
 149+ {
 150+ return array(
 151+ 'namespace' => "Show {$this->description}s in this namespace(s) only"
 152+ );
 153+ }
 154+
135155 protected function getDescription() {
136156 return "Returns all {$this->description}s from the given page(s)";
137157 }
@@ -140,7 +160,9 @@
141161 "Get {$this->description}s from the [[Main Page]]:",
142162 " api.php?action=query&prop={$this->getModuleName()}&titles=Main%20Page",
143163 "Get information about the {$this->description} pages in the [[Main Page]]:",
144 - " api.php?action=query&generator={$this->getModuleName()}&titles=Main%20Page&prop=info"
 164+ " api.php?action=query&generator={$this->getModuleName()}&titles=Main%20Page&prop=info",
 165+ "Get {$this->description}s from the Main Page in the User and Template namespaces:",
 166+ " api.php?action=query&prop={$this->getModuleName()}&titles=Main%20Page&{$this->prefix}namespace=2|10"
145167 );
146168 }
147169

Follow-up revisions

RevisionCommit summaryAuthorDate
r23050Merged revisions 23038-23049 via svnmerge from...david00:01, 18 June 2007

Status & tagging log