4a85b0b403a93deb737d971d46849f1b7bc3c66c
5 * Created on Sep 25, 2006
7 * Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
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.
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.
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
28 * A query module to show basic page information.
32 class ApiQueryInfo
extends ApiQueryBase
{
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;
39 private $params, $titles, $missing, $everything, $pageCounter;
41 private $pageRestrictions, $pageIsRedir, $pageIsNew, $pageTouched,
42 $pageLatest, $pageLength;
44 private $protections, $watched, $talkids, $subjectids, $displaytitles;
46 private $tokenFunctions;
48 public function __construct( $query, $moduleName ) {
49 parent
::__construct( $query, $moduleName, 'in' );
53 * @param $pageSet ApiPageSet
56 public function requestExtraData( $pageSet ) {
57 global $wgDisableCounters;
59 $pageSet->requestField( 'page_restrictions' );
60 // when resolving redirects, no page will have this field
61 if( !$pageSet->isResolvingRedirects() ) {
62 $pageSet->requestField( 'page_is_redirect' );
64 $pageSet->requestField( 'page_is_new' );
65 if ( !$wgDisableCounters ) {
66 $pageSet->requestField( 'page_counter' );
68 $pageSet->requestField( 'page_touched' );
69 $pageSet->requestField( 'page_latest' );
70 $pageSet->requestField( 'page_len' );
74 * Get an array mapping token names to their handler functions.
75 * The prototype for a token function is func($pageid, $title)
76 * it should return a token or false (permission denied)
77 * @return array array(tokenname => function)
79 protected function getTokenFunctions() {
80 // Don't call the hooks twice
81 if ( isset( $this->tokenFunctions
) ) {
82 return $this->tokenFunctions
;
85 // If we're in JSON callback mode, no tokens can be obtained
86 if ( !is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) ) {
90 $this->tokenFunctions
= array(
91 'edit' => array( 'ApiQueryInfo', 'getEditToken' ),
92 'delete' => array( 'ApiQueryInfo', 'getDeleteToken' ),
93 'protect' => array( 'ApiQueryInfo', 'getProtectToken' ),
94 'move' => array( 'ApiQueryInfo', 'getMoveToken' ),
95 'block' => array( 'ApiQueryInfo', 'getBlockToken' ),
96 'unblock' => array( 'ApiQueryInfo', 'getUnblockToken' ),
97 'email' => array( 'ApiQueryInfo', 'getEmailToken' ),
98 'import' => array( 'ApiQueryInfo', 'getImportToken' ),
99 'watch' => array( 'ApiQueryInfo', 'getWatchToken'),
101 wfRunHooks( 'APIQueryInfoTokens', array( &$this->tokenFunctions
) );
102 return $this->tokenFunctions
;
105 static $cachedTokens = array();
107 public static function resetTokenCache() {
108 ApiQueryInfo
::$cachedTokens = array();
111 public static function getEditToken( $pageid, $title ) {
112 // We could check for $title->userCan('edit') here,
113 // but that's too expensive for this purpose
114 // and would break caching
116 if ( !$wgUser->isAllowed( 'edit' ) ) {
120 // The token is always the same, let's exploit that
121 if ( !isset( ApiQueryInfo
::$cachedTokens[ 'edit' ] ) ) {
122 ApiQueryInfo
::$cachedTokens[ 'edit' ] = $wgUser->getEditToken();
125 return ApiQueryInfo
::$cachedTokens[ 'edit' ];
128 public static function getDeleteToken( $pageid, $title ) {
130 if ( !$wgUser->isAllowed( 'delete' ) ) {
134 // The token is always the same, let's exploit that
135 if ( !isset( ApiQueryInfo
::$cachedTokens[ 'delete' ] ) ) {
136 ApiQueryInfo
::$cachedTokens[ 'delete' ] = $wgUser->getEditToken();
139 return ApiQueryInfo
::$cachedTokens[ 'delete' ];
142 public static function getProtectToken( $pageid, $title ) {
144 if ( !$wgUser->isAllowed( 'protect' ) ) {
148 // The token is always the same, let's exploit that
149 if ( !isset( ApiQueryInfo
::$cachedTokens[ 'protect' ] ) ) {
150 ApiQueryInfo
::$cachedTokens[ 'protect' ] = $wgUser->getEditToken();
153 return ApiQueryInfo
::$cachedTokens[ 'protect' ];
156 public static function getMoveToken( $pageid, $title ) {
158 if ( !$wgUser->isAllowed( 'move' ) ) {
162 // The token is always the same, let's exploit that
163 if ( !isset( ApiQueryInfo
::$cachedTokens[ 'move' ] ) ) {
164 ApiQueryInfo
::$cachedTokens[ 'move' ] = $wgUser->getEditToken();
167 return ApiQueryInfo
::$cachedTokens[ 'move' ];
170 public static function getBlockToken( $pageid, $title ) {
172 if ( !$wgUser->isAllowed( 'block' ) ) {
176 // The token is always the same, let's exploit that
177 if ( !isset( ApiQueryInfo
::$cachedTokens[ 'block' ] ) ) {
178 ApiQueryInfo
::$cachedTokens[ 'block' ] = $wgUser->getEditToken();
181 return ApiQueryInfo
::$cachedTokens[ 'block' ];
184 public static function getUnblockToken( $pageid, $title ) {
185 // Currently, this is exactly the same as the block token
186 return self
::getBlockToken( $pageid, $title );
189 public static function getEmailToken( $pageid, $title ) {
191 if ( !$wgUser->canSendEmail() ||
$wgUser->isBlockedFromEmailUser() ) {
195 // The token is always the same, let's exploit that
196 if ( !isset( ApiQueryInfo
::$cachedTokens[ 'email' ] ) ) {
197 ApiQueryInfo
::$cachedTokens[ 'email' ] = $wgUser->getEditToken();
200 return ApiQueryInfo
::$cachedTokens[ 'email' ];
203 public static function getImportToken( $pageid, $title ) {
205 if ( !$wgUser->isAllowedAny( 'import', 'importupload' ) ) {
209 // The token is always the same, let's exploit that
210 if ( !isset( ApiQueryInfo
::$cachedTokens[ 'import' ] ) ) {
211 ApiQueryInfo
::$cachedTokens[ 'import' ] = $wgUser->getEditToken();
214 return ApiQueryInfo
::$cachedTokens[ 'import' ];
217 public static function getWatchToken( $pageid, $title ) {
219 if ( !$wgUser->isLoggedIn() ) {
223 // The token is always the same, let's exploit that
224 if ( !isset( ApiQueryInfo
::$cachedTokens[ 'watch' ] ) ) {
225 ApiQueryInfo
::$cachedTokens[ 'watch' ] = $wgUser->getEditToken( 'watch' );
228 return ApiQueryInfo
::$cachedTokens[ 'watch' ];
231 public static function getOptionsToken( $pageid, $title ) {
233 if ( !$wgUser->isLoggedIn() ) {
237 // The token is always the same, let's exploit that
238 if ( !isset( ApiQueryInfo
::$cachedTokens[ 'options' ] ) ) {
239 ApiQueryInfo
::$cachedTokens[ 'options' ] = $wgUser->getEditToken();
242 return ApiQueryInfo
::$cachedTokens[ 'options' ];
245 public function execute() {
246 $this->params
= $this->extractRequestParams();
247 if ( !is_null( $this->params
['prop'] ) ) {
248 $prop = array_flip( $this->params
['prop'] );
249 $this->fld_protection
= isset( $prop['protection'] );
250 $this->fld_watched
= isset( $prop['watched'] );
251 $this->fld_talkid
= isset( $prop['talkid'] );
252 $this->fld_subjectid
= isset( $prop['subjectid'] );
253 $this->fld_url
= isset( $prop['url'] );
254 $this->fld_readable
= isset( $prop['readable'] );
255 $this->fld_preload
= isset( $prop['preload'] );
256 $this->fld_displaytitle
= isset( $prop['displaytitle'] );
259 $pageSet = $this->getPageSet();
260 $this->titles
= $pageSet->getGoodTitles();
261 $this->missing
= $pageSet->getMissingTitles();
262 $this->everything
= $this->titles +
$this->missing
;
263 $result = $this->getResult();
265 uasort( $this->everything
, array( 'Title', 'compare' ) );
266 if ( !is_null( $this->params
['continue'] ) ) {
267 // Throw away any titles we're gonna skip so they don't
269 $cont = explode( '|', $this->params
['continue'] );
270 if ( count( $cont ) != 2 ) {
271 $this->dieUsage( 'Invalid continue param. You should pass the original ' .
272 'value returned by the previous query', '_badcontinue' );
274 $conttitle = Title
::makeTitleSafe( $cont[0], $cont[1] );
275 foreach ( $this->everything
as $pageid => $title ) {
276 if ( Title
::compare( $title, $conttitle ) >= 0 ) {
279 unset( $this->titles
[$pageid] );
280 unset( $this->missing
[$pageid] );
281 unset( $this->everything
[$pageid] );
285 $this->pageRestrictions
= $pageSet->getCustomField( 'page_restrictions' );
286 // when resolving redirects, no page will have this field
287 $this->pageIsRedir
= !$pageSet->isResolvingRedirects()
288 ?
$pageSet->getCustomField( 'page_is_redirect' )
290 $this->pageIsNew
= $pageSet->getCustomField( 'page_is_new' );
292 global $wgDisableCounters;
294 if ( !$wgDisableCounters ) {
295 $this->pageCounter
= $pageSet->getCustomField( 'page_counter' );
297 $this->pageTouched
= $pageSet->getCustomField( 'page_touched' );
298 $this->pageLatest
= $pageSet->getCustomField( 'page_latest' );
299 $this->pageLength
= $pageSet->getCustomField( 'page_len' );
301 // Get protection info if requested
302 if ( $this->fld_protection
) {
303 $this->getProtectionInfo();
306 if ( $this->fld_watched
) {
307 $this->getWatchedInfo();
310 // Run the talkid/subjectid query if requested
311 if ( $this->fld_talkid ||
$this->fld_subjectid
) {
315 if ( $this->fld_displaytitle
) {
316 $this->getDisplayTitle();
319 foreach ( $this->everything
as $pageid => $title ) {
320 $pageInfo = $this->extractPageInfo( $pageid, $title );
321 $fit = $result->addValue( array(
324 ), $pageid, $pageInfo );
326 $this->setContinueEnumParameter( 'continue',
327 $title->getNamespace() . '|' .
335 * Get a result array with information about a title
336 * @param $pageid int Page ID (negative for missing titles)
337 * @param $title Title object
340 private function extractPageInfo( $pageid, $title ) {
342 $titleExists = $pageid > 0; //$title->exists() needs pageid, which is not set for all title objects
343 $ns = $title->getNamespace();
344 $dbkey = $title->getDBkey();
345 if ( $titleExists ) {
346 global $wgDisableCounters;
348 $pageInfo['touched'] = wfTimestamp( TS_ISO_8601
, $this->pageTouched
[$pageid] );
349 $pageInfo['lastrevid'] = intval( $this->pageLatest
[$pageid] );
350 $pageInfo['counter'] = $wgDisableCounters
352 : intval( $this->pageCounter
[$pageid] );
353 $pageInfo['length'] = intval( $this->pageLength
[$pageid] );
355 if ( isset( $this->pageIsRedir
[$pageid] ) && $this->pageIsRedir
[$pageid] ) {
356 $pageInfo['redirect'] = '';
358 if ( $this->pageIsNew
[$pageid] ) {
359 $pageInfo['new'] = '';
363 if ( !is_null( $this->params
['token'] ) ) {
364 $tokenFunctions = $this->getTokenFunctions();
365 $pageInfo['starttimestamp'] = wfTimestamp( TS_ISO_8601
, time() );
366 foreach ( $this->params
['token'] as $t ) {
367 $val = call_user_func( $tokenFunctions[$t], $pageid, $title );
368 if ( $val === false ) {
369 $this->setWarning( "Action '$t' is not allowed for the current user" );
371 $pageInfo[$t . 'token'] = $val;
376 if ( $this->fld_protection
) {
377 $pageInfo['protection'] = array();
378 if ( isset( $this->protections
[$ns][$dbkey] ) ) {
379 $pageInfo['protection'] =
380 $this->protections
[$ns][$dbkey];
382 $this->getResult()->setIndexedTagName( $pageInfo['protection'], 'pr' );
385 if ( $this->fld_watched
&& isset( $this->watched
[$ns][$dbkey] ) ) {
386 $pageInfo['watched'] = '';
389 if ( $this->fld_talkid
&& isset( $this->talkids
[$ns][$dbkey] ) ) {
390 $pageInfo['talkid'] = $this->talkids
[$ns][$dbkey];
393 if ( $this->fld_subjectid
&& isset( $this->subjectids
[$ns][$dbkey] ) ) {
394 $pageInfo['subjectid'] = $this->subjectids
[$ns][$dbkey];
397 if ( $this->fld_url
) {
398 $pageInfo['fullurl'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT
);
399 $pageInfo['editurl'] = wfExpandUrl( $title->getFullURL( 'action=edit' ), PROTO_CURRENT
);
401 if ( $this->fld_readable
&& $title->userCan( 'read' ) ) {
402 $pageInfo['readable'] = '';
405 if ( $this->fld_preload
) {
406 if ( $titleExists ) {
407 $pageInfo['preload'] = '';
410 wfRunHooks( 'EditFormPreloadText', array( &$text, &$title ) );
412 $pageInfo['preload'] = $text;
416 if ( $this->fld_displaytitle
) {
417 if ( isset( $this->displaytitles
[$pageid] ) ) {
418 $pageInfo['displaytitle'] = $this->displaytitles
[$pageid];
420 $pageInfo['displaytitle'] = $title->getPrefixedText();
428 * Get information about protections and put it in $protections
430 private function getProtectionInfo() {
432 $this->protections
= array();
433 $db = $this->getDB();
435 // Get normal protections for existing titles
436 if ( count( $this->titles
) ) {
437 $this->resetQueryParams();
438 $this->addTables( 'page_restrictions' );
439 $this->addFields( array( 'pr_page', 'pr_type', 'pr_level',
440 'pr_expiry', 'pr_cascade' ) );
441 $this->addWhereFld( 'pr_page', array_keys( $this->titles
) );
443 $res = $this->select( __METHOD__
);
444 foreach ( $res as $row ) {
445 $title = $this->titles
[$row->pr_page
];
447 'type' => $row->pr_type
,
448 'level' => $row->pr_level
,
449 'expiry' => $wgContLang->formatExpiry( $row->pr_expiry
, TS_ISO_8601
)
451 if ( $row->pr_cascade
) {
454 $this->protections
[$title->getNamespace()][$title->getDBkey()][] = $a;
456 // Also check old restrictions
457 foreach( $this->titles
as $pageId => $title ) {
458 if ( $this->pageRestrictions
[$pageId] ) {
459 $namespace = $title->getNamespace();
460 $dbKey = $title->getDBkey();
461 $restrictions = explode( ':', trim( $this->pageRestrictions
[$pageId] ) );
462 foreach ( $restrictions as $restrict ) {
463 $temp = explode( '=', trim( $restrict ) );
464 if ( count( $temp ) == 1 ) {
465 // old old format should be treated as edit/move restriction
466 $restriction = trim( $temp[0] );
468 if ( $restriction == '' ) {
471 $this->protections
[$namespace][$dbKey][] = array(
473 'level' => $restriction,
474 'expiry' => 'infinity',
476 $this->protections
[$namespace][$dbKey][] = array(
478 'level' => $restriction,
479 'expiry' => 'infinity',
482 $restriction = trim( $temp[1] );
483 if ( $restriction == '' ) {
486 $this->protections
[$namespace][$dbKey][] = array(
488 'level' => $restriction,
489 'expiry' => 'infinity',
497 // Get protections for missing titles
498 if ( count( $this->missing
) ) {
499 $this->resetQueryParams();
500 $lb = new LinkBatch( $this->missing
);
501 $this->addTables( 'protected_titles' );
502 $this->addFields( array( 'pt_title', 'pt_namespace', 'pt_create_perm', 'pt_expiry' ) );
503 $this->addWhere( $lb->constructSet( 'pt', $db ) );
504 $res = $this->select( __METHOD__
);
505 foreach ( $res as $row ) {
506 $this->protections
[$row->pt_namespace
][$row->pt_title
][] = array(
508 'level' => $row->pt_create_perm
,
509 'expiry' => $wgContLang->formatExpiry( $row->pt_expiry
, TS_ISO_8601
)
514 // Cascading protections
515 $images = $others = array();
516 foreach ( $this->everything
as $title ) {
517 if ( $title->getNamespace() == NS_FILE
) {
518 $images[] = $title->getDBkey();
524 if ( count( $others ) ) {
525 // Non-images: check templatelinks
526 $lb = new LinkBatch( $others );
527 $this->resetQueryParams();
528 $this->addTables( array( 'page_restrictions', 'page', 'templatelinks' ) );
529 $this->addFields( array( 'pr_type', 'pr_level', 'pr_expiry',
530 'page_title', 'page_namespace',
531 'tl_title', 'tl_namespace' ) );
532 $this->addWhere( $lb->constructSet( 'tl', $db ) );
533 $this->addWhere( 'pr_page = page_id' );
534 $this->addWhere( 'pr_page = tl_from' );
535 $this->addWhereFld( 'pr_cascade', 1 );
537 $res = $this->select( __METHOD__
);
538 foreach ( $res as $row ) {
539 $source = Title
::makeTitle( $row->page_namespace
, $row->page_title
);
540 $this->protections
[$row->tl_namespace
][$row->tl_title
][] = 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()
549 if ( count( $images ) ) {
550 // Images: check imagelinks
551 $this->resetQueryParams();
552 $this->addTables( array( 'page_restrictions', 'page', 'imagelinks' ) );
553 $this->addFields( array( 'pr_type', 'pr_level', 'pr_expiry',
554 'page_title', 'page_namespace', 'il_to' ) );
555 $this->addWhere( 'pr_page = page_id' );
556 $this->addWhere( 'pr_page = il_from' );
557 $this->addWhereFld( 'pr_cascade', 1 );
558 $this->addWhereFld( 'il_to', $images );
560 $res = $this->select( __METHOD__
);
561 foreach ( $res as $row ) {
562 $source = Title
::makeTitle( $row->page_namespace
, $row->page_title
);
563 $this->protections
[NS_FILE
][$row->il_to
][] = array(
564 'type' => $row->pr_type
,
565 'level' => $row->pr_level
,
566 'expiry' => $wgContLang->formatExpiry( $row->pr_expiry
, TS_ISO_8601
),
567 'source' => $source->getPrefixedText()
574 * Get talk page IDs (if requested) and subject page IDs (if requested)
575 * and put them in $talkids and $subjectids
577 private function getTSIDs() {
578 $getTitles = $this->talkids
= $this->subjectids
= array();
580 foreach ( $this->everything
as $t ) {
581 if ( MWNamespace
::isTalk( $t->getNamespace() ) ) {
582 if ( $this->fld_subjectid
) {
583 $getTitles[] = $t->getSubjectPage();
585 } elseif ( $this->fld_talkid
) {
586 $getTitles[] = $t->getTalkPage();
589 if ( !count( $getTitles ) ) {
593 $db = $this->getDB();
595 // Construct a custom WHERE clause that matches
596 // all titles in $getTitles
597 $lb = new LinkBatch( $getTitles );
598 $this->resetQueryParams();
599 $this->addTables( 'page' );
600 $this->addFields( array( 'page_title', 'page_namespace', 'page_id' ) );
601 $this->addWhere( $lb->constructSet( 'page', $db ) );
602 $res = $this->select( __METHOD__
);
603 foreach ( $res as $row ) {
604 if ( MWNamespace
::isTalk( $row->page_namespace
) ) {
605 $this->talkids
[MWNamespace
::getSubject( $row->page_namespace
)][$row->page_title
] =
606 intval( $row->page_id
);
608 $this->subjectids
[MWNamespace
::getTalk( $row->page_namespace
)][$row->page_title
] =
609 intval( $row->page_id
);
614 private function getDisplayTitle() {
615 $this->displaytitles
= array();
617 $pageIds = array_keys( $this->titles
);
619 if ( !count( $pageIds ) ) {
623 $this->resetQueryParams();
624 $this->addTables( 'page_props' );
625 $this->addFields( array( 'pp_page', 'pp_value' ) );
626 $this->addWhereFld( 'pp_page', $pageIds );
627 $this->addWhereFld( 'pp_propname', 'displaytitle' );
628 $res = $this->select( __METHOD__
);
630 foreach ( $res as $row ) {
631 $this->displaytitles
[$row->pp_page
] = $row->pp_value
;
636 * Get information about watched status and put it in $this->watched
638 private function getWatchedInfo() {
639 $user = $this->getUser();
641 if ( $user->isAnon() ||
count( $this->everything
) == 0 ) {
645 $this->watched
= array();
646 $db = $this->getDB();
648 $lb = new LinkBatch( $this->everything
);
650 $this->resetQueryParams();
651 $this->addTables( array( 'watchlist' ) );
652 $this->addFields( array( 'wl_title', 'wl_namespace' ) );
653 $this->addWhere( array(
654 $lb->constructSet( 'wl', $db ),
655 'wl_user' => $user->getID()
658 $res = $this->select( __METHOD__
);
660 foreach ( $res as $row ) {
661 $this->watched
[$row->wl_namespace
][$row->wl_title
] = true;
665 public function getCacheMode( $params ) {
666 $publicProps = array(
674 if ( !is_null( $params['prop'] ) ) {
675 foreach ( $params['prop'] as $prop ) {
676 if ( !in_array( $prop, $publicProps ) ) {
681 if ( !is_null( $params['token'] ) ) {
687 public function getAllowedParams() {
690 ApiBase
::PARAM_DFLT
=> null,
691 ApiBase
::PARAM_ISMULTI
=> true,
692 ApiBase
::PARAM_TYPE
=> array(
698 'readable', # private
701 // If you add more properties here, please consider whether they
702 // need to be added to getCacheMode()
705 ApiBase
::PARAM_DFLT
=> null,
706 ApiBase
::PARAM_ISMULTI
=> true,
707 ApiBase
::PARAM_TYPE
=> array_keys( $this->getTokenFunctions() )
713 public function getParamDescription() {
716 'Which additional properties to get:',
717 ' protection - List the protection level of each page',
718 ' talkid - The page ID of the talk page for each non-talk page',
719 ' watched - List the watched status of each page',
720 ' subjectid - The page ID of the parent page for each talk page',
721 ' url - Gives a full URL to the page, and also an edit URL',
722 ' readable - Whether the user can read this page',
723 ' preload - Gives the text returned by EditFormPreloadText',
724 ' displaytitle - Gives the way the page title is actually displayed',
726 'token' => 'Request a token to perform a data-modifying action on a page',
727 'continue' => 'When more results are available, use this to continue',
731 public function getResultProperties() {
733 ApiBase
::PROP_LIST
=> false,
735 'touched' => 'timestamp',
736 'lastrevid' => 'integer',
738 ApiBase
::PROP_TYPE
=> 'integer',
739 ApiBase
::PROP_NULLABLE
=> true
741 'length' => 'integer',
742 'redirect' => 'boolean',
744 'starttimestamp' => array(
745 ApiBase
::PROP_TYPE
=> 'timestamp',
746 ApiBase
::PROP_NULLABLE
=> true
750 'watched' => 'boolean'
754 ApiBase
::PROP_TYPE
=> 'integer',
755 ApiBase
::PROP_NULLABLE
=> true
758 'subjectid' => array(
759 'subjectid' => array(
760 ApiBase
::PROP_TYPE
=> 'integer',
761 ApiBase
::PROP_NULLABLE
=> true
765 'fullurl' => 'string',
766 'editurl' => 'string'
769 'readable' => 'boolean'
772 'preload' => 'string'
774 'displaytitle' => array(
775 'displaytitle' => 'string'
779 self
::addTokenProperties( $props, $this->getTokenFunctions() );
784 public function getDescription() {
785 return 'Get basic page information such as namespace, title, last touched date, ...';
788 public function getPossibleErrors() {
789 return array_merge( parent
::getPossibleErrors(), array(
790 array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ),
794 public function getExamples() {
796 'api.php?action=query&prop=info&titles=Main%20Page',
797 'api.php?action=query&prop=info&inprop=protection&titles=Main%20Page'
801 public function getHelpUrls() {
802 return 'https://www.mediawiki.org/wiki/API:Properties#info_.2F_in';
805 public function getVersion() {
806 return __CLASS__
. ': $Id$';