Remove errant string; now I look like a fscking noob
[lhc/web/wiklou.git] / includes / SpecialVersion.php
index 4f3a81a..7ad58b5 100644 (file)
@@ -1,6 +1,6 @@
 <?php
-/**
- * Give information about the version of MediaWiki, PHP, the DB and extensions
+/**#@+
+ * Give information about the version of MediaWiki, PHP, server software, the DB and extensions
  *
  * @package MediaWiki
  * @subpackage SpecialPage
@@ -21,6 +21,7 @@ function wfSpecialVersion() {
 class SpecialVersion {
        /**
         * @var object
+        * @access private
         */
        var $langObj;
        
@@ -28,18 +29,32 @@ class SpecialVersion {
         * Constructor
         */
        function SpecialVersion() {
-               // English motherfucker, do you speak it?
+               # Force to English language
                $this->langObj = setupLangObj( 'LanguageEn' );
                $this->langObj->initEncoding();
        }
-       
+
+       /**
+        * main()
+        */
        function execute() {
                global $wgOut;
                
-               $wgOut->addWikiText( $this->MediaWikiCredits() . $this->extensionCredits() . $this->wgHooks() );
+               $wgOut->addWikiText(
+                       $this->MediaWikiCredits() .
+                       $this->extensionCredits() .
+                       $this->wgHooks()
+               );
                $wgOut->addHTML( $this->IPInfo() );
        }
 
+       /**#@+
+        * @access private
+        */
+       
+       /**
+        * @static
+        */
        function MediaWikiCredits() {
                global $wgVersion;
                
@@ -69,12 +84,24 @@ class SpecialVersion {
                
                * [http://www.mediawiki.org/ MediaWiki]: $wgVersion
                * [http://www.php.net/ PHP]: " . phpversion() . " (" . php_sapi_name() . ")
+               " . $this->getServerSoftware() . "
                * " . $dbr->getSoftwareLink() . ": " . $dbr->getServerVersion() . "
                </div>";
 
                return str_replace( "\t\t", '', $ret );
        }
 
+       function getServerSoftware() {
+               # Return tweaked version of $_SERVER['SERVER_SOFTWARE']
+               if( isset( $_SERVER['SERVER_SOFTWARE'] ) ) {
+                       $osver = explode( ' ', $_SERVER['SERVER_SOFTWARE'] );
+                       $ssoft = "* " . ( count( $osver ) > 1 ? $osver[0] . ' ' . $osver[1] : $osver[0] );
+               } else {
+                       $ssoft = "";
+               }
+               return( $ssoft );
+       }
+
        function extensionCredits() {
                global $wgExtensionCredits, $wgExtensionFunctions, $wgSkinExtensionFunction;
                
@@ -87,12 +114,15 @@ class SpecialVersion {
                        'variable' => 'Variables',
                        'other' => 'Other',
                );
-               wfRunHooks( 'SpecialVersionExtensionTypes', array( &$extensionTypes ) );
+               wfRunHooks( 'SpecialVersionExtensionTypes', array( &$this, &$extensionTypes ) );
                
                $out = "\n* Extensions:\n";
                foreach ( $extensionTypes as $type => $text ) {
                        if ( count( @$wgExtensionCredits[$type] ) ) {
                                $out .= "** $text:\n";
+                               
+                               usort( $wgExtensionCredits[$type], array( $this, 'compare' ) );
+                               
                                foreach ( $wgExtensionCredits[$type] as $extension ) {
                                        wfSuppressWarnings();
                                        $out .= $this->formatCredits(
@@ -120,6 +150,13 @@ class SpecialVersion {
                return $out;
        }
 
+       function compare( $a, $b ) {
+               if ( $a['name'] === $b['name'] )
+                       return 0;
+               else
+                       return $this->langObj->lc( $a['name'] ) > $this->langObj->lc( $b['name'] ) ? 1 : -1;
+       }
+
        function formatCredits( $name, $version = null, $author = null, $url = null, $description = null) {
                $ret = '*** ';
                if ( isset( $url ) )
@@ -137,22 +174,32 @@ class SpecialVersion {
                if ( isset( $author ) )
                        $ret .= ' by ' . $this->langObj->listToText( (array)$author );
 
-               return htmlspecialchars( $ret ) . "\n";
+               return "$ret\n";
        }
 
        function wgHooks() {
                global $wgHooks;
 
-               $ret = "* Hooks:\n";
-               foreach ($wgHooks as $hook => $hooks)
-                       $ret .= "** $hook: " . $this->langObj->listToText( $hooks ) . "\n";
+               $myWgHooks = $wgHooks;
+               ksort( $myWgHooks );
 
+               $ret = "* Hooks:\n";
+               foreach ($myWgHooks as $hook => $hooks)
+                       $ret .= "** $hook:" . $this->langObj->listToText( $hooks ) . "\n";
+               
                return $ret;
        }
 
+       /**
+        * @static
+        */
        function IPInfo() {
-               $ip =  str_replace( '--', ' - ', htmlspecialchars( wfGetIP() ) );
+               $ip =  str_replace( '--', ' - ', htmlspecialchars( wfGetIP() ) );
                return "<!-- visited from $ip -->\n";
        }
+       
+       /**#@-*/
 }
+
+/**#@-*/
 ?>