Code cleanup, covert leading spaces into tabs per coding style
authorOverlordQ <overlordq@users.mediawiki.org>
Sat, 14 Nov 2009 21:27:13 +0000 (21:27 +0000)
committerOverlordQ <overlordq@users.mediawiki.org>
Sat, 14 Nov 2009 21:27:13 +0000 (21:27 +0000)
includes/IP.php
includes/Import.php
includes/LogPage.php
includes/OutputHandler.php
includes/OutputPage.php
includes/User.php
includes/Xml.php

index c20ebcd..bbe7033 100644 (file)
@@ -108,13 +108,13 @@ class IP {
         */
        public static function toUnsigned6( $ip ) {
                if ( !$ip ) return null;
-               $ip = explode(':', self::sanitizeIP( $ip ) );
-               $r_ip = '';
-               foreach ($ip as $v) {
-                       $r_ip .= str_pad( $v, 4, 0, STR_PAD_LEFT );
-        }
-        $r_ip = wfBaseConvert( $r_ip, 16, 10 );
-               return $r_ip;
+               $ip = explode(':', self::sanitizeIP( $ip ) );
+               $r_ip = '';
+               foreach ($ip as $v) {
+                       $r_ip .= str_pad( $v, 4, 0, STR_PAD_LEFT );
+               }
+               $r_ip = wfBaseConvert( $r_ip, 16, 10 );
+               return $r_ip;
        }
 
        /**
@@ -145,11 +145,11 @@ class IP {
                        } else {
                                $repeat = ':0'; $extra = ':'; $pad = 8; // 6+2 (due to '::')
                        }
-               $ip = str_replace('::', str_repeat($repeat, $pad-substr_count($ip,':')).$extra, $ip);
-       }
-       // Remove leading zereos from each bloc as needed
-       $ip = preg_replace( '/(^|:)0+' . RE_IPV6_WORD . '/', '$1$2', $ip );
-       return $ip;
+                       $ip = str_replace('::', str_repeat($repeat, $pad-substr_count($ip,':')).$extra, $ip);
+               }
+               // Remove leading zereos from each bloc as needed
+               $ip = preg_replace( '/(^|:)0+' . RE_IPV6_WORD . '/', '$1$2', $ip );
+               return $ip;
        }
 
        /**
@@ -167,7 +167,7 @@ class IP {
                }
                // NO leading zeroes
                $ip_oct = preg_replace( '/(^|:)0+' . RE_IPV6_WORD . '/', '$1$2', $ip_oct );
-               return $ip_oct;
+               return $ip_oct;
        }
 
        /**
@@ -196,7 +196,7 @@ class IP {
                }
                // NO leading zeroes
                $ip_oct = preg_replace( '/(^|:)0+' . RE_IPV6_WORD . '/', '$1$2', $ip_oct );
-               return $ip_oct;
+               return $ip_oct;
        }
        
        /**
@@ -297,7 +297,7 @@ class IP {
                } else {
                        return array( $start, $end );
                }
-    }
+       }
 
        /**
         * Validate an IP address.
@@ -511,33 +511,33 @@ class IP {
                } else {
                        return array( $start, $end );
                }
-    }
+       }
 
-    /**
-     * Determine if a given IPv4/IPv6 address is in a given CIDR network
-     * @param $addr The address to check against the given range.
-     * @param $range The range to check the given address against.
-     * @return bool Whether or not the given address is in the given range.
-     */
-    public static function isInRange( $addr, $range ) {
-    // Convert to IPv6 if needed
-        $hexIP = self::toHex( $addr );
-        list( $start, $end ) = self::parseRange( $range );
-        return (strcmp($hexIP, $start) >= 0 &&
+       /**
+        * Determine if a given IPv4/IPv6 address is in a given CIDR network
+        * @param $addr The address to check against the given range.
+        * @param $range The range to check the given address against.
+        * @return bool Whether or not the given address is in the given range.
+        */
+       public static function isInRange( $addr, $range ) {
+               // Convert to IPv6 if needed
+               $hexIP = self::toHex( $addr );
+               list( $start, $end ) = self::parseRange( $range );
+               return (strcmp($hexIP, $start) >= 0 &&
                strcmp($hexIP, $end) <= 0);
-    }
+       }
 
-    /**
-     * Convert some unusual representations of IPv4 addresses to their
-     * canonical dotted quad representation.
-     *
-     * This currently only checks a few IPV4-to-IPv6 related cases.  More
-     * unusual representations may be added later.
-     *
-     * @param $addr something that might be an IP address
-     * @return valid dotted quad IPv4 address or null
-     */
-    public static function canonicalize( $addr ) {
+       /**
+        * Convert some unusual representations of IPv4 addresses to their
+        * canonical dotted quad representation.
+        *
+        * This currently only checks a few IPV4-to-IPv6 related cases.  More
+        * unusual representations may be added later.
+        *
+        * @param $addr something that might be an IP address
+        * @return valid dotted quad IPv4 address or null
+        */
+       public static function canonicalize( $addr ) {
                if ( self::isValid( $addr ) )
                        return $addr;
 
@@ -554,10 +554,10 @@ class IP {
 
                // IPv4-mapped and IPv4-compatible IPv6 addresses
                if ( preg_match( '/^' . RE_IPV6_V4_PREFIX . '(' . RE_IP_ADD . ')$/i', $addr, $m ) )
-                   return $m[1];
+                       return $m[1];
                if ( preg_match( '/^' . RE_IPV6_V4_PREFIX . RE_IPV6_WORD . ':' . RE_IPV6_WORD . '$/i', $addr, $m ) )
-                   return long2ip( ( hexdec( $m[1] ) << 16 ) + hexdec( $m[2] ) );
+                       return long2ip( ( hexdec( $m[1] ) << 16 ) + hexdec( $m[2] ) );
 
                return null;  // give up
-    }
+       }
 }
index ecd6866..5bc28cb 100644 (file)
@@ -400,21 +400,21 @@ class WikiImporter {
        }
 
        function handleXmlNamespace ( $parser, $data, $prefix=false, $uri=false ) {
-                if( preg_match( '/www.mediawiki.org/',$prefix ) ) {
-                       $prefix = str_replace( '/','\/',$prefix );
+               if( preg_match( '/www.mediawiki.org/',$prefix ) ) {
+                       $prefix = str_replace( '/','\/',$prefix );
                        $this->mXmlNamespace='/^'.$prefix.':/';
                 }
        }
 
        function stripXmlNamespace($name) {
                if( $this->mXmlNamespace ) {
-                      return(preg_replace($this->mXmlNamespace,'',$name,1));
+                       return(preg_replace($this->mXmlNamespace,'',$name,1));
                }
                else {
-                      return($name);
-                }
+                       return($name);
+               }
        }
-   
+
        # --------------
 
        function doImport() {
@@ -621,7 +621,7 @@ class WikiImporter {
        }
 
        function in_start( $parser, $name, $attribs ) {
-               $name = $this->stripXmlNamespace($name);
+               $name = $this->stripXmlNamespace($name);
                $this->debug( "in_start $name" );
                if( $name != "mediawiki" ) {
                        return $this->throwXMLerror( "Expected <mediawiki>, got <$name>" );
@@ -630,7 +630,7 @@ class WikiImporter {
        }
 
        function in_mediawiki( $parser, $name, $attribs ) {
-               $name = $this->stripXmlNamespace($name);
+               $name = $this->stripXmlNamespace($name);
                $this->debug( "in_mediawiki $name" );
                if( $name == 'siteinfo' ) {
                        xml_set_element_handler( $parser, "in_siteinfo", "out_siteinfo" );
@@ -650,7 +650,7 @@ class WikiImporter {
                }
        }
        function out_mediawiki( $parser, $name ) {
-               $name = $this->stripXmlNamespace($name);
+               $name = $this->stripXmlNamespace($name);
                $this->debug( "out_mediawiki $name" );
                if( $name != "mediawiki" ) {
                        return $this->throwXMLerror( "Expected </mediawiki>, got </$name>" );
@@ -661,7 +661,7 @@ class WikiImporter {
 
        function in_siteinfo( $parser, $name, $attribs ) {
                // no-ops for now
-               $name = $this->stripXmlNamespace($name);
+               $name = $this->stripXmlNamespace($name);
                $this->debug( "in_siteinfo $name" );
                switch( $name ) {
                case "sitename":
@@ -677,7 +677,7 @@ class WikiImporter {
        }
 
        function out_siteinfo( $parser, $name ) {
-               $name = $this->stripXmlNamespace($name);
+               $name = $this->stripXmlNamespace($name);
                if( $name == "siteinfo" ) {
                        xml_set_element_handler( $parser, "in_mediawiki", "out_mediawiki" );
                }
@@ -685,7 +685,7 @@ class WikiImporter {
 
 
        function in_page( $parser, $name, $attribs ) {
-               $name = $this->stripXmlNamespace($name);
+               $name = $this->stripXmlNamespace($name);
                $this->debug( "in_page $name" );
                switch( $name ) {
                case "id":
@@ -727,7 +727,7 @@ class WikiImporter {
        }
 
        function out_page( $parser, $name ) {
-               $name = $this->stripXmlNamespace($name);
+               $name = $this->stripXmlNamespace($name);
                $this->debug( "out_page $name" );
                $this->pop();
                if( $name != "page" ) {
@@ -747,7 +747,7 @@ class WikiImporter {
        }
 
        function in_nothing( $parser, $name, $attribs ) {
-               $name = $this->stripXmlNamespace($name);
+               $name = $this->stripXmlNamespace($name);
                $this->debug( "in_nothing $name" );
                return $this->throwXMLerror( "No child elements allowed here; got <$name>" );
        }
@@ -758,7 +758,7 @@ class WikiImporter {
        }
 
        function out_append( $parser, $name ) {
-               $name = $this->stripXmlNamespace($name);
+               $name = $this->stripXmlNamespace($name);
                $this->debug( "out_append $name" );
                if( $name != $this->appendfield ) {
                        return $this->throwXMLerror( "Expected </{$this->appendfield}>, got </$name>" );
@@ -854,7 +854,7 @@ class WikiImporter {
        }
 
        function in_revision( $parser, $name, $attribs ) {
-               $name = $this->stripXmlNamespace($name);
+               $name = $this->stripXmlNamespace($name);
                $this->debug( "in_revision $name" );
                switch( $name ) {
                case "id":
@@ -876,7 +876,7 @@ class WikiImporter {
        }
 
        function out_revision( $parser, $name ) {
-               $name = $this->stripXmlNamespace($name);
+               $name = $this->stripXmlNamespace($name);
                $this->debug( "out_revision $name" );
                $this->pop();
                if( $name != "revision" ) {
@@ -892,9 +892,9 @@ class WikiImporter {
                        }
                }
        }
-       
+
        function in_logitem( $parser, $name, $attribs ) {
-               $name = $this->stripXmlNamespace($name);
+               $name = $this->stripXmlNamespace($name);
                $this->debug( "in_logitem $name" );
                switch( $name ) {
                case "id":
@@ -918,7 +918,7 @@ class WikiImporter {
        }
 
        function out_logitem( $parser, $name ) {
-               $name = $this->stripXmlNamespace($name);
+               $name = $this->stripXmlNamespace($name);
                $this->debug( "out_logitem $name" );
                $this->pop();
                if( $name != "logitem" ) {
@@ -936,7 +936,7 @@ class WikiImporter {
        }
 
        function in_upload( $parser, $name, $attribs ) {
-               $name = $this->stripXmlNamespace($name);
+               $name = $this->stripXmlNamespace($name);
                $this->debug( "in_upload $name" );
                switch( $name ) {
                case "timestamp":
@@ -959,7 +959,7 @@ class WikiImporter {
        }
 
        function out_upload( $parser, $name ) {
-               $name = $this->stripXmlNamespace($name);
+               $name = $this->stripXmlNamespace($name);
                $this->debug( "out_revision $name" );
                $this->pop();
                if( $name != "upload" ) {
@@ -977,7 +977,7 @@ class WikiImporter {
        }
 
        function in_contributor( $parser, $name, $attribs ) {
-               $name = $this->stripXmlNamespace($name);
+               $name = $this->stripXmlNamespace($name);
                $this->debug( "in_contributor $name" );
                switch( $name ) {
                case "username":
@@ -993,7 +993,7 @@ class WikiImporter {
        }
 
        function out_contributor( $parser, $name ) {
-               $name = $this->stripXmlNamespace($name);
+               $name = $this->stripXmlNamespace($name);
                $this->debug( "out_contributor $name" );
                $this->pop();
                if( $name != "contributor" ) {
@@ -1085,9 +1085,9 @@ class ImportStreamSource {
                                        return new WikiErrorMsg( 'importuploaderrorsize' );
                                case 3: # The uploaded file was only partially uploaded
                                        return new WikiErrorMsg( 'importuploaderrorpartial' );
-                           case 6: #Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.
-                               return new WikiErrorMsg( 'importuploaderrortemp' );
-                           # case else: # Currently impossible
+                               case 6: #Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.
+                                       return new WikiErrorMsg( 'importuploaderrortemp' );
+                               # case else: # Currently impossible
                        }
 
                }
index 6beb094..8cd9dea 100644 (file)
@@ -33,7 +33,7 @@ class LogPage {
        const DELETED_ACTION = 1;
        const DELETED_COMMENT = 2;
        const DELETED_USER = 4;
-    const DELETED_RESTRICTED = 8;
+       const DELETED_RESTRICTED = 8;
        // Convenience fields
        const SUPPRESSED_USER = 12;
        const SUPPRESSED_ACTION = 9;
index c730dc7..a4fc047 100644 (file)
@@ -5,8 +5,8 @@
  */
 function wfOutputHandler( $s ) {
        global $wgDisableOutputCompression, $wgValidateAllHtml;
-    $s = wfMangleFlashPolicy( $s );
-    if ( $wgValidateAllHtml ) {
+       $s = wfMangleFlashPolicy( $s );
+       if ( $wgValidateAllHtml ) {
                $headers = apache_response_headers();
                $isHTML = true;
                foreach ( $headers as $name => $value ) {
index de43865..e32884e 100644 (file)
@@ -571,7 +571,7 @@ class OutputPage {
         * This function allows good tags like <sup> in the <h1> tag, but not bad tags like <script>.
         * This function automatically sets <title> to the same content as <h1> but with all tags removed.
         * Bad tags that were escaped in <h1> will still be escaped in <title>, and good tags like <i> will be dropped entirely.
-         */
+        */
        public function setPageTitle( $name ) {
                global $wgContLang;
                $name = $wgContLang->convert( $name, true );
index a20523c..84b4dc2 100644 (file)
@@ -44,7 +44,7 @@ class User {
 
        /**
         * \type{\arrayof{\string}} A list of default user toggles, i.e., boolean user
-         * preferences that are displayed by Special:Preferences as checkboxes.
+        * preferences that are displayed by Special:Preferences as checkboxes.
         * This list can be extended via the UserToggles hook or by
         * $wgContLang::getExtraUserToggles().
         * @showinitializer
index 9466e08..56a8adc 100644 (file)
@@ -162,12 +162,12 @@ class Xml {
        public static function monthSelector( $selected = '', $allmonths = null, $id = 'month' ) {
                global $wgLang;
                $options = array();
-           if( is_null( $selected ) )
+               if( is_null( $selected ) )
                        $selected = '';
-           if( !is_null( $allmonths ) )
+               if( !is_null( $allmonths ) )
                        $options[] = self::option( wfMsg( 'monthsall' ), $allmonths, $selected === $allmonths );
                for( $i = 1; $i < 13; $i++ )
-                               $options[] = self::option( $wgLang->getMonthName( $i ), $i, $selected === $i );
+                       $options[] = self::option( $wgLang->getMonthName( $i ), $i, $selected === $i );
                return self::openElement( 'select', array( 'id' => $id, 'name' => 'month', 'class' => 'mw-month-selector' ) )
                        . implode( "\n", $options )
                        . self::closeElement( 'select' );