add braces + some other coding style tweaks
authorJack Phoenix <ashley@users.mediawiki.org>
Sat, 19 Feb 2011 02:07:10 +0000 (02:07 +0000)
committerJack Phoenix <ashley@users.mediawiki.org>
Sat, 19 Feb 2011 02:07:10 +0000 (02:07 +0000)
includes/specials/SpecialNewpages.php

index 62d7765..52c281e 100644 (file)
@@ -73,27 +73,36 @@ class SpecialNewpages extends IncludableSpecialPage {
                global $wgLang;
                $bits = preg_split( '/\s*,\s*/', trim( $par ) );
                foreach ( $bits as $bit ) {
-                       if ( 'shownav' == $bit )
+                       if ( 'shownav' == $bit ) {
                                $this->showNavigation = true;
-                       if ( 'hideliu' === $bit )
+                       }
+                       if ( 'hideliu' === $bit ) {
                                $this->opts->setValue( 'hideliu', true );
-                       if ( 'hidepatrolled' == $bit )
+                       }
+                       if ( 'hidepatrolled' == $bit ) {
                                $this->opts->setValue( 'hidepatrolled', true );
-                       if ( 'hidebots' == $bit )
+                       }
+                       if ( 'hidebots' == $bit ) {
                                $this->opts->setValue( 'hidebots', true );
-                       if ( 'showredirs' == $bit )
+                       }
+                       if ( 'showredirs' == $bit ) {
                                $this->opts->setValue( 'hideredirs', false );
-                       if ( is_numeric( $bit ) )
+                       }
+                       if ( is_numeric( $bit ) ) {
                                $this->opts->setValue( 'limit', intval( $bit ) );
+                       }
 
                        $m = array();
-                       if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) )
-                               $this->opts->setValue( 'limit', intval($m[1]) );
+                       if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
+                               $this->opts->setValue( 'limit', intval( $m[1] ) );
+                       }
                        // PG offsets not just digits!
-                       if ( preg_match( '/^offset=([^=]+)$/', $bit, $m ) )
-                               $this->opts->setValue( 'offset',  intval($m[1]) );
-                       if ( preg_match( '/^username=(.*)$/', $bit, $m ) )
+                       if ( preg_match( '/^offset=([^=]+)$/', $bit, $m ) ) {
+                               $this->opts->setValue( 'offset',  intval( $m[1] ) );
+                       }
+                       if ( preg_match( '/^username=(.*)$/', $bit, $m ) ) {
                                $this->opts->setValue( 'username', $m[1] );
+                       }
                        if ( preg_match( '/^namespace=(.*)$/', $bit, $m ) ) {
                                $ns = $wgLang->getNsIndex( $m[1] );
                                if( $ns !== false ) {
@@ -135,7 +144,9 @@ class SpecialNewpages extends IncludableSpecialPage {
 
                if( $pager->getNumRows() ) {
                        $navigation = '';
-                       if ( $this->showNavigation ) $navigation = $pager->getNavigationBar();
+                       if ( $this->showNavigation ) {
+                               $navigation = $pager->getNavigationBar();
+                       }
                        $wgOut->addHTML( $navigation . $pager->getBody() . $navigation );
                } else {
                        $wgOut->addWikiMsg( 'specialpage-empty' );
@@ -157,22 +168,24 @@ class SpecialNewpages extends IncludableSpecialPage {
                );
 
                // Disable some if needed
-               # FIXME: throws E_NOTICEs if not set; and doesn't obey hooks etc
-               if ( $wgGroupPermissions['*']['createpage'] !== true )
-                       unset($filters['hideliu']);
+               # FIXME: throws E_NOTICEs if not set; and doesn't obey hooks etc.
+               if ( $wgGroupPermissions['*']['createpage'] !== true ) {
+                       unset( $filters['hideliu'] );
+               }
 
-               if ( !$wgUser->useNPPatrol() )
-                       unset($filters['hidepatrolled']);
+               if ( !$wgUser->useNPPatrol() ) {
+                       unset( $filters['hidepatrolled'] );
+               }
 
                $links = array();
                $changed = $this->opts->getChangedValues();
-               unset($changed['offset']); // Reset offset if query type changes
+               unset( $changed['offset'] ); // Reset offset if query type changes
 
                $self = $this->getTitle();
                foreach ( $filters as $key => $msg ) {
-                       $onoff = 1 - $this->opts->getValue($key);
+                       $onoff = 1 - $this->opts->getValue( $key );
                        $link = $this->skin->link( $self, $showhide[$onoff], array(),
-                                array( $key => $onoff ) + $changed
+                                       array( $key => $onoff ) + $changed
                        );
                        $links[$key] = wfMsgHtml( $msg, $link );
                }
@@ -201,8 +214,9 @@ class SpecialNewpages extends IncludableSpecialPage {
                $hidden = implode( "\n", $hidden );
 
                $tagFilter = ChangeTags::buildTagFilterSelector( $tagFilterVal );
-               if ($tagFilter)
+               if ( $tagFilter ) {
                        list( $tagFilterLabel, $tagFilterSelector ) = $tagFilter;
+               }
 
                $form = Xml::openElement( 'form', array( 'action' => $wgScript ) ) .
                        Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) .
@@ -224,7 +238,7 @@ class SpecialNewpages extends IncludableSpecialPage {
                                        $tagFilterSelector .
                                "</td>
                        </tr>" ) : '' ) .
-                       ($wgEnableNewpagesUserFilter ?
+                       ( $wgEnableNewpagesUserFilter ?
                        "<tr>
                                <td class='mw-label'>" .
                                        Xml::label( wfMsg( 'newpages-username' ), 'mw-np-username' ) .
@@ -232,7 +246,7 @@ class SpecialNewpages extends IncludableSpecialPage {
                                <td class='mw-input'>" .
                                        Xml::input( 'username', 30, $userText, array( 'id' => 'mw-np-username' ) ) .
                                "</td>
-                       </tr>" : "" ) .
+                       </tr>" : '' ) .
                        "<tr> <td></td>
                                <td class='mw-submit'>" .
                                        Xml::submitButton( wfMsg( 'allpagessubmit' ) ) .
@@ -278,8 +292,9 @@ class SpecialNewpages extends IncludableSpecialPage {
 
                $query = array( 'redirect' => 'no' );
 
-               if( $this->patrollable( $result ) )
+               if( $this->patrollable( $result ) ) {
                        $query['rcid'] = $result->rc_id;
+               }
 
                $plink = $this->skin->linkKnown(
                        $title,
@@ -321,7 +336,7 @@ class SpecialNewpages extends IncludableSpecialPage {
                        $tagDisplay = '';
                }
 
-               $css = count($classes) ? ' class="'.implode( " ", $classes).'"' : '';
+               $css = count( $classes ) ? ' class="' . implode( ' ', $classes ) . '"' : '';
 
                return "<li{$css}>{$time} {$dm}{$plink} {$hist} {$dm}{$length} {$dm}{$ulink} {$comment} {$tagDisplay}</li>\n";
        }
@@ -358,7 +373,8 @@ class SpecialNewpages extends IncludableSpecialPage {
                $feed = new $wgFeedClasses[$type](
                        $this->feedTitle(),
                        wfMsgExt( 'tagline', 'parsemag' ),
-                       $this->getTitle()->getFullUrl() );
+                       $this->getTitle()->getFullUrl()
+               );
 
                $pager = new NewPagesPager( $this, $this->opts );
                $limit = $this->opts->getValue( 'limit' );
@@ -392,7 +408,8 @@ class SpecialNewpages extends IncludableSpecialPage {
                                $title->getFullURL(),
                                $date,
                                $this->feedItemAuthor( $row ),
-                               $comments);
+                               $comments
+                       );
                } else {
                        return null;
                }
@@ -429,8 +446,9 @@ class NewPagesPager extends ReverseChronologicalPager {
 
        function getTitle() {
                static $title = null;
-               if ( $title === null )
+               if ( $title === null ) {
                        $title = $this->mForm->getTitle();
+               }
                return $title;
        }
 
@@ -473,29 +491,35 @@ class NewPagesPager extends ReverseChronologicalPager {
                }
   
                // Allow changes to the New Pages query
-               wfRunHooks('SpecialNewpagesConditions', array(&$this, $this->opts, &$conds));
+               wfRunHooks( 'SpecialNewpagesConditions', array( &$this, $this->opts, &$conds ) );
 
                $info = array(
                        'tables' => array( 'recentchanges', 'page' ),
-                       'fields' => array( 'rc_namespace', 'rc_title', 'rc_cur_id', 'rc_user', 'rc_user_text', 'rc_comment',
-                               'rc_timestamp', 'rc_patrolled', 'rc_id', 'page_len AS length', 'page_latest AS rev_id', 'ts_tags'),
+                       'fields' => array(
+                               'rc_namespace', 'rc_title', 'rc_cur_id', 'rc_user',
+                               'rc_user_text', 'rc_comment', 'rc_timestamp', 'rc_patrolled',
+                               'rc_id', 'page_len AS length', 'page_latest AS rev_id',
+                               'ts_tags'
+                       ),
                        'conds' => $conds,
-                       'options' => array( 'USE INDEX' => array('recentchanges' => $rcIndexes) ),
+                       'options' => array( 'USE INDEX' => array( 'recentchanges' => $rcIndexes ) ),
                        'join_conds' => array(
-                               'page' => array('INNER JOIN', 'page_id=rc_cur_id'),
+                               'page' => array( 'INNER JOIN', 'page_id=rc_cur_id' ),
                        ),
                );
 
-               ## Empty array for fields, it'll be set by us anyway.
+               // Empty array for fields, it'll be set by us anyway.
                $fields = array();
 
-               ## Modify query for tags
-               ChangeTags::modifyDisplayQuery( $info['tables'],
-                                                                               $fields,
-                                                                               $info['conds'],
-                                                                               $info['join_conds'],
-                                                                               $info['options'],
-                                                                               $this->opts['tagfilter'] );
+               // Modify query for tags
+               ChangeTags::modifyDisplayQuery(
+                       $info['tables'],
+                       $fields,
+                       $info['conds'],
+                       $info['join_conds'],
+                       $info['options'],
+                       $this->opts['tagfilter']
+               );
 
                return $info;
        }
@@ -517,10 +541,10 @@ class NewPagesPager extends ReverseChronologicalPager {
                        $linkBatch->add( $row->rc_namespace, $row->rc_title );
                }
                $linkBatch->execute();
-               return "<ul>";
+               return '<ul>';
        }
 
        function getEndBody() {
-               return "</ul>";
+               return '</ul>';
        }
 }