Index: trunk/phase3/includes/Xml.php |
— | — | @@ -46,8 +46,9 @@ |
47 | 47 | if( is_null( $attribs ) ) { |
48 | 48 | return null; |
49 | 49 | } elseif( is_array( $attribs ) ) { |
50 | | - foreach( $attribs as $name => $val ) |
| 50 | + foreach( $attribs as $name => $val ) { |
51 | 51 | $out .= " {$name}=\"" . Sanitizer::encodeAttribute( $val ) . '"'; |
| 52 | + } |
52 | 53 | return $out; |
53 | 54 | } else { |
54 | 55 | throw new MWException( 'Expected attribute array, got something else in ' . __METHOD__ ); |
— | — | @@ -133,10 +134,12 @@ |
134 | 135 | if( !is_null( $all ) ) |
135 | 136 | $namespaces = array( $all => wfMsg( 'namespacesall' ) ) + $namespaces; |
136 | 137 | foreach( $namespaces as $index => $name ) { |
137 | | - if( $index < NS_MAIN ) |
| 138 | + if( $index < NS_MAIN ) { |
138 | 139 | continue; |
139 | | - if( $index === 0 ) |
| 140 | + } |
| 141 | + if( $index === 0 ) { |
140 | 142 | $name = wfMsg( 'blanknamespace' ); |
| 143 | + } |
141 | 144 | $options[] = self::option( $name, $index, $index === $selected ); |
142 | 145 | } |
143 | 146 | |
— | — | @@ -749,9 +752,15 @@ |
750 | 753 | protected $attributes = array(); |
751 | 754 | |
752 | 755 | public function __construct( $name = false, $id = false, $default = false ) { |
753 | | - if ( $name ) $this->setAttribute( 'name', $name ); |
754 | | - if ( $id ) $this->setAttribute( 'id', $id ); |
755 | | - if ( $default !== false ) $this->default = $default; |
| 756 | + if ( $name ) { |
| 757 | + $this->setAttribute( 'name', $name ); |
| 758 | + } |
| 759 | + if ( $id ) { |
| 760 | + $this->setAttribute( 'id', $id ); |
| 761 | + } |
| 762 | + if ( $default !== false ) { |
| 763 | + $this->default = $default; |
| 764 | + } |
756 | 765 | } |
757 | 766 | |
758 | 767 | public function setDefault( $default ) { |
Index: trunk/phase3/includes/WatchlistEditor.php |
— | — | @@ -100,15 +100,17 @@ |
101 | 101 | $titles = array(); |
102 | 102 | if( !is_array( $list ) ) { |
103 | 103 | $list = explode( "\n", trim( $list ) ); |
104 | | - if( !is_array( $list ) ) |
| 104 | + if( !is_array( $list ) ) { |
105 | 105 | return array(); |
| 106 | + } |
106 | 107 | } |
107 | 108 | foreach( $list as $text ) { |
108 | 109 | $text = trim( $text ); |
109 | 110 | if( strlen( $text ) > 0 ) { |
110 | 111 | $title = Title::newFromText( $text ); |
111 | | - if( $title instanceof Title && $title->isWatchable() ) |
| 112 | + if( $title instanceof Title && $title->isWatchable() ) { |
112 | 113 | $titles[] = $title->getPrefixedText(); |
| 114 | + } |
113 | 115 | } |
114 | 116 | } |
115 | 117 | return array_unique( $titles ); |
— | — | @@ -129,8 +131,9 @@ |
130 | 132 | // Do a batch existence check |
131 | 133 | $batch = new LinkBatch(); |
132 | 134 | foreach( $titles as $title ) { |
133 | | - if( !$title instanceof Title ) |
| 135 | + if( !$title instanceof Title ) { |
134 | 136 | $title = Title::newFromText( $title ); |
| 137 | + } |
135 | 138 | if( $title instanceof Title ) { |
136 | 139 | $batch->addObj( $title ); |
137 | 140 | $batch->addObj( $title->getTalkPage() ); |
— | — | @@ -140,8 +143,9 @@ |
141 | 144 | // Print out the list |
142 | 145 | $output->addHTML( "<ul>\n" ); |
143 | 146 | foreach( $titles as $title ) { |
144 | | - if( !$title instanceof Title ) |
| 147 | + if( !$title instanceof Title ) { |
145 | 148 | $title = Title::newFromText( $title ); |
| 149 | + } |
146 | 150 | if( $title instanceof Title ) { |
147 | 151 | $output->addHTML( "<li>" . $skin->link( $title ) |
148 | 152 | . ' (' . $skin->link( $title->getTalkPage(), $talk ) . ")</li>\n" ); |
— | — | @@ -221,8 +225,9 @@ |
222 | 226 | $cache->addBadLinkObj( $title ); |
223 | 227 | } |
224 | 228 | // Ignore non-talk |
225 | | - if( !$title->isTalkPage() ) |
| 229 | + if( !$title->isTalkPage() ) { |
226 | 230 | $titles[$row->wl_namespace][$row->wl_title] = $row->page_is_redirect; |
| 231 | + } |
227 | 232 | } |
228 | 233 | } |
229 | 234 | } |
— | — | @@ -270,8 +275,9 @@ |
271 | 276 | $dbw = wfGetDB( DB_MASTER ); |
272 | 277 | $rows = array(); |
273 | 278 | foreach( $titles as $title ) { |
274 | | - if( !$title instanceof Title ) |
| 279 | + if( !$title instanceof Title ) { |
275 | 280 | $title = Title::newFromText( $title ); |
| 281 | + } |
276 | 282 | if( $title instanceof Title ) { |
277 | 283 | $rows[] = array( |
278 | 284 | 'wl_user' => $user->getId(), |
— | — | @@ -302,8 +308,9 @@ |
303 | 309 | private function unwatchTitles( $titles, $user ) { |
304 | 310 | $dbw = wfGetDB( DB_MASTER ); |
305 | 311 | foreach( $titles as $title ) { |
306 | | - if( !$title instanceof Title ) |
| 312 | + if( !$title instanceof Title ) { |
307 | 313 | $title = Title::newFromText( $title ); |
| 314 | + } |
308 | 315 | if( $title instanceof Title ) { |
309 | 316 | $dbw->delete( |
310 | 317 | 'watchlist', |
— | — | @@ -410,8 +417,9 @@ |
411 | 418 | global $wgLang; |
412 | 419 | |
413 | 420 | $link = $skin->link( $title ); |
414 | | - if( $redirect ) |
| 421 | + if( $redirect ) { |
415 | 422 | $link = '<span class="watchlistredir">' . $link . '</span>'; |
| 423 | + } |
416 | 424 | $tools[] = $skin->link( $title->getTalkPage(), wfMsgHtml( 'talkpagelinktext' ) ); |
417 | 425 | if( $title->exists() ) { |
418 | 426 | $tools[] = $skin->link( |
— | — | @@ -459,8 +467,9 @@ |
460 | 468 | $form .= Xml::openElement( 'textarea', array( 'id' => 'titles', 'name' => 'titles', |
461 | 469 | 'rows' => $wgUser->getIntOption( 'rows' ), 'cols' => $wgUser->getIntOption( 'cols' ) ) ); |
462 | 470 | $titles = $this->getWatchlist( $user ); |
463 | | - foreach( $titles as $title ) |
| 471 | + foreach( $titles as $title ) { |
464 | 472 | $form .= htmlspecialchars( $title ) . "\n"; |
| 473 | + } |
465 | 474 | $form .= '</textarea>'; |
466 | 475 | $form .= '<p>' . Xml::submitButton( wfMsg( 'watchlistedit-raw-submit' ) ) . '</p>'; |
467 | 476 | $form .= '</fieldset></form>'; |
Index: trunk/phase3/includes/ZhClient.php |
— | — | @@ -35,7 +35,7 @@ |
36 | 36 | $errno = $errstr = ''; |
37 | 37 | $this->mFP = fsockopen($this->mHost, $this->mPort, $errno, $errstr, 30); |
38 | 38 | wfRestoreWarnings(); |
39 | | - if(!$this->mFP) { |
| 39 | + if ( !$this->mFP ) { |
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | return true; |
— | — | @@ -47,8 +47,9 @@ |
48 | 48 | * @access private |
49 | 49 | */ |
50 | 50 | function query($request) { |
51 | | - if(!$this->mConnected) |
| 51 | + if ( !$this->mConnected ) { |
52 | 52 | return false; |
| 53 | + } |
53 | 54 | |
54 | 55 | fwrite($this->mFP, $request); |
55 | 56 | |
— | — | @@ -68,8 +69,9 @@ |
69 | 70 | $data .= $str; |
70 | 71 | } |
71 | 72 | //data should be of length $len. otherwise something is wrong |
72 | | - if(strlen($data) != $len) |
| 73 | + if ( strlen($data) != $len ) { |
73 | 74 | return false; |
| 75 | + } |
74 | 76 | return $data; |
75 | 77 | } |
76 | 78 | |
— | — | @@ -84,8 +86,9 @@ |
85 | 87 | $len = strlen($text); |
86 | 88 | $q = "CONV $tolang $len\n$text"; |
87 | 89 | $result = $this->query($q); |
88 | | - if(!$result) |
| 90 | + if ( !$result ) { |
89 | 91 | $result = $text; |
| 92 | + } |
90 | 93 | return $result; |
91 | 94 | } |
92 | 95 | |
— | — | @@ -99,8 +102,9 @@ |
100 | 103 | $len = strlen($text); |
101 | 104 | $q = "CONV ALL $len\n$text"; |
102 | 105 | $result = $this->query($q); |
103 | | - if(!$result) |
| 106 | + if ( !$result ) { |
104 | 107 | return false; |
| 108 | + } |
105 | 109 | list($infoline, $data) = explode('|', $result, 2); |
106 | 110 | $info = explode(";", $infoline); |
107 | 111 | $ret = array(); |
— | — | @@ -122,7 +126,7 @@ |
123 | 127 | $len = strlen($text); |
124 | 128 | $q = "SEG $len\n$text"; |
125 | 129 | $result = $this->query($q); |
126 | | - if(!$result) {// fallback to character based segmentation |
| 130 | + if ( !$result ) {// fallback to character based segmentation |
127 | 131 | $result = $this->segment($text); |
128 | 132 | } |
129 | 133 | return $result; |
Index: trunk/phase3/includes/Html.php |
— | — | @@ -571,10 +571,12 @@ |
572 | 572 | global $wgHtml5; |
573 | 573 | $attribs['name'] = $name; |
574 | 574 | if ( !$wgHtml5 ) { |
575 | | - if ( !isset( $attribs['cols'] ) ) |
| 575 | + if ( !isset( $attribs['cols'] ) ) { |
576 | 576 | $attribs['cols'] = ""; |
577 | | - if ( !isset( $attribs['rows'] ) ) |
| 577 | + } |
| 578 | + if ( !isset( $attribs['rows'] ) ) { |
578 | 579 | $attribs['rows'] = ""; |
| 580 | + } |
579 | 581 | } |
580 | 582 | return self::element( 'textarea', $attribs, $value ); |
581 | 583 | } |
— | — | @@ -610,7 +612,9 @@ |
611 | 613 | } |
612 | 614 | } |
613 | 615 | $html = Html::openElement( 'html', $attribs ); |
614 | | - if ( $html ) $html .= "\n"; |
| 616 | + if ( $html ) { |
| 617 | + $html .= "\n"; |
| 618 | + } |
615 | 619 | $ret .= $html; |
616 | 620 | return $ret; |
617 | 621 | } |
— | — | @@ -623,12 +627,12 @@ |
624 | 628 | */ |
625 | 629 | public static function isXmlMimeType( $mimetype ) { |
626 | 630 | switch ( $mimetype ) { |
627 | | - case 'text/xml': |
628 | | - case 'application/xhtml+xml': |
629 | | - case 'application/xml': |
630 | | - return true; |
631 | | - default: |
632 | | - return false; |
| 631 | + case 'text/xml': |
| 632 | + case 'application/xhtml+xml': |
| 633 | + case 'application/xml': |
| 634 | + return true; |
| 635 | + default: |
| 636 | + return false; |
633 | 637 | } |
634 | 638 | } |
635 | 639 | } |
Index: trunk/phase3/includes/WebRequest.php |
— | — | @@ -563,15 +563,23 @@ |
564 | 564 | global $wgUser; |
565 | 565 | |
566 | 566 | $limit = $this->getInt( 'limit', 0 ); |
567 | | - if( $limit < 0 ) $limit = 0; |
| 567 | + if( $limit < 0 ) { |
| 568 | + $limit = 0; |
| 569 | + } |
568 | 570 | if( ( $limit == 0 ) && ( $optionname != '' ) ) { |
569 | 571 | $limit = (int)$wgUser->getOption( $optionname ); |
570 | 572 | } |
571 | | - if( $limit <= 0 ) $limit = $deflimit; |
572 | | - if( $limit > 5000 ) $limit = 5000; # We have *some* limits... |
| 573 | + if( $limit <= 0 ) { |
| 574 | + $limit = $deflimit; |
| 575 | + } |
| 576 | + if( $limit > 5000 ) { |
| 577 | + $limit = 5000; # We have *some* limits... |
| 578 | + } |
573 | 579 | |
574 | 580 | $offset = $this->getInt( 'offset', 0 ); |
575 | | - if( $offset < 0 ) $offset = 0; |
| 581 | + if( $offset < 0 ) { |
| 582 | + $offset = 0; |
| 583 | + } |
576 | 584 | |
577 | 585 | return array( $limit, $offset ); |
578 | 586 | } |
— | — | @@ -686,8 +694,9 @@ |
687 | 695 | * @return Mixed |
688 | 696 | */ |
689 | 697 | public function getSessionData( $key ) { |
690 | | - if( !isset( $_SESSION[$key] ) ) |
| 698 | + if( !isset( $_SESSION[$key] ) ) { |
691 | 699 | return null; |
| 700 | + } |
692 | 701 | return $_SESSION[$key]; |
693 | 702 | } |
694 | 703 | |
— | — | @@ -939,13 +948,15 @@ |
940 | 949 | global $wgTitle; |
941 | 950 | $basequery = ''; |
942 | 951 | foreach( $this->data as $var => $val ) { |
943 | | - if ( $var == 'title' ) |
| 952 | + if ( $var == 'title' ) { |
944 | 953 | continue; |
945 | | - if ( is_array( $val ) ) |
| 954 | + } |
| 955 | + if ( is_array( $val ) ) { |
946 | 956 | /* This will happen given a request like |
947 | 957 | * http://en.wikipedia.org/w/index.php?title[]=Special:Userlogin&returnto[]=Main_Page |
948 | 958 | */ |
949 | 959 | continue; |
| 960 | + } |
950 | 961 | $basequery .= '&' . urlencode( $var ) . '=' . urlencode( $val ); |
951 | 962 | } |
952 | 963 | $basequery .= '&' . $query; |
Index: trunk/phase3/includes/WikiMap.php |
— | — | @@ -68,12 +68,14 @@ |
69 | 69 | global $wgUser; |
70 | 70 | $sk = $wgUser->getSkin(); |
71 | 71 | |
72 | | - if ( !$text ) |
| 72 | + if ( !$text ) { |
73 | 73 | $text = $page; |
| 74 | + } |
74 | 75 | |
75 | 76 | $url = self::getForeignURL( $wikiID, $page ); |
76 | | - if ( $url === false ) |
| 77 | + if ( $url === false ) { |
77 | 78 | return false; |
| 79 | + } |
78 | 80 | |
79 | 81 | return $sk->makeExternalLink( $url, $text ); |
80 | 82 | } |
— | — | @@ -88,8 +90,9 @@ |
89 | 91 | public static function getForeignURL( $wikiID, $page ) { |
90 | 92 | $wiki = WikiMap::getWiki( $wikiID ); |
91 | 93 | |
92 | | - if ( $wiki ) |
| 94 | + if ( $wiki ) { |
93 | 95 | return $wiki->getUrl( $page ); |
| 96 | + } |
94 | 97 | |
95 | 98 | return false; |
96 | 99 | } |