From: Sam Reed Date: Sun, 31 Jan 2010 22:06:02 +0000 (+0000) Subject: * (bug 20809) Expose EditFormPreloadText via the API X-Git-Tag: 1.31.0-rc.0~38010 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=affac2406af6a948fe5e40abefab6013dfb60e4c;p=lhc%2Fweb%2Fwiklou.git * (bug 20809) Expose EditFormPreloadText via the API If page exists, don't run hook and just display '' Comment for readable and url --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 01f4756496..982b893898 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index 13474d5d8d..5f31b119b4 100644 --- a/includes/api/ApiQueryInfo.php +++ b/includes/api/ApiQueryInfo.php @@ -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',