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, $fld_notificationtimestamp = 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, $notificationtimestamps, $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_notificationtimestamp
= isset( $prop['notificationtimestamp'] );
252 $this->fld_talkid
= isset( $prop['talkid'] );
253 $this->fld_subjectid
= isset( $prop['subjectid'] );
254 $this->fld_url
= isset( $prop['url'] );
255 $this->fld_readable
= isset( $prop['readable'] );
256 $this->fld_preload
= isset( $prop['preload'] );
257 $this->fld_displaytitle
= isset( $prop['displaytitle'] );
260 $pageSet = $this->getPageSet();
261 $this->titles
= $pageSet->getGoodTitles();
262 $this->missing
= $pageSet->getMissingTitles();
263 $this->everything
= $this->titles +
$this->missing
;
264 $result = $this->getResult();
266 uasort( $this->everything
, array( 'Title', 'compare' ) );
267 if ( !is_null( $this->params
['continue'] ) ) {
268 // Throw away any titles we're gonna skip so they don't
270 $cont = explode( '|', $this->params
['continue'] );
271 if ( count( $cont ) != 2 ) {
272 $this->dieUsage( 'Invalid continue param. You should pass the original ' .
273 'value returned by the previous query', '_badcontinue' );
275 $conttitle = Title
::makeTitleSafe( $cont[0], $cont[1] );
276 foreach ( $this->everything
as $pageid => $title ) {
277 if ( Title
::compare( $title, $conttitle ) >= 0 ) {
280 unset( $this->titles
[$pageid] );
281 unset( $this->missing
[$pageid] );
282 unset( $this->everything
[$pageid] );
286 $this->pageRestrictions
= $pageSet->getCustomField( 'page_restrictions' );
287 // when resolving redirects, no page will have this field
288 $this->pageIsRedir
= !$pageSet->isResolvingRedirects()
289 ?
$pageSet->getCustomField( 'page_is_redirect' )
291 $this->pageIsNew
= $pageSet->getCustomField( 'page_is_new' );
293 global $wgDisableCounters;
295 if ( !$wgDisableCounters ) {
296 $this->pageCounter
= $pageSet->getCustomField( 'page_counter' );
298 $this->pageTouched
= $pageSet->getCustomField( 'page_touched' );
299 $this->pageLatest
= $pageSet->getCustomField( 'page_latest' );
300 $this->pageLength
= $pageSet->getCustomField( 'page_len' );
302 // Get protection info if requested
303 if ( $this->fld_protection
) {
304 $this->getProtectionInfo();
307 if ( $this->fld_watched ||
$this->fld_notificationtimestamp
) {
308 $this->getWatchedInfo();
311 // Run the talkid/subjectid query if requested
312 if ( $this->fld_talkid ||
$this->fld_subjectid
) {
316 if ( $this->fld_displaytitle
) {
317 $this->getDisplayTitle();
320 foreach ( $this->everything
as $pageid => $title ) {
321 $pageInfo = $this->extractPageInfo( $pageid, $title );
322 $fit = $result->addValue( array(
325 ), $pageid, $pageInfo );
327 $this->setContinueEnumParameter( 'continue',
328 $title->getNamespace() . '|' .
336 * Get a result array with information about a title
337 * @param $pageid int Page ID (negative for missing titles)
338 * @param $title Title object
341 private function extractPageInfo( $pageid, $title ) {
343 $titleExists = $pageid > 0; //$title->exists() needs pageid, which is not set for all title objects
344 $ns = $title->getNamespace();
345 $dbkey = $title->getDBkey();
346 if ( $titleExists ) {
347 global $wgDisableCounters;
349 $pageInfo['touched'] = wfTimestamp( TS_ISO_8601
, $this->pageTouched
[$pageid] );
350 $pageInfo['lastrevid'] = intval( $this->pageLatest
[$pageid] );
351 $pageInfo['counter'] = $wgDisableCounters
353 : intval( $this->pageCounter
[$pageid] );
354 $pageInfo['length'] = intval( $this->pageLength
[$pageid] );
356 if ( isset( $this->pageIsRedir
[$pageid] ) && $this->pageIsRedir
[$pageid] ) {
357 $pageInfo['redirect'] = '';
359 if ( $this->pageIsNew
[$pageid] ) {
360 $pageInfo['new'] = '';
364 if ( !is_null( $this->params
['token'] ) ) {
365 $tokenFunctions = $this->getTokenFunctions();
366 $pageInfo['starttimestamp'] = wfTimestamp( TS_ISO_8601
, time() );
367 foreach ( $this->params
['token'] as $t ) {
368 $val = call_user_func( $tokenFunctions[$t], $pageid, $title );
369 if ( $val === false ) {
370 $this->setWarning( "Action '$t' is not allowed for the current user" );
372 $pageInfo[$t . 'token'] = $val;
377 if ( $this->fld_protection
) {
378 $pageInfo['protection'] = array();
379 if ( isset( $this->protections
[$ns][$dbkey] ) ) {
380 $pageInfo['protection'] =
381 $this->protections
[$ns][$dbkey];
383 $this->getResult()->setIndexedTagName( $pageInfo['protection'], 'pr' );
386 if ( $this->fld_watched
&& isset( $this->watched
[$ns][$dbkey] ) ) {
387 $pageInfo['watched'] = '';
390 if ( $this->fld_notificationtimestamp
) {
391 $pageInfo['notificationtimestamp'] = '';
392 if ( isset( $this->notificationtimestamps
[$ns][$dbkey] ) ) {
393 $pageInfo['notificationtimestamp'] = wfTimestamp( TS_ISO_8601
, $this->notificationtimestamps
[$ns][$dbkey] );
397 if ( $this->fld_talkid
&& isset( $this->talkids
[$ns][$dbkey] ) ) {
398 $pageInfo['talkid'] = $this->talkids
[$ns][$dbkey];
401 if ( $this->fld_subjectid
&& isset( $this->subjectids
[$ns][$dbkey] ) ) {
402 $pageInfo['subjectid'] = $this->subjectids
[$ns][$dbkey];
405 if ( $this->fld_url
) {
406 $pageInfo['fullurl'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT
);
407 $pageInfo['editurl'] = wfExpandUrl( $title->getFullURL( 'action=edit' ), PROTO_CURRENT
);
409 if ( $this->fld_readable
&& $title->userCan( 'read', $this->getUser() ) ) {
410 $pageInfo['readable'] = '';
413 if ( $this->fld_preload
) {
414 if ( $titleExists ) {
415 $pageInfo['preload'] = '';
418 wfRunHooks( 'EditFormPreloadText', array( &$text, &$title ) );
420 $pageInfo['preload'] = $text;
424 if ( $this->fld_displaytitle
) {
425 if ( isset( $this->displaytitles
[$pageid] ) ) {
426 $pageInfo['displaytitle'] = $this->displaytitles
[$pageid];
428 $pageInfo['displaytitle'] = $title->getPrefixedText();
436 * Get information about protections and put it in $protections
438 private function getProtectionInfo() {
440 $this->protections
= array();
441 $db = $this->getDB();
443 // Get normal protections for existing titles
444 if ( count( $this->titles
) ) {
445 $this->resetQueryParams();
446 $this->addTables( 'page_restrictions' );
447 $this->addFields( array( 'pr_page', 'pr_type', 'pr_level',
448 'pr_expiry', 'pr_cascade' ) );
449 $this->addWhereFld( 'pr_page', array_keys( $this->titles
) );
451 $res = $this->select( __METHOD__
);
452 foreach ( $res as $row ) {
453 $title = $this->titles
[$row->pr_page
];
455 'type' => $row->pr_type
,
456 'level' => $row->pr_level
,
457 'expiry' => $wgContLang->formatExpiry( $row->pr_expiry
, TS_ISO_8601
)
459 if ( $row->pr_cascade
) {
462 $this->protections
[$title->getNamespace()][$title->getDBkey()][] = $a;
464 // Also check old restrictions
465 foreach( $this->titles
as $pageId => $title ) {
466 if ( $this->pageRestrictions
[$pageId] ) {
467 $namespace = $title->getNamespace();
468 $dbKey = $title->getDBkey();
469 $restrictions = explode( ':', trim( $this->pageRestrictions
[$pageId] ) );
470 foreach ( $restrictions as $restrict ) {
471 $temp = explode( '=', trim( $restrict ) );
472 if ( count( $temp ) == 1 ) {
473 // old old format should be treated as edit/move restriction
474 $restriction = trim( $temp[0] );
476 if ( $restriction == '' ) {
479 $this->protections
[$namespace][$dbKey][] = array(
481 'level' => $restriction,
482 'expiry' => 'infinity',
484 $this->protections
[$namespace][$dbKey][] = array(
486 'level' => $restriction,
487 'expiry' => 'infinity',
490 $restriction = trim( $temp[1] );
491 if ( $restriction == '' ) {
494 $this->protections
[$namespace][$dbKey][] = array(
496 'level' => $restriction,
497 'expiry' => 'infinity',
505 // Get protections for missing titles
506 if ( count( $this->missing
) ) {
507 $this->resetQueryParams();
508 $lb = new LinkBatch( $this->missing
);
509 $this->addTables( 'protected_titles' );
510 $this->addFields( array( 'pt_title', 'pt_namespace', 'pt_create_perm', 'pt_expiry' ) );
511 $this->addWhere( $lb->constructSet( 'pt', $db ) );
512 $res = $this->select( __METHOD__
);
513 foreach ( $res as $row ) {
514 $this->protections
[$row->pt_namespace
][$row->pt_title
][] = array(
516 'level' => $row->pt_create_perm
,
517 'expiry' => $wgContLang->formatExpiry( $row->pt_expiry
, TS_ISO_8601
)
522 // Cascading protections
523 $images = $others = array();
524 foreach ( $this->everything
as $title ) {
525 if ( $title->getNamespace() == NS_FILE
) {
526 $images[] = $title->getDBkey();
532 if ( count( $others ) ) {
533 // Non-images: check templatelinks
534 $lb = new LinkBatch( $others );
535 $this->resetQueryParams();
536 $this->addTables( array( 'page_restrictions', 'page', 'templatelinks' ) );
537 $this->addFields( array( 'pr_type', 'pr_level', 'pr_expiry',
538 'page_title', 'page_namespace',
539 'tl_title', 'tl_namespace' ) );
540 $this->addWhere( $lb->constructSet( 'tl', $db ) );
541 $this->addWhere( 'pr_page = page_id' );
542 $this->addWhere( 'pr_page = tl_from' );
543 $this->addWhereFld( 'pr_cascade', 1 );
545 $res = $this->select( __METHOD__
);
546 foreach ( $res as $row ) {
547 $source = Title
::makeTitle( $row->page_namespace
, $row->page_title
);
548 $this->protections
[$row->tl_namespace
][$row->tl_title
][] = array(
549 'type' => $row->pr_type
,
550 'level' => $row->pr_level
,
551 'expiry' => $wgContLang->formatExpiry( $row->pr_expiry
, TS_ISO_8601
),
552 'source' => $source->getPrefixedText()
557 if ( count( $images ) ) {
558 // Images: check imagelinks
559 $this->resetQueryParams();
560 $this->addTables( array( 'page_restrictions', 'page', 'imagelinks' ) );
561 $this->addFields( array( 'pr_type', 'pr_level', 'pr_expiry',
562 'page_title', 'page_namespace', 'il_to' ) );
563 $this->addWhere( 'pr_page = page_id' );
564 $this->addWhere( 'pr_page = il_from' );
565 $this->addWhereFld( 'pr_cascade', 1 );
566 $this->addWhereFld( 'il_to', $images );
568 $res = $this->select( __METHOD__
);
569 foreach ( $res as $row ) {
570 $source = Title
::makeTitle( $row->page_namespace
, $row->page_title
);
571 $this->protections
[NS_FILE
][$row->il_to
][] = array(
572 'type' => $row->pr_type
,
573 'level' => $row->pr_level
,
574 'expiry' => $wgContLang->formatExpiry( $row->pr_expiry
, TS_ISO_8601
),
575 'source' => $source->getPrefixedText()
582 * Get talk page IDs (if requested) and subject page IDs (if requested)
583 * and put them in $talkids and $subjectids
585 private function getTSIDs() {
586 $getTitles = $this->talkids
= $this->subjectids
= array();
588 foreach ( $this->everything
as $t ) {
589 if ( MWNamespace
::isTalk( $t->getNamespace() ) ) {
590 if ( $this->fld_subjectid
) {
591 $getTitles[] = $t->getSubjectPage();
593 } elseif ( $this->fld_talkid
) {
594 $getTitles[] = $t->getTalkPage();
597 if ( !count( $getTitles ) ) {
601 $db = $this->getDB();
603 // Construct a custom WHERE clause that matches
604 // all titles in $getTitles
605 $lb = new LinkBatch( $getTitles );
606 $this->resetQueryParams();
607 $this->addTables( 'page' );
608 $this->addFields( array( 'page_title', 'page_namespace', 'page_id' ) );
609 $this->addWhere( $lb->constructSet( 'page', $db ) );
610 $res = $this->select( __METHOD__
);
611 foreach ( $res as $row ) {
612 if ( MWNamespace
::isTalk( $row->page_namespace
) ) {
613 $this->talkids
[MWNamespace
::getSubject( $row->page_namespace
)][$row->page_title
] =
614 intval( $row->page_id
);
616 $this->subjectids
[MWNamespace
::getTalk( $row->page_namespace
)][$row->page_title
] =
617 intval( $row->page_id
);
622 private function getDisplayTitle() {
623 $this->displaytitles
= array();
625 $pageIds = array_keys( $this->titles
);
627 if ( !count( $pageIds ) ) {
631 $this->resetQueryParams();
632 $this->addTables( 'page_props' );
633 $this->addFields( array( 'pp_page', 'pp_value' ) );
634 $this->addWhereFld( 'pp_page', $pageIds );
635 $this->addWhereFld( 'pp_propname', 'displaytitle' );
636 $res = $this->select( __METHOD__
);
638 foreach ( $res as $row ) {
639 $this->displaytitles
[$row->pp_page
] = $row->pp_value
;
644 * Get information about watched status and put it in $this->watched
645 * and $this->notificationtimestamps
647 private function getWatchedInfo() {
648 $user = $this->getUser();
650 if ( $user->isAnon() ||
count( $this->everything
) == 0 ) {
654 $this->watched
= array();
655 $this->notificationtimestamps
= array();
656 $db = $this->getDB();
658 $lb = new LinkBatch( $this->everything
);
660 $this->resetQueryParams();
661 $this->addTables( array( 'watchlist' ) );
662 $this->addFields( array( 'wl_title', 'wl_namespace' ) );
663 $this->addFieldsIf( 'wl_notificationtimestamp', $this->fld_notificationtimestamp
);
664 $this->addWhere( array(
665 $lb->constructSet( 'wl', $db ),
666 'wl_user' => $user->getID()
669 $res = $this->select( __METHOD__
);
671 foreach ( $res as $row ) {
672 if ( $this->fld_watched
) {
673 $this->watched
[$row->wl_namespace
][$row->wl_title
] = true;
675 if ( $this->fld_notificationtimestamp
) {
676 $this->notificationtimestamps
[$row->wl_namespace
][$row->wl_title
] = $row->wl_notificationtimestamp
;
681 public function getCacheMode( $params ) {
682 $publicProps = array(
690 if ( !is_null( $params['prop'] ) ) {
691 foreach ( $params['prop'] as $prop ) {
692 if ( !in_array( $prop, $publicProps ) ) {
697 if ( !is_null( $params['token'] ) ) {
703 public function getAllowedParams() {
706 ApiBase
::PARAM_DFLT
=> null,
707 ApiBase
::PARAM_ISMULTI
=> true,
708 ApiBase
::PARAM_TYPE
=> array(
712 'notificationtimestamp', # private
715 'readable', # private
718 // If you add more properties here, please consider whether they
719 // need to be added to getCacheMode()
722 ApiBase
::PARAM_DFLT
=> null,
723 ApiBase
::PARAM_ISMULTI
=> true,
724 ApiBase
::PARAM_TYPE
=> array_keys( $this->getTokenFunctions() )
730 public function getParamDescription() {
733 'Which additional properties to get:',
734 ' protection - List the protection level of each page',
735 ' talkid - The page ID of the talk page for each non-talk page',
736 ' watched - List the watched status of each page',
737 ' notificationtimestamp - The watchlist notification timestamp of each page',
738 ' subjectid - The page ID of the parent page for each talk page',
739 ' url - Gives a full URL to the page, and also an edit URL',
740 ' readable - Whether the user can read this page',
741 ' preload - Gives the text returned by EditFormPreloadText',
742 ' displaytitle - Gives the way the page title is actually displayed',
744 'token' => 'Request a token to perform a data-modifying action on a page',
745 'continue' => 'When more results are available, use this to continue',
749 public function getResultProperties() {
751 ApiBase
::PROP_LIST
=> false,
753 'touched' => 'timestamp',
754 'lastrevid' => 'integer',
756 ApiBase
::PROP_TYPE
=> 'integer',
757 ApiBase
::PROP_NULLABLE
=> true
759 'length' => 'integer',
760 'redirect' => 'boolean',
762 'starttimestamp' => array(
763 ApiBase
::PROP_TYPE
=> 'timestamp',
764 ApiBase
::PROP_NULLABLE
=> true
768 'watched' => 'boolean'
770 'notificationtimestamp' => array(
771 'notificationtimestamp' => array(
772 ApiBase
::PROP_TYPE
=> 'timestamp',
773 ApiBase
::PROP_NULLABLE
=> true
778 ApiBase
::PROP_TYPE
=> 'integer',
779 ApiBase
::PROP_NULLABLE
=> true
782 'subjectid' => array(
783 'subjectid' => array(
784 ApiBase
::PROP_TYPE
=> 'integer',
785 ApiBase
::PROP_NULLABLE
=> true
789 'fullurl' => 'string',
790 'editurl' => 'string'
793 'readable' => 'boolean'
796 'preload' => 'string'
798 'displaytitle' => array(
799 'displaytitle' => 'string'
803 self
::addTokenProperties( $props, $this->getTokenFunctions() );
808 public function getDescription() {
809 return 'Get basic page information such as namespace, title, last touched date, ...';
812 public function getPossibleErrors() {
813 return array_merge( parent
::getPossibleErrors(), array(
814 array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ),
818 public function getExamples() {
820 'api.php?action=query&prop=info&titles=Main%20Page',
821 'api.php?action=query&prop=info&inprop=protection&titles=Main%20Page'
825 public function getHelpUrls() {
826 return 'https://www.mediawiki.org/wiki/API:Properties#info_.2F_in';
829 public function getVersion() {
830 return __CLASS__
. ': $Id$';