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