r61786 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61785‎ | r61786 | r61787 >
Date:13:52, 1 February 2010
Author:ashley
Status:ok
Tags:
Comment:
Skin class: documentation and spacing tweaks, shortened some long lines, added braces
Modified paths:
  • /trunk/phase3/includes/Skin.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Skin.php
@@ -3,8 +3,9 @@
44 * @defgroup Skins Skins
55 */
66
7 -if ( ! defined( 'MEDIAWIKI' ) )
 7+if ( !defined( 'MEDIAWIKI' ) ) {
88 die( 1 );
 9+}
910
1011 /**
1112 * The main skin class that provide methods and properties for all other skins.
@@ -28,12 +29,13 @@
2930 var $mTitle = null;
3031
3132 /** Constructor, call parent constructor */
32 - function Skin() { parent::__construct(); }
 33+ function __construct() {
 34+ parent::__construct();
 35+ }
3336
3437 /**
3538 * Fetch the set of available skins.
3639 * @return array of strings
37 - * @static
3840 */
3941 static function getSkinNames() {
4042 global $wgValidSkinNames;
@@ -53,7 +55,7 @@
5456 $matches = array();
5557 if( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) {
5658 $aSkin = $matches[1];
57 - $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
 59+ $wgValidSkinNames[strtolower( $aSkin )] = $aSkin;
5860 }
5961 }
6062 $skinDir->close();
@@ -82,9 +84,8 @@
8385 * Normalize a skin preference value to a form that can be loaded.
8486 * If a skin can't be found, it will fall back to the configured
8587 * default (or the old 'Classic' skin if that's broken).
86 - * @param string $key
 88+ * @param $key String: 'monobook', 'standard', etc.
8789 * @return string
88 - * @static
8990 */
9091 static function normalizeKey( $key ) {
9192 global $wgDefaultSkin;
@@ -105,9 +106,10 @@
106107 $fallback = array(
107108 0 => $wgDefaultSkin,
108109 1 => 'nostalgia',
109 - 2 => 'cologneblue' );
 110+ 2 => 'cologneblue'
 111+ );
110112
111 - if( isset( $fallback[$key] ) ){
 113+ if( isset( $fallback[$key] ) ) {
112114 $key = $fallback[$key];
113115 }
114116
@@ -120,9 +122,8 @@
121123
122124 /**
123125 * Factory method for loading a skin of a given type
124 - * @param string $key 'monobook', 'standard', etc
 126+ * @param $key String: 'monobook', 'standard', etc.
125127 * @return Skin
126 - * @static
127128 */
128129 static function &newFromKey( $key ) {
129130 global $wgStyleDirectory;
@@ -131,13 +132,15 @@
132133
133134 $skinNames = Skin::getSkinNames();
134135 $skinName = $skinNames[$key];
135 - $className = 'Skin'.ucfirst($key);
 136+ $className = 'Skin' . ucfirst( $key );
136137
137138 # Grab the skin class and initialise it.
138139 if ( !class_exists( $className ) ) {
139140 // Preload base classes to work around APC/PHP5 bug
140141 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
141 - if( file_exists( $deps ) ) include_once( $deps );
 142+ if( file_exists( $deps ) ) {
 143+ include_once( $deps );
 144+ }
142145 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
143146
144147 # Check if we got if not failback to default skin
@@ -168,7 +171,9 @@
169172 function qbSetting() {
170173 global $wgOut, $wgUser;
171174
172 - if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
 175+ if ( $wgOut->isQuickbarSuppressed() ) {
 176+ return 0;
 177+ }
173178 $q = $wgUser->getOption( 'quickbar', 0 );
174179 return $q;
175180 }
@@ -180,7 +185,7 @@
181186
182187 # Generally the order of the favicon and apple-touch-icon links
183188 # should not matter, but Konqueror (3.5.9 at least) incorrectly
184 - # uses whichever one appears later in the HTML source. Make sure
 189+ # uses whichever one appears later in the HTML source. Make sure
185190 # apple-touch-icon is specified first to avoid this.
186191 if( false !== $wgAppleTouchIcon ) {
187192 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
@@ -229,6 +234,11 @@
230235 $lb->execute();
231236 }
232237
 238+ /**
 239+ * Adds metadata links (Creative Commons/Dublin Core/copyright) to the HTML
 240+ * output.
 241+ * @param $out Object: instance of OutputPage
 242+ */
233243 function addMetadataLinks( OutputPage $out ) {
234244 global $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
235245 global $wgRightsPage, $wgRightsUrl;
@@ -271,7 +281,7 @@
272282 /**
273283 * Set some local variables
274284 */
275 - protected function setMembers(){
 285+ protected function setMembers() {
276286 global $wgUser;
277287 $this->mUser = $wgUser;
278288 $this->userpage = $wgUser->getUserPage()->getPrefixedText();
@@ -291,6 +301,10 @@
292302 return $this->mTitle;
293303 }
294304
 305+ /**
 306+ * Outputs the HTML generated by other functions.
 307+ * @param $out Object: instance of OutputPage
 308+ */
295309 function outputPage( OutputPage $out ) {
296310 global $wgDebugComments;
297311 wfProfileIn( __METHOD__ );
@@ -416,25 +430,26 @@
417431 $vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
418432 }
419433
420 - //if on upload page output the extension list & js_upload
421 - if( SpecialPage::resolveAlias( $wgTitle->getDBkey() ) == "Upload" ) {
 434+ // if on upload page output the extension list & js_upload
 435+ if( SpecialPage::resolveAlias( $wgTitle->getDBkey() ) == 'Upload' ) {
422436 global $wgFileExtensions, $wgAjaxUploadInterface;
423437 $vars['wgFileExtensions'] = $wgFileExtensions;
424438 }
425439
426 - if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ){
 440+ if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ) {
427441 $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
428442 $vars['wgDBname'] = $wgDBname;
429443 $vars['wgSearchNamespaces'] = SearchEngine::userNamespaces( $wgUser );
430444 $vars['wgMWSuggestMessages'] = array( wfMsg( 'search-mwsuggest-enabled' ), wfMsg( 'search-mwsuggest-disabled' ) );
431445 }
432446
433 - foreach( $wgRestrictionTypes as $type )
 447+ foreach( $wgRestrictionTypes as $type ) {
434448 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
 449+ }
435450
436451 if ( $wgOut->isArticleRelated() && $wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
437452 $msgs = (object)array();
438 - foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching',
 453+ foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching',
439454 'tooltip-ca-watch', 'tooltip-ca-unwatch' ) as $msgName ) {
440455 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
441456 }
@@ -454,26 +469,30 @@
455470 * passed back with the preview request, we won't render
456471 * the code.
457472 *
458 - * @param string $action
 473+ * @param $action String: 'edit', 'submit' etc.
459474 * @return bool
460475 */
461476 public function userCanPreview( $action ) {
462477 global $wgRequest, $wgUser;
463478
464 - if( $action != 'submit' )
 479+ if( $action != 'submit' ) {
465480 return false;
466 - if( !$wgRequest->wasPosted() )
 481+ }
 482+ if( !$wgRequest->wasPosted() ) {
467483 return false;
468 - if( !$this->mTitle->userCanEditCssSubpage() )
 484+ }
 485+ if( !$this->mTitle->userCanEditCssSubpage() ) {
469486 return false;
470 - if( !$this->mTitle->userCanEditJsSubpage() )
 487+ }
 488+ if( !$this->mTitle->userCanEditJsSubpage() ) {
471489 return false;
 490+ }
472491 return $wgUser->matchEditToken(
473492 $wgRequest->getVal( 'wpEditToken' ) );
474493 }
475494
476495 /**
477 - * generated JavaScript action=raw&gen=js
 496+ * Generated JavaScript action=raw&gen=js
478497 * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
479498 * nated together. For some bizarre reason, it does *not* return any
480499 * custom user JS from subpages. Huh?
@@ -483,8 +502,7 @@
484503 * top. For now Monobook.js will be maintained, but it should be consi-
485504 * dered deprecated.
486505 *
487 - * @param $force_skin string If set, overrides the skin name
488 - *
 506+ * @param $skinName String: If set, overrides the skin name
489507 * @return string
490508 */
491509 public function generateUserJs( $skinName = null ) {
@@ -496,7 +514,7 @@
497515 }
498516
499517 $s = "/* generated javascript */\n";
500 - $s .= "var skin = '" . Xml::escapeJsString($skinName ) . "';\n";
 518+ $s .= "var skin = '" . Xml::escapeJsString( $skinName ) . "';\n";
501519 $s .= "var stylepath = '" . Xml::escapeJsString( $wgStylePath ) . "';";
502520 $s .= "\n\n/* MediaWiki:Common.js */\n";
503521 $commonJs = wfMsgExt( 'common.js', 'content' );
@@ -504,7 +522,7 @@
505523 $s .= $commonJs;
506524 }
507525
508 - $s .= "\n\n/* MediaWiki:".ucfirst( $skinName ).".js */\n";
 526+ $s .= "\n\n/* MediaWiki:" . ucfirst( $skinName ) . ".js */\n";
509527 // avoid inclusion of non defined user JavaScript (with custom skins only)
510528 // by checking for default message content
511529 $msgKey = ucfirst( $skinName ) . '.js';
@@ -531,7 +549,7 @@
532550 /**
533551 * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
534552 */
535 - protected function reallyGenerateUserStylesheet(){
 553+ protected function reallyGenerateUserStylesheet() {
536554 global $wgUser;
537555 $s = '';
538556 if( ( $undopt = $wgUser->getOption( 'underline' ) ) < 2 ) {
@@ -632,8 +650,10 @@
633651 // @FIXME: properly escape the cdata!
634652 $out->addInlineStyle( $wgRequest->getText( 'wpTextbox1' ) );
635653 } else {
636 - $out->addStyle( self::makeUrl( $this->userpage . '/' . $this->getSkinName() .'.css',
637 - 'action=raw&ctype=text/css' ) );
 654+ $out->addStyle( self::makeUrl(
 655+ $this->userpage . '/' . $this->getSkinName() . '.css',
 656+ 'action=raw&ctype=text/css' )
 657+ );
638658 }
639659 }
640660
@@ -652,7 +672,7 @@
653673 }
654674
655675 function getPageClasses( $title ) {
656 - $numeric = 'ns-'.$title->getNamespace();
 676+ $numeric = 'ns-' . $title->getNamespace();
657677 if( $title->getNamespace() == NS_SPECIAL ) {
658678 $type = 'ns-special';
659679 } elseif( $title->isTalkPage() ) {
@@ -660,7 +680,7 @@
661681 } else {
662682 $type = 'ns-subject';
663683 }
664 - $name = Sanitizer::escapeClass( 'page-'.$title->getPrefixedText() );
 684+ $name = Sanitizer::escapeClass( 'page-' . $title->getPrefixedText() );
665685 return "$numeric $type $name";
666686 }
667687
@@ -687,7 +707,8 @@
688708 $s = '';
689709 $qb = $this->qbSetting();
690710
691 - if( $langlinks = $this->otherLanguages() ) {
 711+ $langlinks = $this->otherLanguages();
 712+ if( $langlinks ) {
692713 $rows = 2;
693714 $borderhack = '';
694715 } else {
@@ -701,11 +722,13 @@
702723
703724 $shove = ( $qb != 0 );
704725 $left = ( $qb == 1 || $qb == 3 );
705 - if( $wgContLang->isRTL() ) $left = !$left;
 726+ if( $wgContLang->isRTL() ) {
 727+ $left = !$left;
 728+ }
706729
707730 if( !$shove ) {
708731 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
709 - $this->logoText() . '</td>';
 732+ $this->logoText() . '</td>';
710733 } elseif( $left ) {
711734 $s .= $this->getQuickbarCompensator( $rows );
712735 }
@@ -713,12 +736,12 @@
714737 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
715738
716739 $s .= $this->topLinks();
717 - $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
 740+ $s .= '<p class="subtitle">' . $this->pageTitleLinks() . "</p>\n";
718741
719742 $r = $wgContLang->alignEnd();
720743 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
721744 $s .= $this->nameAndLogin();
722 - $s .= "\n<br />" . $this->searchForm() . "</td>";
 745+ $s .= "\n<br />" . $this->searchForm() . '</td>';
723746
724747 if ( $langlinks ) {
725748 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
@@ -741,12 +764,13 @@
742765 return $s;
743766 }
744767
745 -
746768 function getCategoryLinks() {
747769 global $wgOut, $wgUseCategoryBrowser;
748770 global $wgContLang, $wgUser;
749771
750 - if( count( $wgOut->mCategoryLinks ) == 0 ) return '';
 772+ if( count( $wgOut->mCategoryLinks ) == 0 ) {
 773+ return '';
 774+ }
751775
752776 # Separator
753777 $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) );
@@ -781,12 +805,12 @@
782806 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
783807 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
784808 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
785 - "</div>";
 809+ '</div>';
786810 }
787811
788812 # optional 'dmoz-like' category browser. Will be shown under the list
789813 # of categories an article belong to
790 - if( $wgUseCategoryBrowser ){
 814+ if( $wgUseCategoryBrowser ) {
791815 $s .= '<br /><hr />';
792816
793817 # get a big array of the parents tree
@@ -810,7 +834,7 @@
811835 * @param &skin Object: skin passed by reference
812836 * @return String separated by &gt;, terminate with "\n"
813837 */
814 - function drawCategoryBrowser( $tree, &$skin ){
 838+ function drawCategoryBrowser( $tree, &$skin ) {
815839 $return = '';
816840 foreach( $tree as $element => $parent ) {
817841 if( empty( $parent ) ) {
@@ -838,7 +862,7 @@
839863 $showHidden = $wgUser->getBoolOption( 'showhiddencats' ) ||
840864 $this->mTitle->getNamespace() == NS_CATEGORY;
841865
842 - if( empty($allCats['normal']) && !( !empty($allCats['hidden']) && $showHidden ) ) {
 866+ if( empty( $allCats['normal'] ) && !( !empty( $allCats['hidden'] ) && $showHidden ) ) {
843867 $classes .= ' catlinks-allhidden';
844868 }
845869
@@ -866,10 +890,10 @@
867891 protected function afterContentHook() {
868892 $data = '';
869893
870 - if( wfRunHooks( 'SkinAfterContent', array( &$data ) ) ){
 894+ if( wfRunHooks( 'SkinAfterContent', array( &$data ) ) ) {
871895 // adding just some spaces shouldn't toggle the output
872896 // of the whole <div/>, so we use trim() here
873 - if( trim( $data ) != '' ){
 897+ if( trim( $data ) != '' ) {
874898 // Doing this here instead of in the skins to
875899 // ensure that the div has the same ID in all
876900 // skins
@@ -909,8 +933,9 @@
910934 $ident = strlen( $line ) - strlen( $display );
911935 $diff = $ident - $curIdent;
912936
913 - if ( $display == '' )
 937+ if ( $display == '' ) {
914938 $display = "\xc2\xa0";
 939+ }
915940
916941 if ( !$ident && $diff < 0 && substr( $display, 0, 9 ) != 'Entering ' && substr( $display, 0, 8 ) != 'Exiting ' ) {
917942 $ident = $curIdent;
@@ -920,12 +945,13 @@
921946 $display = htmlspecialchars( $display );
922947 }
923948
924 - if ( $diff < 0 )
 949+ if ( $diff < 0 ) {
925950 $ret .= str_repeat( "</li></ul>\n", -$diff ) . "</li><li>\n";
926 - elseif ( $diff == 0 )
 951+ } elseif ( $diff == 0 ) {
927952 $ret .= "</li><li>\n";
928 - else
 953+ } else {
929954 $ret .= str_repeat( "<ul><li>\n", $diff );
 955+ }
930956 $ret .= $display . "\n";
931957
932958 $curIdent = $ident;
@@ -956,7 +982,7 @@
957983 /** @return string Retrievied from HTML text */
958984 function printSource() {
959985 $url = htmlspecialchars( $this->mTitle->getFullURL() );
960 - return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
 986+ return wfMsg( 'retrievedfrom', '<a href="' . $url . '">' . $url . '</a>' );
961987 }
962988
963989 function printFooter() {
@@ -965,7 +991,9 @@
966992 }
967993
968994 /** overloaded by derived classes */
969 - function doAfterContent() { return '</div></div>'; }
 995+ function doAfterContent() {
 996+ return '</div></div>';
 997+ }
970998
971999 function pageTitleLinks() {
9721000 global $wgOut, $wgUser, $wgRequest, $wgLang;
@@ -1087,6 +1115,10 @@
10881116 return $wgLang->pipeList( $s );
10891117 }
10901118
 1119+ /**
 1120+ * Gets the h1 element with the page title.
 1121+ * @return string
 1122+ */
10911123 function pageTitle() {
10921124 global $wgOut;
10931125 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
@@ -1109,8 +1141,9 @@
11101142
11111143 function subPageSubtitle() {
11121144 $subpages = '';
1113 - if( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages ) ) )
 1145+ if( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages ) ) ) {
11141146 return $subpages;
 1147+ }
11151148
11161149 global $wgOut;
11171150 if( $wgOut->isArticle() && MWNamespace::hasSubpages( $this->mTitle->getNamespace() ) ) {
@@ -1125,7 +1158,7 @@
11261159 $growinglink .= $link;
11271160 $display .= $link;
11281161 $linkObj = Title::newFromText( $growinglink );
1129 - if( is_object( $linkObj ) && $linkObj->exists() ){
 1162+ if( is_object( $linkObj ) && $linkObj->exists() ) {
11301163 $getlink = $this->link(
11311164 $linkObj,
11321165 htmlspecialchars( $display ),
@@ -1230,16 +1263,17 @@
12311264 global $wgRequest, $wgUseTwoButtonsSearchForm;
12321265 $search = $wgRequest->getText( 'search' );
12331266
1234 - $s = '<form id="searchform'.$this->searchboxes.'" name="search" class="inline" method="post" action="'
 1267+ $s = '<form id="searchform' . $this->searchboxes . '" name="search" class="inline" method="post" action="'
12351268 . $this->escapeSearchLink() . "\">\n"
1236 - . '<input type="text" id="searchInput'.$this->searchboxes.'" name="search" size="19" value="'
 1269+ . '<input type="text" id="searchInput' . $this->searchboxes . '" name="search" size="19" value="'
12371270 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
12381271 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
12391272
1240 - if( $wgUseTwoButtonsSearchForm )
 1273+ if( $wgUseTwoButtonsSearchForm ) {
12411274 $s .= '&nbsp;<input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
1242 - else
 1275+ } else {
12431276 $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
 1277+ }
12441278
12451279 $s .= '</form>';
12461280
@@ -1315,11 +1349,12 @@
13161350 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
13171351 foreach( $variants as $code ) {
13181352 $varname = $wgContLang->getVariantname( $code );
1319 - if( $varname == 'disable' )
 1353+ if( $varname == 'disable' ) {
13201354 continue;
 1355+ }
13211356 $s = $wgLang->pipeList( array(
13221357 $s,
1323 - '<a href="' . $this->mTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
 1358+ '<a href="' . $this->mTitle->escapeLocalURL( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
13241359 ) );
13251360 }
13261361 }
@@ -1341,15 +1376,20 @@
13421377 $element[] = $this->whatLinksHere();
13431378 $element[] = $this->watchPageLinksLink();
13441379
1345 - if( $wgUseTrackbacks )
 1380+ if( $wgUseTrackbacks ) {
13461381 $element[] = $this->trackbackLink();
 1382+ }
13471383
1348 - if ( $this->mTitle->getNamespace() == NS_USER
1349 - || $this->mTitle->getNamespace() == NS_USER_TALK ){
 1384+ if (
 1385+ $this->mTitle->getNamespace() == NS_USER ||
 1386+ $this->mTitle->getNamespace() == NS_USER_TALK
 1387+ )
 1388+ {
13501389 $id = User::idFromName( $this->mTitle->getText() );
13511390 $ip = User::isIP( $this->mTitle->getText() );
13521391
1353 - if( $id || $ip ) { # both anons and non-anons have contri list
 1392+ # Both anons and non-anons have contributions list
 1393+ if( $id || $ip ) {
13541394 $element[] = $this->userContribsLink();
13551395 }
13561396 if( $this->showEmailUser( $id ) ) {
@@ -1361,9 +1401,16 @@
13621402
13631403 if ( $this->mTitle->getArticleId() ) {
13641404 $s .= "\n<br />";
1365 - if( $wgUser->isAllowed( 'delete' ) ) { $s .= $this->deleteThisPage(); }
1366 - if( $wgUser->isAllowed( 'protect' ) ) { $s .= $sep . $this->protectThisPage(); }
1367 - if( $wgUser->isAllowed( 'move' ) ) { $s .= $sep . $this->moveThisPage(); }
 1405+ // Delete/protect/move links for privileged users
 1406+ if( $wgUser->isAllowed( 'delete' ) ) {
 1407+ $s .= $this->deleteThisPage();
 1408+ }
 1409+ if( $wgUser->isAllowed( 'protect' ) ) {
 1410+ $s .= $sep . $this->protectThisPage();
 1411+ }
 1412+ if( $wgUser->isAllowed( 'move' ) ) {
 1413+ $s .= $sep . $this->moveThisPage();
 1414+ }
13681415 }
13691416 $s .= "<br />\n" . $this->otherLanguages();
13701417 }
@@ -1377,10 +1424,18 @@
13781425
13791426 $oldid = $wgRequest->getVal( 'oldid' );
13801427 $diff = $wgRequest->getVal( 'diff' );
1381 - if ( ! $wgOut->isArticle() ) { return ''; }
1382 - if( !$wgArticle instanceOf Article ) { return ''; }
1383 - if ( isset( $oldid ) || isset( $diff ) ) { return ''; }
1384 - if ( 0 == $wgArticle->getID() ) { return ''; }
 1428+ if ( !$wgOut->isArticle() ) {
 1429+ return '';
 1430+ }
 1431+ if( !$wgArticle instanceof Article ) {
 1432+ return '';
 1433+ }
 1434+ if ( isset( $oldid ) || isset( $diff ) ) {
 1435+ return '';
 1436+ }
 1437+ if ( 0 == $wgArticle->getID() ) {
 1438+ return '';
 1439+ }
13851440
13861441 $s = '';
13871442 if ( !$wgDisableCounters ) {
@@ -1390,7 +1445,7 @@
13911446 }
13921447 }
13931448
1394 - if( $wgMaxCredits != 0 ){
 1449+ if( $wgMaxCredits != 0 ) {
13951450 $s .= ' ' . Credits::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
13961451 } else {
13971452 $s .= $this->lastModified();
@@ -1398,9 +1453,13 @@
13991454
14001455 if( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
14011456 $dbr = wfGetDB( DB_SLAVE );
1402 - $res = $dbr->select( 'watchlist',
 1457+ $res = $dbr->select(
 1458+ 'watchlist',
14031459 array( 'COUNT(*) AS n' ),
1404 - array( 'wl_title' => $dbr->strencode( $this->mTitle->getDBkey() ), 'wl_namespace' => $this->mTitle->getNamespace() ),
 1460+ array(
 1461+ 'wl_title' => $dbr->strencode( $this->mTitle->getDBkey() ),
 1462+ 'wl_namespace' => $this->mTitle->getNamespace()
 1463+ ),
14051464 __METHOD__
14061465 );
14071466 $x = $dbr->fetchObject( $res );
@@ -1445,8 +1504,9 @@
14461505 return $out;
14471506 }
14481507 // Allow for site and per-namespace customization of copyright notice.
1449 - if( isset($wgArticle) )
 1508+ if( isset( $wgArticle ) ) {
14501509 wfRunHooks( 'SkinCopyrightFooter', array( $wgArticle->getTitle(), $type, &$msg, &$link ) );
 1510+ }
14511511
14521512 $out .= wfMsgForContent( $msg, $link );
14531513 return $out;
@@ -1457,7 +1517,7 @@
14581518 $out = '';
14591519 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
14601520 $out = $wgCopyrightIcon;
1461 - } else if ( $wgRightsIcon ) {
 1521+ } elseif ( $wgRightsIcon ) {
14621522 $icon = htmlspecialchars( $wgRightsIcon );
14631523 if ( $wgRightsUrl ) {
14641524 $url = htmlspecialchars( $wgRightsUrl );
@@ -1472,16 +1532,20 @@
14731533 return $out;
14741534 }
14751535
 1536+ /**
 1537+ * Gets the powered by MediaWiki icon.
 1538+ * @return string
 1539+ */
14761540 function getPoweredBy() {
14771541 global $wgStylePath;
14781542 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1479 - $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" height="31" width="88" alt="Powered by MediaWiki" /></a>';
 1543+ $img = '<a href="http://www.mediawiki.org/"><img src="' . $url . '" height="31" width="88" alt="Powered by MediaWiki" /></a>';
14801544 return $img;
14811545 }
14821546
14831547 function lastModified() {
14841548 global $wgLang, $wgArticle;
1485 - if( $this->mRevisionId && $this->mRevisionId != $wgArticle->getLatest()) {
 1549+ if( $this->mRevisionId && $this->mRevisionId != $wgArticle->getLatest() ) {
14861550 $timestamp = Revision::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId );
14871551 } else {
14881552 $timestamp = $wgArticle->getTimestamp();
@@ -1516,7 +1580,7 @@
15171581 }
15181582
15191583 /**
1520 - * show a drop-down box of special pages
 1584+ * Show a drop-down box of special pages
15211585 */
15221586 function specialPagesList() {
15231587 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
@@ -1545,6 +1609,10 @@
15461610 return $s;
15471611 }
15481612
 1613+ /**
 1614+ * Gets the link to the wiki's main page.
 1615+ * @return string
 1616+ */
15491617 function mainPageLink() {
15501618 $s = $this->link(
15511619 Title::newMainPage(),
@@ -1556,7 +1624,7 @@
15571625 return $s;
15581626 }
15591627
1560 - private function footerLink ( $desc, $page ) {
 1628+ private function footerLink( $desc, $page ) {
15611629 // if the link description has been set to "-" in the default language,
15621630 if ( wfMsgForContent( $desc ) == '-') {
15631631 // then it is disabled, for all languages.
@@ -1573,14 +1641,23 @@
15741642 }
15751643 }
15761644
 1645+ /**
 1646+ * Gets the link to the wiki's privacy policy page.
 1647+ */
15771648 function privacyLink() {
15781649 return $this->footerLink( 'privacy', 'privacypage' );
15791650 }
15801651
 1652+ /**
 1653+ * Gets the link to the wiki's about page.
 1654+ */
15811655 function aboutLink() {
15821656 return $this->footerLink( 'aboutsite', 'aboutpage' );
15831657 }
15841658
 1659+ /**
 1660+ * Gets the link to the wiki's general disclaimers page.
 1661+ */
15851662 function disclaimerLink() {
15861663 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
15871664 }
@@ -1750,7 +1827,7 @@
17511828 function showEmailUser( $id ) {
17521829 global $wgUser;
17531830 $targetUser = User::newFromId( $id );
1754 - return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
 1831+ return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
17551832 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
17561833 }
17571834
@@ -1766,7 +1843,7 @@
17671844
17681845 function watchPageLinksLink() {
17691846 global $wgOut;
1770 - if ( ! $wgOut->isArticleRelated() ) {
 1847+ if ( !$wgOut->isArticleRelated() ) {
17711848 return '(' . wfMsg( 'notanarticle' ) . ')';
17721849 } else {
17731850 return $this->link(
@@ -1798,7 +1875,9 @@
17991876
18001877 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
18011878 $first = true;
1802 - if( $wgContLang->isRTL() ) $s .= '<span dir="LTR">';
 1879+ if( $wgContLang->isRTL() ) {
 1880+ $s .= '<span dir="LTR">';
 1881+ }
18031882 foreach( $a as $l ) {
18041883 if ( !$first ) {
18051884 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
@@ -1809,11 +1888,15 @@
18101889 $url = $nt->escapeFullURL();
18111890 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
18121891
1813 - if ( $text == '' ) { $text = $l; }
 1892+ if ( $text == '' ) {
 1893+ $text = $l;
 1894+ }
18141895 $style = $this->getExternalLinkAttributes();
18151896 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
18161897 }
1817 - if( $wgContLang->isRTL() ) $s .= '</span>';
 1898+ if( $wgContLang->isRTL() ) {
 1899+ $s .= '</span>';
 1900+ }
18181901 return $s;
18191902 }
18201903
@@ -1927,8 +2010,10 @@
19282011 return $title->getLocalURL( $urlaction );
19292012 }
19302013
1931 - # If url string starts with http, consider as external URL, else
1932 - # internal
 2014+ /**
 2015+ * If url string starts with http, consider as external URL, else
 2016+ * internal
 2017+ */
19332018 static function makeInternalOrExternalUrl( $name ) {
19342019 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
19352020 return $name;
@@ -2000,14 +2085,16 @@
20012086 $this->addToSidebar( $bar, 'sidebar' );
20022087
20032088 wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
2004 - if ( $wgEnableSidebarCache ) $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
 2089+ if ( $wgEnableSidebarCache ) {
 2090+ $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
 2091+ }
20052092 wfProfileOut( __METHOD__ );
20062093 return $bar;
20072094 }
20082095 /**
20092096 * Add content from a sidebar system message
20102097 * Currently only used for MediaWiki:Sidebar (but may be used by Extensions)
2011 - *
 2098+ *
20122099 * @param &$bar array
20132100 * @param $message String
20142101 */
@@ -2015,23 +2102,29 @@
20162103 $lines = explode( "\n", wfMsgForContent( $message ) );
20172104 $heading = '';
20182105 foreach( $lines as $line ) {
2019 - if( strpos( $line, '*' ) !== 0 )
 2106+ if( strpos( $line, '*' ) !== 0 ) {
20202107 continue;
 2108+ }
20212109 if( strpos( $line, '**') !== 0 ) {
20222110 $heading = trim( $line, '* ' );
2023 - if( !array_key_exists( $heading, $bar ) ) $bar[$heading] = array();
 2111+ if( !array_key_exists( $heading, $bar ) ) {
 2112+ $bar[$heading] = array();
 2113+ }
20242114 } else {
20252115 if( strpos( $line, '|' ) !== false ) { // sanity check
20262116 $line = array_map( 'trim', explode( '|', trim( $line, '* ' ), 2 ) );
20272117 $link = wfMsgForContent( $line[0] );
2028 - if( $link == '-' )
 2118+ if( $link == '-' ) {
20292119 continue;
 2120+ }
20302121
20312122 $text = wfMsgExt( $line[1], 'parsemag' );
2032 - if( wfEmptyMsg( $line[1], $text ) )
 2123+ if( wfEmptyMsg( $line[1], $text ) ) {
20332124 $text = $line[1];
2034 - if( wfEmptyMsg( $line[0], $link ) )
 2125+ }
 2126+ if( wfEmptyMsg( $line[0], $link ) ) {
20352127 $link = $line[0];
 2128+ }
20362129
20372130 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
20382131 $href = $link;
@@ -2051,7 +2144,9 @@
20522145 'id' => 'n-' . strtr( $line[1], ' ', '-' ),
20532146 'active' => false
20542147 );
2055 - } else { continue; }
 2148+ } else {
 2149+ continue;
 2150+ }
20562151 }
20572152 }
20582153 }

Status & tagging log