Skin.php/SkinTemplate.php: cleanup, spacing tweaks, double quotes to single quotes...
authorJack Phoenix <ashley@users.mediawiki.org>
Sun, 29 Mar 2009 12:46:11 +0000 (12:46 +0000)
committerJack Phoenix <ashley@users.mediawiki.org>
Sun, 29 Mar 2009 12:46:11 +0000 (12:46 +0000)
includes/Skin.php
includes/SkinTemplate.php

index c2c4aee..b0e72f0 100644 (file)
@@ -23,7 +23,7 @@ class Skin extends Linker {
        protected $searchboxes = '';
        /**#@-*/
        protected $mRevisionId; // The revision ID we're looking at, null if not applicable.
-       protected $skinname = 'standard' ;
+       protected $skinname = 'standard';
 
        /** Constructor, call parent constructor */
        function Skin() { parent::__construct(); }
@@ -46,10 +46,10 @@ class Skin extends Linker {
                        $skinDir = dir( $wgStyleDirectory );
 
                        # while code from www.php.net
-                       while (false !== ($file = $skinDir->read())) {
+                       while( false !== ( $file = $skinDir->read() ) ) {
                                // Skip non-PHP files, hidden files, and '.dep' includes
                                $matches = array();
-                               if(preg_match('/^([^.]*)\.php$/',$file, $matches)) {
+                               if( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) {
                                        $aSkin = $matches[1];
                                        $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
                                }
@@ -196,7 +196,7 @@ class Skin extends Linker {
                        'title' => wfMsgForContent( 'opensearch-desc' ),
                ));
 
-               $this->addMetadataLinks($out);
+               $this->addMetadataLinks( $out );
 
                $this->mRevisionId = $out->mRevisionId;
 
@@ -237,13 +237,15 @@ class Skin extends Linker {
                                $out->addMetadataLink( array(
                                        'title' => 'Creative Commons',
                                        'type' => 'application/rdf+xml',
-                                       'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
+                                       'href' => $wgTitle->getLocalURL( 'action=creativecommons' ) )
+                               );
                        }
                        if( $wgEnableDublinCoreRdf ) {
                                $out->addMetadataLink( array(
                                        'title' => 'Dublin Core',
                                        'type' => 'application/rdf+xml',
-                                       'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
+                                       'href' => $wgTitle->getLocalURL( 'action=dublincore' ) )
+                               );
                        }
                }
                $copyright = '';
@@ -259,7 +261,8 @@ class Skin extends Linker {
                if( $copyright ) {
                        $out->addLink( array(
                                'rel' => 'copyright',
-                               'href' => $copyright ) );
+                               'href' => $copyright )
+                       );
                }
        }
 
@@ -384,11 +387,11 @@ class Skin extends Linker {
                        'wgDigitTransformTable' => $compactDigitTransTable,
                );
                
-               if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false )){
+               if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ){
                        $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
                        $vars['wgDBname'] = $wgDBname;
                        $vars['wgSearchNamespaces'] = SearchEngine::userNamespaces( $wgUser );
-                       $vars['wgMWSuggestMessages'] = array( wfMsg('search-mwsuggest-enabled'), wfMsg('search-mwsuggest-disabled'));
+                       $vars['wgMWSuggestMessages'] = array( wfMsg( 'search-mwsuggest-enabled' ), wfMsg( 'search-mwsuggest-disabled' ) );
                }
 
                foreach( $wgRestrictionTypes as $type )
@@ -409,7 +412,8 @@ class Skin extends Linker {
                        $vars['wgAjaxWatch'] = $msgs;
                }
 
-               wfRunHooks('MakeGlobalVariablesScript', array(&$vars));
+               // Allow extensions to add their custom variables to the global JS variables
+               wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
 
                return self::makeVariablesScript( $vars );
        }
@@ -421,10 +425,10 @@ class Skin extends Linker {
 
                $r = array( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>" );
                global $wgUseSiteJs;
-               if ($wgUseSiteJs) {
+               if( $wgUseSiteJs ) {
                        $jsCache = $wgUser->isLoggedIn() ? '&smaxage=0' : '';
                        $r[] = "<script type=\"$wgJsMimeType\" src=\"".
-                               htmlspecialchars(self::makeUrl('-',
+                               htmlspecialchars( self::makeUrl( '-',
                                        "action=raw$jsCache&gen=js&useskin=" .
                                        urlencode( $this->getSkinName() ) ) ) .
                                "\"><!-- site js --></script>";
@@ -433,7 +437,7 @@ class Skin extends Linker {
                        $userpage = $wgUser->getUserPage();
                        $userjs = htmlspecialchars( self::makeUrl(
                                $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
-                               'action=raw&ctype='.$wgJsMimeType));
+                               'action=raw&ctype='.$wgJsMimeType ) );
                        $r[] = '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>";
                }
                return $vars . "\t\t" . implode ( "\n\t\t", $r );
@@ -485,8 +489,8 @@ class Skin extends Linker {
                $s .= "var skin = '" . Xml::escapeJsString( $this->getSkinName() ) . "';\n";
                $s .= "var stylepath = '" . Xml::escapeJsString( $wgStylePath ) . "';";
                $s .= "\n\n/* MediaWiki:Common.js */\n";
-               $commonJs = wfMsgForContent('common.js');
-               if ( !wfEmptyMsg ( 'common.js', $commonJs ) ) {
+               $commonJs = wfMsgForContent( 'common.js' );
+               if ( !wfEmptyMsg( 'common.js', $commonJs ) ) {
                        $s .= $commonJs;
                }
 
@@ -494,7 +498,7 @@ class Skin extends Linker {
                // avoid inclusion of non defined user JavaScript (with custom skins only)
                // by checking for default message content
                $msgKey = ucfirst( $this->getSkinName() ).'.js';
-               $userJS = wfMsgForContent($msgKey);
+               $userJS = wfMsgForContent( $msgKey );
                if ( !wfEmptyMsg( $msgKey, $userJS ) ) {
                        $s .= $userJS;
                }
@@ -504,7 +508,7 @@ class Skin extends Linker {
        }
 
        /**
-        * generate user stylesheet for action=raw&gen=css
+        * Generate user stylesheet for action=raw&gen=css
         */
        public function generateUserStylesheet() {
                wfProfileIn( __METHOD__ );
@@ -520,7 +524,7 @@ class Skin extends Linker {
        protected function reallyGenerateUserStylesheet(){
                global $wgUser;
                $s = '';
-               if (($undopt = $wgUser->getOption("underline")) < 2) {
+               if( ( $undopt = $wgUser->getOption( 'underline' ) ) < 2 ) {
                        $underline = $undopt ? 'underline' : 'none';
                        $s .= "a { text-decoration: $underline; }\n";
                }
@@ -608,14 +612,14 @@ END;
 
                // Per-user custom style pages
                if( $wgAllowUserCss && $wgUser->isLoggedIn() ) {
-                       $action = $wgRequest->getVal('action');
+                       $action = $wgRequest->getVal( 'action' );
                        # If we're previewing the CSS page, use it
                        if( $this->mTitle->isCssSubpage() && $this->userCanPreview( $action ) ) {
-                               $previewCss = $wgRequest->getText('wpTextbox1');
+                               $previewCss = $wgRequest->getText( 'wpTextbox1' );
                                // @FIXME: properly escape the cdata!
                                $this->usercss = "/*<![CDATA[*/\n" . $previewCss . "/*]]>*/";
                        } else {
-                               $out->addStyle( self::makeUrl($this->userpage . '/' . $this->getSkinName() .'.css',
+                               $out->addStyle( self::makeUrl( $this->userpage . '/' . $this->getSkinName() .'.css',
                                        'action=raw&ctype=text/css' ) );
                        }
                }
@@ -643,30 +647,29 @@ END;
                        $a = array( 'bgcolor' => '#ffffec' );
                }
                else $a = array( 'bgcolor' => '#FFFFFF' );
-               if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
+               if( $wgOut->isArticle() && $wgUser->getOption( 'editondblclick' ) &&
                  $wgTitle->quickUserCan( 'edit' ) ) {
                        $s = $wgTitle->getFullURL( $this->editUrlOptions() );
                        $s = 'document.location = "' .Xml::escapeJsString( $s ) .'";';
-                       $a += array ('ondblclick' => $s);
-
+                       $a += array( 'ondblclick' => $s );
                }
                $a['onload'] = $wgOut->getOnloadHandler();
                $a['class'] =
                        'mediawiki' .
-                       ' '.( $wgContLang->isRTL() ? "rtl" : "ltr" ).
+                       ' '.( $wgContLang->isRTL() ? 'rtl' : 'ltr' ).
                        ' '.$this->getPageClasses( $wgTitle ) .
-                       ' skin-'. Sanitizer::escapeClass( $this->getSkinName( ) );
+                       ' skin-'. Sanitizer::escapeClass( $this->getSkinName() );
                return $a;
        }
        
        function getPageClasses( $title ) {
                $numeric = 'ns-'.$title->getNamespace();
                if( $title->getNamespace() == NS_SPECIAL ) {
-                       $type = "ns-special";
+                       $type = 'ns-special';
                } elseif( $title->isTalkPage() ) {
-                       $type = "ns-talk";
+                       $type = 'ns-talk';
                } else {
-                       $type = "ns-subject";
+                       $type = 'ns-subject';
                }
                $name = Sanitizer::escapeClass( 'page-'.$title->getPrefixedText() );
                return "$numeric $type $name";
@@ -690,8 +693,7 @@ END;
 
        function doBeforeContent() {
                global $wgContLang;
-               $fname = 'Skin::doBeforeContent';
-               wfProfileIn( $fname );
+               wfProfileIn( __METHOD__ );
 
                $s = '';
                $qb = $this->qbSetting();
@@ -721,10 +723,10 @@ END;
                $l = $wgContLang->isRTL() ? 'right' : 'left';
                $s .= "<td {$borderhack} align='$l' valign='top'>\n";
 
-               $s .= $this->topLinks() ;
+               $s .= $this->topLinks();
                $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
 
-               $r = $wgContLang->isRTL() ? "left" : "right";
+               $r = $wgContLang->isRTL() ? 'left' : 'right';
                $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
                $s .= $this->nameAndLogin();
                $s .= "\n<br />" . $this->searchForm() . "</td>";
@@ -744,9 +746,9 @@ END;
                        $s .= "\n<div id='siteNotice'>$notice</div>\n";
                }
                $s .= $this->pageTitle();
-               $s .= $this->pageSubtitle() ;
+               $s .= $this->pageSubtitle();
                $s .= $this->getCategories();
-               wfProfileOut( $fname );
+               wfProfileOut( __METHOD__ );
                return $s;
        }
 
@@ -770,11 +772,11 @@ END;
                $s = '';
                $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
                if ( !empty( $allCats['normal'] ) ) {
-                       $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
+                       $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
 
                        $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
                        $s .= '<div id="mw-normal-catlinks">' .
-                               $this->link( Title::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
+                               $this->link( Title::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
                                . $colon . $t . '</div>';
                }
 
@@ -802,35 +804,36 @@ END;
                        $parenttree = $wgTitle->getParentCategoryTree();
                        # Skin object passed by reference cause it can not be
                        # accessed under the method subfunction drawCategoryBrowser
-                       $tempout = explode("\n", Skin::drawCategoryBrowser($parenttree, $this) );
+                       $tempout = explode( "\n", Skin::drawCategoryBrowser( $parenttree, $this ) );
                        # Clean out bogus first entry and sort them
-                       unset($tempout[0]);
-                       asort($tempout);
+                       unset( $tempout[0] );
+                       asort( $tempout );
                        # Output one per line
-                       $s .= implode("<br />\n", $tempout);
+                       $s .= implode( "<br />\n", $tempout );
                }
 
                return $s;
        }
 
-       /** Render the array as a serie of links.
+       /**
+        * Render the array as a serie of links.
         * @param $tree Array: categories tree returned by Title::getParentCategoryTree
         * @param &skin Object: skin passed by reference
         * @return String separated by &gt;, terminate with "\n"
         */
        function drawCategoryBrowser( $tree, &$skin ){
                $return = '';
-               foreach ($tree as $element => $parent) {
-                       if (empty($parent)) {
+               foreach( $tree as $element => $parent ) {
+                       if( empty( $parent ) ) {
                                # element start a new list
                                $return .= "\n";
                        } else {
                                # grab the others elements
-                               $return .= Skin::drawCategoryBrowser($parent, $skin) . ' &gt; ';
+                               $return .= Skin::drawCategoryBrowser( $parent, $skin ) . ' &gt; ';
                        }
                        # add our current element to the list
-                       $eltitle = Title::newFromText($element);
-                       $return .=  $skin->link( $eltitle, $eltitle->getText() ) ;
+                       $eltitle = Title::newFromText( $element );
+                       $return .=  $skin->link( $eltitle, $eltitle->getText() );
                }
                return $return;
        }
@@ -869,7 +872,7 @@ END;
         * Returns an empty string by default, if not changed by any hook function.
         */
        protected function afterContentHook() {
-               $data = "";
+               $data = '';
 
                if( wfRunHooks( 'SkinAfterContent', array( &$data ) ) ){
                        // adding just some spaces shouldn't toggle the output
@@ -937,7 +940,7 @@ END;
        }
 
        /** overloaded by derived classes */
-       function doAfterContent() { return "</div></div>"; }
+       function doAfterContent() { return '</div></div>'; }
 
        function pageTitleLinks() {
                global $wgOut, $wgTitle, $wgUser, $wgRequest, $wgLang;
@@ -980,8 +983,8 @@ END;
                                $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
                                $s[] = '<strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
                                # disable caching
-                               $wgOut->setSquidMaxage(0);
-                               $wgOut->enableClientCache(false);
+                               $wgOut->setSquidMaxage( 0 );
+                               $wgOut->enableClientCache( false );
                        }
                }
 
@@ -995,9 +998,8 @@ END;
        function getUndeleteLink() {
                global $wgUser, $wgTitle, $wgContLang, $wgLang, $action;
                if(     $wgUser->isAllowed( 'deletedhistory' ) &&
-                       (($wgTitle->getArticleId() == 0) || ($action == "history")) &&
-                       ($n = $wgTitle->isDeleted() ) )
-               {
+                       ( ( $wgTitle->getArticleId() == 0 ) || ( $action == 'history' ) ) &&
+                       ( $n = $wgTitle->isDeleted() ) ){
                        if ( $wgUser->isAllowed( 'undelete' ) ) {
                                $msg = 'thisisdeleted';
                        } else {
@@ -1042,34 +1044,34 @@ END;
                        $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
                }
                $subpages = $this->subPageSubtitle();
-               $sub .= !empty($subpages)?"</p><p class='subpages'>$subpages":'';
+               $sub .= !empty( $subpages ) ? "</p><p class='subpages'>$subpages" : '';
                $s = "<p class='subtitle'>{$sub}</p>\n";
                return $s;
        }
 
        function subPageSubtitle() {
                $subpages = '';
-               if(!wfRunHooks('SkinSubPageSubtitle', array(&$subpages)))
+               if( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages ) ) )
                        return $subpages;
 
                global $wgOut, $wgTitle;
-               if($wgOut->isArticle() && MWNamespace::hasSubpages( $wgTitle->getNamespace() )) {
-                       $ptext=$wgTitle->getPrefixedText();
-                       if(preg_match('/\//',$ptext)) {
-                               $links = explode('/',$ptext);
+               if( $wgOut->isArticle() && MWNamespace::hasSubpages( $wgTitle->getNamespace() ) ) {
+                       $ptext = $wgTitle->getPrefixedText();
+                       if( preg_match( '/\//', $ptext ) ) {
+                               $links = explode( '/', $ptext );
                                array_pop( $links );
                                $c = 0;
                                $growinglink = '';
                                $display = '';
-                               foreach($links as $link) {
+                               foreach( $links as $link ) {
                                        $growinglink .= $link;
                                        $display .= $link;
                                        $linkObj = Title::newFromText( $growinglink );
                                        if( is_object( $linkObj ) && $linkObj->exists() ){
                                                $getlink = $this->makeKnownLinkObj( $linkObj, htmlspecialchars( $display ) );
                                                $c++;
-                                               if ($c>1) {
-                                                       $subpages .= wfMsgExt( 'pipe-separator' , 'escapenoentities' );
+                                               if( $c > 1 ) {
+                                                       $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
                                                } else  {
                                                        $subpages .= '&lt; ';
                                                }
@@ -1167,19 +1169,19 @@ END;
                $s = '<form id="searchform'.$this->searchboxes.'" name="search" class="inline" method="post" action="'
                  . $this->escapeSearchLink() . "\">\n"
                  . '<input type="text" id="searchInput'.$this->searchboxes.'" name="search" size="19" value="'
-                 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
-                 . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" />';
-               
-               if ($wgUseTwoButtonsSearchForm)
-                       $s .= '&nbsp;<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n";
+                 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
+                 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
+
+               if( $wgUseTwoButtonsSearchForm )
+                       $s .= '&nbsp;<input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
                else
-                       $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg ('powersearch-legend') . "</a>\n";
-               
+                       $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
+
                $s .= '</form>';
-               
+
                // Ensure unique id's for search boxes made after the first
                $this->searchboxes = $this->searchboxes == '' ? 2 : $this->searchboxes + 1;
-               
+
                return $s;
        }
 
@@ -1207,7 +1209,7 @@ END;
                }
 
                // FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
-               return implode( $s, wfMsgExt( 'pipe-separator' , 'escapenoentities' ) . "\n" );
+               return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
        }
 
        /**
@@ -1251,7 +1253,10 @@ END;
                                $varname = $wgContLang->getVariantname( $code );
                                if( $varname == 'disable' )
                                        continue;
-                               $s = $wgLang->pipeList( array( $s, '<a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>' ) );
+                               $s = $wgLang->pipeList( array(
+                                       $s,
+                                       '<a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
+                               ) );
                        }
                }
                return $s;
@@ -1259,7 +1264,7 @@ END;
 
        function bottomLinks() {
                global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
-               $sep = wfMsgExt( 'pipe-separator' , 'escapenoentities' ) . "\n";
+               $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
 
                $s = '';
                if ( $wgOut->isArticleRelated() ) {
@@ -1272,17 +1277,15 @@ END;
                        $element[] = $this->whatLinksHere();
                        $element[] = $this->watchPageLinksLink();
 
-                       if ($wgUseTrackbacks)
+                       if( $wgUseTrackbacks )
                                $element[] = $this->trackbackLink();
 
                        if ( $wgTitle->getNamespace() == NS_USER
-                           || $wgTitle->getNamespace() == NS_USER_TALK )
+                           || $wgTitle->getNamespace() == NS_USER_TALK ){
+                               $id = User::idFromName( $wgTitle->getText() );
+                               $ip = User::isIP( $wgTitle->getText() );
 
-                       {
-                               $id=User::idFromName($wgTitle->getText());
-                               $ip=User::isIP($wgTitle->getText());
-
-                               if($id || $ip) { # both anons and non-anons have contri list
+                               if( $id || $ip ) { # both anons and non-anons have contri list
                                        $element[] = $this->userContribsLink();
                                }
                                if( $this->showEmailUser( $id ) ) {
@@ -1294,9 +1297,9 @@ END;
 
                        if ( $wgTitle->getArticleId() ) {
                                $s .= "\n<br />";
-                               if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
-                               if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
-                               if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
+                               if( $wgUser->isAllowed( 'delete' ) ) { $s .= $this->deleteThisPage(); }
+                               if( $wgUser->isAllowed( 'protect' ) ) { $s .= $sep . $this->protectThisPage(); }
+                               if( $wgUser->isAllowed( 'move' ) ) { $s .= $sep . $this->moveThisPage(); }
                        }
                        $s .= "<br />\n" . $this->otherLanguages();
                }
@@ -1331,15 +1334,15 @@ END;
 
                if( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
                        $dbr = wfGetDB( DB_SLAVE );
-                       $watchlist = $dbr->tableName( 'watchlist' );
-                       $sql = "SELECT COUNT(*) AS n FROM $watchlist
-                               WHERE wl_title='" . $dbr->strencode($wgTitle->getDBkey()) .
-                               "' AND  wl_namespace=" . $wgTitle->getNamespace() ;
-                       $res = $dbr->query( $sql, 'Skin::pageStats');
+                       $res = $dbr->select( 'watchlist',
+                               array( 'COUNT(*) AS n' ),
+                               array( 'wl_title' => $dbr->strencode( $wgTitle->getDBkey() ), 'wl_namespace' => $wgTitle->getNamespace() ),
+                               __METHOD__
+                       );
                        $x = $dbr->fetchObject( $res );
 
                        $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
-                               array( 'parseinline' ), $wgLang->formatNum($x->n)
+                               array( 'parseinline' ), $wgLang->formatNum( $x->n )
                        );
                }
 
@@ -1428,12 +1431,15 @@ END;
        }
 
        function logoText( $align = '' ) {
-               if ( '' != $align ) { $a = " align='{$align}'"; }
-               else { $a = ''; }
+               if ( '' != $align ) {
+                       $a = " align='{$align}'";
+               } else {
+                       $a = '';
+               }
 
                $mp = wfMsg( 'mainpage' );
                $mptitle = Title::newMainPage();
-               $url = ( is_object($mptitle) ? $mptitle->escapeLocalURL() : '' );
+               $url = ( is_object( $mptitle ) ? $mptitle->escapeLocalURL() : '' );
 
                $logourl = $this->getLogo();
                $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
@@ -1537,9 +1543,9 @@ END;
                global $wgArticle;
 
                if( $this->mRevisionId && ! $wgArticle->isCurrent() ) {
-                       return "action=edit&oldid=" . intval( $this->mRevisionId );
+                       return 'action=edit&oldid=' . intval( $this->mRevisionId );
                } else {
-                       return "action=edit";
+                       return 'action=edit';
                }
        }
 
@@ -1547,7 +1553,7 @@ END;
                global $wgUser, $wgTitle, $wgRequest;
 
                $diff = $wgRequest->getVal( 'diff' );
-               if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
+               if ( $wgTitle->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
                        $t = wfMsg( 'deletethispage' );
 
                        $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
@@ -1584,11 +1590,11 @@ END;
                        if ( $wgTitle->userIsWatching() ) {
                                $t = wfMsg( 'unwatchthispage' );
                                $q = 'action=unwatch';
-                               $id = "mw-unwatch-link".$this->mWatchLinkNum;
+                               $id = 'mw-unwatch-link' . $this->mWatchLinkNum;
                        } else {
                                $t = wfMsg( 'watchthispage' );
                                $q = 'action=watch';
-                               $id = 'mw-watch-link'.$this->mWatchLinkNum;
+                               $id = 'mw-watch-link' . $this->mWatchLinkNum;
                        }
                        $s = $this->makeKnownLinkObj( $wgTitle, $t, $q, '', '', " id=\"$id\"" );
                } else {
@@ -1662,8 +1668,8 @@ END;
        function trackbackLink() {
                global $wgTitle;
 
-               return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
-                       . wfMsg('trackbacklink') . "</a>";
+               return '<a href="' . $wgTitle->trackbackURL() . '">'
+                       . wfMsg( 'trackbacklink' ) . '</a>';
        }
 
        function otherLanguages() {
@@ -1680,9 +1686,11 @@ END;
 
                $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
                $first = true;
-               if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
+               if( $wgContLang->isRTL() ) $s .= '<span dir="LTR">';
                foreach( $a as $l ) {
-                       if ( ! $first ) { $s .= wfMsgExt( 'pipe-separator' , 'escapenoentities' ); }
+                       if ( !$first ) {
+                               $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
+                       }
                        $first = false;
 
                        $nt = Title::newFromText( $l );
@@ -1693,7 +1701,7 @@ END;
                        $style = $this->getExternalLinkAttributes( $l, $text );
                        $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
                }
-               if($wgContLang->isRTL()) $s .= '</span>';
+               if( $wgContLang->isRTL() ) $s .= '</span>';
                return $s;
        }
 
@@ -1872,24 +1880,24 @@ END;
                $bar = array();
                $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
                $heading = '';
-               foreach ($lines as $line) {
-                       if (strpos($line, '*') !== 0)
+               foreach( $lines as $line ) {
+                       if( strpos( $line, '*' ) !== 0 )
                                continue;
-                       if (strpos($line, '**') !== 0) {
-                               $line = trim($line, '* ');
+                       if( strpos( $line, '**') !== 0 ) {
+                               $line = trim( $line, '* ' );
                                $heading = $line;
-                               if( !array_key_exists($heading, $bar) ) $bar[$heading] = array();
+                               if( !array_key_exists( $heading, $bar ) ) $bar[$heading] = array();
                        } else {
-                               if (strpos($line, '|') !== false) { // sanity check
-                                       $line = array_map('trim', explode( '|' , trim($line, '* '), 2 ) );
+                               if( strpos( $line, '|' ) !== false ) { // sanity check
+                                       $line = array_map( 'trim', explode( '|', trim( $line, '* ' ), 2 ) );
                                        $link = wfMsgForContent( $line[0] );
-                                       if ($link == '-')
+                                       if( $link == '-' )
                                                continue;
 
-                                       $text = wfMsgExt($line[1], 'parsemag');
-                                       if (wfEmptyMsg($line[1], $text))
+                                       $text = wfMsgExt( $line[1], 'parsemag' );
+                                       if( wfEmptyMsg( $line[1], $text ) )
                                                $text = $line[1];
-                                       if (wfEmptyMsg($line[0], $link))
+                                       if( wfEmptyMsg( $line[0], $link ) )
                                                $link = $line[0];
 
                                        if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
@@ -1907,15 +1915,15 @@ END;
                                        $bar[$heading][] = array(
                                                'text' => $text,
                                                'href' => $href,
-                                               'id' => 'n-' . strtr($line[1], ' ', '-'),
+                                               'id' => 'n-' . strtr( $line[1], ' ', '-' ),
                                                'active' => false
                                        );
                                } else { continue; }
                        }
                }
-               wfRunHooks('SkinBuildSidebar', array($this, &$bar));
+               wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
                if ( $wgEnableSidebarCache ) $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
                wfProfileOut( __METHOD__ );
                return $bar;
        }
-}
+}
\ No newline at end of file
index 4317a93..526b549 100644 (file)
@@ -27,11 +27,11 @@ if ( ! defined( 'MEDIAWIKI' ) )
 class MediaWiki_I18N {
        var $_context = array();
 
-       function set($varName, $value) {
+       function set( $varName, $value ) {
                $this->_context[$varName] = $value;
        }
 
-       function translate($value) {
+       function translate( $value ) {
                wfProfileIn( __METHOD__ );
 
                // Hack for i18n:attributes in PHPTAL 1.0.0 dev version as of 2004-10-23
@@ -40,12 +40,12 @@ class MediaWiki_I18N {
                $value = wfMsg( $value );
                // interpolate variables
                $m = array();
-               while (preg_match('/\$([0-9]*?)/sm', $value, $m)) {
-                       list($src, $var) = $m;
+               while( preg_match( '/\$([0-9]*?)/sm', $value, $m ) ) {
+                       list( $src, $var ) = $m;
                        wfSuppressWarnings();
                        $varValue = $this->_context[$var];
                        wfRestoreWarnings();
-                       $value = str_replace($src, $varValue, $value);
+                       $value = str_replace( $src, $varValue, $value );
                }
                wfProfileOut( __METHOD__ );
                return $value;
@@ -124,7 +124,7 @@ class SkinTemplate extends Skin {
         * @return object
         * @private
         */
-       function setupTemplate( $classname, $repository=false, $cache_dir=false ) {
+       function setupTemplate( $classname, $repository = false, $cache_dir = false ) {
                return new $classname();
        }
 
@@ -150,23 +150,23 @@ class SkinTemplate extends Skin {
                $diff = $wgRequest->getVal( 'diff' );
                $action = $wgRequest->getVal( 'action', 'view' );
 
-               wfProfileIn( __METHOD__."-init" );
+               wfProfileIn( __METHOD__ . '-init' );
                $this->initPage( $out );
 
                $this->setMembers();
                $tpl = $this->setupTemplate( $this->template, 'skins' );
 
                #if ( $wgUseDatabaseMessages ) { // uncomment this to fall back to GetText
-               $tpl->setTranslator(new MediaWiki_I18N());
+               $tpl->setTranslator( new MediaWiki_I18N() );
                #}
-               wfProfileOut( __METHOD__."-init" );
+               wfProfileOut( __METHOD__ . '-init' );
 
-               wfProfileIn( __METHOD__."-stuff" );
-               $this->thispage = $this->mTitle->getPrefixedDbKey();
+               wfProfileIn( __METHOD__ . '-stuff' );
+               $this->thispage = $this->mTitle->getPrefixedDBkey();
                $this->thisurl = $this->mTitle->getPrefixedURL();
                $this->loggedin = $wgUser->isLoggedIn();
-               $this->iscontent = ($this->mTitle->getNamespace() != NS_SPECIAL );
-               $this->iseditable = ($this->iscontent and !($action == 'edit' or $action == 'submit'));
+               $this->iscontent = ( $this->mTitle->getNamespace() != NS_SPECIAL );
+               $this->iseditable = ( $this->iscontent and !( $action == 'edit' or $action == 'submit' ) );
                $this->username = $wgUser->getName();
 
                if ( $wgUser->isLoggedIn() || $this->showIPinHeader() ) {
@@ -181,18 +181,18 @@ class SkinTemplate extends Skin {
                $this->setupUserCss( $out );
                $this->setupUserJs( $out->isUserJsAllowed() );
                $this->titletxt = $this->mTitle->getPrefixedText();
-               wfProfileOut( __METHOD__."-stuff" );
+               wfProfileOut( __METHOD__ . '-stuff' );
 
-               wfProfileIn( __METHOD__."-stuff2" );
+               wfProfileIn( __METHOD__ . '-stuff2' );
                $tpl->set( 'title', $out->getPageTitle() );
                $tpl->set( 'pagetitle', $out->getHTMLTitle() );
                $tpl->set( 'displaytitle', $out->mPageLinkTitle );
                $tpl->set( 'pageclass', $this->getPageClasses( $this->mTitle ) );
-               $tpl->set( 'skinnameclass', ( "skin-" . Sanitizer::escapeClass( $this->getSkinName ( ) ) ) );
+               $tpl->set( 'skinnameclass', ( 'skin-' . Sanitizer::escapeClass( $this->getSkinName() ) ) );
 
                $nsname = isset( $wgCanonicalNamespaceNames[ $this->mTitle->getNamespace() ] ) ?
-                         $wgCanonicalNamespaceNames[ $this->mTitle->getNamespace() ] :
-                         $this->mTitle->getNsText();
+                                       $wgCanonicalNamespaceNames[ $this->mTitle->getNamespace() ] :
+                                       $this->mTitle->getNsText();
 
                $tpl->set( 'nscanonical', $nsname );
                $tpl->set( 'nsnumber', $this->mTitle->getNamespace() );
@@ -203,33 +203,34 @@ class SkinTemplate extends Skin {
 
                $tpl->set( 'isarticle', $out->isArticle() );
 
-               $tpl->setRef( "thispage", $this->thispage );
+               $tpl->setRef( 'thispage', $this->thispage );
                $subpagestr = $this->subPageSubtitle();
                $tpl->set(
-                       'subtitle',  !empty($subpagestr)?
-                       '<span class="subpages">'.$subpagestr.'</span>'.$out->getSubtitle():
+                       'subtitle', !empty( $subpagestr ) ?
+                       '<span class="subpages">'.$subpagestr.'</span>'.$out->getSubtitle() :
                        $out->getSubtitle()
                );
                $undelete = $this->getUndeleteLink();
                $tpl->set(
-                       "undelete", !empty($undelete)?
-                       '<span class="subpages">'.$undelete.'</span>':
+                       'undelete', !empty( $undelete ) ?
+                       '<span class="subpages">'.$undelete.'</span>' :
                        ''
                );
 
-               $tpl->set( 'catlinks', $this->getCategories());
+               $tpl->set( 'catlinks', $this->getCategories() );
                if( $out->isSyndicated() ) {
                        $feeds = array();
                        foreach( $out->getSyndicationLinks() as $format => $link ) {
                                $feeds[$format] = array(
                                        'text' => wfMsg( "feed-$format" ),
-                                       'href' => $link );
+                                       'href' => $link
+                               );
                        }
                        $tpl->setRef( 'feeds', $feeds );
                } else {
                        $tpl->set( 'feeds', false );
                }
-               if ($wgUseTrackbacks && $out->isArticleRelated()) {
+               if( $wgUseTrackbacks && $out->isArticleRelated() ) {
                        $tpl->set( 'trackbackhtml', $wgTitle->trackbackRDF() );
                } else {
                        $tpl->set( 'trackbackhtml', null );
@@ -250,7 +251,7 @@ class SkinTemplate extends Skin {
                $tpl->set( 'printable', $wgRequest->getBool( 'printable' ) );
                $tpl->set( 'handheld', $wgRequest->getBool( 'handheld' ) );
                $tpl->setRef( 'loggedin', $this->loggedin );
-               $tpl->set('notspecialpage', $this->mTitle->getNamespace() != NS_SPECIAL);
+               $tpl->set( 'notspecialpage', $this->mTitle->getNamespace() != NS_SPECIAL );
                /* XXX currently unused, might get useful later
                $tpl->set( "editable", ($this->mTitle->getNamespace() != NS_SPECIAL ) );
                $tpl->set( "exists", $this->mTitle->getArticleID() != 0 );
@@ -259,38 +260,38 @@ class SkinTemplate extends Skin {
                $tpl->set( "helppage", wfMsg('helppage'));
                */
                $tpl->set( 'searchaction', $this->escapeSearchLink() );
-               $tpl->set( 'searchtitle', SpecialPage::getTitleFor('search')->getPrefixedDBKey() );
+               $tpl->set( 'searchtitle', SpecialPage::getTitleFor( 'Search' )->getPrefixedDBKey() );
                $tpl->set( 'search', trim( $wgRequest->getVal( 'search' ) ) );
                $tpl->setRef( 'stylepath', $wgStylePath );
                $tpl->setRef( 'articlepath', $wgArticlePath );
                $tpl->setRef( 'scriptpath', $wgScriptPath );
                $tpl->setRef( 'serverurl', $wgServer );
                $tpl->setRef( 'logopath', $wgLogo );
-               $tpl->setRef( "lang", $wgContLanguageCode );
-               $tpl->set( 'dir', $wgContLang->isRTL() ? "rtl" : "ltr" );
+               $tpl->setRef( 'lang', $wgContLanguageCode );
+               $tpl->set( 'dir', $wgContLang->isRTL() ? 'rtl' : 'ltr' );
                $tpl->set( 'rtl', $wgContLang->isRTL() );
                $tpl->set( 'langname', $wgContLang->getLanguageName( $wgContLanguageCode ) );
                $tpl->set( 'showjumplinks', $wgUser->getOption( 'showjumplinks' ) );
                $tpl->set( 'username', $wgUser->isAnon() ? NULL : $this->username );
-               $tpl->setRef( 'userpage', $this->userpage);
-               $tpl->setRef( 'userpageurl', $this->userpageUrlDetails['href']);
+               $tpl->setRef( 'userpage', $this->userpage );
+               $tpl->setRef( 'userpageurl', $this->userpageUrlDetails['href'] );
                $tpl->set( 'userlang', $wgLang->getCode() );
                $tpl->set( 'pagecss', $this->setupPageCss() );
-               $tpl->setRef( 'usercss', $this->usercss);
-               $tpl->setRef( 'userjs', $this->userjs);
-               $tpl->setRef( 'userjsprev', $this->userjsprev);
+               $tpl->setRef( 'usercss', $this->usercss );
+               $tpl->setRef( 'userjs', $this->userjs );
+               $tpl->setRef( 'userjsprev', $this->userjsprev );
                if( $wgUseSiteJs ) {
                        $jsCache = $this->loggedin ? '&smaxage=0' : '';
                        $tpl->set( 'jsvarurl',
-                               self::makeUrl('-',
+                               self::makeUrl( '-',
                                        "action=raw$jsCache&gen=js&useskin=" .
                                                urlencode( $this->getSkinName() ) ) );
                } else {
-                       $tpl->set('jsvarurl', false);
+                       $tpl->set( 'jsvarurl', false );
                }
                $newtalks = $wgUser->getNewMessageLinks();
 
-               if (count($newtalks) == 1 && $newtalks[0]["wiki"] === wfWikiID() ) {
+               if( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
                        $usertitle = $this->mUser->getUserPage();
                        $usertalktitle = $usertitle->getTalkPage();
                        if( !$usertalktitle->equals( $this->mTitle ) ) {
@@ -307,63 +308,63 @@ class SkinTemplate extends Skin {
                                        )
                                );
                                # Disable Cache
-                               $out->setSquidMaxage(0);
+                               $out->setSquidMaxage( 0 );
                        }
-               } else if (count($newtalks)) {
-                       $sep = str_replace("_", " ", wfMsgHtml("newtalkseparator"));
+               } else if( count( $newtalks ) ) {
+                       $sep = str_replace( '_', ' ', wfMsgHtml( 'newtalkseparator' ) );
                        $msgs = array();
-                       foreach ($newtalks as $newtalk) {
-                               $msgs[] = Xml::element("a",
-                                       array('href' => $newtalk["link"]), $newtalk["wiki"]);
+                       foreach( $newtalks as $newtalk ) {
+                               $msgs[] = Xml::element('a',
+                                       array( 'href' => $newtalk['link'] ), $newtalk['wiki'] );
                        }
-                       $parts = implode($sep, $msgs);
-                       $ntl = wfMsgHtml('youhavenewmessagesmulti', $parts);
-                       $out->setSquidMaxage(0);
+                       $parts = implode( $sep, $msgs );
+                       $ntl = wfMsgHtml( 'youhavenewmessagesmulti', $parts );
+                       $out->setSquidMaxage( 0 );
                } else {
                        $ntl = '';
                }
-               wfProfileOut( __METHOD__."-stuff2" );
+               wfProfileOut( __METHOD__ . '-stuff2' );
 
-               wfProfileIn( __METHOD__."-stuff3" );
+               wfProfileIn( __METHOD__ . '-stuff3' );
                $tpl->setRef( 'newtalk', $ntl );
                $tpl->setRef( 'skin', $this );
                $tpl->set( 'logo', $this->logoText() );
-               if ( $out->isArticle() and (!isset( $oldid ) or isset( $diff )) and
-                       $wgArticle and 0 != $wgArticle->getID() )
-               {
+               if ( $out->isArticle() and ( !isset( $oldid ) or isset( $diff ) ) and
+                       $wgArticle and 0 != $wgArticle->getID() ){
                        if ( !$wgDisableCounters ) {
                                $viewcount = $wgLang->formatNum( $wgArticle->getCount() );
                                if ( $viewcount ) {
-                                       $tpl->set('viewcount', wfMsgExt( 'viewcount', array( 'parseinline' ), $viewcount ) );
+                                       $tpl->set( 'viewcount', wfMsgExt( 'viewcount', array( 'parseinline' ), $viewcount ) );
                                } else {
-                                       $tpl->set('viewcount', false);
+                                       $tpl->set( 'viewcount', false );
                                }
                        } else {
-                               $tpl->set('viewcount', false);
+                               $tpl->set( 'viewcount', false );
                        }
 
-                       if ($wgPageShowWatchingUsers) {
+                       if( $wgPageShowWatchingUsers ) {
                                $dbr = wfGetDB( DB_SLAVE );
                                $watchlist = $dbr->tableName( 'watchlist' );
-                               $sql = "SELECT COUNT(*) AS n FROM $watchlist
-                                       WHERE wl_title='" . $dbr->strencode($this->mTitle->getDBkey()) .
-                                       "' AND  wl_namespace=" . $this->mTitle->getNamespace() ;
-                               $res = $dbr->query( $sql, 'SkinTemplate::outputPage');
+                               $res = $dbr->select( 'watchlist',
+                                       array( 'COUNT(*) AS n' ),
+                                       array( 'wl_title' => $dbr->strencode( $this->mTitle->getDBkey() ), 'wl_namespace' => $this->mTitle->getNamespace() ),
+                                       __METHOD__
+                               );
                                $x = $dbr->fetchObject( $res );
                                $numberofwatchingusers = $x->n;
-                               if ($numberofwatchingusers > 0) {
-                                       $tpl->set('numberofwatchingusers',
-                                               wfMsgExt('number_of_watching_users_pageview', array('parseinline'),
-                                               $wgLang->formatNum($numberofwatchingusers))
+                               if( $numberofwatchingusers > 0 ) {
+                                       $tpl->set( 'numberofwatchingusers',
+                                               wfMsgExt( 'number_of_watching_users_pageview', array( 'parseinline' ),
+                                               $wgLang->formatNum( $numberofwatchingusers ) )
                                        );
                                } else {
-                                       $tpl->set('numberofwatchingusers', false);
+                                       $tpl->set( 'numberofwatchingusers', false );
                                }
                        } else {
-                               $tpl->set('numberofwatchingusers', false);
+                               $tpl->set( 'numberofwatchingusers', false );
                        }
 
-                       $tpl->set('copyright',$this->getCopyright());
+                       $tpl->set( 'copyright', $this->getCopyright() );
 
                        $this->credits = false;
 
@@ -376,21 +377,21 @@ class SkinTemplate extends Skin {
                        $tpl->setRef( 'credits', $this->credits );
 
                } elseif ( isset( $oldid ) && !isset( $diff ) ) {
-                       $tpl->set('copyright', $this->getCopyright());
-                       $tpl->set('viewcount', false);
-                       $tpl->set('lastmod', false);
-                       $tpl->set('credits', false);
-                       $tpl->set('numberofwatchingusers', false);
+                       $tpl->set( 'copyright', $this->getCopyright() );
+                       $tpl->set( 'viewcount', false );
+                       $tpl->set( 'lastmod', false );
+                       $tpl->set( 'credits', false );
+                       $tpl->set( 'numberofwatchingusers', false );
                } else {
-                       $tpl->set('copyright', false);
-                       $tpl->set('viewcount', false);
-                       $tpl->set('lastmod', false);
-                       $tpl->set('credits', false);
-                       $tpl->set('numberofwatchingusers', false);
+                       $tpl->set( 'copyright', false );
+                       $tpl->set( 'viewcount', false );
+                       $tpl->set( 'lastmod', false );
+                       $tpl->set( 'credits', false );
+                       $tpl->set( 'numberofwatchingusers', false );
                }
-               wfProfileOut( __METHOD__."-stuff3" );
+               wfProfileOut( __METHOD__ . '-stuff3' );
 
-               wfProfileIn( __METHOD__."-stuff4" );
+               wfProfileIn( __METHOD__ . '-stuff4' );
                $tpl->set( 'copyrightico', $this->getCopyrightIcon() );
                $tpl->set( 'poweredbyico', $this->getPoweredBy() );
                $tpl->set( 'disclaimer', $this->disclaimerLink() );
@@ -413,37 +414,37 @@ class SkinTemplate extends Skin {
                        foreach( $out->getLanguageLinks() as $l ) {
                                $tmp = explode( ':', $l, 2 );
                                $class = 'interwiki-' . $tmp[0];
-                               unset($tmp);
+                               unset( $tmp );
                                $nt = Title::newFromText( $l );
                                if ( $nt ) {
                                        $language_urls[] = array(
                                                'href' => $nt->getFullURL(),
-                                               'text' => ($wgContLang->getLanguageName( $nt->getInterwiki()) != ''?$wgContLang->getLanguageName( $nt->getInterwiki()) : $l),
+                                               'text' => ( $wgContLang->getLanguageName( $nt->getInterwiki() ) != '' ?
+                                                                       $wgContLang->getLanguageName( $nt->getInterwiki() ) : $l ),
                                                'class' => $class
                                        );
                                }
                        }
                }
-               if(count($language_urls)) {
-                       $tpl->setRef( 'language_urls', $language_urls);
+               if( count( $language_urls ) ) {
+                       $tpl->setRef( 'language_urls', $language_urls );
                } else {
-                       $tpl->set('language_urls', false);
+                       $tpl->set( 'language_urls', false );
                }
-               wfProfileOut( __METHOD__."-stuff4" );
+               wfProfileOut( __METHOD__ . '-stuff4' );
 
-               wfProfileIn( __METHOD__."-stuff5" );
+               wfProfileIn( __METHOD__ . '-stuff5' );
                # Personal toolbar
-               $tpl->set('personal_urls', $this->buildPersonalUrls());
+               $tpl->set( 'personal_urls', $this->buildPersonalUrls() );
                $content_actions = $this->buildContentActionUrls();
-               $tpl->setRef('content_actions', $content_actions);
+               $tpl->setRef( 'content_actions', $content_actions );
 
                // XXX: attach this from javascript, same with section editing
-               if($this->iseditable && $wgUser->getOption("editondblclick") )
-               {
+               if( $this->iseditable && $wgUser->getOption( 'editondblclick' ) ){
                        $encEditUrl = Xml::escapeJsString( $this->mTitle->getLocalUrl( $this->editUrlOptions() ) );
-                       $tpl->set('body_ondblclick', 'document.location = "' . $encEditUrl . '";');
+                       $tpl->set( 'body_ondblclick', 'document.location = "' . $encEditUrl . '";' );
                } else {
-                       $tpl->set('body_ondblclick', false);
+                       $tpl->set( 'body_ondblclick', false );
                }
                $tpl->set( 'body_onload', false );
                $tpl->set( 'sidebar', $this->buildSidebar() );
@@ -456,13 +457,13 @@ class SkinTemplate extends Skin {
 
                // allow extensions adding stuff after the page content.
                // See Skin::afterContentHook() for further documentation.
-               $tpl->set ('dataAfterContent', $this->afterContentHook());
-               wfProfileOut( __METHOD__."-stuff5" );
+               $tpl->set( 'dataAfterContent', $this->afterContentHook() );
+               wfProfileOut( __METHOD__ . '-stuff5' );
 
                // execute template
-               wfProfileIn( __METHOD__."-execute" );
+               wfProfileIn( __METHOD__ . '-execute' );
                $res = $tpl->execute();
-               wfProfileOut( __METHOD__."-execute" );
+               wfProfileOut( __METHOD__ . '-execute' );
 
                // result may be an error
                $this->printOrError( $res );
@@ -494,18 +495,18 @@ class SkinTemplate extends Skin {
 
                /* set up the default links for the personal toolbar */
                $personal_urls = array();
-               if ($this->loggedin) {
+               if( $this->loggedin ) {
                        $personal_urls['userpage'] = array(
                                'text' => $this->username,
                                'href' => &$this->userpageUrlDetails['href'],
-                               'class' => $this->userpageUrlDetails['exists']?false:'new',
+                               'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
                                'active' => ( $this->userpageUrlDetails['href'] == $pageurl )
                        );
-                       $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage);
+                       $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage );
                        $personal_urls['mytalk'] = array(
-                               'text' => wfMsg('mytalk'),
+                               'text' => wfMsg( 'mytalk' ),
                                'href' => &$usertalkUrlDetails['href'],
-                               'class' => $usertalkUrlDetails['exists']?false:'new',
+                               'class' => $usertalkUrlDetails['exists'] ? false : 'new',
                                'active' => ( $usertalkUrlDetails['href'] == $pageurl )
                        );
                        $href = self::makeSpecialUrl( 'Preferences' );
@@ -560,15 +561,15 @@ class SkinTemplate extends Skin {
                                $personal_urls['anonuserpage'] = array(
                                        'text' => $this->username,
                                        'href' => $href,
-                                       'class' => $this->userpageUrlDetails['exists']?false:'new',
+                                       'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
                                        'active' => ( $pageurl == $href )
                                );
-                               $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage);
+                               $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage );
                                $href = &$usertalkUrlDetails['href'];
                                $personal_urls['anontalk'] = array(
-                                       'text' => wfMsg('anontalk'),
+                                       'text' => wfMsg( 'anontalk' ),
                                        'href' => $href,
-                                       'class' => $usertalkUrlDetails['exists']?false:'new',
+                                       'class' => $usertalkUrlDetails['exists'] ? false : 'new',
                                        'active' => ( $pageurl == $href )
                                );
                                $personal_urls['anonlogin'] = array(
@@ -577,7 +578,6 @@ class SkinTemplate extends Skin {
                                        'active' => $wgTitle->isSpecial( 'Userlogin' )
                                );
                        } else {
-
                                $personal_urls['login'] = array(
                                        'text' => wfMsg( $loginlink ),
                                        'href' => self::makeSpecialUrl( 'Userlogin', 'returnto=' . $this->thisurl ),
@@ -591,7 +591,7 @@ class SkinTemplate extends Skin {
                return $personal_urls;
        }
 
-       function tabAction( $title, $message, $selected, $query='', $checkEdit=false ) {
+       function tabAction( $title, $message, $selected, $query = '', $checkEdit = false ) {
                $classes = array();
                if( $selected ) {
                        $classes[] = 'selected';
@@ -608,9 +608,9 @@ class SkinTemplate extends Skin {
                }
 
                $result = array();
-               if( !wfRunHooks('SkinTemplateTabAction', array(&$this,
+               if( !wfRunHooks( 'SkinTemplateTabAction', array( &$this,
                                $title, $message, $selected, $checkEdit,
-                               &$classes, &$query, &$text, &$result)) ) {
+                               &$classes, &$query, &$text, &$result ) ) ) {
                        return $result;
                }
 
@@ -622,8 +622,8 @@ class SkinTemplate extends Skin {
 
        function makeTalkUrlDetails( $name, $urlaction = '' ) {
                $title = Title::newFromText( $name );
-               if( !is_object($title) ) {
-                       throw new MWException( __METHOD__." given invalid pagename $name" );
+               if( !is_object( $title ) ) {
+                       throw new MWException( __METHOD__ . " given invalid pagename $name" );
                }
                $title = $title->getTalkPage();
                self::checkTitle( $title, $name );
@@ -657,8 +657,8 @@ class SkinTemplate extends Skin {
                $section = $wgRequest->getVal( 'section' );
                $content_actions = array();
 
-               $prevent_active_tabs = false ;
-               wfRunHooks( 'SkinTemplatePreventOtherActiveTabs', array( &$this , &$prevent_active_tabs ) )     ;
+               $prevent_active_tabs = false;
+               wfRunHooks( 'SkinTemplatePreventOtherActiveTabs', array( &$this, &$prevent_active_tabs ) );
 
                if( $this->iscontent ) {
                        $subjpage = $this->mTitle->getSubjectPage();
@@ -669,21 +669,23 @@ class SkinTemplate extends Skin {
                                $subjpage,
                                $nskey,
                                !$this->mTitle->isTalkPage() && !$prevent_active_tabs,
-                               '', true);
+                               '', true
+                       );
 
                        $content_actions['talk'] = $this->tabAction(
                                $talkpage,
                                'talk',
                                $this->mTitle->isTalkPage() && !$prevent_active_tabs,
                                '',
-                               true);
+                               true
+                       );
 
-                       wfProfileIn( __METHOD__."-edit" );
+                       wfProfileIn( __METHOD__ . '-edit' );
                        if ( $this->mTitle->quickUserCan( 'edit' ) && ( $this->mTitle->exists() || $this->mTitle->quickUserCan( 'create' ) ) ) {
                                $istalk = $this->mTitle->isTalkPage();
                                $istalkclass = $istalk?' istalk':'';
                                $content_actions['edit'] = array(
-                                       'class' => ((($action == 'edit' or $action == 'submit') and $section != 'new') ? 'selected' : '').$istalkclass,
+                                       'class' => ( ( ( $action == 'edit' or $action == 'submit' ) and $section != 'new' ) ? 'selected' : '' ) . $istalkclass,
                                        'text' => $this->mTitle->exists()
                                                ? wfMsg( 'edit' )
                                                : wfMsg( 'create' ),
@@ -694,7 +696,7 @@ class SkinTemplate extends Skin {
                                        if ( !$wgOut->forceHideNewSectionLink() ) {
                                                $content_actions['addsection'] = array(
                                                        'class' => $section == 'new' ? 'selected' : false,
-                                                       'text' => wfMsg('addsection'),
+                                                       'text' => wfMsg( 'addsection' ),
                                                        'href' => $this->mTitle->getLocalUrl( 'action=edit&section=new' )
                                                );
                                        }
@@ -702,26 +704,26 @@ class SkinTemplate extends Skin {
                        } elseif ( $this->mTitle->isKnown() ) {
                                $content_actions['viewsource'] = array(
                                        'class' => ($action == 'edit') ? 'selected' : false,
-                                       'text' => wfMsg('viewsource'),
+                                       'text' => wfMsg( 'viewsource' ),
                                        'href' => $this->mTitle->getLocalUrl( $this->editUrlOptions() )
                                );
                        }
-                       wfProfileOut( __METHOD__."-edit" );
+                       wfProfileOut( __METHOD__ . '-edit' );
 
-                       wfProfileIn( __METHOD__."-live" );
+                       wfProfileIn( __METHOD__ . '-live' );
                        if ( $this->mTitle->exists() ) {
 
                                $content_actions['history'] = array(
                                        'class' => ($action == 'history') ? 'selected' : false,
-                                       'text' => wfMsg('history_short'),
+                                       'text' => wfMsg( 'history_short' ),
                                        'href' => $this->mTitle->getLocalUrl( 'action=history' ),
                                        'rel' => 'archives',
                                );
 
-                               if( $wgUser->isAllowed('delete') ) {
+                               if( $wgUser->isAllowed( 'delete' ) ) {
                                        $content_actions['delete'] = array(
                                                'class' => ($action == 'delete') ? 'selected' : false,
-                                               'text' => wfMsg('delete'),
+                                               'text' => wfMsg( 'delete' ),
                                                'href' => $this->mTitle->getLocalUrl( 'action=delete' )
                                        );
                                }
@@ -729,7 +731,7 @@ class SkinTemplate extends Skin {
                                        $moveTitle = SpecialPage::getTitleFor( 'Movepage', $this->thispage );
                                        $content_actions['move'] = array(
                                                'class' => $this->mTitle->isSpecial( 'Movepage' ) ? 'selected' : false,
-                                               'text' => wfMsg('move'),
+                                               'text' => wfMsg( 'move' ),
                                                'href' => $moveTitle->getLocalUrl()
                                        );
                                }
@@ -738,14 +740,14 @@ class SkinTemplate extends Skin {
                                        if( !$this->mTitle->isProtected() ){
                                                $content_actions['protect'] = array(
                                                        'class' => ($action == 'protect') ? 'selected' : false,
-                                                       'text' => wfMsg('protect'),
+                                                       'text' => wfMsg( 'protect' ),
                                                        'href' => $this->mTitle->getLocalUrl( 'action=protect' )
                                                );
 
                                        } else {
                                                $content_actions['unprotect'] = array(
                                                        'class' => ($action == 'unprotect') ? 'selected' : false,
-                                                       'text' => wfMsg('unprotect'),
+                                                       'text' => wfMsg( 'unprotect' ),
                                                        'href' => $this->mTitle->getLocalUrl( 'action=unprotect' )
                                                );
                                        }
@@ -757,7 +759,7 @@ class SkinTemplate extends Skin {
                                                $undelTitle = SpecialPage::getTitleFor( 'Undelete' );
                                                $content_actions['undelete'] = array(
                                                        'class' => false,
-                                                       'text' => wfMsgExt( 'undelete_short', array( 'parsemag' ), $wgLang->formatNum($n) ),
+                                                       'text' => wfMsgExt( 'undelete_short', array( 'parsemag' ), $wgLang->formatNum( $n ) ),
                                                        'href' => $undelTitle->getLocalUrl( 'target=' . urlencode( $this->thispage ) )
                                                        #'href' => self::makeSpecialUrl( "Undelete/$this->thispage" )
                                                );
@@ -768,40 +770,40 @@ class SkinTemplate extends Skin {
                                        if( !$this->mTitle->getRestrictions( 'create' ) ) {
                                                $content_actions['protect'] = array(
                                                        'class' => ($action == 'protect') ? 'selected' : false,
-                                                       'text' => wfMsg('protect'),
+                                                       'text' => wfMsg( 'protect' ),
                                                        'href' => $this->mTitle->getLocalUrl( 'action=protect' )
                                                );
 
                                        } else {
                                                $content_actions['unprotect'] = array(
                                                        'class' => ($action == 'unprotect') ? 'selected' : false,
-                                                       'text' => wfMsg('unprotect'),
+                                                       'text' => wfMsg( 'unprotect' ),
                                                        'href' => $this->mTitle->getLocalUrl( 'action=unprotect' )
                                                );
                                        }
                                }
                        }
 
-                       wfProfileOut( __METHOD__."-live" );
+                       wfProfileOut( __METHOD__ . '-live' );
 
                        if( $this->loggedin ) {
                                if( !$this->mTitle->userIsWatching()) {
                                        $content_actions['watch'] = array(
                                                'class' => ($action == 'watch' or $action == 'unwatch') ? 'selected' : false,
-                                               'text' => wfMsg('watch'),
+                                               'text' => wfMsg( 'watch' ),
                                                'href' => $this->mTitle->getLocalUrl( 'action=watch' )
                                        );
                                } else {
                                        $content_actions['unwatch'] = array(
                                                'class' => ($action == 'unwatch' or $action == 'watch') ? 'selected' : false,
-                                               'text' => wfMsg('unwatch'),
+                                               'text' => wfMsg( 'unwatch' ),
                                                'href' => $this->mTitle->getLocalUrl( 'action=unwatch' )
                                        );
                                }
                        }
 
 
-                       wfRunHooks( 'SkinTemplateTabs', array( &$this , &$content_actions ) )   ;
+                       wfRunHooks( 'SkinTemplateTabs', array( &$this, &$content_actions ) );
                } else {
                        /* show special page tab */
 
@@ -826,10 +828,10 @@ class SkinTemplate extends Skin {
                                        continue;
                                $selected = ( $code == $preferred )? 'selected' : false;
                                $content_actions['varlang-' . $vcount] = array(
-                                               'class' => $selected,
-                                               'text' => $varname,
-                                               'href' => $this->mTitle->getLocalURL('',$code)
-                                       );
+                                       'class' => $selected,
+                                       'text' => $varname,
+                                       'href' => $this->mTitle->getLocalURL( '', $code )
+                               );
                                $vcount ++;
                        }
                }
@@ -840,8 +842,6 @@ class SkinTemplate extends Skin {
                return $content_actions;
        }
 
-
-
        /**
         * build array of common navigation links
         * @return array
@@ -858,13 +858,13 @@ class SkinTemplate extends Skin {
                $nav_urls = array();
                $nav_urls['mainpage'] = array( 'href' => self::makeMainPageUrl() );
                if( $wgEnableUploads && $wgUser->isAllowed( 'upload' ) ) {
-                       if ($wgUploadNavigationUrl) {
+                       if( $wgUploadNavigationUrl ) {
                                $nav_urls['upload'] = array( 'href' => $wgUploadNavigationUrl );
                        } else {
                                $nav_urls['upload'] = array( 'href' => self::makeSpecialUrl( 'Upload' ) );
                        }
                } else {
-                       if ($wgUploadNavigationUrl)
+                       if( $wgUploadNavigationUrl )
                                $nav_urls['upload'] = array( 'href' => $wgUploadNavigationUrl );
                        else
                                $nav_urls['upload'] = false;
@@ -908,21 +908,21 @@ class SkinTemplate extends Skin {
                        } else {
                                $nav_urls['recentchangeslinked'] = false;
                        }
-                       if ($wgUseTrackbacks)
+                       if( $wgUseTrackbacks )
                                $nav_urls['trackbacklink'] = array(
                                        'href' => $wgTitle->trackbackURL()
                                );
                }
 
                if( $this->mTitle->getNamespace() == NS_USER || $this->mTitle->getNamespace() == NS_USER_TALK ) {
-                       $id = User::idFromName($this->mTitle->getText());
-                       $ip = User::isIP($this->mTitle->getText());
+                       $id = User::idFromName( $this->mTitle->getText() );
+                       $ip = User::isIP( $this->mTitle->getText() );
                } else {
                        $id = 0;
                        $ip = false;
                }
 
-               if($id || $ip) { # both anons and non-anons have contribs list
+               if( $id || $ip ) { # both anons and non-anons have contribs list
                        $nav_urls['contributions'] = array(
                                'href' => self::makeSpecialUrlSubpage( 'Contributions', $this->mTitle->getText() )
                        );
@@ -979,9 +979,9 @@ class SkinTemplate extends Skin {
                if( $allowUserJs && $this->loggedin ) {
                        if( $this->mTitle->isJsSubpage() and $this->userCanPreview( $action ) ) {
                                # XXX: additional security check/prompt?
-                               $this->userjsprev = '/*<![CDATA[*/ ' . $wgRequest->getText('wpTextbox1') . ' /*]]>*/';
+                               $this->userjsprev = '/*<![CDATA[*/ ' . $wgRequest->getText( 'wpTextbox1' ) . ' /*]]>*/';
                        } else {
-                               $this->userjs = self::makeUrl($this->userpage.'/'.$this->skinname.'.js', 'action=raw&ctype='.$wgJsMimeType);
+                               $this->userjs = self::makeUrl( $this->userpage . '/' . $this->skinname . '.js', 'action=raw&ctype=' . $wgJsMimeType );
                        }
                }
                wfProfileOut( __METHOD__ );
@@ -1009,42 +1009,45 @@ class SkinTemplate extends Skin {
  */
 class QuickTemplate {
        /**
-        * @public
+        * Constructor
         */
-       function QuickTemplate() {
+       public function QuickTemplate() {
                $this->data = array();
                $this->translator = new MediaWiki_I18N();
        }
 
        /**
-        * @public
+        * Sets the value $value to $name
+        * @param $name
+        * @param $value
         */
-       function set( $name, $value ) {
+       public function set( $name, $value ) {
                $this->data[$name] = $value;
        }
 
        /**
-        * @public
+        * @param $name
+        * @param $value
         */
-       function setRef($name, &$value) {
+       public function setRef( $name, &$value ) {
                $this->data[$name] =& $value;
        }
 
        /**
-        * @public
+        * @param $t
         */
-       function setTranslator( &$t ) {
+       public function setTranslator( &$t ) {
                $this->translator = &$t;
        }
 
        /**
-        * @public
+        * Main function, used by classes that subclass QuickTemplate
+        * to show the actual HTML output
         */
-       function execute() {
-               echo "Override this function.";
+       public function execute() {
+               echo 'Override this function.';
        }
 
-
        /**
         * @private
         */
@@ -1105,6 +1108,6 @@ class QuickTemplate {
         */
        function haveMsg( $str ) {
                $msg = $this->translator->translate( $str );
-               return ($msg != '-') && ($msg != ''); # ????
+               return ( $msg != '-' ) && ( $msg != '' ); # ????
        }
-}
+}
\ No newline at end of file