From 3d220be8d6eaa1bcfafaf47c7aa7c81b39e4dd7c Mon Sep 17 00:00:00 2001 From: Daniel Friesen Date: Fri, 4 Feb 2011 04:18:05 +0000 Subject: [PATCH] Completely remove support for legacy style skins. All legacy skinning options are now part of a SkinLegacy/LegacySkinTemplate pair that inherits from the normal SkinTemplate setup. Also ported our three built in skins to use the new legacy classes. ( ;) if you want to kill legacy skins now, you only have to svn rm 4 files) --- includes/AutoLoader.php | 2 + includes/OutputPage.php | 24 - includes/Skin.php | 887 +-------------------------- includes/SkinLegacy.php | 937 +++++++++++++++++++++++++++++ includes/diff/DifferenceEngine.php | 5 +- skins/CologneBlue.php | 130 ++-- skins/Nostalgia.php | 38 +- skins/Standard.php | 52 +- 8 files changed, 1061 insertions(+), 1014 deletions(-) create mode 100644 includes/SkinLegacy.php diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index d99a0978b0..1dc5e30087 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -223,6 +223,8 @@ $wgAutoloadLocalClasses = array( 'SiteStatsUpdate' => 'includes/SiteStats.php', 'Skin' => 'includes/Skin.php', 'SkinTemplate' => 'includes/SkinTemplate.php', + 'SkinLegacy' => 'includes/SkinLegacy.php', + 'LegacyTemplate' => 'includes/SkinLegacy.php', 'SpecialMycontributions' => 'includes/SpecialPage.php', 'SpecialMypage' => 'includes/SpecialPage.php', 'SpecialMytalk' => 'includes/SpecialPage.php', diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 8c5eba747e..77fa0586dc 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -128,13 +128,6 @@ class OutputPage { * Should probably get deleted / rewritten ... */ var $mAllowUserJs; - /** - * This was for the old skins and for users with 640x480 screen. - * Please note old skins are still used and might prove useful for - * users having old computers or visually impaired. - */ - var $mSuppressQuickbar = false; - /** * @EasterEgg I just love the name for this self documenting variable. * @todo document @@ -1071,23 +1064,6 @@ class OutputPage { return $this->mCategories; } - /** - * Suppress the quickbar from the output, only for skin supporting - * the quickbar - */ - public function suppressQuickbar() { - $this->mSuppressQuickbar = true; - } - - /** - * Return whether the quickbar should be suppressed from the output - * - * @return Boolean - */ - public function isQuickbarSuppressed() { - return $this->mSuppressQuickbar; - } - /** * Remove user JavaScript from scripts to load */ diff --git a/includes/Skin.php b/includes/Skin.php index b5f407d433..6623d26650 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -15,13 +15,11 @@ if ( !defined( 'MEDIAWIKI' ) ) { * * @ingroup Skins */ -class Skin extends Linker { +abstract class Skin extends Linker { /**#@+ * @private */ var $mWatchLinkNum = 0; // Appended to end of watch link id's - // How many search boxes have we made? Avoid duplicate id's. - protected $searchboxes = ''; /**#@-*/ protected $mRevisionId; // The revision ID we're looking at, null if not applicable. protected $skinname = 'standard'; @@ -181,18 +179,6 @@ class Skin extends Linker { return $this->skinname; } - function qbSetting() { - global $wgOut, $wgUser; - - if ( $wgOut->isQuickbarSuppressed() ) { - return 0; - } - - $q = $wgUser->getOption( 'quickbar', 0 ); - - return $q; - } - function initPage( OutputPage $out ) { global $wgFavicon, $wgAppleTouchIcon, $wgEnableAPI; @@ -439,6 +425,7 @@ class Skin extends Linker { /** * Outputs the HTML generated by other functions. * @param $out Object: instance of OutputPage + * @todo Exterminate! */ function outputPage( OutputPage $out ) { global $wgDebugComments; @@ -656,11 +643,9 @@ class Skin extends Linker { /** * Add skin specific stylesheets * @param $out OutputPage + * @delete */ - function setupSkinUserCss( OutputPage $out ) { - $out->addModuleStyles( 'mediawiki.legacy.shared' ); - $out->addModuleStyles( 'mediawiki.legacy.oldshared' ); - } + abstract function setupSkinUserCss( OutputPage $out ); function getPageClasses( $title ) { $numeric = 'ns-' . $title->getNamespace(); @@ -695,79 +680,6 @@ class Skin extends Linker { return $wgLogo; } - /** - * This will be called immediately after the tag. Split into - * two functions to make it easier to subclass. - */ - function beforeContent() { - return $this->doBeforeContent(); - } - - function doBeforeContent() { - global $wgContLang; - wfProfileIn( __METHOD__ ); - - $s = ''; - $qb = $this->qbSetting(); - - $langlinks = $this->otherLanguages(); - if ( $langlinks ) { - $rows = 2; - $borderhack = ''; - } else { - $rows = 1; - $langlinks = false; - $borderhack = 'class="top"'; - } - - $s .= "\n
\n
\n" . - "\n\n"; - - $shove = ( $qb != 0 ); - $left = ( $qb == 1 || $qb == 3 ); - - if ( !$shove ) { - $s .= "'; - } elseif ( $left ) { - $s .= $this->getQuickbarCompensator( $rows ); - } - - $l = $wgContLang->alignStart(); - $s .= "\n'; - - if ( $langlinks ) { - $s .= "\n\n\n"; - } - - if ( $shove && !$left ) { # Right - $s .= $this->getQuickbarCompensator( $rows ); - } - - $s .= "\n
\n" . - $this->logoText() . '\n"; - - $s .= $this->topLinks(); - $s .= '

' . $this->pageTitleLinks() . "

\n"; - - $r = $wgContLang->alignEnd(); - $s .= "
"; - $s .= $this->nameAndLogin(); - $s .= "\n
" . $this->searchForm() . '
$langlinks
\n
\n"; - $s .= "\n
\n"; - - $notice = wfGetSiteNotice(); - - if ( $notice ) { - $s .= "\n
$notice
\n"; - } - $s .= $this->pageTitle(); - $s .= $this->pageSubtitle(); - $s .= $this->getCategories(); - - wfProfileOut( __METHOD__ ); - return $s; - } - function getCategoryLinks() { global $wgOut, $wgUseCategoryBrowser; global $wgContLang, $wgUser; @@ -879,10 +791,6 @@ class Skin extends Linker { return ""; } - function getQuickbarCompensator( $rows = 1 ) { - return " "; - } - /** * This runs a hook to allow extensions placing their stuff after content * and article metadata (e.g. categories). @@ -974,15 +882,6 @@ class Skin extends Linker { return $ret; } - /** - * This gets called shortly before the tag. - * @return String HTML to be put before - */ - function afterContent() { - $printfooter = "
\n" . $this->printFooter() . "
\n"; - return $printfooter . $this->generateDebugHTML() . $this->doAfterContent(); - } - /** * This gets called shortly before the tag. * @param $out OutputPage object @@ -1001,94 +900,6 @@ class Skin extends Linker { return wfMsg( 'retrievedfrom', '' . $url . '' ); } - function printFooter() { - return "

" . $this->printSource() . - "

\n\n

" . $this->pageStats() . "

\n"; - } - - /** overloaded by derived classes */ - function doAfterContent() { - return '
'; - } - - function pageTitleLinks() { - global $wgOut, $wgUser, $wgRequest, $wgLang; - - $oldid = $wgRequest->getVal( 'oldid' ); - $diff = $wgRequest->getVal( 'diff' ); - $action = $wgRequest->getText( 'action' ); - - $s[] = $this->printableLink(); - $disclaimer = $this->disclaimerLink(); # may be empty - - if ( $disclaimer ) { - $s[] = $disclaimer; - } - - $privacy = $this->privacyLink(); # may be empty too - - if ( $privacy ) { - $s[] = $privacy; - } - - if ( $wgOut->isArticleRelated() ) { - if ( $this->mTitle->getNamespace() == NS_FILE ) { - $name = $this->mTitle->getDBkey(); - $image = wfFindFile( $this->mTitle ); - - if ( $image ) { - $link = htmlspecialchars( $image->getURL() ); - $style = $this->getInternalLinkAttributes( $link, $name ); - $s[] = "{$name}"; - } - } - } - - if ( 'history' == $action || isset( $diff ) || isset( $oldid ) ) { - $s[] .= $this->link( - $this->mTitle, - wfMsg( 'currentrev' ), - array(), - array(), - array( 'known', 'noclasses' ) - ); - } - - if ( $wgUser->getNewtalk() ) { - # do not show "You have new messages" text when we are viewing our - # own talk page - if ( !$this->mTitle->equals( $wgUser->getTalkPage() ) ) { - $tl = $this->link( - $wgUser->getTalkPage(), - wfMsgHtml( 'newmessageslink' ), - array(), - array( 'redirect' => 'no' ), - array( 'known', 'noclasses' ) - ); - - $dl = $this->link( - $wgUser->getTalkPage(), - wfMsgHtml( 'newmessagesdifflink' ), - array(), - array( 'diff' => 'cur' ), - array( 'known', 'noclasses' ) - ); - $s[] = '' . wfMsg( 'youhavenewmessages', $tl, $dl ) . ''; - # disable caching - $wgOut->setSquidMaxage( 0 ); - $wgOut->enableClientCache( false ); - } - } - - $undelete = $this->getUndeleteLink(); - - if ( !empty( $undelete ) ) { - $s[] = $undelete; - } - - return $wgLang->pipeList( $s ); - } - function getUndeleteLink() { global $wgUser, $wgLang, $wgRequest; @@ -1121,53 +932,6 @@ class Skin extends Linker { return ''; } - function printableLink() { - global $wgOut, $wgFeedClasses, $wgRequest, $wgLang; - - $s = array(); - - if ( !$wgOut->isPrintable() ) { - $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' ); - $s[] = "" . wfMsg( 'printableversion' ) . ''; - } - - if ( $wgOut->isSyndicated() ) { - foreach ( $wgFeedClasses as $format => $class ) { - $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" ); - $s[] = "" . wfMsgHtml( "feed-$format" ) . ""; - } - } - return $wgLang->pipeList( $s ); - } - - /** - * Gets the h1 element with the page title. - * @return string - */ - function pageTitle() { - global $wgOut; - $s = '

' . $wgOut->getPageTitle() . '

'; - return $s; - } - - function pageSubtitle() { - global $wgOut; - - $sub = $wgOut->getSubtitle(); - - if ( $sub == '' ) { - global $wgExtraSubtitle; - $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle; - } - - $subpages = $this->subPageSubtitle(); - $sub .= !empty( $subpages ) ? "

$subpages" : ''; - $s = "

{$sub}

\n"; - - return $s; - } - function subPageSubtitle() { $subpages = ''; @@ -1229,67 +993,6 @@ class Skin extends Linker { return $wgShowIPinHeader && session_id() != ''; } - function nameAndLogin() { - global $wgUser, $wgLang, $wgContLang; - - $logoutPage = $wgContLang->specialPage( 'Userlogout' ); - - $ret = ''; - - if ( $wgUser->isAnon() ) { - if ( $this->showIPinHeader() ) { - $name = wfGetIP(); - - $talkLink = $this->link( $wgUser->getTalkPage(), - $wgLang->getNsText( NS_TALK ) ); - - $ret .= "$name ($talkLink)"; - } else { - $ret .= wfMsg( 'notloggedin' ); - } - - $returnTo = $this->mTitle->getPrefixedDBkey(); - $query = array(); - - if ( $logoutPage != $returnTo ) { - $query['returnto'] = $returnTo; - } - - $loginlink = $wgUser->isAllowed( 'createaccount' ) - ? 'nav-login-createaccount' - : 'login'; - $ret .= "\n
" . $this->link( - SpecialPage::getTitleFor( 'Userlogin' ), - wfMsg( $loginlink ), array(), $query - ); - } else { - $returnTo = $this->mTitle->getPrefixedDBkey(); - $talkLink = $this->link( $wgUser->getTalkPage(), - $wgLang->getNsText( NS_TALK ) ); - - $ret .= $this->link( $wgUser->getUserPage(), - htmlspecialchars( $wgUser->getName() ) ); - $ret .= " ($talkLink)
"; - $ret .= $wgLang->pipeList( array( - $this->link( - SpecialPage::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ), - array(), array( 'returnto' => $returnTo ) - ), - $this->specialLink( 'Preferences' ), - ) ); - } - - $ret = $wgLang->pipeList( array( - $ret, - $this->link( - Title::newFromText( wfMsgForContent( 'helppage' ) ), - wfMsg( 'help' ) - ), - ) ); - - return $ret; - } - function getSearchLink() { $searchPage = SpecialPage::getTitleFor( 'Search' ); return $searchPage->getLocalURL(); @@ -1299,229 +1002,6 @@ class Skin extends Linker { return htmlspecialchars( $this->getSearchLink() ); } - function searchForm() { - global $wgRequest, $wgUseTwoButtonsSearchForm; - - $search = $wgRequest->getText( 'search' ); - - $s = '
\n" - . '\n" - . ''; - - if ( $wgUseTwoButtonsSearchForm ) { - $s .= ' \n"; - } else { - $s .= ' \n"; - } - - $s .= '
'; - - // Ensure unique id's for search boxes made after the first - $this->searchboxes = $this->searchboxes == '' ? 2 : $this->searchboxes + 1; - - return $s; - } - - function topLinks() { - global $wgOut; - - $s = array( - $this->mainPageLink(), - $this->specialLink( 'Recentchanges' ) - ); - - if ( $wgOut->isArticleRelated() ) { - $s[] = $this->editThisPage(); - $s[] = $this->historyLink(); - } - - # Many people don't like this dropdown box - # $s[] = $this->specialPagesList(); - - if ( $this->variantLinks() ) { - $s[] = $this->variantLinks(); - } - - if ( $this->extensionTabLinks() ) { - $s[] = $this->extensionTabLinks(); - } - - // @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" ); - } - - /** - * Compatibility for extensions adding functionality through tabs. - * Eventually these old skins should be replaced with SkinTemplate-based - * versions, sigh... - * @return string - */ - function extensionTabLinks() { - $tabs = array(); - $out = ''; - $s = array(); - wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) ); - foreach ( $tabs as $tab ) { - $s[] = Xml::element( 'a', - array( 'href' => $tab['href'] ), - $tab['text'] ); - } - - if ( count( $s ) ) { - global $wgLang; - - $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' ); - $out .= $wgLang->pipeList( $s ); - } - - return $out; - } - - /** - * Language/charset variant links for classic-style skins - * @return string - */ - function variantLinks() { - $s = ''; - - /* show links to different language variants */ - global $wgDisableLangConversion, $wgLang, $wgContLang; - - $variants = $wgContLang->getVariants(); - - if ( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) { - foreach ( $variants as $code ) { - $varname = $wgContLang->getVariantname( $code ); - - if ( $varname == 'disable' ) { - continue; - } - $s = $wgLang->pipeList( array( - $s, - '' . htmlspecialchars( $varname ) . '' - ) ); - } - } - - return $s; - } - - function bottomLinks() { - global $wgOut, $wgUser, $wgUseTrackbacks; - $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n"; - - $s = ''; - if ( $wgOut->isArticleRelated() ) { - $element[] = '' . $this->editThisPage() . ''; - - if ( $wgUser->isLoggedIn() ) { - $element[] = $this->watchThisPage(); - } - - $element[] = $this->talkLink(); - $element[] = $this->historyLink(); - $element[] = $this->whatLinksHere(); - $element[] = $this->watchPageLinksLink(); - - if ( $wgUseTrackbacks ) { - $element[] = $this->trackbackLink(); - } - - if ( - $this->mTitle->getNamespace() == NS_USER || - $this->mTitle->getNamespace() == NS_USER_TALK - ) { - $id = User::idFromName( $this->mTitle->getText() ); - $ip = User::isIP( $this->mTitle->getText() ); - - # Both anons and non-anons have contributions list - if ( $id || $ip ) { - $element[] = $this->userContribsLink(); - } - - if ( $this->showEmailUser( $id ) ) { - $element[] = $this->emailUserLink(); - } - } - - $s = implode( $element, $sep ); - - if ( $this->mTitle->getArticleId() ) { - $s .= "\n
"; - - // Delete/protect/move links for privileged users - if ( $wgUser->isAllowed( 'delete' ) ) { - $s .= $this->deleteThisPage(); - } - - if ( $wgUser->isAllowed( 'protect' ) ) { - $s .= $sep . $this->protectThisPage(); - } - - if ( $wgUser->isAllowed( 'move' ) ) { - $s .= $sep . $this->moveThisPage(); - } - } - - $s .= "
\n" . $this->otherLanguages(); - } - - return $s; - } - - function pageStats() { - global $wgOut, $wgLang, $wgRequest, $wgUser; - global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers; - - if ( !is_null( $wgRequest->getVal( 'oldid' ) ) || !is_null( $wgRequest->getVal( 'diff' ) ) ) { - return ''; - } - - if ( !$wgOut->isArticle() || !$this->mTitle->exists() ) { - return ''; - } - - $article = new Article( $this->mTitle, 0 ); - - $s = ''; - - if ( !$wgDisableCounters ) { - $count = $wgLang->formatNum( $article->getCount() ); - - if ( $count ) { - $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count ); - } - } - - if ( $wgMaxCredits != 0 ) { - $s .= ' ' . Credits::getCredits( $article, $wgMaxCredits, $wgShowCreditsIfMax ); - } else { - $s .= $this->lastModified( $article ); - } - - if ( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) { - $dbr = wfGetDB( DB_SLAVE ); - $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 ); - - $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview', - array( 'parseinline' ), $wgLang->formatNum( $x->n ) - ); - } - - return $s . ' ' . $this->getCopyright(); - } - function getCopyright( $type = 'detect' ) { global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest; @@ -1655,40 +1135,6 @@ class Skin extends Linker { return $s; } - /** - * Show a drop-down box of special pages - */ - function specialPagesList() { - global $wgContLang, $wgServer, $wgRedirectScript; - - $pages = array_merge( SpecialPage::getRegularPages(), SpecialPage::getRestrictedPages() ); - - foreach ( $pages as $name => $page ) { - $pages[$name] = $page->getDescription(); - } - - $go = wfMsg( 'go' ); - $sp = wfMsg( 'specialpages' ); - $spp = $wgContLang->specialPage( 'Specialpages' ); - - $s = '
\n"; - $s .= "\n"; - $s .= "\n"; - $s .= "
\n"; - - return $s; - } - /** * Renders a $wgFooterIcons icon acording to the method's arguments * @param $icon Array: The icon to build the html for, see $wgFooterIcons for the format of this array @@ -1767,32 +1213,6 @@ class Skin extends Linker { return $this->footerLink( 'disclaimers', 'disclaimerpage' ); } - function editThisPage() { - global $wgOut; - - if ( !$wgOut->isArticleRelated() ) { - $s = wfMsg( 'protectedpage' ); - } else { - if ( $this->mTitle->quickUserCan( 'edit' ) && $this->mTitle->exists() ) { - $t = wfMsg( 'editthispage' ); - } elseif ( $this->mTitle->quickUserCan( 'create' ) && !$this->mTitle->exists() ) { - $t = wfMsg( 'create-this-page' ); - } else { - $t = wfMsg( 'viewsource' ); - } - - $s = $this->link( - $this->mTitle, - $t, - array(), - $this->editUrlOptions(), - array( 'known', 'noclasses' ) - ); - } - - return $s; - } - /** * Return URL options for the 'edit page' link. * This may include an 'oldid' specifier, if the current page view is such. @@ -1810,129 +1230,6 @@ class Skin extends Linker { return $options; } - function deleteThisPage() { - global $wgUser, $wgRequest; - - $diff = $wgRequest->getVal( 'diff' ); - - if ( $this->mTitle->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) { - $t = wfMsg( 'deletethispage' ); - - $s = $this->link( - $this->mTitle, - $t, - array(), - array( 'action' => 'delete' ), - array( 'known', 'noclasses' ) - ); - } else { - $s = ''; - } - - return $s; - } - - function protectThisPage() { - global $wgUser, $wgRequest; - - $diff = $wgRequest->getVal( 'diff' ); - - if ( $this->mTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) { - if ( $this->mTitle->isProtected() ) { - $text = wfMsg( 'unprotectthispage' ); - $query = array( 'action' => 'unprotect' ); - } else { - $text = wfMsg( 'protectthispage' ); - $query = array( 'action' => 'protect' ); - } - - $s = $this->link( - $this->mTitle, - $text, - array(), - $query, - array( 'known', 'noclasses' ) - ); - } else { - $s = ''; - } - - return $s; - } - - function watchThisPage() { - global $wgOut; - ++$this->mWatchLinkNum; - - if ( $wgOut->isArticleRelated() ) { - if ( $this->mTitle->userIsWatching() ) { - $text = wfMsg( 'unwatchthispage' ); - $query = array( 'action' => 'unwatch' ); - $id = 'mw-unwatch-link' . $this->mWatchLinkNum; - } else { - $text = wfMsg( 'watchthispage' ); - $query = array( 'action' => 'watch' ); - $id = 'mw-watch-link' . $this->mWatchLinkNum; - } - - $s = $this->link( - $this->mTitle, - $text, - array( 'id' => $id ), - $query, - array( 'known', 'noclasses' ) - ); - } else { - $s = wfMsg( 'notanarticle' ); - } - - return $s; - } - - function moveThisPage() { - if ( $this->mTitle->quickUserCan( 'move' ) ) { - return $this->link( - SpecialPage::getTitleFor( 'Movepage' ), - wfMsg( 'movethispage' ), - array(), - array( 'target' => $this->mTitle->getPrefixedDBkey() ), - array( 'known', 'noclasses' ) - ); - } else { - // no message if page is protected - would be redundant - return ''; - } - } - - function historyLink() { - return $this->link( - $this->mTitle, - wfMsgHtml( 'history' ), - array( 'rel' => 'archives' ), - array( 'action' => 'history' ) - ); - } - - function whatLinksHere() { - return $this->link( - SpecialPage::getTitleFor( 'Whatlinkshere', $this->mTitle->getPrefixedDBkey() ), - wfMsgHtml( 'whatlinkshere' ), - array(), - array(), - array( 'known', 'noclasses' ) - ); - } - - function userContribsLink() { - return $this->link( - SpecialPage::getTitleFor( 'Contributions', $this->mTitle->getDBkey() ), - wfMsgHtml( 'contributions' ), - array(), - array(), - array( 'known', 'noclasses' ) - ); - } - function showEmailUser( $id ) { global $wgUser; $targetUser = User::newFromId( $id ); @@ -1940,182 +1237,6 @@ class Skin extends Linker { $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users } - function emailUserLink() { - return $this->link( - SpecialPage::getTitleFor( 'Emailuser', $this->mTitle->getDBkey() ), - wfMsg( 'emailuser' ), - array(), - array(), - array( 'known', 'noclasses' ) - ); - } - - function watchPageLinksLink() { - global $wgOut; - - if ( !$wgOut->isArticleRelated() ) { - return '(' . wfMsg( 'notanarticle' ) . ')'; - } else { - return $this->link( - SpecialPage::getTitleFor( 'Recentchangeslinked', $this->mTitle->getPrefixedDBkey() ), - wfMsg( 'recentchangeslinked-toolbox' ), - array(), - array(), - array( 'known', 'noclasses' ) - ); - } - } - - function trackbackLink() { - return '' - . wfMsg( 'trackbacklink' ) . ''; - } - - function otherLanguages() { - global $wgOut, $wgContLang, $wgHideInterlanguageLinks; - - if ( $wgHideInterlanguageLinks ) { - return ''; - } - - $a = $wgOut->getLanguageLinks(); - - if ( 0 == count( $a ) ) { - return ''; - } - - $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' ); - $first = true; - - if ( $wgContLang->isRTL() ) { - $s .= ''; - } - - foreach ( $a as $l ) { - if ( !$first ) { - $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' ); - } - - $first = false; - - $nt = Title::newFromText( $l ); - $url = $nt->escapeFullURL(); - $text = $wgContLang->getLanguageName( $nt->getInterwiki() ); - $title = htmlspecialchars( $nt->getText() ); - - if ( $text == '' ) { - $text = $l; - } - - $style = $this->getExternalLinkAttributes(); - $s .= "{$text}"; - } - - if ( $wgContLang->isRTL() ) { - $s .= ''; - } - - return $s; - } - - function talkLink() { - if ( NS_SPECIAL == $this->mTitle->getNamespace() ) { - # No discussion links for special pages - return ''; - } - - $linkOptions = array(); - - if ( $this->mTitle->isTalkPage() ) { - $link = $this->mTitle->getSubjectPage(); - switch( $link->getNamespace() ) { - case NS_MAIN: - $text = wfMsg( 'articlepage' ); - break; - case NS_USER: - $text = wfMsg( 'userpage' ); - break; - case NS_PROJECT: - $text = wfMsg( 'projectpage' ); - break; - case NS_FILE: - $text = wfMsg( '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' ); - break; - case NS_TEMPLATE: - $text = wfMsg( 'templatepage' ); - break; - case NS_HELP: - $text = wfMsg( 'viewhelppage' ); - break; - case NS_CATEGORY: - $text = wfMsg( 'categorypage' ); - break; - default: - $text = wfMsg( 'articlepage' ); - } - } else { - $link = $this->mTitle->getTalkPage(); - $text = wfMsg( 'talkpage' ); - } - - $s = $this->link( $link, $text, array(), array(), $linkOptions ); - - return $s; - } - - function commentLink() { - global $wgOut; - - if ( $this->mTitle->getNamespace() == NS_SPECIAL ) { - return ''; - } - - # __NEWSECTIONLINK___ changes behaviour here - # If it is present, the link points to this page, otherwise - # it points to the talk page - if ( $this->mTitle->isTalkPage() ) { - $title = $this->mTitle; - } elseif ( $wgOut->showNewSectionLink() ) { - $title = $this->mTitle; - } else { - $title = $this->mTitle->getTalkPage(); - } - - return $this->link( - $title, - wfMsg( 'postcomment' ), - array(), - array( - 'action' => 'edit', - 'section' => 'new' - ), - array( 'known', 'noclasses' ) - ); - } - - function getUploadLink() { - global $wgUploadNavigationUrl; - - if ( $wgUploadNavigationUrl ) { - # Using an empty class attribute to avoid automatic setting of "external" class - return $this->makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) ); - } else { - return $this->link( - SpecialPage::getTitleFor( 'Upload' ), - wfMsgHtml( 'upload' ), - array(), - array(), - array( 'known', 'noclasses' ) - ); - } - } - /** * Return a fully resolved style path url to images or styles stored in the common folder. * This method returns a url resolved using the configured skin style path diff --git a/includes/SkinLegacy.php b/includes/SkinLegacy.php new file mode 100644 index 0000000000..0137ad21c3 --- /dev/null +++ b/includes/SkinLegacy.php @@ -0,0 +1,937 @@ +addModuleStyles( 'mediawiki.legacy.shared' ); + $out->addModuleStyles( 'mediawiki.legacy.oldshared' ); + } + + public function commonPrintStylesheet() { + return true; + } + + /** + * This was for the old skins and for users with 640x480 screen. + * Please note old skins are still used and might prove useful for + * users having old computers or visually impaired. + */ + var $mSuppressQuickbar = false; + + /** + * Suppress the quickbar from the output, only for skin supporting + * the quickbar + */ + public function suppressQuickbar() { + $this->mSuppressQuickbar = true; + } + + /** + * Return whether the quickbar should be suppressed from the output + * + * @return Boolean + */ + public function isQuickbarSuppressed() { + return $this->mSuppressQuickbar; + } + + function qbSetting() { + global $wgOut, $wgUser; + if ( $this->isQuickbarSuppressed() ) { + return 0; + } + $q = $wgUser->getOption( 'quickbar', 0 ); + return $q; + } + +} + +class LegacyTemplate extends BaseTemplate { + + // How many search boxes have we made? Avoid duplicate id's. + protected $searchboxes = ''; + + function execute() { + $this->html( 'headelement' ); + echo $this->beforeContent(); + $this->html( 'bodytext' ); + echo "\n"; + echo $this->afterContent(); + $this->html( 'dataAfterContent' ); + $this->printTrail(); + echo "\n"; + } + + /** + * This will be called immediately after the tag. Split into + * two functions to make it easier to subclass. + */ + function beforeContent() { + return $this->doBeforeContent(); + } + + function doBeforeContent() { + global $wgContLang; + wfProfileIn( __METHOD__ ); + + $s = ''; + $qb = $this->getSkin()->qbSetting(); + + $langlinks = $this->otherLanguages(); + if ( $langlinks ) { + $rows = 2; + $borderhack = ''; + } else { + $rows = 1; + $langlinks = false; + $borderhack = 'class="top"'; + } + + $s .= "\n
\n
\n" . + "\n\n"; + + $shove = ( $qb != 0 ); + $left = ( $qb == 1 || $qb == 3 ); + + if ( !$shove ) { + $s .= "'; + } elseif ( $left ) { + $s .= $this->getQuickbarCompensator( $rows ); + } + + $l = $wgContLang->alignStart(); + $s .= "\n'; + + if ( $langlinks ) { + $s .= "\n\n\n"; + } + + if ( $shove && !$left ) { # Right + $s .= $this->getQuickbarCompensator( $rows ); + } + + $s .= "\n
\n" . + $this->logoText() . '\n"; + + $s .= $this->topLinks(); + $s .= '

' . $this->pageTitleLinks() . "

\n"; + + $r = $wgContLang->alignEnd(); + $s .= "
"; + $s .= $this->nameAndLogin(); + $s .= "\n
" . $this->searchForm() . '
$langlinks
\n
\n"; + $s .= "\n
\n"; + + $notice = wfGetSiteNotice(); + + if ( $notice ) { + $s .= "\n
$notice
\n"; + } + $s .= $this->pageTitle(); + $s .= $this->pageSubtitle(); + $s .= $this->getSkin()->getCategories(); + + wfProfileOut( __METHOD__ ); + return $s; + } + + /** + * This gets called shortly before the tag. + * @return String HTML to be put before + */ + function afterContent() { + return $this->doAfterContent(); + } + + /** overloaded by derived classes */ + function doAfterContent() { + return '
'; + } + + function searchForm() { + global $wgRequest, $wgUseTwoButtonsSearchForm; + + $search = $wgRequest->getText( 'search' ); + + $s = '
\n" + . '\n" + . ''; + + if ( $wgUseTwoButtonsSearchForm ) { + $s .= ' \n"; + } else { + $s .= ' \n"; + } + + $s .= '
'; + + // Ensure unique id's for search boxes made after the first + $this->searchboxes = $this->searchboxes == '' ? 2 : $this->searchboxes + 1; + + return $s; + } + + function pageStats() { + global $wgOut, $wgLang, $wgRequest, $wgUser; + global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers; + + if ( !is_null( $wgRequest->getVal( 'oldid' ) ) || !is_null( $wgRequest->getVal( 'diff' ) ) ) { + return ''; + } + + if ( !$wgOut->isArticle() || !$this->getSkin()->getTitle()->exists() ) { + return ''; + } + + $article = new Article( $this->getSkin()->getTitle(), 0 ); + + $s = ''; + + if ( !$wgDisableCounters ) { + $count = $wgLang->formatNum( $article->getCount() ); + + if ( $count ) { + $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count ); + } + } + + if ( $wgMaxCredits != 0 ) { + $s .= ' ' . Credits::getCredits( $article, $wgMaxCredits, $wgShowCreditsIfMax ); + } else { + $s .= $this->data['lastmod']; + } + + if ( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) { + $dbr = wfGetDB( DB_SLAVE ); + $res = $dbr->select( + 'watchlist', + array( 'COUNT(*) AS n' ), + array( + 'wl_title' => $dbr->strencode( $this->getSkin()->getTitle()->getDBkey() ), + 'wl_namespace' => $this->getSkin()->getTitle()->getNamespace() + ), + __METHOD__ + ); + $x = $dbr->fetchObject( $res ); + + $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview', + array( 'parseinline' ), $wgLang->formatNum( $x->n ) + ); + } + + return $s . ' ' . $this->getSkin()->getCopyright(); + } + + function topLinks() { + global $wgOut; + + $s = array( + $this->getSkin()->mainPageLink(), + $this->getSkin()->specialLink( 'Recentchanges' ) + ); + + if ( $wgOut->isArticleRelated() ) { + $s[] = $this->editThisPage(); + $s[] = $this->historyLink(); + } + + # Many people don't like this dropdown box + # $s[] = $this->specialPagesList(); + + if ( $this->variantLinks() ) { + $s[] = $this->variantLinks(); + } + + if ( $this->extensionTabLinks() ) { + $s[] = $this->extensionTabLinks(); + } + + // @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" ); + } + + /** + * Language/charset variant links for classic-style skins + * @return string + */ + function variantLinks() { + $s = ''; + + /* show links to different language variants */ + global $wgDisableLangConversion, $wgLang, $wgContLang; + + $variants = $wgContLang->getVariants(); + + if ( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) { + foreach ( $variants as $code ) { + $varname = $wgContLang->getVariantname( $code ); + + if ( $varname == 'disable' ) { + continue; + } + $s = $wgLang->pipeList( array( + $s, + '' . htmlspecialchars( $varname ) . '' + ) ); + } + } + + return $s; + } + + /** + * Compatibility for extensions adding functionality through tabs. + * Eventually these old skins should be replaced with SkinTemplate-based + * versions, sigh... + * @return string + * @todo Exterminate! ...that, and replace it with normal SkinTemplate stuff + */ + function extensionTabLinks() { + $tabs = array(); + $out = ''; + $s = array(); + wfRunHooks( 'SkinTemplateTabs', array( $this->getSkin(), &$tabs ) ); + foreach ( $tabs as $tab ) { + $s[] = Xml::element( 'a', + array( 'href' => $tab['href'] ), + $tab['text'] ); + } + + if ( count( $s ) ) { + global $wgLang; + + $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' ); + $out .= $wgLang->pipeList( $s ); + } + + return $out; + } + + function bottomLinks() { + global $wgOut, $wgUser, $wgUseTrackbacks; + $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n"; + + $s = ''; + if ( $wgOut->isArticleRelated() ) { + $element[] = '' . $this->editThisPage() . ''; + + if ( $wgUser->isLoggedIn() ) { + $element[] = $this->watchThisPage(); + } + + $element[] = $this->talkLink(); + $element[] = $this->historyLink(); + $element[] = $this->whatLinksHere(); + $element[] = $this->watchPageLinksLink(); + + if ( $wgUseTrackbacks ) { + $element[] = $this->trackbackLink(); + } + + if ( + $this->getSkin()->getTitle()->getNamespace() == NS_USER || + $this->getSkin()->getTitle()->getNamespace() == NS_USER_TALK + ) { + $id = User::idFromName( $this->getSkin()->getTitle()->getText() ); + $ip = User::isIP( $this->getSkin()->getTitle()->getText() ); + + # Both anons and non-anons have contributions list + if ( $id || $ip ) { + $element[] = $this->userContribsLink(); + } + + if ( $this->getSkin()->showEmailUser( $id ) ) { + $element[] = $this->emailUserLink(); + } + } + + $s = implode( $element, $sep ); + + if ( $this->getSkin()->getTitle()->getArticleId() ) { + $s .= "\n
"; + + // Delete/protect/move links for privileged users + if ( $wgUser->isAllowed( 'delete' ) ) { + $s .= $this->deleteThisPage(); + } + + if ( $wgUser->isAllowed( 'protect' ) ) { + $s .= $sep . $this->protectThisPage(); + } + + if ( $wgUser->isAllowed( 'move' ) ) { + $s .= $sep . $this->moveThisPage(); + } + } + + $s .= "
\n" . $this->otherLanguages(); + } + + return $s; + } + + function otherLanguages() { + global $wgOut, $wgContLang, $wgHideInterlanguageLinks; + + if ( $wgHideInterlanguageLinks ) { + return ''; + } + + $a = $wgOut->getLanguageLinks(); + + if ( 0 == count( $a ) ) { + return ''; + } + + $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' ); + $first = true; + + if ( $wgContLang->isRTL() ) { + $s .= ''; + } + + foreach ( $a as $l ) { + if ( !$first ) { + $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' ); + } + + $first = false; + + $nt = Title::newFromText( $l ); + $url = $nt->escapeFullURL(); + $text = $wgContLang->getLanguageName( $nt->getInterwiki() ); + $title = htmlspecialchars( $nt->getText() ); + + if ( $text == '' ) { + $text = $l; + } + + $style = $this->getExternalLinkAttributes(); + $s .= "{$text}"; + } + + if ( $wgContLang->isRTL() ) { + $s .= ''; + } + + return $s; + } + + /** + * Show a drop-down box of special pages + */ + function specialPagesList() { + global $wgContLang, $wgServer, $wgRedirectScript; + + $pages = array_merge( SpecialPage::getRegularPages(), SpecialPage::getRestrictedPages() ); + + foreach ( $pages as $name => $page ) { + $pages[$name] = $page->getDescription(); + } + + $go = wfMsg( 'go' ); + $sp = wfMsg( 'specialpages' ); + $spp = $wgContLang->specialPage( 'Specialpages' ); + + $s = '
\n"; + $s .= "\n"; + $s .= "\n"; + $s .= "
\n"; + + return $s; + } + + function pageTitleLinks() { + global $wgOut, $wgUser, $wgRequest, $wgLang; + + $oldid = $wgRequest->getVal( 'oldid' ); + $diff = $wgRequest->getVal( 'diff' ); + $action = $wgRequest->getText( 'action' ); + + $s[] = $this->printableLink(); + $disclaimer = $this->getSkin()->disclaimerLink(); # may be empty + + if ( $disclaimer ) { + $s[] = $disclaimer; + } + + $privacy = $this->getSkin()->privacyLink(); # may be empty too + + if ( $privacy ) { + $s[] = $privacy; + } + + if ( $wgOut->isArticleRelated() ) { + if ( $this->getSkin()->getTitle()->getNamespace() == NS_FILE ) { + $name = $this->getSkin()->getTitle()->getDBkey(); + $image = wfFindFile( $this->getSkin()->getTitle() ); + + if ( $image ) { + $link = htmlspecialchars( $image->getURL() ); + $style = $this->getInternalLinkAttributes( $link, $name ); + $s[] = "{$name}"; + } + } + } + + if ( 'history' == $action || isset( $diff ) || isset( $oldid ) ) { + $s[] .= $this->getSkin()->link( + $this->getSkin()->getTitle(), + wfMsg( 'currentrev' ), + array(), + array(), + array( 'known', 'noclasses' ) + ); + } + + if ( $wgUser->getNewtalk() ) { + # do not show "You have new messages" text when we are viewing our + # own talk page + if ( !$this->getSkin()->getTitle()->equals( $wgUser->getTalkPage() ) ) { + $tl = $this->getSkin()->link( + $wgUser->getTalkPage(), + wfMsgHtml( 'newmessageslink' ), + array(), + array( 'redirect' => 'no' ), + array( 'known', 'noclasses' ) + ); + + $dl = $this->getSkin()->link( + $wgUser->getTalkPage(), + wfMsgHtml( 'newmessagesdifflink' ), + array(), + array( 'diff' => 'cur' ), + array( 'known', 'noclasses' ) + ); + $s[] = '' . wfMsg( 'youhavenewmessages', $tl, $dl ) . ''; + # disable caching + $wgOut->setSquidMaxage( 0 ); + $wgOut->enableClientCache( false ); + } + } + + $undelete = $this->getSkin()->getUndeleteLink(); + + if ( !empty( $undelete ) ) { + $s[] = $undelete; + } + + return $wgLang->pipeList( $s ); + } + + /** + * Gets the h1 element with the page title. + * @return string + */ + function pageTitle() { + global $wgOut; + $s = '

' . $wgOut->getPageTitle() . '

'; + return $s; + } + + function pageSubtitle() { + global $wgOut; + + $sub = $wgOut->getSubtitle(); + + if ( $sub == '' ) { + global $wgExtraSubtitle; + $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle; + } + + $subpages = $this->getSkin()->subPageSubtitle(); + $sub .= !empty( $subpages ) ? "

$subpages" : ''; + $s = "

{$sub}

\n"; + + return $s; + } + + function printableLink() { + global $wgOut, $wgFeedClasses, $wgRequest, $wgLang; + + $s = array(); + + if ( !$wgOut->isPrintable() ) { + $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' ); + $s[] = "" . wfMsg( 'printableversion' ) . ''; + } + + if ( $wgOut->isSyndicated() ) { + foreach ( $wgFeedClasses as $format => $class ) { + $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" ); + $s[] = "" . wfMsgHtml( "feed-$format" ) . ""; + } + } + return $wgLang->pipeList( $s ); + } + + function getQuickbarCompensator( $rows = 1 ) { + return " "; + } + + function editThisPage() { + global $wgOut; + + if ( !$wgOut->isArticleRelated() ) { + $s = wfMsg( 'protectedpage' ); + } else { + if ( $this->getSkin()->getTitle()->quickUserCan( 'edit' ) && $this->getSkin()->getTitle()->exists() ) { + $t = wfMsg( 'editthispage' ); + } elseif ( $this->getSkin()->getTitle()->quickUserCan( 'create' ) && !$this->getSkin()->getTitle()->exists() ) { + $t = wfMsg( 'create-this-page' ); + } else { + $t = wfMsg( 'viewsource' ); + } + + $s = $this->getSkin()->link( + $this->getSkin()->getTitle(), + $t, + array(), + $this->getSkin()->editUrlOptions(), + array( 'known', 'noclasses' ) + ); + } + + return $s; + } + + function deleteThisPage() { + global $wgUser, $wgRequest; + + $diff = $wgRequest->getVal( 'diff' ); + + if ( $this->getSkin()->getTitle()->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) { + $t = wfMsg( 'deletethispage' ); + + $s = $this->getSkin()->link( + $this->getSkin()->getTitle(), + $t, + array(), + array( 'action' => 'delete' ), + array( 'known', 'noclasses' ) + ); + } else { + $s = ''; + } + + return $s; + } + + function protectThisPage() { + global $wgUser, $wgRequest; + + $diff = $wgRequest->getVal( 'diff' ); + + if ( $this->getSkin()->getTitle()->getArticleId() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) { + if ( $this->getSkin()->getTitle()->isProtected() ) { + $text = wfMsg( 'unprotectthispage' ); + $query = array( 'action' => 'unprotect' ); + } else { + $text = wfMsg( 'protectthispage' ); + $query = array( 'action' => 'protect' ); + } + + $s = $this->getSkin()->link( + $this->getSkin()->getTitle(), + $text, + array(), + $query, + array( 'known', 'noclasses' ) + ); + } else { + $s = ''; + } + + return $s; + } + + function watchThisPage() { + global $wgOut; + ++$this->mWatchLinkNum; + + if ( $wgOut->isArticleRelated() ) { + if ( $this->getSkin()->getTitle()->userIsWatching() ) { + $text = wfMsg( 'unwatchthispage' ); + $query = array( 'action' => 'unwatch' ); + $id = 'mw-unwatch-link' . $this->mWatchLinkNum; + } else { + $text = wfMsg( 'watchthispage' ); + $query = array( 'action' => 'watch' ); + $id = 'mw-watch-link' . $this->mWatchLinkNum; + } + + $s = $this->getSkin()->link( + $this->getSkin()->getTitle(), + $text, + array( 'id' => $id ), + $query, + array( 'known', 'noclasses' ) + ); + } else { + $s = wfMsg( 'notanarticle' ); + } + + return $s; + } + + function moveThisPage() { + if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) { + return $this->getSkin()->link( + SpecialPage::getTitleFor( 'Movepage' ), + wfMsg( 'movethispage' ), + array(), + array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() ), + array( 'known', 'noclasses' ) + ); + } else { + // no message if page is protected - would be redundant + return ''; + } + } + + function historyLink() { + return $this->getSkin()->link( + $this->getSkin()->getTitle(), + wfMsgHtml( 'history' ), + array( 'rel' => 'archives' ), + array( 'action' => 'history' ) + ); + } + + function whatLinksHere() { + return $this->getSkin()->link( + SpecialPage::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ), + wfMsgHtml( 'whatlinkshere' ), + array(), + array(), + array( 'known', 'noclasses' ) + ); + } + + function userContribsLink() { + return $this->getSkin()->link( + SpecialPage::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ), + wfMsgHtml( 'contributions' ), + array(), + array(), + array( 'known', 'noclasses' ) + ); + } + + function emailUserLink() { + return $this->getSkin()->link( + SpecialPage::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ), + wfMsg( 'emailuser' ), + array(), + array(), + array( 'known', 'noclasses' ) + ); + } + + function watchPageLinksLink() { + global $wgOut; + + if ( !$wgOut->isArticleRelated() ) { + return '(' . wfMsg( 'notanarticle' ) . ')'; + } else { + return $this->getSkin()->link( + SpecialPage::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ), + wfMsg( 'recentchangeslinked-toolbox' ), + array(), + array(), + array( 'known', 'noclasses' ) + ); + } + } + + function trackbackLink() { + return '' + . wfMsg( 'trackbacklink' ) . ''; + } + + function talkLink() { + if ( NS_SPECIAL == $this->getSkin()->getTitle()->getNamespace() ) { + # No discussion links for special pages + return ''; + } + + $linkOptions = array(); + + if ( $this->getSkin()->getTitle()->isTalkPage() ) { + $link = $this->getSkin()->getTitle()->getSubjectPage(); + switch( $link->getNamespace() ) { + case NS_MAIN: + $text = wfMsg( 'articlepage' ); + break; + case NS_USER: + $text = wfMsg( 'userpage' ); + break; + case NS_PROJECT: + $text = wfMsg( 'projectpage' ); + break; + case NS_FILE: + $text = wfMsg( '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' ); + break; + case NS_TEMPLATE: + $text = wfMsg( 'templatepage' ); + break; + case NS_HELP: + $text = wfMsg( 'viewhelppage' ); + break; + case NS_CATEGORY: + $text = wfMsg( 'categorypage' ); + break; + default: + $text = wfMsg( 'articlepage' ); + } + } else { + $link = $this->getSkin()->getTitle()->getTalkPage(); + $text = wfMsg( 'talkpage' ); + } + + $s = $this->getSkin()->link( $link, $text, array(), array(), $linkOptions ); + + return $s; + } + + function commentLink() { + global $wgOut; + + if ( $this->getSkin()->getTitle()->getNamespace() == NS_SPECIAL ) { + return ''; + } + + # __NEWSECTIONLINK___ changes behaviour here + # If it is present, the link points to this page, otherwise + # it points to the talk page + if ( $this->getSkin()->getTitle()->isTalkPage() ) { + $title = $this->getSkin()->getTitle(); + } elseif ( $wgOut->showNewSectionLink() ) { + $title = $this->getSkin()->getTitle(); + } else { + $title = $this->getSkin()->getTitle()->getTalkPage(); + } + + return $this->getSkin()->link( + $title, + wfMsg( 'postcomment' ), + array(), + array( + 'action' => 'edit', + 'section' => 'new' + ), + array( 'known', 'noclasses' ) + ); + } + + function getUploadLink() { + global $wgUploadNavigationUrl; + + if ( $wgUploadNavigationUrl ) { + # Using an empty class attribute to avoid automatic setting of "external" class + return $this->makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) ); + } else { + return $this->getSkin()->link( + SpecialPage::getTitleFor( 'Upload' ), + wfMsgHtml( 'upload' ), + array(), + array(), + array( 'known', 'noclasses' ) + ); + } + } + + function nameAndLogin() { + global $wgUser, $wgLang, $wgContLang; + + $logoutPage = $wgContLang->specialPage( 'Userlogout' ); + + $ret = ''; + + if ( $wgUser->isAnon() ) { + if ( $this->getSkin()->showIPinHeader() ) { + $name = wfGetIP(); + + $talkLink = $this->getSkin()->link( $wgUser->getTalkPage(), + $wgLang->getNsText( NS_TALK ) ); + + $ret .= "$name ($talkLink)"; + } else { + $ret .= wfMsg( 'notloggedin' ); + } + + $returnTo = $this->getSkin()->getTitle()->getPrefixedDBkey(); + $query = array(); + + if ( $logoutPage != $returnTo ) { + $query['returnto'] = $returnTo; + } + + $loginlink = $wgUser->isAllowed( 'createaccount' ) + ? 'nav-login-createaccount' + : 'login'; + $ret .= "\n
" . $this->getSkin()->link( + SpecialPage::getTitleFor( 'Userlogin' ), + wfMsg( $loginlink ), array(), $query + ); + } else { + $returnTo = $this->getSkin()->getTitle()->getPrefixedDBkey(); + $talkLink = $this->getSkin()->link( $wgUser->getTalkPage(), + $wgLang->getNsText( NS_TALK ) ); + + $ret .= $this->getSkin()->link( $wgUser->getUserPage(), + htmlspecialchars( $wgUser->getName() ) ); + $ret .= " ($talkLink)
"; + $ret .= $wgLang->pipeList( array( + $this->getSkin()->link( + SpecialPage::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ), + array(), array( 'returnto' => $returnTo ) + ), + $this->getSkin()->specialLink( 'Preferences' ), + ) ); + } + + $ret = $wgLang->pipeList( array( + $ret, + $this->getSkin()->link( + Title::newFromText( wfMsgForContent( 'helppage' ) ), + wfMsg( 'help' ) + ), + ) ); + + return $ret; + } + +} + diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index 0faec2f208..7da49835de 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -179,8 +179,6 @@ CONTROL; return; } - $wgOut->suppressQuickbar(); - $oldTitle = $this->mOldPage->getPrefixedText(); $newTitle = $this->mNewPage->getPrefixedText(); if ( $oldTitle == $newTitle ) { @@ -204,6 +202,9 @@ CONTROL; } $sk = $wgUser->getSkin(); + if ( method_exists( $sk, 'suppressQuickbar' ) ) { + $sk->suppressQuickbar(); + } // Check if page is editable $editable = $this->mNewRev->getTitle()->userCan( 'edit' ); diff --git a/skins/CologneBlue.php b/skins/CologneBlue.php index 2fdfe878cc..0363072fd2 100644 --- a/skins/CologneBlue.php +++ b/skins/CologneBlue.php @@ -15,12 +15,46 @@ if( !defined( 'MEDIAWIKI' ) ) { * @todo document * @ingroup Skins */ -class SkinCologneBlue extends Skin { +class SkinCologneBlue extends SkinLegacy { + var $skinname = 'cologneblue', $stylename = 'cologneblue', + $template = 'CologneBlueTemplate'; - function getSkinName() { - return 'cologneblue'; + function setupSkinUserCss( OutputPage $out ){ + parent::setupSkinUserCss( $out ); + $out->addModuleStyles( 'skins.cologneblue' ); + + global $wgContLang; + $qb = $this->qbSetting(); + $rules = array(); + + if ( 2 == $qb ) { # Right + $rules[] = "#quickbar { position: absolute; right: 4px; }"; + $rules[] = "#article { margin-left: 4px; margin-right: 148px; }"; + } elseif ( 1 == $qb ) { + $rules[] = "#quickbar { position: absolute; left: 4px; }"; + $rules[] = "#article { margin-left: 148px; margin-right: 4px; }"; + } elseif ( 3 == $qb ) { # Floating left + $rules[] = "#quickbar { position:absolute; left:4px }"; + $rules[] = "#topbar { margin-left: 148px }"; + $rules[] = "#article { margin-left:148px; margin-right: 4px; }"; + $rules[] = "body>#quickbar { position:fixed; left:4px; top:4px; overflow:auto ;bottom:4px;}"; # Hides from IE + } elseif ( 4 == $qb ) { # Floating right + $rules[] = "#quickbar { position: fixed; right: 4px; }"; + $rules[] = "#topbar { margin-right: 148px }"; + $rules[] = "#article { margin-right: 148px; margin-left: 4px; }"; + $rules[] = "body>#quickbar { position: fixed; right: 4px; top: 4px; overflow: auto ;bottom:4px;}"; # Hides from IE + } + $style = implode( "\n", $rules ); + if ( $wgContLang->getDir() === 'rtl' ) { + $style = CSSJanus::transform( $style, true, false ); + } + $out->addInlineStyle( $style ); } +} + +class CologneBlueTemplate extends LegacyTemplate { + function doBeforeContent() { $mainPageObj = Title::newMainPage(); @@ -41,7 +75,7 @@ class SkinCologneBlue extends Skin { $s .= ''; $s .= str_replace( '
', '', $this->otherLanguages() ); - $cat = $this->getCategoryLinks(); + $cat = $this->getSkin()->getCategoryLinks(); if( $cat ) { $s .= "
$cat\n"; } @@ -69,7 +103,7 @@ class SkinCologneBlue extends Skin { $s .= "\n