Merge "Add licensing for extensions to Special:Version"
[lhc/web/wiklou.git] / includes / api / ApiQuerySiteinfo.php
index a94f5bb..0a74d98 100644 (file)
@@ -199,7 +199,10 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                if ( $wgContLang->hasVariants() ) {
                        $variants = array();
                        foreach ( $wgContLang->getVariants() as $code ) {
-                               $variants[] = array( 'code' => $code );
+                               $variants[] = array(
+                                       'code' => $code,
+                                       'name' => $wgContLang->getVariantname( $code ),
+                               );
                        }
                        $data['variants'] = $variants;
                        $this->getResult()->setIndexedTagName( $data['variants'], 'lang' );
@@ -547,6 +550,31 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                ) {
                                        $ret['version'] = 'r' . $m[1];
                                }
+                               if ( isset( $ext['path'] ) ) {
+                                       $extensionPath = dirname( $ext['path'] );
+                                       $gitInfo = new GitInfo( $extensionPath );
+                                       $vcsVersion = $gitInfo->getHeadSHA1();
+                                       if ( $vcsVersion !== false ) {
+                                               $ret['vcs-system'] = 'git';
+                                               $ret['vcs-version'] =  $vcsVersion;
+                                               $ret['vcs-url'] = $gitInfo->getHeadViewUrl();
+                                               $ret['vcs-date'] = wfTimestamp( TS_ISO_8601, $gitInfo->getHeadCommitDate() );
+                                       } else {
+                                               $svnInfo = SpecialVersion::getSvnInfo( $extensionPath );
+                                               if ( $svnInfo !== false ) {
+                                                       $ret['vcs-system'] = 'svn';
+                                                       $ret['vcs-version'] = $svnInfo['checkout-rev'];
+                                                       $ret['vcs-url'] = isset( $svnInfo['viewvc-url'] ) ? $svnInfo['viewvc-url'] : '';
+                                               }
+                                       }
+                                       if ( SpecialVersion::getExtLicenseFileName( $extensionPath ) ) {
+                                               $ret['license-name'] = isset( $ext['license-name'] ) ? $ext['license-name'] : '';
+                                               $ret['license'] = SpecialPage::getTitleFor( 'Version', "License/{$ext['name']}" )->getLinkURL();
+                                       }
+                                       if ( SpecialVersion::getExtAuthorsFileName( $extensionPath ) ) {
+                                               $ret['credits'] = SpecialPage::getTitleFor( 'Version', "Credits/{$ext['name']}" )->getLinkURL();
+                                       }
+                               }
                                $data[] = $ret;
                        }
                }