(bug 15609) Add inprop=url (full URL to page and edit form) and inprop=readable ...
authorRoan Kattouw <catrope@users.mediawiki.org>
Thu, 25 Sep 2008 15:55:09 +0000 (15:55 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Thu, 25 Sep 2008 15:55:09 +0000 (15:55 +0000)
RELEASE-NOTES
includes/api/ApiQueryInfo.php

index 72b9d1a..2871780 100644 (file)
@@ -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 ===
 
index a8cc0c6..96a98e6 100644 (file)
@@ -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,