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