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