Index: trunk/phase3/includes/api/ApiQueryLinks.php |
— | — | @@ -46,11 +46,13 @@ |
47 | 47 | $this->table = 'pagelinks'; |
48 | 48 | $this->prefix = 'pl'; |
49 | 49 | $this->description = 'link'; |
| 50 | + $this->titlesParam = 'titles'; |
50 | 51 | break; |
51 | 52 | case self::TEMPLATES: |
52 | 53 | $this->table = 'templatelinks'; |
53 | 54 | $this->prefix = 'tl'; |
54 | 55 | $this->description = 'template'; |
| 56 | + $this->titlesParam = 'templates'; |
55 | 57 | break; |
56 | 58 | default: |
57 | 59 | ApiBase::dieDebug( __METHOD__, 'Unknown module name' ); |
— | — | @@ -83,6 +85,22 @@ |
84 | 86 | $this->addTables( $this->table ); |
85 | 87 | $this->addWhereFld( $this->prefix . '_from', array_keys( $this->getPageSet()->getGoodTitles() ) ); |
86 | 88 | $this->addWhereFld( $this->prefix . '_namespace', $params['namespace'] ); |
| 89 | + |
| 90 | + if ( !is_null( $params[$this->titlesParam] ) ) { |
| 91 | + $lb = new LinkBatch; |
| 92 | + foreach ( $params[$this->titlesParam] as $t ) { |
| 93 | + $title = Title::newFromText( $t ); |
| 94 | + if ( !$title ) { |
| 95 | + $this->setWarning( "``$t'' is not a valid title" ); |
| 96 | + } else { |
| 97 | + $lb->addObj( $title ); |
| 98 | + } |
| 99 | + } |
| 100 | + $cond = $lb->constructSet( $this->prefix, $this->getDB() ); |
| 101 | + if ( $cond ) { |
| 102 | + $this->addWhere( $cond ); |
| 103 | + } |
| 104 | + } |
87 | 105 | |
88 | 106 | if ( !is_null( $params['continue'] ) ) { |
89 | 107 | $cont = explode( '|', $params['continue'] ); |
— | — | @@ -178,16 +196,25 @@ |
179 | 197 | ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2 |
180 | 198 | ), |
181 | 199 | 'continue' => null, |
| 200 | + $this->titlesParam => array( |
| 201 | + ApiBase::PARAM_ISMULTI => true, |
| 202 | + ), |
182 | 203 | ); |
183 | 204 | } |
184 | 205 | |
185 | 206 | public function getParamDescription() { |
186 | | - $desc = $this->description; |
187 | | - return array( |
| 207 | + $desc = $this->description; |
| 208 | + $arr = array( |
188 | 209 | 'namespace' => "Show {$desc}s in this namespace(s) only", |
189 | 210 | 'limit' => "How many {$desc}s to return", |
190 | 211 | 'continue' => 'When more results are available, use this to continue', |
191 | 212 | ); |
| 213 | + if ( $this->getModuleName() == self::LINKS ) { |
| 214 | + $arr[$this->titlesParam] = 'Only list links to these titles. Useful for checking whether a certain page links to a certain title.'; |
| 215 | + } else if ( $this->getModuleName() == self::TEMPLATES ) { |
| 216 | + $arr[$this->titlesParam] = 'Only list these templates. Useful for checking whether a certain page uses a certain template.'; |
| 217 | + } |
| 218 | + return $arr; |
192 | 219 | } |
193 | 220 | |
194 | 221 | public function getDescription() { |