Index: trunk/phase3/includes/Skin.php |
— | — | @@ -3,8 +3,9 @@ |
4 | 4 | * @defgroup Skins Skins |
5 | 5 | */ |
6 | 6 | |
7 | | -if ( ! defined( 'MEDIAWIKI' ) ) |
| 7 | +if ( !defined( 'MEDIAWIKI' ) ) { |
8 | 8 | die( 1 ); |
| 9 | +} |
9 | 10 | |
10 | 11 | /** |
11 | 12 | * The main skin class that provide methods and properties for all other skins. |
— | — | @@ -28,12 +29,13 @@ |
29 | 30 | var $mTitle = null; |
30 | 31 | |
31 | 32 | /** Constructor, call parent constructor */ |
32 | | - function Skin() { parent::__construct(); } |
| 33 | + function __construct() { |
| 34 | + parent::__construct(); |
| 35 | + } |
33 | 36 | |
34 | 37 | /** |
35 | 38 | * Fetch the set of available skins. |
36 | 39 | * @return array of strings |
37 | | - * @static |
38 | 40 | */ |
39 | 41 | static function getSkinNames() { |
40 | 42 | global $wgValidSkinNames; |
— | — | @@ -53,7 +55,7 @@ |
54 | 56 | $matches = array(); |
55 | 57 | if( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) { |
56 | 58 | $aSkin = $matches[1]; |
57 | | - $wgValidSkinNames[strtolower($aSkin)] = $aSkin; |
| 59 | + $wgValidSkinNames[strtolower( $aSkin )] = $aSkin; |
58 | 60 | } |
59 | 61 | } |
60 | 62 | $skinDir->close(); |
— | — | @@ -82,9 +84,8 @@ |
83 | 85 | * Normalize a skin preference value to a form that can be loaded. |
84 | 86 | * If a skin can't be found, it will fall back to the configured |
85 | 87 | * default (or the old 'Classic' skin if that's broken). |
86 | | - * @param string $key |
| 88 | + * @param $key String: 'monobook', 'standard', etc. |
87 | 89 | * @return string |
88 | | - * @static |
89 | 90 | */ |
90 | 91 | static function normalizeKey( $key ) { |
91 | 92 | global $wgDefaultSkin; |
— | — | @@ -105,9 +106,10 @@ |
106 | 107 | $fallback = array( |
107 | 108 | 0 => $wgDefaultSkin, |
108 | 109 | 1 => 'nostalgia', |
109 | | - 2 => 'cologneblue' ); |
| 110 | + 2 => 'cologneblue' |
| 111 | + ); |
110 | 112 | |
111 | | - if( isset( $fallback[$key] ) ){ |
| 113 | + if( isset( $fallback[$key] ) ) { |
112 | 114 | $key = $fallback[$key]; |
113 | 115 | } |
114 | 116 | |
— | — | @@ -120,9 +122,8 @@ |
121 | 123 | |
122 | 124 | /** |
123 | 125 | * Factory method for loading a skin of a given type |
124 | | - * @param string $key 'monobook', 'standard', etc |
| 126 | + * @param $key String: 'monobook', 'standard', etc. |
125 | 127 | * @return Skin |
126 | | - * @static |
127 | 128 | */ |
128 | 129 | static function &newFromKey( $key ) { |
129 | 130 | global $wgStyleDirectory; |
— | — | @@ -131,13 +132,15 @@ |
132 | 133 | |
133 | 134 | $skinNames = Skin::getSkinNames(); |
134 | 135 | $skinName = $skinNames[$key]; |
135 | | - $className = 'Skin'.ucfirst($key); |
| 136 | + $className = 'Skin' . ucfirst( $key ); |
136 | 137 | |
137 | 138 | # Grab the skin class and initialise it. |
138 | 139 | if ( !class_exists( $className ) ) { |
139 | 140 | // Preload base classes to work around APC/PHP5 bug |
140 | 141 | $deps = "{$wgStyleDirectory}/{$skinName}.deps.php"; |
141 | | - if( file_exists( $deps ) ) include_once( $deps ); |
| 142 | + if( file_exists( $deps ) ) { |
| 143 | + include_once( $deps ); |
| 144 | + } |
142 | 145 | require_once( "{$wgStyleDirectory}/{$skinName}.php" ); |
143 | 146 | |
144 | 147 | # Check if we got if not failback to default skin |
— | — | @@ -168,7 +171,9 @@ |
169 | 172 | function qbSetting() { |
170 | 173 | global $wgOut, $wgUser; |
171 | 174 | |
172 | | - if ( $wgOut->isQuickbarSuppressed() ) { return 0; } |
| 175 | + if ( $wgOut->isQuickbarSuppressed() ) { |
| 176 | + return 0; |
| 177 | + } |
173 | 178 | $q = $wgUser->getOption( 'quickbar', 0 ); |
174 | 179 | return $q; |
175 | 180 | } |
— | — | @@ -180,7 +185,7 @@ |
181 | 186 | |
182 | 187 | # Generally the order of the favicon and apple-touch-icon links |
183 | 188 | # 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 |
185 | 190 | # apple-touch-icon is specified first to avoid this. |
186 | 191 | if( false !== $wgAppleTouchIcon ) { |
187 | 192 | $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) ); |
— | — | @@ -229,6 +234,11 @@ |
230 | 235 | $lb->execute(); |
231 | 236 | } |
232 | 237 | |
| 238 | + /** |
| 239 | + * Adds metadata links (Creative Commons/Dublin Core/copyright) to the HTML |
| 240 | + * output. |
| 241 | + * @param $out Object: instance of OutputPage |
| 242 | + */ |
233 | 243 | function addMetadataLinks( OutputPage $out ) { |
234 | 244 | global $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf; |
235 | 245 | global $wgRightsPage, $wgRightsUrl; |
— | — | @@ -271,7 +281,7 @@ |
272 | 282 | /** |
273 | 283 | * Set some local variables |
274 | 284 | */ |
275 | | - protected function setMembers(){ |
| 285 | + protected function setMembers() { |
276 | 286 | global $wgUser; |
277 | 287 | $this->mUser = $wgUser; |
278 | 288 | $this->userpage = $wgUser->getUserPage()->getPrefixedText(); |
— | — | @@ -291,6 +301,10 @@ |
292 | 302 | return $this->mTitle; |
293 | 303 | } |
294 | 304 | |
| 305 | + /** |
| 306 | + * Outputs the HTML generated by other functions. |
| 307 | + * @param $out Object: instance of OutputPage |
| 308 | + */ |
295 | 309 | function outputPage( OutputPage $out ) { |
296 | 310 | global $wgDebugComments; |
297 | 311 | wfProfileIn( __METHOD__ ); |
— | — | @@ -416,25 +430,26 @@ |
417 | 431 | $vars['wgUserVariant'] = $wgContLang->getPreferredVariant(); |
418 | 432 | } |
419 | 433 | |
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' ) { |
422 | 436 | global $wgFileExtensions, $wgAjaxUploadInterface; |
423 | 437 | $vars['wgFileExtensions'] = $wgFileExtensions; |
424 | 438 | } |
425 | 439 | |
426 | | - if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ){ |
| 440 | + if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ) { |
427 | 441 | $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate(); |
428 | 442 | $vars['wgDBname'] = $wgDBname; |
429 | 443 | $vars['wgSearchNamespaces'] = SearchEngine::userNamespaces( $wgUser ); |
430 | 444 | $vars['wgMWSuggestMessages'] = array( wfMsg( 'search-mwsuggest-enabled' ), wfMsg( 'search-mwsuggest-disabled' ) ); |
431 | 445 | } |
432 | 446 | |
433 | | - foreach( $wgRestrictionTypes as $type ) |
| 447 | + foreach( $wgRestrictionTypes as $type ) { |
434 | 448 | $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type ); |
| 449 | + } |
435 | 450 | |
436 | 451 | if ( $wgOut->isArticleRelated() && $wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) { |
437 | 452 | $msgs = (object)array(); |
438 | | - foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching', |
| 453 | + foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching', |
439 | 454 | 'tooltip-ca-watch', 'tooltip-ca-unwatch' ) as $msgName ) { |
440 | 455 | $msgs->{$msgName . 'Msg'} = wfMsg( $msgName ); |
441 | 456 | } |
— | — | @@ -454,26 +469,30 @@ |
455 | 470 | * passed back with the preview request, we won't render |
456 | 471 | * the code. |
457 | 472 | * |
458 | | - * @param string $action |
| 473 | + * @param $action String: 'edit', 'submit' etc. |
459 | 474 | * @return bool |
460 | 475 | */ |
461 | 476 | public function userCanPreview( $action ) { |
462 | 477 | global $wgRequest, $wgUser; |
463 | 478 | |
464 | | - if( $action != 'submit' ) |
| 479 | + if( $action != 'submit' ) { |
465 | 480 | return false; |
466 | | - if( !$wgRequest->wasPosted() ) |
| 481 | + } |
| 482 | + if( !$wgRequest->wasPosted() ) { |
467 | 483 | return false; |
468 | | - if( !$this->mTitle->userCanEditCssSubpage() ) |
| 484 | + } |
| 485 | + if( !$this->mTitle->userCanEditCssSubpage() ) { |
469 | 486 | return false; |
470 | | - if( !$this->mTitle->userCanEditJsSubpage() ) |
| 487 | + } |
| 488 | + if( !$this->mTitle->userCanEditJsSubpage() ) { |
471 | 489 | return false; |
| 490 | + } |
472 | 491 | return $wgUser->matchEditToken( |
473 | 492 | $wgRequest->getVal( 'wpEditToken' ) ); |
474 | 493 | } |
475 | 494 | |
476 | 495 | /** |
477 | | - * generated JavaScript action=raw&gen=js |
| 496 | + * Generated JavaScript action=raw&gen=js |
478 | 497 | * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate- |
479 | 498 | * nated together. For some bizarre reason, it does *not* return any |
480 | 499 | * custom user JS from subpages. Huh? |
— | — | @@ -483,8 +502,7 @@ |
484 | 503 | * top. For now Monobook.js will be maintained, but it should be consi- |
485 | 504 | * dered deprecated. |
486 | 505 | * |
487 | | - * @param $force_skin string If set, overrides the skin name |
488 | | - * |
| 506 | + * @param $skinName String: If set, overrides the skin name |
489 | 507 | * @return string |
490 | 508 | */ |
491 | 509 | public function generateUserJs( $skinName = null ) { |
— | — | @@ -496,7 +514,7 @@ |
497 | 515 | } |
498 | 516 | |
499 | 517 | $s = "/* generated javascript */\n"; |
500 | | - $s .= "var skin = '" . Xml::escapeJsString($skinName ) . "';\n"; |
| 518 | + $s .= "var skin = '" . Xml::escapeJsString( $skinName ) . "';\n"; |
501 | 519 | $s .= "var stylepath = '" . Xml::escapeJsString( $wgStylePath ) . "';"; |
502 | 520 | $s .= "\n\n/* MediaWiki:Common.js */\n"; |
503 | 521 | $commonJs = wfMsgExt( 'common.js', 'content' ); |
— | — | @@ -504,7 +522,7 @@ |
505 | 523 | $s .= $commonJs; |
506 | 524 | } |
507 | 525 | |
508 | | - $s .= "\n\n/* MediaWiki:".ucfirst( $skinName ).".js */\n"; |
| 526 | + $s .= "\n\n/* MediaWiki:" . ucfirst( $skinName ) . ".js */\n"; |
509 | 527 | // avoid inclusion of non defined user JavaScript (with custom skins only) |
510 | 528 | // by checking for default message content |
511 | 529 | $msgKey = ucfirst( $skinName ) . '.js'; |
— | — | @@ -531,7 +549,7 @@ |
532 | 550 | /** |
533 | 551 | * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue |
534 | 552 | */ |
535 | | - protected function reallyGenerateUserStylesheet(){ |
| 553 | + protected function reallyGenerateUserStylesheet() { |
536 | 554 | global $wgUser; |
537 | 555 | $s = ''; |
538 | 556 | if( ( $undopt = $wgUser->getOption( 'underline' ) ) < 2 ) { |
— | — | @@ -632,8 +650,10 @@ |
633 | 651 | // @FIXME: properly escape the cdata! |
634 | 652 | $out->addInlineStyle( $wgRequest->getText( 'wpTextbox1' ) ); |
635 | 653 | } 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 | + ); |
638 | 658 | } |
639 | 659 | } |
640 | 660 | |
— | — | @@ -652,7 +672,7 @@ |
653 | 673 | } |
654 | 674 | |
655 | 675 | function getPageClasses( $title ) { |
656 | | - $numeric = 'ns-'.$title->getNamespace(); |
| 676 | + $numeric = 'ns-' . $title->getNamespace(); |
657 | 677 | if( $title->getNamespace() == NS_SPECIAL ) { |
658 | 678 | $type = 'ns-special'; |
659 | 679 | } elseif( $title->isTalkPage() ) { |
— | — | @@ -660,7 +680,7 @@ |
661 | 681 | } else { |
662 | 682 | $type = 'ns-subject'; |
663 | 683 | } |
664 | | - $name = Sanitizer::escapeClass( 'page-'.$title->getPrefixedText() ); |
| 684 | + $name = Sanitizer::escapeClass( 'page-' . $title->getPrefixedText() ); |
665 | 685 | return "$numeric $type $name"; |
666 | 686 | } |
667 | 687 | |
— | — | @@ -687,7 +707,8 @@ |
688 | 708 | $s = ''; |
689 | 709 | $qb = $this->qbSetting(); |
690 | 710 | |
691 | | - if( $langlinks = $this->otherLanguages() ) { |
| 711 | + $langlinks = $this->otherLanguages(); |
| 712 | + if( $langlinks ) { |
692 | 713 | $rows = 2; |
693 | 714 | $borderhack = ''; |
694 | 715 | } else { |
— | — | @@ -701,11 +722,13 @@ |
702 | 723 | |
703 | 724 | $shove = ( $qb != 0 ); |
704 | 725 | $left = ( $qb == 1 || $qb == 3 ); |
705 | | - if( $wgContLang->isRTL() ) $left = !$left; |
| 726 | + if( $wgContLang->isRTL() ) { |
| 727 | + $left = !$left; |
| 728 | + } |
706 | 729 | |
707 | 730 | if( !$shove ) { |
708 | 731 | $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" . |
709 | | - $this->logoText() . '</td>'; |
| 732 | + $this->logoText() . '</td>'; |
710 | 733 | } elseif( $left ) { |
711 | 734 | $s .= $this->getQuickbarCompensator( $rows ); |
712 | 735 | } |
— | — | @@ -713,12 +736,12 @@ |
714 | 737 | $s .= "<td {$borderhack} align='$l' valign='top'>\n"; |
715 | 738 | |
716 | 739 | $s .= $this->topLinks(); |
717 | | - $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n"; |
| 740 | + $s .= '<p class="subtitle">' . $this->pageTitleLinks() . "</p>\n"; |
718 | 741 | |
719 | 742 | $r = $wgContLang->alignEnd(); |
720 | 743 | $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>"; |
721 | 744 | $s .= $this->nameAndLogin(); |
722 | | - $s .= "\n<br />" . $this->searchForm() . "</td>"; |
| 745 | + $s .= "\n<br />" . $this->searchForm() . '</td>'; |
723 | 746 | |
724 | 747 | if ( $langlinks ) { |
725 | 748 | $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n"; |
— | — | @@ -741,12 +764,13 @@ |
742 | 765 | return $s; |
743 | 766 | } |
744 | 767 | |
745 | | - |
746 | 768 | function getCategoryLinks() { |
747 | 769 | global $wgOut, $wgUseCategoryBrowser; |
748 | 770 | global $wgContLang, $wgUser; |
749 | 771 | |
750 | | - if( count( $wgOut->mCategoryLinks ) == 0 ) return ''; |
| 772 | + if( count( $wgOut->mCategoryLinks ) == 0 ) { |
| 773 | + return ''; |
| 774 | + } |
751 | 775 | |
752 | 776 | # Separator |
753 | 777 | $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) ); |
— | — | @@ -781,12 +805,12 @@ |
782 | 806 | $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" . |
783 | 807 | wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) . |
784 | 808 | $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop . |
785 | | - "</div>"; |
| 809 | + '</div>'; |
786 | 810 | } |
787 | 811 | |
788 | 812 | # optional 'dmoz-like' category browser. Will be shown under the list |
789 | 813 | # of categories an article belong to |
790 | | - if( $wgUseCategoryBrowser ){ |
| 814 | + if( $wgUseCategoryBrowser ) { |
791 | 815 | $s .= '<br /><hr />'; |
792 | 816 | |
793 | 817 | # get a big array of the parents tree |
— | — | @@ -810,7 +834,7 @@ |
811 | 835 | * @param &skin Object: skin passed by reference |
812 | 836 | * @return String separated by >, terminate with "\n" |
813 | 837 | */ |
814 | | - function drawCategoryBrowser( $tree, &$skin ){ |
| 838 | + function drawCategoryBrowser( $tree, &$skin ) { |
815 | 839 | $return = ''; |
816 | 840 | foreach( $tree as $element => $parent ) { |
817 | 841 | if( empty( $parent ) ) { |
— | — | @@ -838,7 +862,7 @@ |
839 | 863 | $showHidden = $wgUser->getBoolOption( 'showhiddencats' ) || |
840 | 864 | $this->mTitle->getNamespace() == NS_CATEGORY; |
841 | 865 | |
842 | | - if( empty($allCats['normal']) && !( !empty($allCats['hidden']) && $showHidden ) ) { |
| 866 | + if( empty( $allCats['normal'] ) && !( !empty( $allCats['hidden'] ) && $showHidden ) ) { |
843 | 867 | $classes .= ' catlinks-allhidden'; |
844 | 868 | } |
845 | 869 | |
— | — | @@ -866,10 +890,10 @@ |
867 | 891 | protected function afterContentHook() { |
868 | 892 | $data = ''; |
869 | 893 | |
870 | | - if( wfRunHooks( 'SkinAfterContent', array( &$data ) ) ){ |
| 894 | + if( wfRunHooks( 'SkinAfterContent', array( &$data ) ) ) { |
871 | 895 | // adding just some spaces shouldn't toggle the output |
872 | 896 | // of the whole <div/>, so we use trim() here |
873 | | - if( trim( $data ) != '' ){ |
| 897 | + if( trim( $data ) != '' ) { |
874 | 898 | // Doing this here instead of in the skins to |
875 | 899 | // ensure that the div has the same ID in all |
876 | 900 | // skins |
— | — | @@ -909,8 +933,9 @@ |
910 | 934 | $ident = strlen( $line ) - strlen( $display ); |
911 | 935 | $diff = $ident - $curIdent; |
912 | 936 | |
913 | | - if ( $display == '' ) |
| 937 | + if ( $display == '' ) { |
914 | 938 | $display = "\xc2\xa0"; |
| 939 | + } |
915 | 940 | |
916 | 941 | if ( !$ident && $diff < 0 && substr( $display, 0, 9 ) != 'Entering ' && substr( $display, 0, 8 ) != 'Exiting ' ) { |
917 | 942 | $ident = $curIdent; |
— | — | @@ -920,12 +945,13 @@ |
921 | 946 | $display = htmlspecialchars( $display ); |
922 | 947 | } |
923 | 948 | |
924 | | - if ( $diff < 0 ) |
| 949 | + if ( $diff < 0 ) { |
925 | 950 | $ret .= str_repeat( "</li></ul>\n", -$diff ) . "</li><li>\n"; |
926 | | - elseif ( $diff == 0 ) |
| 951 | + } elseif ( $diff == 0 ) { |
927 | 952 | $ret .= "</li><li>\n"; |
928 | | - else |
| 953 | + } else { |
929 | 954 | $ret .= str_repeat( "<ul><li>\n", $diff ); |
| 955 | + } |
930 | 956 | $ret .= $display . "\n"; |
931 | 957 | |
932 | 958 | $curIdent = $ident; |
— | — | @@ -956,7 +982,7 @@ |
957 | 983 | /** @return string Retrievied from HTML text */ |
958 | 984 | function printSource() { |
959 | 985 | $url = htmlspecialchars( $this->mTitle->getFullURL() ); |
960 | | - return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' ); |
| 986 | + return wfMsg( 'retrievedfrom', '<a href="' . $url . '">' . $url . '</a>' ); |
961 | 987 | } |
962 | 988 | |
963 | 989 | function printFooter() { |
— | — | @@ -965,7 +991,9 @@ |
966 | 992 | } |
967 | 993 | |
968 | 994 | /** overloaded by derived classes */ |
969 | | - function doAfterContent() { return '</div></div>'; } |
| 995 | + function doAfterContent() { |
| 996 | + return '</div></div>'; |
| 997 | + } |
970 | 998 | |
971 | 999 | function pageTitleLinks() { |
972 | 1000 | global $wgOut, $wgUser, $wgRequest, $wgLang; |
— | — | @@ -1087,6 +1115,10 @@ |
1088 | 1116 | return $wgLang->pipeList( $s ); |
1089 | 1117 | } |
1090 | 1118 | |
| 1119 | + /** |
| 1120 | + * Gets the h1 element with the page title. |
| 1121 | + * @return string |
| 1122 | + */ |
1091 | 1123 | function pageTitle() { |
1092 | 1124 | global $wgOut; |
1093 | 1125 | $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>'; |
— | — | @@ -1109,8 +1141,9 @@ |
1110 | 1142 | |
1111 | 1143 | function subPageSubtitle() { |
1112 | 1144 | $subpages = ''; |
1113 | | - if( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages ) ) ) |
| 1145 | + if( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages ) ) ) { |
1114 | 1146 | return $subpages; |
| 1147 | + } |
1115 | 1148 | |
1116 | 1149 | global $wgOut; |
1117 | 1150 | if( $wgOut->isArticle() && MWNamespace::hasSubpages( $this->mTitle->getNamespace() ) ) { |
— | — | @@ -1125,7 +1158,7 @@ |
1126 | 1159 | $growinglink .= $link; |
1127 | 1160 | $display .= $link; |
1128 | 1161 | $linkObj = Title::newFromText( $growinglink ); |
1129 | | - if( is_object( $linkObj ) && $linkObj->exists() ){ |
| 1162 | + if( is_object( $linkObj ) && $linkObj->exists() ) { |
1130 | 1163 | $getlink = $this->link( |
1131 | 1164 | $linkObj, |
1132 | 1165 | htmlspecialchars( $display ), |
— | — | @@ -1230,16 +1263,17 @@ |
1231 | 1264 | global $wgRequest, $wgUseTwoButtonsSearchForm; |
1232 | 1265 | $search = $wgRequest->getText( 'search' ); |
1233 | 1266 | |
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="' |
1235 | 1268 | . $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="' |
1237 | 1270 | . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n" |
1238 | 1271 | . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />'; |
1239 | 1272 | |
1240 | | - if( $wgUseTwoButtonsSearchForm ) |
| 1273 | + if( $wgUseTwoButtonsSearchForm ) { |
1241 | 1274 | $s .= ' <input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n"; |
1242 | | - else |
| 1275 | + } else { |
1243 | 1276 | $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n"; |
| 1277 | + } |
1244 | 1278 | |
1245 | 1279 | $s .= '</form>'; |
1246 | 1280 | |
— | — | @@ -1315,11 +1349,12 @@ |
1316 | 1350 | if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) { |
1317 | 1351 | foreach( $variants as $code ) { |
1318 | 1352 | $varname = $wgContLang->getVariantname( $code ); |
1319 | | - if( $varname == 'disable' ) |
| 1353 | + if( $varname == 'disable' ) { |
1320 | 1354 | continue; |
| 1355 | + } |
1321 | 1356 | $s = $wgLang->pipeList( array( |
1322 | 1357 | $s, |
1323 | | - '<a href="' . $this->mTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>' |
| 1358 | + '<a href="' . $this->mTitle->escapeLocalURL( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>' |
1324 | 1359 | ) ); |
1325 | 1360 | } |
1326 | 1361 | } |
— | — | @@ -1341,15 +1376,20 @@ |
1342 | 1377 | $element[] = $this->whatLinksHere(); |
1343 | 1378 | $element[] = $this->watchPageLinksLink(); |
1344 | 1379 | |
1345 | | - if( $wgUseTrackbacks ) |
| 1380 | + if( $wgUseTrackbacks ) { |
1346 | 1381 | $element[] = $this->trackbackLink(); |
| 1382 | + } |
1347 | 1383 | |
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 | + { |
1350 | 1389 | $id = User::idFromName( $this->mTitle->getText() ); |
1351 | 1390 | $ip = User::isIP( $this->mTitle->getText() ); |
1352 | 1391 | |
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 ) { |
1354 | 1394 | $element[] = $this->userContribsLink(); |
1355 | 1395 | } |
1356 | 1396 | if( $this->showEmailUser( $id ) ) { |
— | — | @@ -1361,9 +1401,16 @@ |
1362 | 1402 | |
1363 | 1403 | if ( $this->mTitle->getArticleId() ) { |
1364 | 1404 | $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 | + } |
1368 | 1415 | } |
1369 | 1416 | $s .= "<br />\n" . $this->otherLanguages(); |
1370 | 1417 | } |
— | — | @@ -1377,10 +1424,18 @@ |
1378 | 1425 | |
1379 | 1426 | $oldid = $wgRequest->getVal( 'oldid' ); |
1380 | 1427 | $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 | + } |
1385 | 1440 | |
1386 | 1441 | $s = ''; |
1387 | 1442 | if ( !$wgDisableCounters ) { |
— | — | @@ -1390,7 +1445,7 @@ |
1391 | 1446 | } |
1392 | 1447 | } |
1393 | 1448 | |
1394 | | - if( $wgMaxCredits != 0 ){ |
| 1449 | + if( $wgMaxCredits != 0 ) { |
1395 | 1450 | $s .= ' ' . Credits::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax ); |
1396 | 1451 | } else { |
1397 | 1452 | $s .= $this->lastModified(); |
— | — | @@ -1398,9 +1453,13 @@ |
1399 | 1454 | |
1400 | 1455 | if( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) { |
1401 | 1456 | $dbr = wfGetDB( DB_SLAVE ); |
1402 | | - $res = $dbr->select( 'watchlist', |
| 1457 | + $res = $dbr->select( |
| 1458 | + 'watchlist', |
1403 | 1459 | 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 | + ), |
1405 | 1464 | __METHOD__ |
1406 | 1465 | ); |
1407 | 1466 | $x = $dbr->fetchObject( $res ); |
— | — | @@ -1445,8 +1504,9 @@ |
1446 | 1505 | return $out; |
1447 | 1506 | } |
1448 | 1507 | // Allow for site and per-namespace customization of copyright notice. |
1449 | | - if( isset($wgArticle) ) |
| 1508 | + if( isset( $wgArticle ) ) { |
1450 | 1509 | wfRunHooks( 'SkinCopyrightFooter', array( $wgArticle->getTitle(), $type, &$msg, &$link ) ); |
| 1510 | + } |
1451 | 1511 | |
1452 | 1512 | $out .= wfMsgForContent( $msg, $link ); |
1453 | 1513 | return $out; |
— | — | @@ -1457,7 +1517,7 @@ |
1458 | 1518 | $out = ''; |
1459 | 1519 | if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) { |
1460 | 1520 | $out = $wgCopyrightIcon; |
1461 | | - } else if ( $wgRightsIcon ) { |
| 1521 | + } elseif ( $wgRightsIcon ) { |
1462 | 1522 | $icon = htmlspecialchars( $wgRightsIcon ); |
1463 | 1523 | if ( $wgRightsUrl ) { |
1464 | 1524 | $url = htmlspecialchars( $wgRightsUrl ); |
— | — | @@ -1472,16 +1532,20 @@ |
1473 | 1533 | return $out; |
1474 | 1534 | } |
1475 | 1535 | |
| 1536 | + /** |
| 1537 | + * Gets the powered by MediaWiki icon. |
| 1538 | + * @return string |
| 1539 | + */ |
1476 | 1540 | function getPoweredBy() { |
1477 | 1541 | global $wgStylePath; |
1478 | 1542 | $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>'; |
1480 | 1544 | return $img; |
1481 | 1545 | } |
1482 | 1546 | |
1483 | 1547 | function lastModified() { |
1484 | 1548 | global $wgLang, $wgArticle; |
1485 | | - if( $this->mRevisionId && $this->mRevisionId != $wgArticle->getLatest()) { |
| 1549 | + if( $this->mRevisionId && $this->mRevisionId != $wgArticle->getLatest() ) { |
1486 | 1550 | $timestamp = Revision::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId ); |
1487 | 1551 | } else { |
1488 | 1552 | $timestamp = $wgArticle->getTimestamp(); |
— | — | @@ -1516,7 +1580,7 @@ |
1517 | 1581 | } |
1518 | 1582 | |
1519 | 1583 | /** |
1520 | | - * show a drop-down box of special pages |
| 1584 | + * Show a drop-down box of special pages |
1521 | 1585 | */ |
1522 | 1586 | function specialPagesList() { |
1523 | 1587 | global $wgUser, $wgContLang, $wgServer, $wgRedirectScript; |
— | — | @@ -1545,6 +1609,10 @@ |
1546 | 1610 | return $s; |
1547 | 1611 | } |
1548 | 1612 | |
| 1613 | + /** |
| 1614 | + * Gets the link to the wiki's main page. |
| 1615 | + * @return string |
| 1616 | + */ |
1549 | 1617 | function mainPageLink() { |
1550 | 1618 | $s = $this->link( |
1551 | 1619 | Title::newMainPage(), |
— | — | @@ -1556,7 +1624,7 @@ |
1557 | 1625 | return $s; |
1558 | 1626 | } |
1559 | 1627 | |
1560 | | - private function footerLink ( $desc, $page ) { |
| 1628 | + private function footerLink( $desc, $page ) { |
1561 | 1629 | // if the link description has been set to "-" in the default language, |
1562 | 1630 | if ( wfMsgForContent( $desc ) == '-') { |
1563 | 1631 | // then it is disabled, for all languages. |
— | — | @@ -1573,14 +1641,23 @@ |
1574 | 1642 | } |
1575 | 1643 | } |
1576 | 1644 | |
| 1645 | + /** |
| 1646 | + * Gets the link to the wiki's privacy policy page. |
| 1647 | + */ |
1577 | 1648 | function privacyLink() { |
1578 | 1649 | return $this->footerLink( 'privacy', 'privacypage' ); |
1579 | 1650 | } |
1580 | 1651 | |
| 1652 | + /** |
| 1653 | + * Gets the link to the wiki's about page. |
| 1654 | + */ |
1581 | 1655 | function aboutLink() { |
1582 | 1656 | return $this->footerLink( 'aboutsite', 'aboutpage' ); |
1583 | 1657 | } |
1584 | 1658 | |
| 1659 | + /** |
| 1660 | + * Gets the link to the wiki's general disclaimers page. |
| 1661 | + */ |
1585 | 1662 | function disclaimerLink() { |
1586 | 1663 | return $this->footerLink( 'disclaimers', 'disclaimerpage' ); |
1587 | 1664 | } |
— | — | @@ -1750,7 +1827,7 @@ |
1751 | 1828 | function showEmailUser( $id ) { |
1752 | 1829 | global $wgUser; |
1753 | 1830 | $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 |
1755 | 1832 | $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users |
1756 | 1833 | } |
1757 | 1834 | |
— | — | @@ -1766,7 +1843,7 @@ |
1767 | 1844 | |
1768 | 1845 | function watchPageLinksLink() { |
1769 | 1846 | global $wgOut; |
1770 | | - if ( ! $wgOut->isArticleRelated() ) { |
| 1847 | + if ( !$wgOut->isArticleRelated() ) { |
1771 | 1848 | return '(' . wfMsg( 'notanarticle' ) . ')'; |
1772 | 1849 | } else { |
1773 | 1850 | return $this->link( |
— | — | @@ -1798,7 +1875,9 @@ |
1799 | 1876 | |
1800 | 1877 | $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' ); |
1801 | 1878 | $first = true; |
1802 | | - if( $wgContLang->isRTL() ) $s .= '<span dir="LTR">'; |
| 1879 | + if( $wgContLang->isRTL() ) { |
| 1880 | + $s .= '<span dir="LTR">'; |
| 1881 | + } |
1803 | 1882 | foreach( $a as $l ) { |
1804 | 1883 | if ( !$first ) { |
1805 | 1884 | $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' ); |
— | — | @@ -1809,11 +1888,15 @@ |
1810 | 1889 | $url = $nt->escapeFullURL(); |
1811 | 1890 | $text = $wgContLang->getLanguageName( $nt->getInterwiki() ); |
1812 | 1891 | |
1813 | | - if ( $text == '' ) { $text = $l; } |
| 1892 | + if ( $text == '' ) { |
| 1893 | + $text = $l; |
| 1894 | + } |
1814 | 1895 | $style = $this->getExternalLinkAttributes(); |
1815 | 1896 | $s .= "<a href=\"{$url}\"{$style}>{$text}</a>"; |
1816 | 1897 | } |
1817 | | - if( $wgContLang->isRTL() ) $s .= '</span>'; |
| 1898 | + if( $wgContLang->isRTL() ) { |
| 1899 | + $s .= '</span>'; |
| 1900 | + } |
1818 | 1901 | return $s; |
1819 | 1902 | } |
1820 | 1903 | |
— | — | @@ -1927,8 +2010,10 @@ |
1928 | 2011 | return $title->getLocalURL( $urlaction ); |
1929 | 2012 | } |
1930 | 2013 | |
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 | + */ |
1933 | 2018 | static function makeInternalOrExternalUrl( $name ) { |
1934 | 2019 | if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) { |
1935 | 2020 | return $name; |
— | — | @@ -2000,14 +2085,16 @@ |
2001 | 2086 | $this->addToSidebar( $bar, 'sidebar' ); |
2002 | 2087 | |
2003 | 2088 | wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) ); |
2004 | | - if ( $wgEnableSidebarCache ) $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry ); |
| 2089 | + if ( $wgEnableSidebarCache ) { |
| 2090 | + $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry ); |
| 2091 | + } |
2005 | 2092 | wfProfileOut( __METHOD__ ); |
2006 | 2093 | return $bar; |
2007 | 2094 | } |
2008 | 2095 | /** |
2009 | 2096 | * Add content from a sidebar system message |
2010 | 2097 | * Currently only used for MediaWiki:Sidebar (but may be used by Extensions) |
2011 | | - * |
| 2098 | + * |
2012 | 2099 | * @param &$bar array |
2013 | 2100 | * @param $message String |
2014 | 2101 | */ |
— | — | @@ -2015,23 +2102,29 @@ |
2016 | 2103 | $lines = explode( "\n", wfMsgForContent( $message ) ); |
2017 | 2104 | $heading = ''; |
2018 | 2105 | foreach( $lines as $line ) { |
2019 | | - if( strpos( $line, '*' ) !== 0 ) |
| 2106 | + if( strpos( $line, '*' ) !== 0 ) { |
2020 | 2107 | continue; |
| 2108 | + } |
2021 | 2109 | if( strpos( $line, '**') !== 0 ) { |
2022 | 2110 | $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 | + } |
2024 | 2114 | } else { |
2025 | 2115 | if( strpos( $line, '|' ) !== false ) { // sanity check |
2026 | 2116 | $line = array_map( 'trim', explode( '|', trim( $line, '* ' ), 2 ) ); |
2027 | 2117 | $link = wfMsgForContent( $line[0] ); |
2028 | | - if( $link == '-' ) |
| 2118 | + if( $link == '-' ) { |
2029 | 2119 | continue; |
| 2120 | + } |
2030 | 2121 | |
2031 | 2122 | $text = wfMsgExt( $line[1], 'parsemag' ); |
2032 | | - if( wfEmptyMsg( $line[1], $text ) ) |
| 2123 | + if( wfEmptyMsg( $line[1], $text ) ) { |
2033 | 2124 | $text = $line[1]; |
2034 | | - if( wfEmptyMsg( $line[0], $link ) ) |
| 2125 | + } |
| 2126 | + if( wfEmptyMsg( $line[0], $link ) ) { |
2035 | 2127 | $link = $line[0]; |
| 2128 | + } |
2036 | 2129 | |
2037 | 2130 | if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) { |
2038 | 2131 | $href = $link; |
— | — | @@ -2051,7 +2144,9 @@ |
2052 | 2145 | 'id' => 'n-' . strtr( $line[1], ' ', '-' ), |
2053 | 2146 | 'active' => false |
2054 | 2147 | ); |
2055 | | - } else { continue; } |
| 2148 | + } else { |
| 2149 | + continue; |
| 2150 | + } |
2056 | 2151 | } |
2057 | 2152 | } |
2058 | 2153 | } |