Braces and spaces
authorSam Reed <reedy@users.mediawiki.org>
Sat, 4 Sep 2010 03:43:33 +0000 (03:43 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Sat, 4 Sep 2010 03:43:33 +0000 (03:43 +0000)
includes/Html.php
includes/WatchlistEditor.php
includes/WebRequest.php
includes/WikiMap.php
includes/Xml.php
includes/ZhClient.php

index f388489..20d7ef5 100644 (file)
@@ -571,10 +571,12 @@ class Html {
                global $wgHtml5;
                $attribs['name'] = $name;
                if ( !$wgHtml5 ) {
-                       if ( !isset( $attribs['cols'] ) )
+                       if ( !isset( $attribs['cols'] ) ) {
                                $attribs['cols'] = "";
-                       if ( !isset( $attribs['rows'] ) )
+                       }
+                       if ( !isset( $attribs['rows'] ) ) {
                                $attribs['rows'] = "";
+                       }
                }
                return self::element( 'textarea', $attribs, $value );
        }
@@ -610,7 +612,9 @@ class Html {
                        }
                }
                $html = Html::openElement( 'html', $attribs );
-               if ( $html ) $html .= "\n";
+               if ( $html ) {
+                       $html .= "\n";
+               }
                $ret .= $html;
                return $ret;
        }
@@ -623,12 +627,12 @@ class Html {
         */
        public static function isXmlMimeType( $mimetype ) {
                switch ( $mimetype ) {
-               case 'text/xml':
-               case 'application/xhtml+xml':
-               case 'application/xml':
-                       return true;
-               default:
-                       return false;
+                       case 'text/xml':
+                       case 'application/xhtml+xml':
+                       case 'application/xml':
+                               return true;
+                       default:
+                               return false;
                }
        }
 }
index 1f10a85..0e5a59e 100644 (file)
@@ -100,15 +100,17 @@ class WatchlistEditor {
                $titles = array();
                if( !is_array( $list ) ) {
                        $list = explode( "\n", trim( $list ) );
-                       if( !is_array( $list ) )
+                       if( !is_array( $list ) ) {
                                return array();
+                       }
                }
                foreach( $list as $text ) {
                        $text = trim( $text );
                        if( strlen( $text ) > 0 ) {
                                $title = Title::newFromText( $text );
-                               if( $title instanceof Title && $title->isWatchable() )
+                               if( $title instanceof Title && $title->isWatchable() ) {
                                        $titles[] = $title->getPrefixedText();
+                               }
                        }
                }
                return array_unique( $titles );
@@ -129,8 +131,9 @@ class WatchlistEditor {
                // Do a batch existence check
                $batch = new LinkBatch();
                foreach( $titles as $title ) {
-                       if( !$title instanceof Title )
+                       if( !$title instanceof Title ) {
                                $title = Title::newFromText( $title );
+                       }
                        if( $title instanceof Title ) {
                                $batch->addObj( $title );
                                $batch->addObj( $title->getTalkPage() );
@@ -140,8 +143,9 @@ class WatchlistEditor {
                // Print out the list
                $output->addHTML( "<ul>\n" );
                foreach( $titles as $title ) {
-                       if( !$title instanceof Title )
+                       if( !$title instanceof Title ) {
                                $title = Title::newFromText( $title );
+                       }
                        if( $title instanceof Title ) {
                                $output->addHTML( "<li>" . $skin->link( $title )
                                . ' (' . $skin->link( $title->getTalkPage(), $talk ) . ")</li>\n" );
@@ -221,8 +225,9 @@ class WatchlistEditor {
                                                $cache->addBadLinkObj( $title );
                                        }
                                        // Ignore non-talk
-                                       if( !$title->isTalkPage() )
+                                       if( !$title->isTalkPage() ) {
                                                $titles[$row->wl_namespace][$row->wl_title] = $row->page_is_redirect;
+                                       }
                                }
                        }
                }
@@ -270,8 +275,9 @@ class WatchlistEditor {
                $dbw = wfGetDB( DB_MASTER );
                $rows = array();
                foreach( $titles as $title ) {
-                       if( !$title instanceof Title )
+                       if( !$title instanceof Title ) {
                                $title = Title::newFromText( $title );
+                       }
                        if( $title instanceof Title ) {
                                $rows[] = array(
                                        'wl_user' => $user->getId(),
@@ -302,8 +308,9 @@ class WatchlistEditor {
        private function unwatchTitles( $titles, $user ) {
                $dbw = wfGetDB( DB_MASTER );
                foreach( $titles as $title ) {
-                       if( !$title instanceof Title )
+                       if( !$title instanceof Title ) {
                                $title = Title::newFromText( $title );
+                       }
                        if( $title instanceof Title ) {
                                $dbw->delete(
                                        'watchlist',
@@ -410,8 +417,9 @@ class WatchlistEditor {
                global $wgLang;
 
                $link = $skin->link( $title );
-               if( $redirect )
+               if( $redirect ) {
                        $link = '<span class="watchlistredir">' . $link . '</span>';
+               }
                $tools[] = $skin->link( $title->getTalkPage(), wfMsgHtml( 'talkpagelinktext' ) );
                if( $title->exists() ) {
                        $tools[] = $skin->link(
@@ -459,8 +467,9 @@ class WatchlistEditor {
                $form .= Xml::openElement( 'textarea', array( 'id' => 'titles', 'name' => 'titles',
                        'rows' => $wgUser->getIntOption( 'rows' ), 'cols' => $wgUser->getIntOption( 'cols' ) ) );
                $titles = $this->getWatchlist( $user );
-               foreach( $titles as $title )
+               foreach( $titles as $title ) {
                        $form .= htmlspecialchars( $title ) . "\n";
+               }
                $form .= '</textarea>';
                $form .= '<p>' . Xml::submitButton( wfMsg( 'watchlistedit-raw-submit' ) ) . '</p>';
                $form .= '</fieldset></form>';
index bb1cfd3..a29d76c 100644 (file)
@@ -563,15 +563,23 @@ class WebRequest {
                global $wgUser;
 
                $limit = $this->getInt( 'limit', 0 );
-               if( $limit < 0 ) $limit = 0;
+               if( $limit < 0 ) {
+                       $limit = 0;
+               }
                if( ( $limit == 0 ) && ( $optionname != '' ) ) {
                        $limit = (int)$wgUser->getOption( $optionname );
                }
-               if( $limit <= 0 ) $limit = $deflimit;
-               if( $limit > 5000 ) $limit = 5000; # We have *some* limits...
+               if( $limit <= 0 ) {
+                       $limit = $deflimit;
+               }
+               if( $limit > 5000 ) {
+                       $limit = 5000; # We have *some* limits...
+               }
 
                $offset = $this->getInt( 'offset', 0 );
-               if( $offset < 0 ) $offset = 0;
+               if( $offset < 0 ) {
+                       $offset = 0;
+               }
 
                return array( $limit, $offset );
        }
@@ -686,8 +694,9 @@ class WebRequest {
         * @return Mixed
         */
        public function getSessionData( $key ) {
-               if( !isset( $_SESSION[$key] ) )
+               if( !isset( $_SESSION[$key] ) ) {
                        return null;
+               }
                return $_SESSION[$key];
        }
 
@@ -939,13 +948,15 @@ class FauxRequest extends WebRequest {
                global $wgTitle;
                $basequery = '';
                foreach( $this->data as $var => $val ) {
-                       if ( $var == 'title' )
+                       if ( $var == 'title' ) {
                                continue;
-                       if ( is_array( $val ) )
+                       }
+                       if ( is_array( $val ) ) {
                                /* This will happen given a request like
                                 * http://en.wikipedia.org/w/index.php?title[]=Special:Userlogin&returnto[]=Main_Page
                                 */
                                continue;
+                       }
                        $basequery .= '&' . urlencode( $var ) . '=' . urlencode( $val );
                }
                $basequery .= '&' . $query;
index 0fe12f8..e12f7ab 100644 (file)
@@ -68,12 +68,14 @@ class WikiMap {
                global $wgUser;
                $sk = $wgUser->getSkin();
 
-               if ( !$text )
+               if ( !$text ) {
                        $text = $page;
+               }
 
                $url = self::getForeignURL( $wikiID, $page );
-               if ( $url === false )
+               if ( $url === false ) {
                        return false;
+               }
 
                return $sk->makeExternalLink( $url, $text );
        }
@@ -88,8 +90,9 @@ class WikiMap {
        public static function getForeignURL( $wikiID, $page ) {
                $wiki = WikiMap::getWiki( $wikiID );
                
-               if ( $wiki )
+               if ( $wiki ) {
                        return $wiki->getUrl( $page );
+               }
                        
                return false;
        }
index f7ddb4c..06385d3 100644 (file)
@@ -46,8 +46,9 @@ class Xml {
                if( is_null( $attribs ) ) {
                        return null;
                } elseif( is_array( $attribs ) ) {
-                       foreach( $attribs as $name => $val )
+                       foreach( $attribs as $name => $val ) {
                                $out .= " {$name}=\"" . Sanitizer::encodeAttribute( $val ) . '"';
+                       }
                        return $out;
                } else {
                        throw new MWException( 'Expected attribute array, got something else in ' . __METHOD__ );
@@ -133,10 +134,12 @@ class Xml {
                if( !is_null( $all ) )
                        $namespaces = array( $all => wfMsg( 'namespacesall' ) ) + $namespaces;
                foreach( $namespaces as $index => $name ) {
-                       if( $index < NS_MAIN )
+                       if( $index < NS_MAIN ) {
                                continue;
-                       if( $index === 0 )
+                       }
+                       if( $index === 0 ) {
                                $name = wfMsg( 'blanknamespace' );
+                       }
                        $options[] = self::option( $name, $index, $index === $selected );
                }
 
@@ -749,9 +752,15 @@ class XmlSelect {
        protected $attributes = array();
 
        public function __construct( $name = false, $id = false, $default = false ) {
-               if ( $name ) $this->setAttribute( 'name', $name );
-               if ( $id ) $this->setAttribute( 'id', $id );
-               if ( $default !== false ) $this->default = $default;
+               if ( $name ) {
+                       $this->setAttribute( 'name', $name );
+               }
+               if ( $id ) {
+                       $this->setAttribute( 'id', $id );
+               }
+               if ( $default !== false ) {
+                       $this->default = $default;
+               }
        }
 
        public function setDefault( $default ) {
index 729213e..a04220c 100644 (file)
@@ -35,7 +35,7 @@ class ZhClient {
                $errno = $errstr = '';
                $this->mFP = fsockopen($this->mHost, $this->mPort, $errno, $errstr, 30);
                wfRestoreWarnings();
-               if(!$this->mFP) {
+               if ( !$this->mFP ) {
                        return false;
                }
                return true;
@@ -47,8 +47,9 @@ class ZhClient {
         * @access private
         */
        function query($request) {
-               if(!$this->mConnected)
+               if ( !$this->mConnected ) {
                        return false;
+               }
 
                fwrite($this->mFP, $request);
 
@@ -68,8 +69,9 @@ class ZhClient {
                        $data .= $str;
                }
                //data should be of length $len. otherwise something is wrong
-               if(strlen($data) != $len)
+               if ( strlen($data) != $len ) {
                        return false;
+               }
                return $data;
        }
 
@@ -84,8 +86,9 @@ class ZhClient {
                $len = strlen($text);
                $q = "CONV $tolang $len\n$text";
                $result = $this->query($q);
-               if(!$result)
+               if ( !$result ) {
                        $result = $text;
+               }
                return $result;
        }
 
@@ -99,8 +102,9 @@ class ZhClient {
                $len = strlen($text);
                $q = "CONV ALL $len\n$text";
                $result = $this->query($q);
-               if(!$result)
+               if ( !$result ) {
                        return false;
+               }
                list($infoline, $data) = explode('|', $result, 2);
                $info = explode(";", $infoline);
                $ret = array();
@@ -122,7 +126,7 @@ class ZhClient {
                $len = strlen($text);
                $q = "SEG $len\n$text";
                $result = $this->query($q);
-               if(!$result) {// fallback to character based segmentation
+               if ( !$result ) {// fallback to character based segmentation
                        $result = $this->segment($text);
                }
                return $result;