3 * @defgroup Skins Skins
6 if ( !defined( 'MEDIAWIKI' ) ) {
10 class SkinLegacy
extends SkinTemplate
{
11 var $useHeadElement = true;
12 protected $mWatchLinkNum = 0; // Appended to end of watch link id's
15 * Add skin specific stylesheets
16 * @param $out OutputPage
18 function setupSkinUserCss( OutputPage
$out ) {
19 $out->addModuleStyles( 'mediawiki.legacy.shared' );
20 $out->addModuleStyles( 'mediawiki.legacy.oldshared' );
23 public function commonPrintStylesheet() {
28 * This was for the old skins and for users with 640x480 screen.
29 * Please note old skins are still used and might prove useful for
30 * users having old computers or visually impaired.
32 var $mSuppressQuickbar = false;
35 * Suppress the quickbar from the output, only for skin supporting
38 public function suppressQuickbar() {
39 $this->mSuppressQuickbar
= true;
43 * Return whether the quickbar should be suppressed from the output
47 public function isQuickbarSuppressed() {
48 return $this->mSuppressQuickbar
;
51 function qbSetting() {
53 if ( $this->isQuickbarSuppressed() ) {
56 $q = $wgUser->getOption( 'quickbar', 0 );
58 # 5 is the default, which chooses the setting
59 # depending on the directionality of your interface language
61 return $wgLang->isRTL() ?
2 : 1;
68 class LegacyTemplate
extends BaseTemplate
{
70 // How many search boxes have we made? Avoid duplicate id's.
71 protected $searchboxes = '';
74 $this->html( 'headelement' );
75 echo $this->beforeContent();
76 $this->html( 'bodytext' );
78 echo $this->afterContent();
79 $this->html( 'dataAfterContent' );
81 echo "\n</body></html>";
85 * This will be called immediately after the <body> tag. Split into
86 * two functions to make it easier to subclass.
89 function beforeContent() {
90 return $this->doBeforeContent();
93 function doBeforeContent() {
95 wfProfileIn( __METHOD__
);
99 $langlinks = $this->otherLanguages();
106 $borderhack = 'class="top"';
109 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
110 "<table border='0' cellspacing='0' width='100%'>\n<tr>\n";
112 if ( $this->getSkin()->qbSetting() == 0 ) {
113 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
114 $this->getSkin()->logoText( $wgLang->alignStart() ) . '</td>';
117 $l = $wgLang->alignStart();
118 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
120 $s .= $this->topLinks();
121 $s .= '<p class="subtitle">' . $this->pageTitleLinks() . "</p>\n";
123 $r = $wgLang->alignEnd();
124 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
125 $s .= $this->nameAndLogin();
126 $s .= "\n<br />" . $this->searchForm() . '</td>';
129 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
132 $s .= "</tr>\n</table>\n</div>\n";
133 $s .= "\n<div id='article'>\n";
135 $notice = $this->getSkin()->getSiteNotice();
138 $s .= "\n<div id='siteNotice'>$notice</div>\n";
140 $s .= $this->pageTitle();
141 $s .= $this->pageSubtitle();
142 $s .= $this->getSkin()->getCategories();
144 wfProfileOut( __METHOD__
);
149 * This gets called shortly before the </body> tag.
150 * @return String HTML to be put before </body>
152 function afterContent() {
153 return $this->doAfterContent();
156 /** overloaded by derived classes
159 function doAfterContent() {
160 return '</div></div>';
163 function searchForm() {
164 global $wgRequest, $wgUseTwoButtonsSearchForm;
166 $search = $wgRequest->getText( 'search' );
168 $s = '<form id="searchform' . $this->searchboxes
. '" name="search" class="inline" method="post" action="'
169 . $this->getSkin()->escapeSearchLink() . "\">\n"
170 . '<input type="text" id="searchInput' . $this->searchboxes
. '" name="search" size="19" value="'
171 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
172 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
174 if ( $wgUseTwoButtonsSearchForm ) {
175 $s .= ' <input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
177 $s .= ' <a href="' . $this->getSkin()->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
182 // Ensure unique id's for search boxes made after the first
183 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
188 function pageStats() {
190 $items = array( 'viewcount', 'credits', 'lastmod', 'numberofwatchingusers', 'copyright' );
192 foreach( $items as $item ) {
193 if ( $this->data
[$item] !== false ) {
194 $ret[] = $this->data
[$item];
198 return implode( ' ', $ret );
201 function topLinks() {
205 $this->getSkin()->mainPageLink(),
206 Linker
::specialLink( 'Recentchanges' )
209 if ( $wgOut->isArticleRelated() ) {
210 $s[] = $this->editThisPage();
211 $s[] = $this->historyLink();
214 # Many people don't like this dropdown box
215 # $s[] = $this->specialPagesList();
217 if ( $this->variantLinks() ) {
218 $s[] = $this->variantLinks();
221 if ( $this->extensionTabLinks() ) {
222 $s[] = $this->extensionTabLinks();
225 // @todo FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
226 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
230 * Language/charset variant links for classic-style skins
233 function variantLinks() {
236 /* show links to different language variants */
237 global $wgDisableLangConversion, $wgLang;
239 $title = $this->getSkin()->getTitle();
240 $lang = $title->getPageLanguage();
241 $variants = $lang->getVariants();
243 if ( !$wgDisableLangConversion && sizeof( $variants ) > 1
244 && !$title->isSpecialPage() ) {
245 foreach ( $variants as $code ) {
246 $varname = $lang->getVariantname( $code );
248 if ( $varname == 'disable' ) {
251 $s = $wgLang->pipeList( array(
253 '<a href="' . htmlspecialchars( $title->getLocalURL( 'variant=' . $code ) ) . '" lang="' . $code . '" hreflang="' . $code . '">' . htmlspecialchars( $varname ) . '</a>'
262 * Compatibility for extensions adding functionality through tabs.
263 * Eventually these old skins should be replaced with SkinTemplate-based
266 * @todo Exterminate! ...that, and replace it with normal SkinTemplate stuff
268 function extensionTabLinks() {
272 wfRunHooks( 'SkinTemplateTabs', array( $this->getSkin(), &$tabs ) );
273 foreach ( $tabs as $tab ) {
274 $s[] = Xml
::element( 'a',
275 array( 'href' => $tab['href'] ),
282 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
283 $out .= $wgLang->pipeList( $s );
289 function bottomLinks() {
290 global $wgOut, $wgUser;
291 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
294 if ( $wgOut->isArticleRelated() ) {
295 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
297 if ( $wgUser->isLoggedIn() ) {
298 $element[] = $this->watchThisPage();
301 $element[] = $this->talkLink();
302 $element[] = $this->historyLink();
303 $element[] = $this->whatLinksHere();
304 $element[] = $this->watchPageLinksLink();
306 $title = $this->getSkin()->getTitle();
309 $title->getNamespace() == NS_USER ||
310 $title->getNamespace() == NS_USER_TALK
312 $id = User
::idFromName( $title->getText() );
313 $ip = User
::isIP( $title->getText() );
315 # Both anons and non-anons have contributions list
317 $element[] = $this->userContribsLink();
320 if ( $this->getSkin()->showEmailUser( $id ) ) {
321 $element[] = $this->emailUserLink();
325 $s = implode( $element, $sep );
327 if ( $title->getArticleID() ) {
330 // Delete/protect/move links for privileged users
331 if ( $wgUser->isAllowed( 'delete' ) ) {
332 $s .= $this->deleteThisPage();
335 if ( $wgUser->isAllowed( 'protect' ) ) {
336 $s .= $sep . $this->protectThisPage();
339 if ( $wgUser->isAllowed( 'move' ) ) {
340 $s .= $sep . $this->moveThisPage();
344 $s .= "<br />\n" . $this->otherLanguages();
350 function otherLanguages() {
351 global $wgOut, $wgLang, $wgHideInterlanguageLinks;
353 if ( $wgHideInterlanguageLinks ) {
357 $a = $wgOut->getLanguageLinks();
359 if ( 0 == count( $a ) ) {
363 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
366 if ( $wgLang->isRTL() ) {
367 $s .= '<span dir="ltr">';
370 foreach ( $a as $l ) {
372 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
377 $nt = Title
::newFromText( $l );
378 $text = Language
::fetchLanguageName( $nt->getInterwiki() );
380 $s .= Html
::element( 'a',
381 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
382 $text == '' ?
$l : $text );
385 if ( $wgLang->isRTL() ) {
393 * Show a drop-down box of special pages
396 function specialPagesList() {
399 $select = new XmlSelect( 'title' );
400 $pages = SpecialPageFactory
::getUsablePages();
401 array_unshift( $pages, SpecialPageFactory
::getPage( 'SpecialPages' ) );
402 foreach ( $pages as $obj ) {
403 $select->addOption( $obj->getDescription(),
404 $obj->getTitle()->getPrefixedDBkey() );
407 return Html
::rawElement( 'form', array( 'id' => 'specialpages', 'method' => 'get',
408 'action' => $wgScript ), $select->getHTML() . Xml
::submitButton( wfMsg( 'go' ) ) );
411 function pageTitleLinks() {
412 global $wgOut, $wgUser, $wgRequest, $wgLang;
414 $oldid = $wgRequest->getVal( 'oldid' );
415 $diff = $wgRequest->getVal( 'diff' );
416 $action = $wgRequest->getText( 'action' );
418 $skin = $this->getSkin();
419 $title = $skin->getTitle();
421 $s[] = $this->printableLink();
422 $disclaimer = $skin->disclaimerLink(); # may be empty
428 $privacy = $skin->privacyLink(); # may be empty too
434 if ( $wgOut->isArticleRelated() ) {
435 if ( $title->getNamespace() == NS_FILE
) {
436 $name = $title->getDBkey();
437 $image = wfFindFile( $title );
440 $link = htmlspecialchars( $image->getURL() );
441 $style = Linker
::getInternalLinkAttributes( $link, $name );
442 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
447 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
448 $s[] .= Linker
::linkKnown(
450 wfMsg( 'currentrev' )
454 if ( $wgUser->getNewtalk() ) {
455 # do not show "You have new messages" text when we are viewing our
457 if ( !$title->equals( $wgUser->getTalkPage() ) ) {
458 $tl = Linker
::linkKnown(
459 $wgUser->getTalkPage(),
460 wfMsgHtml( 'newmessageslink' ),
462 array( 'redirect' => 'no' )
465 $dl = Linker
::linkKnown(
466 $wgUser->getTalkPage(),
467 wfMsgHtml( 'newmessagesdifflink' ),
469 array( 'diff' => 'cur' )
471 $s[] = '<strong>' . wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
473 $wgOut->setSquidMaxage( 0 );
474 $wgOut->enableClientCache( false );
478 $undelete = $skin->getUndeleteLink();
480 if ( !empty( $undelete ) ) {
484 return $wgLang->pipeList( $s );
488 * Gets the h1 element with the page title.
491 function pageTitle() {
493 $s = '<h1 class="pagetitle"><span dir="auto">' . $wgOut->getPageTitle() . '</span></h1>';
497 function pageSubtitle() {
500 $sub = $wgOut->getSubtitle();
503 global $wgExtraSubtitle;
504 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
507 $subpages = $this->getSkin()->subPageSubtitle();
508 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
509 $s = "<p class='subtitle'>{$sub}</p>\n";
514 function printableLink() {
515 global $wgOut, $wgRequest, $wgLang;
519 if ( !$wgOut->isPrintable() ) {
520 $printurl = htmlspecialchars( $this->getSkin()->getTitle()->getLocalUrl(
521 $wgRequest->appendQueryValue( 'printable', 'yes', true ) ) );
522 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
525 if ( $wgOut->isSyndicated() ) {
526 foreach ( $wgOut->getSyndicationLinks() as $format => $link ) {
527 $feedurl = htmlspecialchars( $link );
528 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
529 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
532 return $wgLang->pipeList( $s );
536 * @deprecated in 1.19
539 function getQuickbarCompensator( $rows = 1 ) {
540 wfDeprecated( __METHOD__
, '1.19' );
541 return "<td width='152' rowspan='{$rows}'> </td>";
544 function editThisPage() {
547 if ( !$wgOut->isArticleRelated() ) {
548 $s = wfMsg( 'protectedpage' );
550 $title = $this->getSkin()->getTitle();
551 if ( $title->quickUserCan( 'edit' ) && $title->exists() ) {
552 $t = wfMsg( 'editthispage' );
553 } elseif ( $title->quickUserCan( 'create' ) && !$title->exists() ) {
554 $t = wfMsg( 'create-this-page' );
556 $t = wfMsg( 'viewsource' );
559 $s = Linker
::linkKnown(
563 $this->getSkin()->editUrlOptions()
570 function deleteThisPage() {
571 global $wgUser, $wgRequest;
573 $diff = $wgRequest->getVal( 'diff' );
574 $title = $this->getSkin()->getTitle();
576 if ( $title->getArticleID() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
577 $t = wfMsg( 'deletethispage' );
579 $s = Linker
::linkKnown(
583 array( 'action' => 'delete' )
592 function protectThisPage() {
593 global $wgUser, $wgRequest;
595 $diff = $wgRequest->getVal( 'diff' );
596 $title = $this->getSkin()->getTitle();
598 if ( $title->getArticleID() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
599 if ( $title->isProtected() ) {
600 $text = wfMsg( 'unprotectthispage' );
601 $query = array( 'action' => 'unprotect' );
603 $text = wfMsg( 'protectthispage' );
604 $query = array( 'action' => 'protect' );
607 $s = Linker
::linkKnown(
620 function watchThisPage() {
621 global $wgOut, $wgUser;
622 ++
$this->mWatchLinkNum
;
625 $title = $this->getSkin()->getTitle();
627 if ( $wgOut->isArticleRelated() ) {
628 if ( $title->userIsWatching() ) {
629 $text = wfMsg( 'unwatchthispage' );
631 'action' => 'unwatch',
632 'token' => UnwatchAction
::getUnwatchToken( $title, $wgUser ),
634 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
636 $text = wfMsg( 'watchthispage' );
639 'token' => WatchAction
::getWatchToken( $title, $wgUser ),
641 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
644 $s = Linker
::linkKnown(
647 array( 'id' => $id ),
651 $s = wfMsg( 'notanarticle' );
657 function moveThisPage() {
658 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
659 return Linker
::linkKnown(
660 SpecialPage
::getTitleFor( 'Movepage' ),
661 wfMsg( 'movethispage' ),
663 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() )
666 // no message if page is protected - would be redundant
671 function historyLink() {
673 $this->getSkin()->getTitle(),
674 wfMsgHtml( 'history' ),
675 array( 'rel' => 'archives' ),
676 array( 'action' => 'history' )
680 function whatLinksHere() {
681 return Linker
::linkKnown(
682 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
683 wfMsgHtml( 'whatlinkshere' )
687 function userContribsLink() {
688 return Linker
::linkKnown(
689 SpecialPage
::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
690 wfMsgHtml( 'contributions' )
694 function emailUserLink() {
695 return Linker
::linkKnown(
696 SpecialPage
::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
697 wfMsgHtml( 'emailuser' )
701 function watchPageLinksLink() {
704 if ( !$wgOut->isArticleRelated() ) {
705 return wfMessage( 'parentheses', wfMessage( 'notanarticle' )->text() )->escaped();
707 return Linker
::linkKnown(
708 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
709 wfMsgHtml( 'recentchangeslinked-toolbox' )
714 function talkLink() {
715 $title = $this->getSkin()->getTitle();
716 if ( NS_SPECIAL
== $title->getNamespace() ) {
717 # No discussion links for special pages
721 $linkOptions = array();
723 if ( $title->isTalkPage() ) {
724 $link = $title->getSubjectPage();
725 switch( $link->getNamespace() ) {
727 $text = wfMsg( 'articlepage' );
730 $text = wfMsg( 'userpage' );
733 $text = wfMsg( 'projectpage' );
736 $text = wfMsg( 'imagepage' );
737 # Make link known if image exists, even if the desc. page doesn't.
738 if ( wfFindFile( $link ) )
739 $linkOptions[] = 'known';
742 $text = wfMsg( 'mediawikipage' );
745 $text = wfMsg( 'templatepage' );
748 $text = wfMsg( 'viewhelppage' );
751 $text = wfMsg( 'categorypage' );
754 $text = wfMsg( 'articlepage' );
757 $link = $title->getTalkPage();
758 $text = wfMsg( 'talkpage' );
761 $s = Linker
::link( $link, $text, array(), array(), $linkOptions );
766 function commentLink() {
769 $title = $this->getSkin()->getTitle();
770 if ( $title->isSpecialPage() ) {
774 # __NEWSECTIONLINK___ changes behaviour here
775 # If it is present, the link points to this page, otherwise
776 # it points to the talk page
777 if ( !$title->isTalkPage() && !$wgOut->showNewSectionLink() ) {
778 $title = $title->getTalkPage();
781 return Linker
::linkKnown(
783 wfMsg( 'postcomment' ),
792 function getUploadLink() {
793 global $wgUploadNavigationUrl;
795 if ( $wgUploadNavigationUrl ) {
796 # Using an empty class attribute to avoid automatic setting of "external" class
797 return Linker
::makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) );
799 return Linker
::linkKnown(
800 SpecialPage
::getTitleFor( 'Upload' ),
801 wfMsgHtml( 'upload' )
806 function nameAndLogin() {
807 global $wgUser, $wgLang, $wgRequest;
809 $returnTo = $this->getSkin()->getTitle();
812 if ( $wgUser->isAnon() ) {
813 if ( $this->getSkin()->showIPinHeader() ) {
814 $name = $wgRequest->getIP();
816 $talkLink = Linker
::link( $wgUser->getTalkPage(),
817 $wgLang->getNsText( NS_TALK
) );
818 $talkLink = wfMessage( 'parentheses' )->rawParams( $talkLink )->escaped();
820 $ret .= "$name $talkLink";
822 $ret .= wfMsg( 'notloggedin' );
827 if ( !$returnTo->isSpecial( 'Userlogout' ) ) {
828 $query['returnto'] = $returnTo->getPrefixedDBkey();
831 $loginlink = $wgUser->isAllowed( 'createaccount' )
832 ?
'nav-login-createaccount'
834 $ret .= "\n<br />" . Linker
::link(
835 SpecialPage
::getTitleFor( 'Userlogin' ),
836 wfMsg( $loginlink ), array(), $query
839 $talkLink = Linker
::link( $wgUser->getTalkPage(),
840 $wgLang->getNsText( NS_TALK
) );
841 $talkLink = wfMessage( 'parentheses' )->rawParams( $talkLink )->escaped();
843 $ret .= Linker
::link( $wgUser->getUserPage(),
844 htmlspecialchars( $wgUser->getName() ) );
845 $ret .= " $talkLink<br />";
846 $ret .= $wgLang->pipeList( array(
848 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
849 array(), array( 'returnto' => $returnTo->getPrefixedDBkey() )
851 Linker
::specialLink( 'Preferences' ),
855 $ret = $wgLang->pipeList( array(
858 Title
::newFromText( wfMsgForContent( 'helppage' ) ),