From 7dc62e75ed4b79962b1cea1bcc0fd124d8b19650 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Thu, 25 Sep 2008 15:55:09 +0000 Subject: [PATCH] (bug 15609) Add inprop=url (full URL to page and edit form) and inprop=readable (whether the current user can read the page) to prop=info --- RELEASE-NOTES | 1 + includes/api/ApiQueryInfo.php | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 72b9d1ae42..287178087d 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -274,6 +274,7 @@ The following extensions are migrated into MediaWiki 1.14: * (bug 15706) Empty values for apprtype and apprlevel are now silently ignored rather than causing an exception * Added uiprop=preferencestoken to meta=userinfo +* (bug 15609) Add inprop=url and inprop=readable to prop=info === Languages updated in 1.14 === diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index a8cc0c6fdb..96a98e68a8 100644 --- a/includes/api/ApiQueryInfo.php +++ b/includes/api/ApiQueryInfo.php @@ -179,6 +179,8 @@ class ApiQueryInfo extends ApiQueryBase { $fld_protection = isset($prop['protection']); $fld_talkid = isset($prop['talkid']); $fld_subjectid = isset($prop['subjectid']); + $fld_url = isset($prop['url']); + $fld_readable = isset($prop['readable']); } $pageSet = $this->getPageSet(); @@ -450,6 +452,13 @@ class ApiQueryInfo extends ApiQueryBase { $pageInfo['talkid'] = $talkids[$title->getNamespace()][$title->getDbKey()]; if($fld_subjectid && isset($subjectids[$title->getNamespace()][$title->getDbKey()])) $pageInfo['subjectid'] = $subjectids[$title->getNamespace()][$title->getDbKey()]; + if($fld_url) { + $pageInfo['fullurl'] = $title->getFullURL(); + $pageInfo['editurl'] = $title->getFullURL('action=edit'); + } + if($fld_readable) + if($title->userCanRead()) + $pageInfo['readable'] = ''; $result->addValue(array ( 'query', @@ -457,9 +466,9 @@ class ApiQueryInfo extends ApiQueryBase { ), $pageid, $pageInfo); } - // Get edit/protect tokens and protection data for missing titles if requested - // Delete and move tokens are N/A for missing titles anyway - if(!is_null($params['token']) || $fld_protection || $fld_talkid || $fld_subjectid) + // Get properties for missing titles if requested + if(!is_null($params['token']) || $fld_protection || $fld_talkid || $fld_subjectid || + $fld_url || $fld_readable) { $res = &$result->getData(); foreach($missing as $pageid => $title) { @@ -487,6 +496,13 @@ class ApiQueryInfo extends ApiQueryBase { $res['query']['pages'][$pageid]['talkid'] = $talkids[$title->getNamespace()][$title->getDbKey()]; if($fld_subjectid && isset($subjectids[$title->getNamespace()][$title->getDbKey()])) $res['query']['pages'][$pageid]['subjectid'] = $subjectids[$title->getNamespace()][$title->getDbKey()]; + if($fld_url) { + $res['query']['pages'][$pageid]['fullurl'] = $title->getFullURL(); + $res['query']['pages'][$pageid]['editurl'] = $title->getFullURL('action=edit'); + } + if($fld_readable) + if($title->userCanRead()) + $res['query']['pages'][$pageid]['readable'] = ''; } } } @@ -499,7 +515,9 @@ class ApiQueryInfo extends ApiQueryBase { ApiBase :: PARAM_TYPE => array ( 'protection', 'talkid', - 'subjectid' + 'subjectid', + 'url', + 'readable', )), 'token' => array ( ApiBase :: PARAM_DFLT => NULL, -- 2.20.1