Add licensing for extensions to Special:Version
[lhc/web/wiklou.git] / includes / api / ApiQuerySiteinfo.php
index 1c188da..5e9cd08 100644 (file)
@@ -99,6 +99,9 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                case 'protocols':
                                        $fit = $this->appendProtocols( $p );
                                        break;
+                               case 'defaultoptions':
+                                       $fit = $this->appendDefaultOptions( $p );
+                                       break;
                                default:
                                        ApiBase::dieDebug( __METHOD__, "Unknown prop=$p" );
                        }
@@ -239,6 +242,14 @@ class ApiQuerySiteinfo extends ApiQueryBase {
 
                $data['maxuploadsize'] = UploadBase::getMaxUploadSize();
 
+               $data['thumblimits'] = $GLOBALS['wgThumbLimits'];
+               $this->getResult()->setIndexedTagName( $data['thumblimits'], 'limit' );
+               $data['imagelimits'] = array();
+               $this->getResult()->setIndexedTagName( $data['imagelimits'], 'limit' );
+               foreach ( $GLOBALS['wgImageLimits'] as $k => $limit ) {
+                       $data['imagelimits'][$k] = array( 'width' => $limit[0], 'height' => $limit[1] );
+               }
+
                wfRunHooks( 'APIQuerySiteInfoGeneralInfo', array( $this, &$data ) );
 
                return $this->getResult()->addValue( 'query', $property, $data );
@@ -536,6 +547,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;
                        }
                }
@@ -633,6 +669,10 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                return $this->getResult()->addValue( 'query', $property, $protocols );
        }
 
+       public function appendDefaultOptions( $property ) {
+               return $this->getResult()->addValue( 'query', $property, User::getDefaultOptions() );
+       }
+
        private function formatParserTags( $item ) {
                return "<{$item}>";
        }
@@ -687,6 +727,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                        'showhooks',
                                        'variables',
                                        'protocols',
+                                       'defaultoptions',
                                )
                        ),
                        'filteriw' => array(
@@ -728,6 +769,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                ' showhooks             - Returns a list of all subscribed hooks (contents of $wgHooks)',
                                ' variables             - Returns a list of variable IDs',
                                ' protocols             - Returns a list of protocols that are allowed in external links.',
+                               ' defaultoptions        - Returns the default values for user preferences.',
                        ),
                        'filteriw' => 'Return only local or only nonlocal entries of the interwiki map',
                        'showalldb' => 'List all database servers, not just the one lagging the most',