d96808f3f9e445b59bd2a4168574621b8f83912f
[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->isAllowed( 'import' ) ) {
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 $this->protections = array();
401 $db = $this->getDB();
402
403 // Get normal protections for existing titles
404 if ( count( $this->titles ) ) {
405 $this->resetQueryParams();
406 $this->addTables( array( 'page_restrictions', 'page' ) );
407 $this->addWhere( 'page_id=pr_page' );
408 $this->addFields( array( 'pr_page', 'pr_type', 'pr_level',
409 'pr_expiry', 'pr_cascade', 'page_namespace',
410 'page_title' ) );
411 $this->addWhereFld( 'pr_page', array_keys( $this->titles ) );
412
413 $res = $this->select( __METHOD__ );
414 foreach ( $res as $row ) {
415 $a = array(
416 'type' => $row->pr_type,
417 'level' => $row->pr_level,
418 'expiry' => Block::decodeExpiry( $row->pr_expiry, TS_ISO_8601 )
419 );
420 if ( $row->pr_cascade ) {
421 $a['cascade'] = '';
422 }
423 $this->protections[$row->page_namespace][$row->page_title][] = $a;
424
425 // Also check old restrictions
426 if ( $this->pageRestrictions[$row->pr_page] ) {
427 $restrictions = explode( ':', trim( $this->pageRestrictions[$row->pr_page] ) );
428 foreach ( $restrictions as $restrict ) {
429 $temp = explode( '=', trim( $restrict ) );
430 if ( count( $temp ) == 1 ) {
431 // old old format should be treated as edit/move restriction
432 $restriction = trim( $temp[0] );
433
434 if ( $restriction == '' ) {
435 continue;
436 }
437 $this->protections[$row->page_namespace][$row->page_title][] = array(
438 'type' => 'edit',
439 'level' => $restriction,
440 'expiry' => 'infinity',
441 );
442 $this->protections[$row->page_namespace][$row->page_title][] = array(
443 'type' => 'move',
444 'level' => $restriction,
445 'expiry' => 'infinity',
446 );
447 } else {
448 $restriction = trim( $temp[1] );
449 if ( $restriction == '' ) {
450 continue;
451 }
452 $this->protections[$row->page_namespace][$row->page_title][] = array(
453 'type' => $temp[0],
454 'level' => $restriction,
455 'expiry' => 'infinity',
456 );
457 }
458 }
459 }
460 }
461 }
462
463 // Get protections for missing titles
464 if ( count( $this->missing ) ) {
465 $this->resetQueryParams();
466 $lb = new LinkBatch( $this->missing );
467 $this->addTables( 'protected_titles' );
468 $this->addFields( array( 'pt_title', 'pt_namespace', 'pt_create_perm', 'pt_expiry' ) );
469 $this->addWhere( $lb->constructSet( 'pt', $db ) );
470 $res = $this->select( __METHOD__ );
471 foreach ( $res as $row ) {
472 $this->protections[$row->pt_namespace][$row->pt_title][] = array(
473 'type' => 'create',
474 'level' => $row->pt_create_perm,
475 'expiry' => Block::decodeExpiry( $row->pt_expiry, TS_ISO_8601 )
476 );
477 }
478 }
479
480 // Cascading protections
481 $images = $others = array();
482 foreach ( $this->everything as $title ) {
483 if ( $title->getNamespace() == NS_FILE ) {
484 $images[] = $title->getDBkey();
485 } else {
486 $others[] = $title;
487 }
488 }
489
490 if ( count( $others ) ) {
491 // Non-images: check templatelinks
492 $lb = new LinkBatch( $others );
493 $this->resetQueryParams();
494 $this->addTables( array( 'page_restrictions', 'page', 'templatelinks' ) );
495 $this->addFields( array( 'pr_type', 'pr_level', 'pr_expiry',
496 'page_title', 'page_namespace',
497 'tl_title', 'tl_namespace' ) );
498 $this->addWhere( $lb->constructSet( 'tl', $db ) );
499 $this->addWhere( 'pr_page = page_id' );
500 $this->addWhere( 'pr_page = tl_from' );
501 $this->addWhereFld( 'pr_cascade', 1 );
502
503 $res = $this->select( __METHOD__ );
504 foreach ( $res as $row ) {
505 $source = Title::makeTitle( $row->page_namespace, $row->page_title );
506 $this->protections[$row->tl_namespace][$row->tl_title][] = array(
507 'type' => $row->pr_type,
508 'level' => $row->pr_level,
509 'expiry' => Block::decodeExpiry( $row->pr_expiry, TS_ISO_8601 ),
510 'source' => $source->getPrefixedText()
511 );
512 }
513 }
514
515 if ( count( $images ) ) {
516 // Images: check imagelinks
517 $this->resetQueryParams();
518 $this->addTables( array( 'page_restrictions', 'page', 'imagelinks' ) );
519 $this->addFields( array( 'pr_type', 'pr_level', 'pr_expiry',
520 'page_title', 'page_namespace', 'il_to' ) );
521 $this->addWhere( 'pr_page = page_id' );
522 $this->addWhere( 'pr_page = il_from' );
523 $this->addWhereFld( 'pr_cascade', 1 );
524 $this->addWhereFld( 'il_to', $images );
525
526 $res = $this->select( __METHOD__ );
527 foreach ( $res as $row ) {
528 $source = Title::makeTitle( $row->page_namespace, $row->page_title );
529 $this->protections[NS_FILE][$row->il_to][] = array(
530 'type' => $row->pr_type,
531 'level' => $row->pr_level,
532 'expiry' => Block::decodeExpiry( $row->pr_expiry, TS_ISO_8601 ),
533 'source' => $source->getPrefixedText()
534 );
535 }
536 }
537 }
538
539 /**
540 * Get talk page IDs (if requested) and subject page IDs (if requested)
541 * and put them in $talkids and $subjectids
542 */
543 private function getTSIDs() {
544 $getTitles = $this->talkids = $this->subjectids = array();
545
546 foreach ( $this->everything as $t ) {
547 if ( MWNamespace::isTalk( $t->getNamespace() ) ) {
548 if ( $this->fld_subjectid ) {
549 $getTitles[] = $t->getSubjectPage();
550 }
551 } elseif ( $this->fld_talkid ) {
552 $getTitles[] = $t->getTalkPage();
553 }
554 }
555 if ( !count( $getTitles ) ) {
556 return;
557 }
558
559 $db = $this->getDB();
560
561 // Construct a custom WHERE clause that matches
562 // all titles in $getTitles
563 $lb = new LinkBatch( $getTitles );
564 $this->resetQueryParams();
565 $this->addTables( 'page' );
566 $this->addFields( array( 'page_title', 'page_namespace', 'page_id' ) );
567 $this->addWhere( $lb->constructSet( 'page', $db ) );
568 $res = $this->select( __METHOD__ );
569 foreach ( $res as $row ) {
570 if ( MWNamespace::isTalk( $row->page_namespace ) ) {
571 $this->talkids[MWNamespace::getSubject( $row->page_namespace )][$row->page_title] =
572 intval( $row->page_id );
573 } else {
574 $this->subjectids[MWNamespace::getTalk( $row->page_namespace )][$row->page_title] =
575 intval( $row->page_id );
576 }
577 }
578 }
579
580 private function getDisplayTitle() {
581 $this->displaytitles = array();
582
583 $pageIds = array_keys( $this->titles );
584
585 if ( !count( $pageIds ) ) {
586 return;
587 }
588
589 $this->resetQueryParams();
590 $this->addTables( 'page_props' );
591 $this->addFields( array( 'pp_page', 'pp_value' ) );
592 $this->addWhereFld( 'pp_page', $pageIds );
593 $this->addWhereFld( 'pp_propname', 'displaytitle' );
594 $res = $this->select( __METHOD__ );
595
596 foreach ( $res as $row ) {
597 $this->displaytitles[$row->pp_page] = $row->pp_value;
598 }
599 }
600
601 /**
602 * Get information about watched status and put it in $this->watched
603 */
604 private function getWatchedInfo() {
605 global $wgUser;
606
607 if ( $wgUser->isAnon() || count( $this->everything ) == 0 ) {
608 return;
609 }
610
611 $this->watched = array();
612 $db = $this->getDB();
613
614 $lb = new LinkBatch( $this->everything );
615
616 $this->resetQueryParams();
617 $this->addTables( array( 'watchlist' ) );
618 $this->addFields( array( 'wl_title', 'wl_namespace' ) );
619 $this->addWhere( array(
620 $lb->constructSet( 'wl', $db ),
621 'wl_user' => $wgUser->getID()
622 ) );
623
624 $res = $this->select( __METHOD__ );
625
626 foreach ( $res as $row ) {
627 $this->watched[$row->wl_namespace][$row->wl_title] = true;
628 }
629 }
630
631 public function getCacheMode( $params ) {
632 $publicProps = array(
633 'protection',
634 'talkid',
635 'subjectid',
636 'url',
637 'preload',
638 'displaytitle',
639 );
640 if ( !is_null( $params['prop'] ) ) {
641 foreach ( $params['prop'] as $prop ) {
642 if ( !in_array( $prop, $publicProps ) ) {
643 return 'private';
644 }
645 }
646 }
647 if ( !is_null( $params['token'] ) ) {
648 return 'private';
649 }
650 return 'public';
651 }
652
653 public function getAllowedParams() {
654 return array(
655 'prop' => array(
656 ApiBase::PARAM_DFLT => null,
657 ApiBase::PARAM_ISMULTI => true,
658 ApiBase::PARAM_TYPE => array(
659 'protection',
660 'talkid',
661 'watched', # private
662 'subjectid',
663 'url',
664 'readable', # private
665 'preload',
666 'displaytitle',
667 // If you add more properties here, please consider whether they
668 // need to be added to getCacheMode()
669 ) ),
670 'token' => array(
671 ApiBase::PARAM_DFLT => null,
672 ApiBase::PARAM_ISMULTI => true,
673 ApiBase::PARAM_TYPE => array_keys( $this->getTokenFunctions() )
674 ),
675 'continue' => null,
676 );
677 }
678
679 public function getParamDescription() {
680 return array(
681 'prop' => array(
682 'Which additional properties to get:',
683 ' protection - List the protection level of each page',
684 ' talkid - The page ID of the talk page for each non-talk page',
685 ' watched - List the watched status of each page',
686 ' subjectid - The page ID of the parent page for each talk page',
687 ' url - Gives a full URL to the page, and also an edit URL',
688 ' readable - Whether the user can read this page',
689 ' preload - Gives the text returned by EditFormPreloadText',
690 ' displaytitle - Gives the way the page title is actually displayed',
691 ),
692 'token' => 'Request a token to perform a data-modifying action on a page',
693 'continue' => 'When more results are available, use this to continue',
694 );
695 }
696
697 public function getDescription() {
698 return 'Get basic page information such as namespace, title, last touched date, ...';
699 }
700
701 public function getPossibleErrors() {
702 return array_merge( parent::getPossibleErrors(), array(
703 array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ),
704 ) );
705 }
706
707 protected function getExamples() {
708 return array(
709 'api.php?action=query&prop=info&titles=Main%20Page',
710 'api.php?action=query&prop=info&inprop=protection&titles=Main%20Page'
711 );
712 }
713
714 public function getVersion() {
715 return __CLASS__ . ': $Id$';
716 }
717 }