Support extension information in meta=siteinfo.
authorChad Horohoe <demon@users.mediawiki.org>
Sun, 14 Dec 2008 22:06:32 +0000 (22:06 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Sun, 14 Dec 2008 22:06:32 +0000 (22:06 +0000)
RELEASE-NOTES
includes/api/ApiQuerySiteinfo.php

index 4d23988..dc7a996 100644 (file)
@@ -520,6 +520,7 @@ The following extensions are migrated into MediaWiki 1.14:
 * (bug 15579) clshow considers all categories !hidden
 * (bug 16647) list=allcategories, prop=categories don't return "hidden"
   property for hidden categories
+* New siprop parameter of 'extensions' to list all installed extensions
 
 === Languages updated in 1.14 ===
 
index 089f471..3610e27 100644 (file)
@@ -73,6 +73,9 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                case 'usergroups':
                                        $this->appendUserGroups( $p );
                                        break;
+                               case 'extensions':
+                                       $this->appendExtensions( $p );
+                                       break;
                                default :
                                        ApiBase :: dieDebug( __METHOD__, "Unknown prop=$p" );
                        }
@@ -183,7 +186,6 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                $this->getResult()->setIndexedTagName($data, 'magicword');
                $this->getResult()->addValue('query', $property, $data);
        }
-                       
 
        protected function appendInterwikiMap( $property, $filter ) {
                $this->resetQueryParams();
@@ -278,6 +280,40 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                $this->getResult()->addValue( 'query', $property, $data );
        }
 
+       protected function appendExtensions( $property ) {
+               global $wgExtensionCredits;
+               $data = array();
+               foreach ( $wgExtensionCredits as $type => $extensions ) {
+                       foreach ( $extensions as $ext ) {
+                               $ret = array();
+                               $ret['type'] = $type;
+                               if ( isset( $ext['name'] ) ) 
+                                       $ret['name'] = $ext['name'];
+                               if ( isset( $ext['description'] ) ) 
+                                       $ret['description'] = $ext['description'];
+                               if ( isset( $ext['descriptionmsg'] ) ) 
+                                       $ret['descriptionmsg'] = $ext['descriptionmsg'];
+                               if ( isset( $ext['author'] ) ) {
+                                       $ret['author'] = is_array( $ext['author'] ) ? 
+                                               implode( ', ', $ext['author' ] ) : $ext['author'];
+                               }
+                               if ( isset( $ext['version'] ) ) {
+                                               $ret['version'] = $ext['version'];
+                               } elseif ( isset( $ext['svn-revision'] ) && 
+                                       preg_match( '/\$(?:Rev|LastChangedRevision|Revision): *(\d+)/', 
+                                               $ext['svn-revision'], $m ) )  
+                               {
+                                               $ret['version'] = 'r' . $m[1];
+                               }
+                               $data[] = $ret;
+                       }
+               }
+
+               $this->getResult()->setIndexedTagName( $data, 'ext' );
+               $this->getResult()->addValue( 'query', $property, $data );
+       }
+
+
        public function getAllowedParams() {
                return array(
                        'prop' => array(
@@ -293,6 +329,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                        'dbrepllag',
                                        'statistics',
                                        'usergroups',
+                                       'extensions',
                                )
                        ),
                        'filteriw' => array(
@@ -318,6 +355,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                ' "interwikimap" - Returns interwiki map (optionally filtered)',
                                ' "dbrepllag"    - Returns database server with the highest replication lag',
                                ' "usergroups"   - Returns user groups and the associated permissions',
+                               ' "extensions"   - Returns extensions installed on the wiki',
                        ),
                        'filteriw' =>  'Return only local or only nonlocal entries of the interwiki map',
                        'showalldb' => 'List all database servers, not just the one lagging the most',