Kill "* @return void"
[lhc/web/wiklou.git] / includes / api / ApiQueryInfo.php
1 <?php
2 /**
3 *
4 *
5 * Created on Sep 25, 2006
6 *
7 * Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * http://www.gnu.org/copyleft/gpl.html
23 *
24 * @file
25 */
26
27 /**
28 * A query module to show basic page information.
29 *
30 * @ingroup API
31 */
32 class ApiQueryInfo extends ApiQueryBase {
33
34 private $fld_protection = false, $fld_talkid = false,
35 $fld_subjectid = false, $fld_url = false,
36 $fld_readable = false, $fld_watched = false,
37 $fld_preload = false, $fld_displaytitle = false;
38
39 private $params, $titles, $missing, $everything, $pageCounter;
40
41 private $pageRestrictions, $pageIsRedir, $pageIsNew, $pageTouched,
42 $pageLatest, $pageLength;
43
44 private $protections, $watched, $talkids, $subjectids, $displaytitles;
45
46 private $tokenFunctions;
47
48 public function __construct( $query, $moduleName ) {
49 parent::__construct( $query, $moduleName, 'in' );
50 }
51
52 /**
53 * @param $pageSet ApiPageSet
54 */
55 public function requestExtraData( $pageSet ) {
56 global $wgDisableCounters;
57
58 $pageSet->requestField( 'page_restrictions' );
59 $pageSet->requestField( 'page_is_redirect' );
60 $pageSet->requestField( 'page_is_new' );
61 if ( !$wgDisableCounters ) {
62 $pageSet->requestField( 'page_counter' );
63 }
64 $pageSet->requestField( 'page_touched' );
65 $pageSet->requestField( 'page_latest' );
66 $pageSet->requestField( 'page_len' );
67 }
68
69 /**
70 * Get an array mapping token names to their handler functions.
71 * The prototype for a token function is func($pageid, $title)
72 * it should return a token or false (permission denied)
73 * @return array array(tokenname => function)
74 */
75 protected function getTokenFunctions() {
76 // Don't call the hooks twice
77 if ( isset( $this->tokenFunctions ) ) {
78 return $this->tokenFunctions;
79 }
80
81 // If we're in JSON callback mode, no tokens can be obtained
82 if ( !is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) ) {
83 return array();
84 }
85
86 $this->tokenFunctions = array(
87 'edit' => array( 'ApiQueryInfo', 'getEditToken' ),
88 'delete' => array( 'ApiQueryInfo', 'getDeleteToken' ),
89 'protect' => array( 'ApiQueryInfo', 'getProtectToken' ),
90 'move' => array( 'ApiQueryInfo', 'getMoveToken' ),
91 'block' => array( 'ApiQueryInfo', 'getBlockToken' ),
92 'unblock' => array( 'ApiQueryInfo', 'getUnblockToken' ),
93 'email' => array( 'ApiQueryInfo', 'getEmailToken' ),
94 'import' => array( 'ApiQueryInfo', 'getImportToken' ),
95 'watch' => array( 'ApiQueryInfo', 'getWatchToken'),
96 );
97 wfRunHooks( 'APIQueryInfoTokens', array( &$this->tokenFunctions ) );
98 return $this->tokenFunctions;
99 }
100
101 public static function getEditToken( $pageid, $title ) {
102 // We could check for $title->userCan('edit') here,
103 // but that's too expensive for this purpose
104 // and would break caching
105 global $wgUser;
106 if ( !$wgUser->isAllowed( 'edit' ) ) {
107 return false;
108 }
109
110 // The edit token is always the same, let's exploit that
111 static $cachedEditToken = null;
112 if ( !is_null( $cachedEditToken ) ) {
113 return $cachedEditToken;
114 }
115
116 $cachedEditToken = $wgUser->getEditToken();
117 return $cachedEditToken;
118 }
119
120 public static function getDeleteToken( $pageid, $title ) {
121 global $wgUser;
122 if ( !$wgUser->isAllowed( 'delete' ) ) {
123 return false;
124 }
125
126 static $cachedDeleteToken = null;
127 if ( !is_null( $cachedDeleteToken ) ) {
128 return $cachedDeleteToken;
129 }
130
131 $cachedDeleteToken = $wgUser->getEditToken();
132 return $cachedDeleteToken;
133 }
134
135 public static function getProtectToken( $pageid, $title ) {
136 global $wgUser;
137 if ( !$wgUser->isAllowed( 'protect' ) ) {
138 return false;
139 }
140
141 static $cachedProtectToken = null;
142 if ( !is_null( $cachedProtectToken ) ) {
143 return $cachedProtectToken;
144 }
145
146 $cachedProtectToken = $wgUser->getEditToken();
147 return $cachedProtectToken;
148 }
149
150 public static function getMoveToken( $pageid, $title ) {
151 global $wgUser;
152 if ( !$wgUser->isAllowed( 'move' ) ) {
153 return false;
154 }
155
156 static $cachedMoveToken = null;
157 if ( !is_null( $cachedMoveToken ) ) {
158 return $cachedMoveToken;
159 }
160
161 $cachedMoveToken = $wgUser->getEditToken();
162 return $cachedMoveToken;
163 }
164
165 public static function getBlockToken( $pageid, $title ) {
166 global $wgUser;
167 if ( !$wgUser->isAllowed( 'block' ) ) {
168 return false;
169 }
170
171 static $cachedBlockToken = null;
172 if ( !is_null( $cachedBlockToken ) ) {
173 return $cachedBlockToken;
174 }
175
176 $cachedBlockToken = $wgUser->getEditToken();
177 return $cachedBlockToken;
178 }
179
180 public static function getUnblockToken( $pageid, $title ) {
181 // Currently, this is exactly the same as the block token
182 return self::getBlockToken( $pageid, $title );
183 }
184
185 public static function getEmailToken( $pageid, $title ) {
186 global $wgUser;
187 if ( !$wgUser->canSendEmail() || $wgUser->isBlockedFromEmailUser() ) {
188 return false;
189 }
190
191 static $cachedEmailToken = null;
192 if ( !is_null( $cachedEmailToken ) ) {
193 return $cachedEmailToken;
194 }
195
196 $cachedEmailToken = $wgUser->getEditToken();
197 return $cachedEmailToken;
198 }
199
200 public static function getImportToken( $pageid, $title ) {
201 global $wgUser;
202 if ( !$wgUser->isAllowedAny( 'import', 'importupload' ) ) {
203 return false;
204 }
205
206 static $cachedImportToken = null;
207 if ( !is_null( $cachedImportToken ) ) {
208 return $cachedImportToken;
209 }
210
211 $cachedImportToken = $wgUser->getEditToken();
212 return $cachedImportToken;
213 }
214
215 public static function getWatchToken( $pageid, $title ) {
216 global $wgUser;
217 if ( !$wgUser->isLoggedIn() ) {
218 return false;
219 }
220
221 static $cachedWatchToken = null;
222 if ( !is_null( $cachedWatchToken ) ) {
223 return $cachedWatchToken;
224 }
225
226 $cachedWatchToken = $wgUser->getEditToken( 'watch' );
227 return $cachedWatchToken;
228 }
229
230 public function execute() {
231 $this->params = $this->extractRequestParams();
232 if ( !is_null( $this->params['prop'] ) ) {
233 $prop = array_flip( $this->params['prop'] );
234 $this->fld_protection = isset( $prop['protection'] );
235 $this->fld_watched = isset( $prop['watched'] );
236 $this->fld_talkid = isset( $prop['talkid'] );
237 $this->fld_subjectid = isset( $prop['subjectid'] );
238 $this->fld_url = isset( $prop['url'] );
239 $this->fld_readable = isset( $prop['readable'] );
240 $this->fld_preload = isset( $prop['preload'] );
241 $this->fld_displaytitle = isset( $prop['displaytitle'] );
242 }
243
244 $pageSet = $this->getPageSet();
245 $this->titles = $pageSet->getGoodTitles();
246 $this->missing = $pageSet->getMissingTitles();
247 $this->everything = $this->titles + $this->missing;
248 $result = $this->getResult();
249
250 uasort( $this->everything, array( 'Title', 'compare' ) );
251 if ( !is_null( $this->params['continue'] ) ) {
252 // Throw away any titles we're gonna skip so they don't
253 // clutter queries
254 $cont = explode( '|', $this->params['continue'] );
255 if ( count( $cont ) != 2 ) {
256 $this->dieUsage( 'Invalid continue param. You should pass the original ' .
257 'value returned by the previous query', '_badcontinue' );
258 }
259 $conttitle = Title::makeTitleSafe( $cont[0], $cont[1] );
260 foreach ( $this->everything as $pageid => $title ) {
261 if ( Title::compare( $title, $conttitle ) >= 0 ) {
262 break;
263 }
264 unset( $this->titles[$pageid] );
265 unset( $this->missing[$pageid] );
266 unset( $this->everything[$pageid] );
267 }
268 }
269
270 $this->pageRestrictions = $pageSet->getCustomField( 'page_restrictions' );
271 $this->pageIsRedir = $pageSet->getCustomField( 'page_is_redirect' );
272 $this->pageIsNew = $pageSet->getCustomField( 'page_is_new' );
273
274 global $wgDisableCounters;
275
276 if ( !$wgDisableCounters ) {
277 $this->pageCounter = $pageSet->getCustomField( 'page_counter' );
278 }
279 $this->pageTouched = $pageSet->getCustomField( 'page_touched' );
280 $this->pageLatest = $pageSet->getCustomField( 'page_latest' );
281 $this->pageLength = $pageSet->getCustomField( 'page_len' );
282
283 // Get protection info if requested
284 if ( $this->fld_protection ) {
285 $this->getProtectionInfo();
286 }
287
288 if ( $this->fld_watched ) {
289 $this->getWatchedInfo();
290 }
291
292 // Run the talkid/subjectid query if requested
293 if ( $this->fld_talkid || $this->fld_subjectid ) {
294 $this->getTSIDs();
295 }
296
297 if ( $this->fld_displaytitle ) {
298 $this->getDisplayTitle();
299 }
300
301 foreach ( $this->everything as $pageid => $title ) {
302 $pageInfo = $this->extractPageInfo( $pageid, $title );
303 $fit = $result->addValue( array(
304 'query',
305 'pages'
306 ), $pageid, $pageInfo );
307 if ( !$fit ) {
308 $this->setContinueEnumParameter( 'continue',
309 $title->getNamespace() . '|' .
310 $title->getText() );
311 break;
312 }
313 }
314 }
315
316 /**
317 * Get a result array with information about a title
318 * @param $pageid int Page ID (negative for missing titles)
319 * @param $title Title object
320 * @return array
321 */
322 private function extractPageInfo( $pageid, $title ) {
323 $pageInfo = array();
324 if ( $title->exists() ) {
325 global $wgDisableCounters;
326
327 $pageInfo['touched'] = wfTimestamp( TS_ISO_8601, $this->pageTouched[$pageid] );
328 $pageInfo['lastrevid'] = intval( $this->pageLatest[$pageid] );
329 $pageInfo['counter'] = $wgDisableCounters
330 ? ""
331 : intval( $this->pageCounter[$pageid] );
332 $pageInfo['length'] = intval( $this->pageLength[$pageid] );
333
334 if ( $this->pageIsRedir[$pageid] ) {
335 $pageInfo['redirect'] = '';
336 }
337 if ( $this->pageIsNew[$pageid] ) {
338 $pageInfo['new'] = '';
339 }
340 }
341
342 if ( !is_null( $this->params['token'] ) ) {
343 $tokenFunctions = $this->getTokenFunctions();
344 $pageInfo['starttimestamp'] = wfTimestamp( TS_ISO_8601, time() );
345 foreach ( $this->params['token'] as $t ) {
346 $val = call_user_func( $tokenFunctions[$t], $pageid, $title );
347 if ( $val === false ) {
348 $this->setWarning( "Action '$t' is not allowed for the current user" );
349 } else {
350 $pageInfo[$t . 'token'] = $val;
351 }
352 }
353 }
354
355 if ( $this->fld_protection ) {
356 $pageInfo['protection'] = array();
357 if ( isset( $this->protections[$title->getNamespace()][$title->getDBkey()] ) ) {
358 $pageInfo['protection'] =
359 $this->protections[$title->getNamespace()][$title->getDBkey()];
360 }
361 $this->getResult()->setIndexedTagName( $pageInfo['protection'], 'pr' );
362 }
363
364 if ( $this->fld_watched && isset( $this->watched[$title->getNamespace()][$title->getDBkey()] ) ) {
365 $pageInfo['watched'] = '';
366 }
367
368 if ( $this->fld_talkid && isset( $this->talkids[$title->getNamespace()][$title->getDBkey()] ) ) {
369 $pageInfo['talkid'] = $this->talkids[$title->getNamespace()][$title->getDBkey()];
370 }
371
372 if ( $this->fld_subjectid && isset( $this->subjectids[$title->getNamespace()][$title->getDBkey()] ) ) {
373 $pageInfo['subjectid'] = $this->subjectids[$title->getNamespace()][$title->getDBkey()];
374 }
375
376 if ( $this->fld_url ) {
377 $pageInfo['fullurl'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
378 $pageInfo['editurl'] = wfExpandUrl( $title->getFullURL( 'action=edit' ), PROTO_CURRENT );
379 }
380 if ( $this->fld_readable && $title->userCan( 'read' ) ) {
381 $pageInfo['readable'] = '';
382 }
383
384 if ( $this->fld_preload ) {
385 if ( $title->exists() ) {
386 $pageInfo['preload'] = '';
387 } else {
388 $text = null;
389 wfRunHooks( 'EditFormPreloadText', array( &$text, &$title ) );
390
391 $pageInfo['preload'] = $text;
392 }
393 }
394
395 if ( $this->fld_displaytitle ) {
396 if ( isset( $this->displaytitles[$title->getArticleId()] ) ) {
397 $pageInfo['displaytitle'] = $this->displaytitles[$title->getArticleId()];
398 } else {
399 $pageInfo['displaytitle'] = $title->getPrefixedText();
400 }
401 }
402
403 return $pageInfo;
404 }
405
406 /**
407 * Get information about protections and put it in $protections
408 */
409 private function getProtectionInfo() {
410 global $wgContLang;
411 $this->protections = array();
412 $db = $this->getDB();
413
414 // Get normal protections for existing titles
415 if ( count( $this->titles ) ) {
416 $this->resetQueryParams();
417 $this->addTables( array( 'page_restrictions', 'page' ) );
418 $this->addWhere( 'page_id=pr_page' );
419 $this->addFields( array( 'pr_page', 'pr_type', 'pr_level',
420 'pr_expiry', 'pr_cascade', 'page_namespace',
421 'page_title' ) );
422 $this->addWhereFld( 'pr_page', array_keys( $this->titles ) );
423
424 $res = $this->select( __METHOD__ );
425 foreach ( $res as $row ) {
426 $a = array(
427 'type' => $row->pr_type,
428 'level' => $row->pr_level,
429 'expiry' => $wgContLang->formatExpiry( $row->pr_expiry, TS_ISO_8601 )
430 );
431 if ( $row->pr_cascade ) {
432 $a['cascade'] = '';
433 }
434 $this->protections[$row->page_namespace][$row->page_title][] = $a;
435
436 // Also check old restrictions
437 if ( $this->pageRestrictions[$row->pr_page] ) {
438 $restrictions = explode( ':', trim( $this->pageRestrictions[$row->pr_page] ) );
439 foreach ( $restrictions as $restrict ) {
440 $temp = explode( '=', trim( $restrict ) );
441 if ( count( $temp ) == 1 ) {
442 // old old format should be treated as edit/move restriction
443 $restriction = trim( $temp[0] );
444
445 if ( $restriction == '' ) {
446 continue;
447 }
448 $this->protections[$row->page_namespace][$row->page_title][] = array(
449 'type' => 'edit',
450 'level' => $restriction,
451 'expiry' => 'infinity',
452 );
453 $this->protections[$row->page_namespace][$row->page_title][] = array(
454 'type' => 'move',
455 'level' => $restriction,
456 'expiry' => 'infinity',
457 );
458 } else {
459 $restriction = trim( $temp[1] );
460 if ( $restriction == '' ) {
461 continue;
462 }
463 $this->protections[$row->page_namespace][$row->page_title][] = array(
464 'type' => $temp[0],
465 'level' => $restriction,
466 'expiry' => 'infinity',
467 );
468 }
469 }
470 }
471 }
472 }
473
474 // Get protections for missing titles
475 if ( count( $this->missing ) ) {
476 $this->resetQueryParams();
477 $lb = new LinkBatch( $this->missing );
478 $this->addTables( 'protected_titles' );
479 $this->addFields( array( 'pt_title', 'pt_namespace', 'pt_create_perm', 'pt_expiry' ) );
480 $this->addWhere( $lb->constructSet( 'pt', $db ) );
481 $res = $this->select( __METHOD__ );
482 foreach ( $res as $row ) {
483 $this->protections[$row->pt_namespace][$row->pt_title][] = array(
484 'type' => 'create',
485 'level' => $row->pt_create_perm,
486 'expiry' => $wgContLang->formatExpiry( $row->pt_expiry, TS_ISO_8601 )
487 );
488 }
489 }
490
491 // Cascading protections
492 $images = $others = array();
493 foreach ( $this->everything as $title ) {
494 if ( $title->getNamespace() == NS_FILE ) {
495 $images[] = $title->getDBkey();
496 } else {
497 $others[] = $title;
498 }
499 }
500
501 if ( count( $others ) ) {
502 // Non-images: check templatelinks
503 $lb = new LinkBatch( $others );
504 $this->resetQueryParams();
505 $this->addTables( array( 'page_restrictions', 'page', 'templatelinks' ) );
506 $this->addFields( array( 'pr_type', 'pr_level', 'pr_expiry',
507 'page_title', 'page_namespace',
508 'tl_title', 'tl_namespace' ) );
509 $this->addWhere( $lb->constructSet( 'tl', $db ) );
510 $this->addWhere( 'pr_page = page_id' );
511 $this->addWhere( 'pr_page = tl_from' );
512 $this->addWhereFld( 'pr_cascade', 1 );
513
514 $res = $this->select( __METHOD__ );
515 foreach ( $res as $row ) {
516 $source = Title::makeTitle( $row->page_namespace, $row->page_title );
517 $this->protections[$row->tl_namespace][$row->tl_title][] = array(
518 'type' => $row->pr_type,
519 'level' => $row->pr_level,
520 'expiry' => $wgContLang->formatExpiry( $row->pr_expiry, TS_ISO_8601 ),
521 'source' => $source->getPrefixedText()
522 );
523 }
524 }
525
526 if ( count( $images ) ) {
527 // Images: check imagelinks
528 $this->resetQueryParams();
529 $this->addTables( array( 'page_restrictions', 'page', 'imagelinks' ) );
530 $this->addFields( array( 'pr_type', 'pr_level', 'pr_expiry',
531 'page_title', 'page_namespace', 'il_to' ) );
532 $this->addWhere( 'pr_page = page_id' );
533 $this->addWhere( 'pr_page = il_from' );
534 $this->addWhereFld( 'pr_cascade', 1 );
535 $this->addWhereFld( 'il_to', $images );
536
537 $res = $this->select( __METHOD__ );
538 foreach ( $res as $row ) {
539 $source = Title::makeTitle( $row->page_namespace, $row->page_title );
540 $this->protections[NS_FILE][$row->il_to][] = array(
541 'type' => $row->pr_type,
542 'level' => $row->pr_level,
543 'expiry' => $wgContLang->formatExpiry( $row->pr_expiry, TS_ISO_8601 ),
544 'source' => $source->getPrefixedText()
545 );
546 }
547 }
548 }
549
550 /**
551 * Get talk page IDs (if requested) and subject page IDs (if requested)
552 * and put them in $talkids and $subjectids
553 */
554 private function getTSIDs() {
555 $getTitles = $this->talkids = $this->subjectids = array();
556
557 foreach ( $this->everything as $t ) {
558 if ( MWNamespace::isTalk( $t->getNamespace() ) ) {
559 if ( $this->fld_subjectid ) {
560 $getTitles[] = $t->getSubjectPage();
561 }
562 } elseif ( $this->fld_talkid ) {
563 $getTitles[] = $t->getTalkPage();
564 }
565 }
566 if ( !count( $getTitles ) ) {
567 return;
568 }
569
570 $db = $this->getDB();
571
572 // Construct a custom WHERE clause that matches
573 // all titles in $getTitles
574 $lb = new LinkBatch( $getTitles );
575 $this->resetQueryParams();
576 $this->addTables( 'page' );
577 $this->addFields( array( 'page_title', 'page_namespace', 'page_id' ) );
578 $this->addWhere( $lb->constructSet( 'page', $db ) );
579 $res = $this->select( __METHOD__ );
580 foreach ( $res as $row ) {
581 if ( MWNamespace::isTalk( $row->page_namespace ) ) {
582 $this->talkids[MWNamespace::getSubject( $row->page_namespace )][$row->page_title] =
583 intval( $row->page_id );
584 } else {
585 $this->subjectids[MWNamespace::getTalk( $row->page_namespace )][$row->page_title] =
586 intval( $row->page_id );
587 }
588 }
589 }
590
591 private function getDisplayTitle() {
592 $this->displaytitles = array();
593
594 $pageIds = array_keys( $this->titles );
595
596 if ( !count( $pageIds ) ) {
597 return;
598 }
599
600 $this->resetQueryParams();
601 $this->addTables( 'page_props' );
602 $this->addFields( array( 'pp_page', 'pp_value' ) );
603 $this->addWhereFld( 'pp_page', $pageIds );
604 $this->addWhereFld( 'pp_propname', 'displaytitle' );
605 $res = $this->select( __METHOD__ );
606
607 foreach ( $res as $row ) {
608 $this->displaytitles[$row->pp_page] = $row->pp_value;
609 }
610 }
611
612 /**
613 * Get information about watched status and put it in $this->watched
614 */
615 private function getWatchedInfo() {
616 $user = $this->getUser();
617
618 if ( $user->isAnon() || count( $this->everything ) == 0 ) {
619 return;
620 }
621
622 $this->watched = array();
623 $db = $this->getDB();
624
625 $lb = new LinkBatch( $this->everything );
626
627 $this->resetQueryParams();
628 $this->addTables( array( 'watchlist' ) );
629 $this->addFields( array( 'wl_title', 'wl_namespace' ) );
630 $this->addWhere( array(
631 $lb->constructSet( 'wl', $db ),
632 'wl_user' => $user->getID()
633 ) );
634
635 $res = $this->select( __METHOD__ );
636
637 foreach ( $res as $row ) {
638 $this->watched[$row->wl_namespace][$row->wl_title] = true;
639 }
640 }
641
642 public function getCacheMode( $params ) {
643 $publicProps = array(
644 'protection',
645 'talkid',
646 'subjectid',
647 'url',
648 'preload',
649 'displaytitle',
650 );
651 if ( !is_null( $params['prop'] ) ) {
652 foreach ( $params['prop'] as $prop ) {
653 if ( !in_array( $prop, $publicProps ) ) {
654 return 'private';
655 }
656 }
657 }
658 if ( !is_null( $params['token'] ) ) {
659 return 'private';
660 }
661 return 'public';
662 }
663
664 public function getAllowedParams() {
665 return array(
666 'prop' => array(
667 ApiBase::PARAM_DFLT => null,
668 ApiBase::PARAM_ISMULTI => true,
669 ApiBase::PARAM_TYPE => array(
670 'protection',
671 'talkid',
672 'watched', # private
673 'subjectid',
674 'url',
675 'readable', # private
676 'preload',
677 'displaytitle',
678 // If you add more properties here, please consider whether they
679 // need to be added to getCacheMode()
680 ) ),
681 'token' => array(
682 ApiBase::PARAM_DFLT => null,
683 ApiBase::PARAM_ISMULTI => true,
684 ApiBase::PARAM_TYPE => array_keys( $this->getTokenFunctions() )
685 ),
686 'continue' => null,
687 );
688 }
689
690 public function getParamDescription() {
691 return array(
692 'prop' => array(
693 'Which additional properties to get:',
694 ' protection - List the protection level of each page',
695 ' talkid - The page ID of the talk page for each non-talk page',
696 ' watched - List the watched status of each page',
697 ' subjectid - The page ID of the parent page for each talk page',
698 ' url - Gives a full URL to the page, and also an edit URL',
699 ' readable - Whether the user can read this page',
700 ' preload - Gives the text returned by EditFormPreloadText',
701 ' displaytitle - Gives the way the page title is actually displayed',
702 ),
703 'token' => 'Request a token to perform a data-modifying action on a page',
704 'continue' => 'When more results are available, use this to continue',
705 );
706 }
707
708 public function getDescription() {
709 return 'Get basic page information such as namespace, title, last touched date, ...';
710 }
711
712 public function getPossibleErrors() {
713 return array_merge( parent::getPossibleErrors(), array(
714 array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ),
715 ) );
716 }
717
718 public function getExamples() {
719 return array(
720 'api.php?action=query&prop=info&titles=Main%20Page',
721 'api.php?action=query&prop=info&inprop=protection&titles=Main%20Page'
722 );
723 }
724
725 public function getHelpUrls() {
726 return 'https://www.mediawiki.org/wiki/API:Properties#info_.2F_in';
727 }
728
729 public function getVersion() {
730 return __CLASS__ . ': $Id$';
731 }
732 }