diff options
Diffstat (limited to 'includes/SkinLegacy.php')
-rw-r--r-- | includes/SkinLegacy.php | 186 |
1 files changed, 104 insertions, 82 deletions
diff --git a/includes/SkinLegacy.php b/includes/SkinLegacy.php index 77c85a88..e695ba6c 100644 --- a/includes/SkinLegacy.php +++ b/includes/SkinLegacy.php @@ -1,12 +1,25 @@ <?php /** - * @defgroup Skins Skins + * Base class for legacy skins. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @file */ -if ( !defined( 'MEDIAWIKI' ) ) { - die( 1 ); -} - class SkinLegacy extends SkinTemplate { var $useHeadElement = true; protected $mWatchLinkNum = 0; // Appended to end of watch link id's @@ -82,8 +95,9 @@ class LegacyTemplate extends BaseTemplate { } /** - * This will be called immediately after the <body> tag. Split into + * This will be called immediately after the "<body>" tag. Split into * two functions to make it easier to subclass. + * @return string */ function beforeContent() { return $this->doBeforeContent(); @@ -106,21 +120,21 @@ class LegacyTemplate extends BaseTemplate { } $s .= "\n<div id='content'>\n<div id='topbar'>\n" . - "<table border='0' cellspacing='0' width='100%'>\n<tr>\n"; + "<table cellspacing='0' width='100%'>\n<tr>\n"; if ( $this->getSkin()->qbSetting() == 0 ) { - $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" . + $s .= "<td class='top' style='text-align: left; vertical-align: top;' rowspan='{$rows}'>\n" . $this->getSkin()->logoText( $wgLang->alignStart() ) . '</td>'; } $l = $wgLang->alignStart(); - $s .= "<td {$borderhack} align='$l' valign='top'>\n"; + $s .= "<td {$borderhack} style='text-align: $l; vertical-align: top;'>\n"; $s .= $this->topLinks(); $s .= '<p class="subtitle">' . $this->pageTitleLinks() . "</p>\n"; $r = $wgLang->alignEnd(); - $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>"; + $s .= "</td>\n<td {$borderhack} style='text-align: $r; vertical-align: top;' nowrap='nowrap'>"; $s .= $this->nameAndLogin(); $s .= "\n<br />" . $this->searchForm() . '</td>'; @@ -145,14 +159,16 @@ class LegacyTemplate extends BaseTemplate { } /** - * This gets called shortly before the </body> tag. - * @return String HTML to be put before </body> + * This gets called shortly before the "</body>" tag. + * @return String HTML to be put before "</body>" */ function afterContent() { return $this->doAfterContent(); } - /** overloaded by derived classes */ + /** overloaded by derived classes + * @return string + */ function doAfterContent() { return '</div></div>'; } @@ -166,12 +182,12 @@ class LegacyTemplate extends BaseTemplate { . $this->getSkin()->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' ) . '" />'; + . '<input type="submit" name="go" value="' . wfMessage( 'searcharticle' )->text() . '" />'; if ( $wgUseTwoButtonsSearchForm ) { - $s .= ' <input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n"; + $s .= ' <input type="submit" name="fulltext" value="' . wfMessage( 'searchbutton' )->text() . "\" />\n"; } else { - $s .= ' <a href="' . $this->getSkin()->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n"; + $s .= ' <a href="' . $this->getSkin()->escapeSearchLink() . '" rel="search">' . wfMessage( 'powersearch-legend' )->text() . "</a>\n"; } $s .= '</form>'; @@ -220,7 +236,7 @@ class LegacyTemplate extends BaseTemplate { } // @todo 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, wfMessage( 'pipe-separator' )->escaped() . "\n" ); } /** @@ -247,7 +263,7 @@ class LegacyTemplate extends BaseTemplate { } $s = $wgLang->pipeList( array( $s, - '<a href="' . htmlspecialchars( $title->getLocalURL( 'variant=' . $code ) ) . '">' . htmlspecialchars( $varname ) . '</a>' + '<a href="' . htmlspecialchars( $title->getLocalURL( 'variant=' . $code ) ) . '" lang="' . $code . '" hreflang="' . $code . '">' . htmlspecialchars( $varname ) . '</a>' ) ); } } @@ -276,7 +292,7 @@ class LegacyTemplate extends BaseTemplate { if ( count( $s ) ) { global $wgLang; - $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' ); + $out = wfMessage( 'pipe-separator' )->escaped(); $out .= $wgLang->pipeList( $s ); } @@ -285,7 +301,7 @@ class LegacyTemplate extends BaseTemplate { function bottomLinks() { global $wgOut, $wgUser; - $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n"; + $sep = wfMessage( 'pipe-separator' )->escaped() . "\n"; $s = ''; if ( $wgOut->isArticleRelated() ) { @@ -321,7 +337,7 @@ class LegacyTemplate extends BaseTemplate { $s = implode( $element, $sep ); - if ( $title->getArticleId() ) { + if ( $title->getArticleID() ) { $s .= "\n<br />"; // Delete/protect/move links for privileged users @@ -345,7 +361,7 @@ class LegacyTemplate extends BaseTemplate { } function otherLanguages() { - global $wgOut, $wgLang, $wgContLang, $wgHideInterlanguageLinks; + global $wgOut, $wgLang, $wgHideInterlanguageLinks; if ( $wgHideInterlanguageLinks ) { return ''; @@ -357,7 +373,7 @@ class LegacyTemplate extends BaseTemplate { return ''; } - $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' ); + $s = wfMessage( 'otherlanguages' )->text() . wfMessage( 'colon-separator' )->text(); $first = true; if ( $wgLang->isRTL() ) { @@ -366,13 +382,13 @@ class LegacyTemplate extends BaseTemplate { foreach ( $a as $l ) { if ( !$first ) { - $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' ); + $s .= wfMessage( 'pipe-separator' )->escaped(); } $first = false; $nt = Title::newFromText( $l ); - $text = $wgContLang->getLanguageName( $nt->getInterwiki() ); + $text = Language::fetchLanguageName( $nt->getInterwiki() ); $s .= Html::element( 'a', array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ), @@ -388,6 +404,7 @@ class LegacyTemplate extends BaseTemplate { /** * Show a drop-down box of special pages + * @return string */ function specialPagesList() { global $wgScript; @@ -400,8 +417,9 @@ class LegacyTemplate extends BaseTemplate { $obj->getTitle()->getPrefixedDBkey() ); } - return Html::rawElement( 'form', array( 'id' => 'specialpages', 'method' => 'get', - 'action' => $wgScript ), $select->getHTML() . Xml::submitButton( wfMsg( 'go' ) ) ); + return Html::rawElement( 'form', + array( 'id' => 'specialpages', 'method' => 'get', 'action' => $wgScript ), + $select->getHTML() . Xml::submitButton( wfMessage( 'go' )->text() ) ); } function pageTitleLinks() { @@ -429,21 +447,21 @@ class LegacyTemplate extends BaseTemplate { if ( $wgOut->isArticleRelated() ) { if ( $title->getNamespace() == NS_FILE ) { - $name = $title->getDBkey(); $image = wfFindFile( $title ); if ( $image ) { - $link = htmlspecialchars( $image->getURL() ); - $style = Linker::getInternalLinkAttributes( $link, $name ); - $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>"; + $href = $image->getURL(); + $s[] = Html::element( 'a', array( 'href' => $href, + 'title' => $href ), $title->getText() ); + } } } if ( 'history' == $action || isset( $diff ) || isset( $oldid ) ) { $s[] .= Linker::linkKnown( - $title, - wfMsg( 'currentrev' ) + $title, + wfMessage( 'currentrev' )->text() ); } @@ -453,18 +471,18 @@ class LegacyTemplate extends BaseTemplate { if ( !$title->equals( $wgUser->getTalkPage() ) ) { $tl = Linker::linkKnown( $wgUser->getTalkPage(), - wfMsgHtml( 'newmessageslink' ), + wfMessage( 'newmessageslink' )->escaped(), array(), array( 'redirect' => 'no' ) ); $dl = Linker::linkKnown( $wgUser->getTalkPage(), - wfMsgHtml( 'newmessagesdifflink' ), + wfMessage( 'newmessagesdifflink' )->escaped(), array(), array( 'diff' => 'cur' ) ); - $s[] = '<strong>' . wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>'; + $s[] = '<strong>' . wfMessage( 'youhavenewmessages', $tl, $dl )->text() . '</strong>'; # disable caching $wgOut->setSquidMaxage( 0 ); $wgOut->enableClientCache( false ); @@ -497,7 +515,7 @@ class LegacyTemplate extends BaseTemplate { if ( $sub == '' ) { global $wgExtraSubtitle; - $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle; + $sub = wfMessage( 'tagline' )->parse() . $wgExtraSubtitle; } $subpages = $this->getSkin()->subPageSubtitle(); @@ -515,14 +533,15 @@ class LegacyTemplate extends BaseTemplate { if ( !$wgOut->isPrintable() ) { $printurl = htmlspecialchars( $this->getSkin()->getTitle()->getLocalUrl( $wgRequest->appendQueryValue( 'printable', 'yes', true ) ) ); - $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>'; + $s[] = "<a href=\"$printurl\" rel=\"alternate\">" + . wfMessage( 'printableversion' )->text() . '</a>'; } if ( $wgOut->isSyndicated() ) { foreach ( $wgOut->getSyndicationLinks() as $format => $link ) { $feedurl = htmlspecialchars( $link ); $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\"" - . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>"; + . " class=\"feedlink\">" . wfMessage( "feed-$format" )->escaped() . "</a>"; } } return $wgLang->pipeList( $s ); @@ -530,6 +549,7 @@ class LegacyTemplate extends BaseTemplate { /** * @deprecated in 1.19 + * @return string */ function getQuickbarCompensator( $rows = 1 ) { wfDeprecated( __METHOD__, '1.19' ); @@ -540,15 +560,15 @@ class LegacyTemplate extends BaseTemplate { global $wgOut; if ( !$wgOut->isArticleRelated() ) { - $s = wfMsg( 'protectedpage' ); + $s = wfMessage( 'protectedpage' )->text(); } else { $title = $this->getSkin()->getTitle(); if ( $title->quickUserCan( 'edit' ) && $title->exists() ) { - $t = wfMsg( 'editthispage' ); + $t = wfMessage( 'editthispage' )->text(); } elseif ( $title->quickUserCan( 'create' ) && !$title->exists() ) { - $t = wfMsg( 'create-this-page' ); + $t = wfMessage( 'create-this-page' )->text(); } else { - $t = wfMsg( 'viewsource' ); + $t = wfMessage( 'viewsource' )->text(); } $s = Linker::linkKnown( @@ -568,8 +588,8 @@ class LegacyTemplate extends BaseTemplate { $diff = $wgRequest->getVal( 'diff' ); $title = $this->getSkin()->getTitle(); - if ( $title->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) { - $t = wfMsg( 'deletethispage' ); + if ( $title->getArticleID() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) { + $t = wfMessage( 'deletethispage' )->text(); $s = Linker::linkKnown( $title, @@ -590,12 +610,12 @@ class LegacyTemplate extends BaseTemplate { $diff = $wgRequest->getVal( 'diff' ); $title = $this->getSkin()->getTitle(); - if ( $title->getArticleId() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) { + if ( $title->getArticleID() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) { if ( $title->isProtected() ) { - $text = wfMsg( 'unprotectthispage' ); + $text = wfMessage( 'unprotectthispage' )->text(); $query = array( 'action' => 'unprotect' ); } else { - $text = wfMsg( 'protectthispage' ); + $text = wfMessage( 'protectthispage' )->text(); $query = array( 'action' => 'protect' ); } @@ -620,15 +640,15 @@ class LegacyTemplate extends BaseTemplate { $title = $this->getSkin()->getTitle(); if ( $wgOut->isArticleRelated() ) { - if ( $title->userIsWatching() ) { - $text = wfMsg( 'unwatchthispage' ); + if ( $wgUser->isWatched( $title ) ) { + $text = wfMessage( 'unwatchthispage' )->text(); $query = array( 'action' => 'unwatch', 'token' => UnwatchAction::getUnwatchToken( $title, $wgUser ), ); $id = 'mw-unwatch-link' . $this->mWatchLinkNum; } else { - $text = wfMsg( 'watchthispage' ); + $text = wfMessage( 'watchthispage' )->text(); $query = array( 'action' => 'watch', 'token' => WatchAction::getWatchToken( $title, $wgUser ), @@ -643,7 +663,7 @@ class LegacyTemplate extends BaseTemplate { $query ); } else { - $s = wfMsg( 'notanarticle' ); + $s = wfMessage( 'notanarticle' )->text(); } return $s; @@ -653,7 +673,7 @@ class LegacyTemplate extends BaseTemplate { if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) { return Linker::linkKnown( SpecialPage::getTitleFor( 'Movepage' ), - wfMsg( 'movethispage' ), + wfMessage( 'movethispage' )->text(), array(), array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() ) ); @@ -666,7 +686,7 @@ class LegacyTemplate extends BaseTemplate { function historyLink() { return Linker::link( $this->getSkin()->getTitle(), - wfMsgHtml( 'history' ), + wfMessage( 'history' )->escaped(), array( 'rel' => 'archives' ), array( 'action' => 'history' ) ); @@ -675,21 +695,21 @@ class LegacyTemplate extends BaseTemplate { function whatLinksHere() { return Linker::linkKnown( SpecialPage::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ), - wfMsgHtml( 'whatlinkshere' ) + wfMessage( 'whatlinkshere' )->escaped() ); } function userContribsLink() { return Linker::linkKnown( SpecialPage::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ), - wfMsgHtml( 'contributions' ) + wfMessage( 'contributions' )->escaped() ); } function emailUserLink() { return Linker::linkKnown( SpecialPage::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ), - wfMsgHtml( 'emailuser' ) + wfMessage( 'emailuser' )->escaped() ); } @@ -697,11 +717,11 @@ class LegacyTemplate extends BaseTemplate { global $wgOut; if ( !$wgOut->isArticleRelated() ) { - return '(' . wfMsg( 'notanarticle' ) . ')'; + return wfMessage( 'parentheses', wfMessage( 'notanarticle' )->text() )->escaped(); } else { return Linker::linkKnown( SpecialPage::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ), - wfMsgHtml( 'recentchangeslinked-toolbox' ) + wfMessage( 'recentchangeslinked-toolbox' )->escaped() ); } } @@ -719,41 +739,41 @@ class LegacyTemplate extends BaseTemplate { $link = $title->getSubjectPage(); switch( $link->getNamespace() ) { case NS_MAIN: - $text = wfMsg( 'articlepage' ); + $text = wfMessage( 'articlepage' ); break; case NS_USER: - $text = wfMsg( 'userpage' ); + $text = wfMessage( 'userpage' ); break; case NS_PROJECT: - $text = wfMsg( 'projectpage' ); + $text = wfMessage( 'projectpage' ); break; case NS_FILE: - $text = wfMsg( 'imagepage' ); + $text = wfMessage( 'imagepage' ); # Make link known if image exists, even if the desc. page doesn't. if ( wfFindFile( $link ) ) $linkOptions[] = 'known'; break; case NS_MEDIAWIKI: - $text = wfMsg( 'mediawikipage' ); + $text = wfMessage( 'mediawikipage' ); break; case NS_TEMPLATE: - $text = wfMsg( 'templatepage' ); + $text = wfMessage( 'templatepage' ); break; case NS_HELP: - $text = wfMsg( 'viewhelppage' ); + $text = wfMessage( 'viewhelppage' ); break; case NS_CATEGORY: - $text = wfMsg( 'categorypage' ); + $text = wfMessage( 'categorypage' ); break; default: - $text = wfMsg( 'articlepage' ); + $text = wfMessage( 'articlepage' ); } } else { $link = $title->getTalkPage(); - $text = wfMsg( 'talkpage' ); + $text = wfMessage( 'talkpage' ); } - $s = Linker::link( $link, $text, array(), array(), $linkOptions ); + $s = Linker::link( $link, $text->text(), array(), array(), $linkOptions ); return $s; } @@ -775,7 +795,7 @@ class LegacyTemplate extends BaseTemplate { return Linker::linkKnown( $title, - wfMsg( 'postcomment' ), + wfMessage( 'postcomment' )->text(), array(), array( 'action' => 'edit', @@ -789,11 +809,13 @@ class LegacyTemplate extends BaseTemplate { if ( $wgUploadNavigationUrl ) { # Using an empty class attribute to avoid automatic setting of "external" class - return Linker::makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) ); + return Linker::makeExternalLink( $wgUploadNavigationUrl, + wfMessage( 'upload' )->escaped(), + false, null, array( 'class' => '' ) ); } else { return Linker::linkKnown( SpecialPage::getTitleFor( 'Upload' ), - wfMsgHtml( 'upload' ) + wfMessage( 'upload' )->escaped() ); } } @@ -810,10 +832,11 @@ class LegacyTemplate extends BaseTemplate { $talkLink = Linker::link( $wgUser->getTalkPage(), $wgLang->getNsText( NS_TALK ) ); + $talkLink = wfMessage( 'parentheses' )->rawParams( $talkLink )->escaped(); - $ret .= "$name ($talkLink)"; + $ret .= "$name $talkLink"; } else { - $ret .= wfMsg( 'notloggedin' ); + $ret .= wfMessage( 'notloggedin' )->text(); } $query = array(); @@ -827,18 +850,19 @@ class LegacyTemplate extends BaseTemplate { : 'login'; $ret .= "\n<br />" . Linker::link( SpecialPage::getTitleFor( 'Userlogin' ), - wfMsg( $loginlink ), array(), $query + wfMessage( $loginlink )->text(), array(), $query ); } else { $talkLink = Linker::link( $wgUser->getTalkPage(), $wgLang->getNsText( NS_TALK ) ); + $talkLink = wfMessage( 'parentheses' )->rawParams( $talkLink )->escaped(); $ret .= Linker::link( $wgUser->getUserPage(), htmlspecialchars( $wgUser->getName() ) ); - $ret .= " ($talkLink)<br />"; + $ret .= " $talkLink<br />"; $ret .= $wgLang->pipeList( array( Linker::link( - SpecialPage::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ), + SpecialPage::getTitleFor( 'Userlogout' ), wfMessage( 'logout' )->text(), array(), array( 'returnto' => $returnTo->getPrefixedDBkey() ) ), Linker::specialLink( 'Preferences' ), @@ -848,13 +872,11 @@ class LegacyTemplate extends BaseTemplate { $ret = $wgLang->pipeList( array( $ret, Linker::link( - Title::newFromText( wfMsgForContent( 'helppage' ) ), - wfMsg( 'help' ) + Title::newFromText( wfMessage( 'helppage' )->inContentLanguage()->text() ), + wfMessage( 'help' )->text() ), ) ); return $ret; } - } - |