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, $wgContLang;
274 $variants = $wgContLang->getVariants();
276 if ( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
277 foreach ( $variants as $code ) {
278 $varname = $wgContLang->getVariantname( $code );
280 if ( $varname == 'disable' ) {
283 $s = $wgLang->pipeList( array(
285 '<a href="' . $this->getSkin()->getTitle()->escapeLocalURL( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
294 * Compatibility for extensions adding functionality through tabs.
295 * Eventually these old skins should be replaced with SkinTemplate-based
298 * @todo Exterminate! ...that, and replace it with normal SkinTemplate stuff
300 function extensionTabLinks() {
304 wfRunHooks( 'SkinTemplateTabs', array( $this->getSkin(), &$tabs ) );
305 foreach ( $tabs as $tab ) {
306 $s[] = Xml
::element( 'a',
307 array( 'href' => $tab['href'] ),
314 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
315 $out .= $wgLang->pipeList( $s );
321 function bottomLinks() {
322 global $wgOut, $wgUser, $wgUseTrackbacks;
323 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
326 if ( $wgOut->isArticleRelated() ) {
327 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
329 if ( $wgUser->isLoggedIn() ) {
330 $element[] = $this->watchThisPage();
333 $element[] = $this->talkLink();
334 $element[] = $this->historyLink();
335 $element[] = $this->whatLinksHere();
336 $element[] = $this->watchPageLinksLink();
338 if ( $wgUseTrackbacks ) {
339 $element[] = $this->trackbackLink();
343 $this->getSkin()->getTitle()->getNamespace() == NS_USER ||
344 $this->getSkin()->getTitle()->getNamespace() == NS_USER_TALK
346 $id = User
::idFromName( $this->getSkin()->getTitle()->getText() );
347 $ip = User
::isIP( $this->getSkin()->getTitle()->getText() );
349 # Both anons and non-anons have contributions list
351 $element[] = $this->userContribsLink();
354 if ( $this->getSkin()->showEmailUser( $id ) ) {
355 $element[] = $this->emailUserLink();
359 $s = implode( $element, $sep );
361 if ( $this->getSkin()->getTitle()->getArticleId() ) {
364 // Delete/protect/move links for privileged users
365 if ( $wgUser->isAllowed( 'delete' ) ) {
366 $s .= $this->deleteThisPage();
369 if ( $wgUser->isAllowed( 'protect' ) ) {
370 $s .= $sep . $this->protectThisPage();
373 if ( $wgUser->isAllowed( 'move' ) ) {
374 $s .= $sep . $this->moveThisPage();
378 $s .= "<br />\n" . $this->otherLanguages();
384 function otherLanguages() {
385 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
387 if ( $wgHideInterlanguageLinks ) {
391 $a = $wgOut->getLanguageLinks();
393 if ( 0 == count( $a ) ) {
397 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
400 if ( $wgContLang->isRTL() ) {
401 $s .= '<span dir="LTR">';
404 foreach ( $a as $l ) {
406 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
411 $nt = Title
::newFromText( $l );
412 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
414 $s .= Html
::element( 'a',
415 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
416 $text == '' ?
$l : $text );
419 if ( $wgContLang->isRTL() ) {
427 * Show a drop-down box of special pages
429 function specialPagesList() {
430 global $wgContLang, $wgServer, $wgRedirectScript;
432 $pages = SpecialPageFactory
::getUsablePages();
434 foreach ( $pages as $name => $page ) {
435 $pages[$name] = $page->getDescription();
439 $sp = wfMsg( 'specialpages' );
440 $spp = $wgContLang->specialPage( 'Specialpages' );
442 $s = '<form id="specialpages" method="get" ' .
443 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
444 $s .= "<select name=\"wpDropdown\">\n";
445 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
448 foreach ( $pages as $name => $desc ) {
449 $p = $wgContLang->specialPage( $name );
450 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
454 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
460 function pageTitleLinks() {
461 global $wgOut, $wgUser, $wgRequest, $wgLang;
463 $oldid = $wgRequest->getVal( 'oldid' );
464 $diff = $wgRequest->getVal( 'diff' );
465 $action = $wgRequest->getText( 'action' );
467 $s[] = $this->printableLink();
468 $disclaimer = $this->getSkin()->disclaimerLink(); # may be empty
474 $privacy = $this->getSkin()->privacyLink(); # may be empty too
480 if ( $wgOut->isArticleRelated() ) {
481 if ( $this->getSkin()->getTitle()->getNamespace() == NS_FILE
) {
482 $name = $this->getSkin()->getTitle()->getDBkey();
483 $image = wfFindFile( $this->getSkin()->getTitle() );
486 $link = htmlspecialchars( $image->getURL() );
487 $style = $this->getInternalLinkAttributes( $link, $name );
488 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
493 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
494 $s[] .= Linker
::link(
495 $this->getSkin()->getTitle(),
496 wfMsg( 'currentrev' ),
499 array( 'known', 'noclasses' )
503 if ( $wgUser->getNewtalk() ) {
504 # do not show "You have new messages" text when we are viewing our
506 if ( !$this->getSkin()->getTitle()->equals( $wgUser->getTalkPage() ) ) {
508 $wgUser->getTalkPage(),
509 wfMsgHtml( 'newmessageslink' ),
511 array( 'redirect' => 'no' ),
512 array( 'known', 'noclasses' )
516 $wgUser->getTalkPage(),
517 wfMsgHtml( 'newmessagesdifflink' ),
519 array( 'diff' => 'cur' ),
520 array( 'known', 'noclasses' )
522 $s[] = '<strong>' . wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
524 $wgOut->setSquidMaxage( 0 );
525 $wgOut->enableClientCache( false );
529 $undelete = $this->getSkin()->getUndeleteLink();
531 if ( !empty( $undelete ) ) {
535 return $wgLang->pipeList( $s );
539 * Gets the h1 element with the page title.
542 function pageTitle() {
544 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
548 function pageSubtitle() {
551 $sub = $wgOut->getSubtitle();
554 global $wgExtraSubtitle;
555 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
558 $subpages = $this->getSkin()->subPageSubtitle();
559 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
560 $s = "<p class='subtitle'>{$sub}</p>\n";
565 function printableLink() {
566 global $wgOut, $wgRequest, $wgLang;
570 if ( !$wgOut->isPrintable() ) {
571 $printurl = htmlspecialchars( $this->getSkin()->getTitle()->getLocalUrl(
572 $wgRequest->appendQueryValue( 'printable', 'yes', true ) ) );
573 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
576 if ( $wgOut->isSyndicated() ) {
577 foreach ( $wgOut->getSyndicationLinks() as $format => $link ) {
578 $feedurl = htmlspecialchars( $link );
579 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
580 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
583 return $wgLang->pipeList( $s );
587 * @deprecated in 1.19
589 function getQuickbarCompensator( $rows = 1 ) {
590 return "<td width='152' rowspan='{$rows}'> </td>";
593 function editThisPage() {
596 if ( !$wgOut->isArticleRelated() ) {
597 $s = wfMsg( 'protectedpage' );
599 if ( $this->getSkin()->getTitle()->quickUserCan( 'edit' ) && $this->getSkin()->getTitle()->exists() ) {
600 $t = wfMsg( 'editthispage' );
601 } elseif ( $this->getSkin()->getTitle()->quickUserCan( 'create' ) && !$this->getSkin()->getTitle()->exists() ) {
602 $t = wfMsg( 'create-this-page' );
604 $t = wfMsg( 'viewsource' );
608 $this->getSkin()->getTitle(),
611 $this->getSkin()->editUrlOptions(),
612 array( 'known', 'noclasses' )
619 function deleteThisPage() {
620 global $wgUser, $wgRequest;
622 $diff = $wgRequest->getVal( 'diff' );
624 if ( $this->getSkin()->getTitle()->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
625 $t = wfMsg( 'deletethispage' );
628 $this->getSkin()->getTitle(),
631 array( 'action' => 'delete' ),
632 array( 'known', 'noclasses' )
641 function protectThisPage() {
642 global $wgUser, $wgRequest;
644 $diff = $wgRequest->getVal( 'diff' );
646 if ( $this->getSkin()->getTitle()->getArticleId() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
647 if ( $this->getSkin()->getTitle()->isProtected() ) {
648 $text = wfMsg( 'unprotectthispage' );
649 $query = array( 'action' => 'unprotect' );
651 $text = wfMsg( 'protectthispage' );
652 $query = array( 'action' => 'protect' );
656 $this->getSkin()->getTitle(),
660 array( 'known', 'noclasses' )
669 function watchThisPage() {
670 global $wgOut, $wgUser;
671 ++
$this->mWatchLinkNum
;
674 $title = $this->getSkin()->getTitle();
676 if ( $wgOut->isArticleRelated() ) {
677 if ( $title->userIsWatching() ) {
678 $text = wfMsg( 'unwatchthispage' );
680 'action' => 'unwatch',
681 'token' => UnwatchAction
::getUnwatchToken( $title, $wgUser ),
683 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
685 $text = wfMsg( 'watchthispage' );
688 'token' => WatchAction
::getWatchToken( $title, $wgUser ),
690 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
696 array( 'id' => $id ),
698 array( 'known', 'noclasses' )
701 $s = wfMsg( 'notanarticle' );
707 function moveThisPage() {
708 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
710 SpecialPage
::getTitleFor( 'Movepage' ),
711 wfMsg( 'movethispage' ),
713 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() ),
714 array( 'known', 'noclasses' )
717 // no message if page is protected - would be redundant
722 function historyLink() {
724 $this->getSkin()->getTitle(),
725 wfMsgHtml( 'history' ),
726 array( 'rel' => 'archives' ),
727 array( 'action' => 'history' )
731 function whatLinksHere() {
733 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
734 wfMsgHtml( 'whatlinkshere' ),
737 array( 'known', 'noclasses' )
741 function userContribsLink() {
743 SpecialPage
::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
744 wfMsgHtml( 'contributions' ),
747 array( 'known', 'noclasses' )
751 function emailUserLink() {
753 SpecialPage
::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
754 wfMsg( 'emailuser' ),
757 array( 'known', 'noclasses' )
761 function watchPageLinksLink() {
764 if ( !$wgOut->isArticleRelated() ) {
765 return '(' . wfMsg( 'notanarticle' ) . ')';
768 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
769 wfMsg( 'recentchangeslinked-toolbox' ),
772 array( 'known', 'noclasses' )
777 function trackbackLink() {
778 return '<a href="' . $this->getSkin()->getTitle()->trackbackURL() . '">'
779 . wfMsg( 'trackbacklink' ) . '</a>';
782 function talkLink() {
783 if ( NS_SPECIAL
== $this->getSkin()->getTitle()->getNamespace() ) {
784 # No discussion links for special pages
788 $linkOptions = array();
790 if ( $this->getSkin()->getTitle()->isTalkPage() ) {
791 $link = $this->getSkin()->getTitle()->getSubjectPage();
792 switch( $link->getNamespace() ) {
794 $text = wfMsg( 'articlepage' );
797 $text = wfMsg( 'userpage' );
800 $text = wfMsg( 'projectpage' );
803 $text = wfMsg( 'imagepage' );
804 # Make link known if image exists, even if the desc. page doesn't.
805 if ( wfFindFile( $link ) )
806 $linkOptions[] = 'known';
809 $text = wfMsg( 'mediawikipage' );
812 $text = wfMsg( 'templatepage' );
815 $text = wfMsg( 'viewhelppage' );
818 $text = wfMsg( 'categorypage' );
821 $text = wfMsg( 'articlepage' );
824 $link = $this->getSkin()->getTitle()->getTalkPage();
825 $text = wfMsg( 'talkpage' );
828 $s = Linker
::link( $link, $text, array(), array(), $linkOptions );
833 function commentLink() {
836 if ( $this->getSkin()->getTitle()->getNamespace() == NS_SPECIAL
) {
840 # __NEWSECTIONLINK___ changes behaviour here
841 # If it is present, the link points to this page, otherwise
842 # it points to the talk page
843 if ( $this->getSkin()->getTitle()->isTalkPage() ) {
844 $title = $this->getSkin()->getTitle();
845 } elseif ( $wgOut->showNewSectionLink() ) {
846 $title = $this->getSkin()->getTitle();
848 $title = $this->getSkin()->getTitle()->getTalkPage();
853 wfMsg( 'postcomment' ),
859 array( 'known', 'noclasses' )
863 function getUploadLink() {
864 global $wgUploadNavigationUrl;
866 if ( $wgUploadNavigationUrl ) {
867 # Using an empty class attribute to avoid automatic setting of "external" class
868 return Linker
::makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) );
871 SpecialPage
::getTitleFor( 'Upload' ),
872 wfMsgHtml( 'upload' ),
875 array( 'known', 'noclasses' )
880 function nameAndLogin() {
881 global $wgUser, $wgLang, $wgRequest, $wgContLang;
883 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
887 if ( $wgUser->isAnon() ) {
888 if ( $this->getSkin()->showIPinHeader() ) {
889 $name = $wgRequest->getIP();
891 $talkLink = Linker
::link( $wgUser->getTalkPage(),
892 $wgLang->getNsText( NS_TALK
) );
894 $ret .= "$name ($talkLink)";
896 $ret .= wfMsg( 'notloggedin' );
899 $returnTo = $this->getSkin()->getTitle()->getPrefixedDBkey();
902 if ( $logoutPage != $returnTo ) {
903 $query['returnto'] = $returnTo;
906 $loginlink = $wgUser->isAllowed( 'createaccount' )
907 ?
'nav-login-createaccount'
909 $ret .= "\n<br />" . Linker
::link(
910 SpecialPage
::getTitleFor( 'Userlogin' ),
911 wfMsg( $loginlink ), array(), $query
914 $returnTo = $this->getSkin()->getTitle()->getPrefixedDBkey();
915 $talkLink = Linker
::link( $wgUser->getTalkPage(),
916 $wgLang->getNsText( NS_TALK
) );
918 $ret .= Linker
::link( $wgUser->getUserPage(),
919 htmlspecialchars( $wgUser->getName() ) );
920 $ret .= " ($talkLink)<br />";
921 $ret .= $wgLang->pipeList( array(
923 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
924 array(), array( 'returnto' => $returnTo )
926 Linker
::specialLink( 'Preferences' ),
930 $ret = $wgLang->pipeList( array(
933 Title
::newFromText( wfMsgForContent( 'helppage' ) ),