* (bug 20809) Expose EditFormPreloadText via the API
authorSam Reed <reedy@users.mediawiki.org>
Sun, 31 Jan 2010 22:06:02 +0000 (22:06 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Sun, 31 Jan 2010 22:06:02 +0000 (22:06 +0000)
If page exists, don't run hook and just display ''

Comment for readable and url

RELEASE-NOTES
includes/api/ApiQueryInfo.php

index 01f4756..982b893 100644 (file)
@@ -812,6 +812,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 21922) YAML output should quote asterisk when used as key
 * (bug 22297) safesubst: to allow substitution without breaking transclusion
 * (bug 18758) API read of watchlist's wl_notificationtimestamp
+* (bug 20809) Expose EditFormPreloadText via the API
 
 === Languages updated in 1.16 ===
 
index 13474d5..5f31b11 100644 (file)
@@ -37,7 +37,8 @@ class ApiQueryInfo extends ApiQueryBase {
 
        private $fld_protection = false, $fld_talkid = false,
                $fld_subjectid = false, $fld_url = false,
-               $fld_readable = false, $fld_watched = false;
+               $fld_readable = false, $fld_watched = false,
+               $fld_preload = false;
 
        public function __construct( $query, $moduleName ) {
                parent :: __construct( $query, $moduleName, 'in' );
@@ -200,6 +201,7 @@ class ApiQueryInfo extends ApiQueryBase {
                        $this->fld_subjectid = isset( $prop['subjectid'] );
                        $this->fld_url = isset( $prop['url'] );
                        $this->fld_readable = isset( $prop['readable'] );
+                       $this->fld_preload = isset ( $prop['preload'] );
                }
 
                $pageSet = $this->getPageSet();
@@ -321,6 +323,16 @@ class ApiQueryInfo extends ApiQueryBase {
                }
                if ( $this->fld_readable && $title->userCanRead() )
                        $pageInfo['readable'] = '';
+                       
+               if ( $this->fld_preload ) {
+                       if ( $title->exists() )
+                               $pageInfo['preload'] = '';
+                       else {
+                               wfRunHooks( 'EditFormPreloadText', array( &$text, &$title ) );
+                       
+                               $pageInfo['preload'] = $text;
+                       }
+               }               
                return $pageInfo;
        }
 
@@ -553,6 +565,7 @@ class ApiQueryInfo extends ApiQueryBase {
                                        'subjectid',
                                        'url',
                                        'readable',
+                                       'preload'
                                ) ),
                        'token' => array (
                                ApiBase :: PARAM_DFLT => null,
@@ -570,7 +583,10 @@ class ApiQueryInfo extends ApiQueryBase {
                                ' protection   - List the protection level of each page',
                                ' talkid       - The page ID of the talk page for each non-talk page',
                                ' watched      - List the watched status of each page',
-                               ' subjectid    - The page ID of the parent page for each talk page'
+                               ' subjectid    - The page ID of the parent page for each talk page',
+                               ' url          - Gives a full URL to the page, and also an edit URL',
+                               ' readable     - Whether the user can read this page',
+                               ' preload      - Gives the text returned by EditFormPreloadText'
                        ),
                        'token' => 'Request a token to perform a data-modifying action on a page',
                        'continue' => 'When more results are available, use this to continue',