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.
88 function beforeContent() {
89 return $this->doBeforeContent();
92 function doBeforeContent() {
94 wfProfileIn( __METHOD__
);
98 $langlinks = $this->otherLanguages();
105 $borderhack = 'class="top"';
108 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
109 "<table border='0' cellspacing='0' width='100%'>\n<tr>\n";
111 if ( $this->getSkin()->qbSetting() == 0 ) {
112 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
113 $this->getSkin()->logoText( $wgLang->alignStart() ) . '</td>';
116 $l = $wgLang->alignStart();
117 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
119 $s .= $this->topLinks();
120 $s .= '<p class="subtitle">' . $this->pageTitleLinks() . "</p>\n";
122 $r = $wgLang->alignEnd();
123 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
124 $s .= $this->nameAndLogin();
125 $s .= "\n<br />" . $this->searchForm() . '</td>';
128 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
131 $s .= "</tr>\n</table>\n</div>\n";
132 $s .= "\n<div id='article'>\n";
134 $notice = $this->getSkin()->getSiteNotice();
137 $s .= "\n<div id='siteNotice'>$notice</div>\n";
139 $s .= $this->pageTitle();
140 $s .= $this->pageSubtitle();
141 $s .= $this->getSkin()->getCategories();
143 wfProfileOut( __METHOD__
);
148 * This gets called shortly before the </body> tag.
149 * @return String HTML to be put before </body>
151 function afterContent() {
152 return $this->doAfterContent();
155 /** overloaded by derived classes */
156 function doAfterContent() {
157 return '</div></div>';
160 function searchForm() {
161 global $wgRequest, $wgUseTwoButtonsSearchForm;
163 $search = $wgRequest->getText( 'search' );
165 $s = '<form id="searchform' . $this->searchboxes
. '" name="search" class="inline" method="post" action="'
166 . $this->getSkin()->escapeSearchLink() . "\">\n"
167 . '<input type="text" id="searchInput' . $this->searchboxes
. '" name="search" size="19" value="'
168 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
169 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
171 if ( $wgUseTwoButtonsSearchForm ) {
172 $s .= ' <input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
174 $s .= ' <a href="' . $this->getSkin()->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
179 // Ensure unique id's for search boxes made after the first
180 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
185 function pageStats() {
186 global $wgOut, $wgLang, $wgRequest, $wgUser;
187 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
189 if ( !is_null( $wgRequest->getVal( 'oldid' ) ) ||
!is_null( $wgRequest->getVal( 'diff' ) ) ) {
193 if ( !$wgOut->isArticle() ||
!$this->getSkin()->getTitle()->exists() ) {
197 $article = new Article( $this->getSkin()->getTitle(), 0 );
201 if ( !$wgDisableCounters ) {
202 $count = $wgLang->formatNum( $article->getCount() );
205 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
209 if ( $wgMaxCredits != 0 ) {
210 $s .= ' ' . Action
::factory( 'credits', $article )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax );
212 $s .= $this->data
['lastmod'];
215 if ( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
216 $dbr = wfGetDB( DB_SLAVE
);
219 array( 'COUNT(*) AS n' ),
221 'wl_title' => $dbr->strencode( $this->getSkin()->getTitle()->getDBkey() ),
222 'wl_namespace' => $this->getSkin()->getTitle()->getNamespace()
226 $x = $dbr->fetchObject( $res );
228 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
229 array( 'parseinline' ), $wgLang->formatNum( $x->n
)
233 return $s . ' ' . $this->getSkin()->getCopyright();
236 function topLinks() {
240 $this->getSkin()->mainPageLink(),
241 Linker
::specialLink( 'Recentchanges' )
244 if ( $wgOut->isArticleRelated() ) {
245 $s[] = $this->editThisPage();
246 $s[] = $this->historyLink();
249 # Many people don't like this dropdown box
250 # $s[] = $this->specialPagesList();
252 if ( $this->variantLinks() ) {
253 $s[] = $this->variantLinks();
256 if ( $this->extensionTabLinks() ) {
257 $s[] = $this->extensionTabLinks();
260 // @todo FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
261 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
265 * Language/charset variant links for classic-style skins
268 function variantLinks() {
271 /* show links to different language variants */
272 global $wgDisableLangConversion, $wgLang;
274 $lang = $this->getSkin()->getTitle()->getPageLanguage();
275 $variants = $lang->getVariants();
277 if ( !$wgDisableLangConversion && sizeof( $variants ) > 1
278 && $title->getNamespace() != NS_SPECIAL
) {
279 foreach ( $variants as $code ) {
280 $varname = $lang->getVariantname( $code );
282 if ( $varname == 'disable' ) {
285 $s = $wgLang->pipeList( array(
287 '<a href="' . $this->getSkin()->getTitle()->escapeLocalURL( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
296 * Compatibility for extensions adding functionality through tabs.
297 * Eventually these old skins should be replaced with SkinTemplate-based
300 * @todo Exterminate! ...that, and replace it with normal SkinTemplate stuff
302 function extensionTabLinks() {
306 wfRunHooks( 'SkinTemplateTabs', array( $this->getSkin(), &$tabs ) );
307 foreach ( $tabs as $tab ) {
308 $s[] = Xml
::element( 'a',
309 array( 'href' => $tab['href'] ),
316 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
317 $out .= $wgLang->pipeList( $s );
323 function bottomLinks() {
324 global $wgOut, $wgUser, $wgUseTrackbacks;
325 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
328 if ( $wgOut->isArticleRelated() ) {
329 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
331 if ( $wgUser->isLoggedIn() ) {
332 $element[] = $this->watchThisPage();
335 $element[] = $this->talkLink();
336 $element[] = $this->historyLink();
337 $element[] = $this->whatLinksHere();
338 $element[] = $this->watchPageLinksLink();
340 if ( $wgUseTrackbacks ) {
341 $element[] = $this->trackbackLink();
345 $this->getSkin()->getTitle()->getNamespace() == NS_USER ||
346 $this->getSkin()->getTitle()->getNamespace() == NS_USER_TALK
348 $id = User
::idFromName( $this->getSkin()->getTitle()->getText() );
349 $ip = User
::isIP( $this->getSkin()->getTitle()->getText() );
351 # Both anons and non-anons have contributions list
353 $element[] = $this->userContribsLink();
356 if ( $this->getSkin()->showEmailUser( $id ) ) {
357 $element[] = $this->emailUserLink();
361 $s = implode( $element, $sep );
363 if ( $this->getSkin()->getTitle()->getArticleId() ) {
366 // Delete/protect/move links for privileged users
367 if ( $wgUser->isAllowed( 'delete' ) ) {
368 $s .= $this->deleteThisPage();
371 if ( $wgUser->isAllowed( 'protect' ) ) {
372 $s .= $sep . $this->protectThisPage();
375 if ( $wgUser->isAllowed( 'move' ) ) {
376 $s .= $sep . $this->moveThisPage();
380 $s .= "<br />\n" . $this->otherLanguages();
386 function otherLanguages() {
387 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
389 if ( $wgHideInterlanguageLinks ) {
393 $a = $wgOut->getLanguageLinks();
395 if ( 0 == count( $a ) ) {
399 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
402 if ( $wgContLang->isRTL() ) {
403 $s .= '<span dir="LTR">';
406 foreach ( $a as $l ) {
408 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
413 $nt = Title
::newFromText( $l );
414 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
416 $s .= Html
::element( 'a',
417 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
418 $text == '' ?
$l : $text );
421 if ( $wgContLang->isRTL() ) {
429 * Show a drop-down box of special pages
431 function specialPagesList() {
432 global $wgContLang, $wgServer, $wgRedirectScript;
434 $pages = SpecialPageFactory
::getUsablePages();
436 foreach ( $pages as $name => $page ) {
437 $pages[$name] = $page->getDescription();
441 $sp = wfMsg( 'specialpages' );
442 $spp = $wgContLang->specialPage( 'Specialpages' );
444 $s = '<form id="specialpages" method="get" ' .
445 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
446 $s .= "<select name=\"wpDropdown\">\n";
447 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
450 foreach ( $pages as $name => $desc ) {
451 $p = $wgContLang->specialPage( $name );
452 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
456 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
462 function pageTitleLinks() {
463 global $wgOut, $wgUser, $wgRequest, $wgLang;
465 $oldid = $wgRequest->getVal( 'oldid' );
466 $diff = $wgRequest->getVal( 'diff' );
467 $action = $wgRequest->getText( 'action' );
469 $s[] = $this->printableLink();
470 $disclaimer = $this->getSkin()->disclaimerLink(); # may be empty
476 $privacy = $this->getSkin()->privacyLink(); # may be empty too
482 if ( $wgOut->isArticleRelated() ) {
483 if ( $this->getSkin()->getTitle()->getNamespace() == NS_FILE
) {
484 $name = $this->getSkin()->getTitle()->getDBkey();
485 $image = wfFindFile( $this->getSkin()->getTitle() );
488 $link = htmlspecialchars( $image->getURL() );
489 $style = $this->getInternalLinkAttributes( $link, $name );
490 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
495 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
496 $s[] .= Linker
::link(
497 $this->getSkin()->getTitle(),
498 wfMsg( 'currentrev' ),
501 array( 'known', 'noclasses' )
505 if ( $wgUser->getNewtalk() ) {
506 # do not show "You have new messages" text when we are viewing our
508 if ( !$this->getSkin()->getTitle()->equals( $wgUser->getTalkPage() ) ) {
510 $wgUser->getTalkPage(),
511 wfMsgHtml( 'newmessageslink' ),
513 array( 'redirect' => 'no' ),
514 array( 'known', 'noclasses' )
518 $wgUser->getTalkPage(),
519 wfMsgHtml( 'newmessagesdifflink' ),
521 array( 'diff' => 'cur' ),
522 array( 'known', 'noclasses' )
524 $s[] = '<strong>' . wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
526 $wgOut->setSquidMaxage( 0 );
527 $wgOut->enableClientCache( false );
531 $undelete = $this->getSkin()->getUndeleteLink();
533 if ( !empty( $undelete ) ) {
537 return $wgLang->pipeList( $s );
541 * Gets the h1 element with the page title.
544 function pageTitle() {
546 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
550 function pageSubtitle() {
553 $sub = $wgOut->getSubtitle();
556 global $wgExtraSubtitle;
557 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
560 $subpages = $this->getSkin()->subPageSubtitle();
561 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
562 $s = "<p class='subtitle'>{$sub}</p>\n";
567 function printableLink() {
568 global $wgOut, $wgRequest, $wgLang;
572 if ( !$wgOut->isPrintable() ) {
573 $printurl = htmlspecialchars( $this->getSkin()->getTitle()->getLocalUrl(
574 $wgRequest->appendQueryValue( 'printable', 'yes', true ) ) );
575 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
578 if ( $wgOut->isSyndicated() ) {
579 foreach ( $wgOut->getSyndicationLinks() as $format => $link ) {
580 $feedurl = htmlspecialchars( $link );
581 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
582 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
585 return $wgLang->pipeList( $s );
589 * @deprecated in 1.19
591 function getQuickbarCompensator( $rows = 1 ) {
592 return "<td width='152' rowspan='{$rows}'> </td>";
595 function editThisPage() {
598 if ( !$wgOut->isArticleRelated() ) {
599 $s = wfMsg( 'protectedpage' );
601 if ( $this->getSkin()->getTitle()->quickUserCan( 'edit' ) && $this->getSkin()->getTitle()->exists() ) {
602 $t = wfMsg( 'editthispage' );
603 } elseif ( $this->getSkin()->getTitle()->quickUserCan( 'create' ) && !$this->getSkin()->getTitle()->exists() ) {
604 $t = wfMsg( 'create-this-page' );
606 $t = wfMsg( 'viewsource' );
610 $this->getSkin()->getTitle(),
613 $this->getSkin()->editUrlOptions(),
614 array( 'known', 'noclasses' )
621 function deleteThisPage() {
622 global $wgUser, $wgRequest;
624 $diff = $wgRequest->getVal( 'diff' );
626 if ( $this->getSkin()->getTitle()->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
627 $t = wfMsg( 'deletethispage' );
630 $this->getSkin()->getTitle(),
633 array( 'action' => 'delete' ),
634 array( 'known', 'noclasses' )
643 function protectThisPage() {
644 global $wgUser, $wgRequest;
646 $diff = $wgRequest->getVal( 'diff' );
648 if ( $this->getSkin()->getTitle()->getArticleId() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
649 if ( $this->getSkin()->getTitle()->isProtected() ) {
650 $text = wfMsg( 'unprotectthispage' );
651 $query = array( 'action' => 'unprotect' );
653 $text = wfMsg( 'protectthispage' );
654 $query = array( 'action' => 'protect' );
658 $this->getSkin()->getTitle(),
662 array( 'known', 'noclasses' )
671 function watchThisPage() {
672 global $wgOut, $wgUser;
673 ++
$this->mWatchLinkNum
;
676 $title = $this->getSkin()->getTitle();
678 if ( $wgOut->isArticleRelated() ) {
679 if ( $title->userIsWatching() ) {
680 $text = wfMsg( 'unwatchthispage' );
682 'action' => 'unwatch',
683 'token' => UnwatchAction
::getUnwatchToken( $title, $wgUser ),
685 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
687 $text = wfMsg( 'watchthispage' );
690 'token' => WatchAction
::getWatchToken( $title, $wgUser ),
692 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
698 array( 'id' => $id ),
700 array( 'known', 'noclasses' )
703 $s = wfMsg( 'notanarticle' );
709 function moveThisPage() {
710 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
712 SpecialPage
::getTitleFor( 'Movepage' ),
713 wfMsg( 'movethispage' ),
715 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() ),
716 array( 'known', 'noclasses' )
719 // no message if page is protected - would be redundant
724 function historyLink() {
726 $this->getSkin()->getTitle(),
727 wfMsgHtml( 'history' ),
728 array( 'rel' => 'archives' ),
729 array( 'action' => 'history' )
733 function whatLinksHere() {
735 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
736 wfMsgHtml( 'whatlinkshere' ),
739 array( 'known', 'noclasses' )
743 function userContribsLink() {
745 SpecialPage
::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
746 wfMsgHtml( 'contributions' ),
749 array( 'known', 'noclasses' )
753 function emailUserLink() {
755 SpecialPage
::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
756 wfMsg( 'emailuser' ),
759 array( 'known', 'noclasses' )
763 function watchPageLinksLink() {
766 if ( !$wgOut->isArticleRelated() ) {
767 return '(' . wfMsg( 'notanarticle' ) . ')';
770 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
771 wfMsg( 'recentchangeslinked-toolbox' ),
774 array( 'known', 'noclasses' )
779 function trackbackLink() {
780 return '<a href="' . $this->getSkin()->getTitle()->trackbackURL() . '">'
781 . wfMsg( 'trackbacklink' ) . '</a>';
784 function talkLink() {
785 if ( NS_SPECIAL
== $this->getSkin()->getTitle()->getNamespace() ) {
786 # No discussion links for special pages
790 $linkOptions = array();
792 if ( $this->getSkin()->getTitle()->isTalkPage() ) {
793 $link = $this->getSkin()->getTitle()->getSubjectPage();
794 switch( $link->getNamespace() ) {
796 $text = wfMsg( 'articlepage' );
799 $text = wfMsg( 'userpage' );
802 $text = wfMsg( 'projectpage' );
805 $text = wfMsg( 'imagepage' );
806 # Make link known if image exists, even if the desc. page doesn't.
807 if ( wfFindFile( $link ) )
808 $linkOptions[] = 'known';
811 $text = wfMsg( 'mediawikipage' );
814 $text = wfMsg( 'templatepage' );
817 $text = wfMsg( 'viewhelppage' );
820 $text = wfMsg( 'categorypage' );
823 $text = wfMsg( 'articlepage' );
826 $link = $this->getSkin()->getTitle()->getTalkPage();
827 $text = wfMsg( 'talkpage' );
830 $s = Linker
::link( $link, $text, array(), array(), $linkOptions );
835 function commentLink() {
838 if ( $this->getSkin()->getTitle()->getNamespace() == NS_SPECIAL
) {
842 # __NEWSECTIONLINK___ changes behaviour here
843 # If it is present, the link points to this page, otherwise
844 # it points to the talk page
845 if ( $this->getSkin()->getTitle()->isTalkPage() ) {
846 $title = $this->getSkin()->getTitle();
847 } elseif ( $wgOut->showNewSectionLink() ) {
848 $title = $this->getSkin()->getTitle();
850 $title = $this->getSkin()->getTitle()->getTalkPage();
855 wfMsg( 'postcomment' ),
861 array( 'known', 'noclasses' )
865 function getUploadLink() {
866 global $wgUploadNavigationUrl;
868 if ( $wgUploadNavigationUrl ) {
869 # Using an empty class attribute to avoid automatic setting of "external" class
870 return Linker
::makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) );
873 SpecialPage
::getTitleFor( 'Upload' ),
874 wfMsgHtml( 'upload' ),
877 array( 'known', 'noclasses' )
882 function nameAndLogin() {
883 global $wgUser, $wgLang, $wgRequest, $wgContLang;
885 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
889 if ( $wgUser->isAnon() ) {
890 if ( $this->getSkin()->showIPinHeader() ) {
891 $name = $wgRequest->getIP();
893 $talkLink = Linker
::link( $wgUser->getTalkPage(),
894 $wgLang->getNsText( NS_TALK
) );
896 $ret .= "$name ($talkLink)";
898 $ret .= wfMsg( 'notloggedin' );
901 $returnTo = $this->getSkin()->getTitle()->getPrefixedDBkey();
904 if ( $logoutPage != $returnTo ) {
905 $query['returnto'] = $returnTo;
908 $loginlink = $wgUser->isAllowed( 'createaccount' )
909 ?
'nav-login-createaccount'
911 $ret .= "\n<br />" . Linker
::link(
912 SpecialPage
::getTitleFor( 'Userlogin' ),
913 wfMsg( $loginlink ), array(), $query
916 $returnTo = $this->getSkin()->getTitle()->getPrefixedDBkey();
917 $talkLink = Linker
::link( $wgUser->getTalkPage(),
918 $wgLang->getNsText( NS_TALK
) );
920 $ret .= Linker
::link( $wgUser->getUserPage(),
921 htmlspecialchars( $wgUser->getName() ) );
922 $ret .= " ($talkLink)<br />";
923 $ret .= $wgLang->pipeList( array(
925 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
926 array(), array( 'returnto' => $returnTo )
928 Linker
::specialLink( 'Preferences' ),
932 $ret = $wgLang->pipeList( array(
935 Title
::newFromText( wfMsgForContent( 'helppage' ) ),