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 $title = $this->getSkin()->getTitle();
275 $lang = $title->getPageLanguage();
276 $variants = $lang->getVariants();
278 if ( !$wgDisableLangConversion && sizeof( $variants ) > 1
279 && $title->getNamespace() != NS_SPECIAL
) {
280 foreach ( $variants as $code ) {
281 $varname = $lang->getVariantname( $code );
283 if ( $varname == 'disable' ) {
286 $s = $wgLang->pipeList( array(
288 '<a href="' . $this->getSkin()->getTitle()->escapeLocalURL( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
297 * Compatibility for extensions adding functionality through tabs.
298 * Eventually these old skins should be replaced with SkinTemplate-based
301 * @todo Exterminate! ...that, and replace it with normal SkinTemplate stuff
303 function extensionTabLinks() {
307 wfRunHooks( 'SkinTemplateTabs', array( $this->getSkin(), &$tabs ) );
308 foreach ( $tabs as $tab ) {
309 $s[] = Xml
::element( 'a',
310 array( 'href' => $tab['href'] ),
317 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
318 $out .= $wgLang->pipeList( $s );
324 function bottomLinks() {
325 global $wgOut, $wgUser, $wgUseTrackbacks;
326 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
329 if ( $wgOut->isArticleRelated() ) {
330 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
332 if ( $wgUser->isLoggedIn() ) {
333 $element[] = $this->watchThisPage();
336 $element[] = $this->talkLink();
337 $element[] = $this->historyLink();
338 $element[] = $this->whatLinksHere();
339 $element[] = $this->watchPageLinksLink();
341 if ( $wgUseTrackbacks ) {
342 $element[] = $this->trackbackLink();
346 $this->getSkin()->getTitle()->getNamespace() == NS_USER ||
347 $this->getSkin()->getTitle()->getNamespace() == NS_USER_TALK
349 $id = User
::idFromName( $this->getSkin()->getTitle()->getText() );
350 $ip = User
::isIP( $this->getSkin()->getTitle()->getText() );
352 # Both anons and non-anons have contributions list
354 $element[] = $this->userContribsLink();
357 if ( $this->getSkin()->showEmailUser( $id ) ) {
358 $element[] = $this->emailUserLink();
362 $s = implode( $element, $sep );
364 if ( $this->getSkin()->getTitle()->getArticleId() ) {
367 // Delete/protect/move links for privileged users
368 if ( $wgUser->isAllowed( 'delete' ) ) {
369 $s .= $this->deleteThisPage();
372 if ( $wgUser->isAllowed( 'protect' ) ) {
373 $s .= $sep . $this->protectThisPage();
376 if ( $wgUser->isAllowed( 'move' ) ) {
377 $s .= $sep . $this->moveThisPage();
381 $s .= "<br />\n" . $this->otherLanguages();
387 function otherLanguages() {
388 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
390 if ( $wgHideInterlanguageLinks ) {
394 $a = $wgOut->getLanguageLinks();
396 if ( 0 == count( $a ) ) {
400 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
403 if ( $wgContLang->isRTL() ) {
404 $s .= '<span dir="LTR">';
407 foreach ( $a as $l ) {
409 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
414 $nt = Title
::newFromText( $l );
415 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
417 $s .= Html
::element( 'a',
418 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
419 $text == '' ?
$l : $text );
422 if ( $wgContLang->isRTL() ) {
430 * Show a drop-down box of special pages
432 function specialPagesList() {
433 global $wgContLang, $wgServer, $wgRedirectScript;
435 $pages = SpecialPageFactory
::getUsablePages();
437 foreach ( $pages as $name => $page ) {
438 $pages[$name] = $page->getDescription();
442 $sp = wfMsg( 'specialpages' );
443 $spp = $wgContLang->specialPage( 'Specialpages' );
445 $s = '<form id="specialpages" method="get" ' .
446 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
447 $s .= "<select name=\"wpDropdown\">\n";
448 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
451 foreach ( $pages as $name => $desc ) {
452 $p = $wgContLang->specialPage( $name );
453 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
457 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
463 function pageTitleLinks() {
464 global $wgOut, $wgUser, $wgRequest, $wgLang;
466 $oldid = $wgRequest->getVal( 'oldid' );
467 $diff = $wgRequest->getVal( 'diff' );
468 $action = $wgRequest->getText( 'action' );
470 $s[] = $this->printableLink();
471 $disclaimer = $this->getSkin()->disclaimerLink(); # may be empty
477 $privacy = $this->getSkin()->privacyLink(); # may be empty too
483 if ( $wgOut->isArticleRelated() ) {
484 if ( $this->getSkin()->getTitle()->getNamespace() == NS_FILE
) {
485 $name = $this->getSkin()->getTitle()->getDBkey();
486 $image = wfFindFile( $this->getSkin()->getTitle() );
489 $link = htmlspecialchars( $image->getURL() );
490 $style = Linker
::getInternalLinkAttributes( $link, $name );
491 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
496 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
497 $s[] .= Linker
::link(
498 $this->getSkin()->getTitle(),
499 wfMsg( 'currentrev' ),
502 array( 'known', 'noclasses' )
506 if ( $wgUser->getNewtalk() ) {
507 # do not show "You have new messages" text when we are viewing our
509 if ( !$this->getSkin()->getTitle()->equals( $wgUser->getTalkPage() ) ) {
511 $wgUser->getTalkPage(),
512 wfMsgHtml( 'newmessageslink' ),
514 array( 'redirect' => 'no' ),
515 array( 'known', 'noclasses' )
519 $wgUser->getTalkPage(),
520 wfMsgHtml( 'newmessagesdifflink' ),
522 array( 'diff' => 'cur' ),
523 array( 'known', 'noclasses' )
525 $s[] = '<strong>' . wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
527 $wgOut->setSquidMaxage( 0 );
528 $wgOut->enableClientCache( false );
532 $undelete = $this->getSkin()->getUndeleteLink();
534 if ( !empty( $undelete ) ) {
538 return $wgLang->pipeList( $s );
542 * Gets the h1 element with the page title.
545 function pageTitle() {
547 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
551 function pageSubtitle() {
554 $sub = $wgOut->getSubtitle();
557 global $wgExtraSubtitle;
558 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
561 $subpages = $this->getSkin()->subPageSubtitle();
562 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
563 $s = "<p class='subtitle'>{$sub}</p>\n";
568 function printableLink() {
569 global $wgOut, $wgRequest, $wgLang;
573 if ( !$wgOut->isPrintable() ) {
574 $printurl = htmlspecialchars( $this->getSkin()->getTitle()->getLocalUrl(
575 $wgRequest->appendQueryValue( 'printable', 'yes', true ) ) );
576 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
579 if ( $wgOut->isSyndicated() ) {
580 foreach ( $wgOut->getSyndicationLinks() as $format => $link ) {
581 $feedurl = htmlspecialchars( $link );
582 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
583 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
586 return $wgLang->pipeList( $s );
590 * @deprecated in 1.19
592 function getQuickbarCompensator( $rows = 1 ) {
593 return "<td width='152' rowspan='{$rows}'> </td>";
596 function editThisPage() {
599 if ( !$wgOut->isArticleRelated() ) {
600 $s = wfMsg( 'protectedpage' );
602 if ( $this->getSkin()->getTitle()->quickUserCan( 'edit' ) && $this->getSkin()->getTitle()->exists() ) {
603 $t = wfMsg( 'editthispage' );
604 } elseif ( $this->getSkin()->getTitle()->quickUserCan( 'create' ) && !$this->getSkin()->getTitle()->exists() ) {
605 $t = wfMsg( 'create-this-page' );
607 $t = wfMsg( 'viewsource' );
611 $this->getSkin()->getTitle(),
614 $this->getSkin()->editUrlOptions(),
615 array( 'known', 'noclasses' )
622 function deleteThisPage() {
623 global $wgUser, $wgRequest;
625 $diff = $wgRequest->getVal( 'diff' );
627 if ( $this->getSkin()->getTitle()->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
628 $t = wfMsg( 'deletethispage' );
631 $this->getSkin()->getTitle(),
634 array( 'action' => 'delete' ),
635 array( 'known', 'noclasses' )
644 function protectThisPage() {
645 global $wgUser, $wgRequest;
647 $diff = $wgRequest->getVal( 'diff' );
649 if ( $this->getSkin()->getTitle()->getArticleId() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
650 if ( $this->getSkin()->getTitle()->isProtected() ) {
651 $text = wfMsg( 'unprotectthispage' );
652 $query = array( 'action' => 'unprotect' );
654 $text = wfMsg( 'protectthispage' );
655 $query = array( 'action' => 'protect' );
659 $this->getSkin()->getTitle(),
663 array( 'known', 'noclasses' )
672 function watchThisPage() {
673 global $wgOut, $wgUser;
674 ++
$this->mWatchLinkNum
;
677 $title = $this->getSkin()->getTitle();
679 if ( $wgOut->isArticleRelated() ) {
680 if ( $title->userIsWatching() ) {
681 $text = wfMsg( 'unwatchthispage' );
683 'action' => 'unwatch',
684 'token' => UnwatchAction
::getUnwatchToken( $title, $wgUser ),
686 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
688 $text = wfMsg( 'watchthispage' );
691 'token' => WatchAction
::getWatchToken( $title, $wgUser ),
693 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
699 array( 'id' => $id ),
701 array( 'known', 'noclasses' )
704 $s = wfMsg( 'notanarticle' );
710 function moveThisPage() {
711 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
713 SpecialPage
::getTitleFor( 'Movepage' ),
714 wfMsg( 'movethispage' ),
716 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() ),
717 array( 'known', 'noclasses' )
720 // no message if page is protected - would be redundant
725 function historyLink() {
727 $this->getSkin()->getTitle(),
728 wfMsgHtml( 'history' ),
729 array( 'rel' => 'archives' ),
730 array( 'action' => 'history' )
734 function whatLinksHere() {
736 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
737 wfMsgHtml( 'whatlinkshere' ),
740 array( 'known', 'noclasses' )
744 function userContribsLink() {
746 SpecialPage
::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
747 wfMsgHtml( 'contributions' ),
750 array( 'known', 'noclasses' )
754 function emailUserLink() {
756 SpecialPage
::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
757 wfMsg( 'emailuser' ),
760 array( 'known', 'noclasses' )
764 function watchPageLinksLink() {
767 if ( !$wgOut->isArticleRelated() ) {
768 return '(' . wfMsg( 'notanarticle' ) . ')';
771 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
772 wfMsg( 'recentchangeslinked-toolbox' ),
775 array( 'known', 'noclasses' )
780 function trackbackLink() {
781 return '<a href="' . $this->getSkin()->getTitle()->trackbackURL() . '">'
782 . wfMsg( 'trackbacklink' ) . '</a>';
785 function talkLink() {
786 if ( NS_SPECIAL
== $this->getSkin()->getTitle()->getNamespace() ) {
787 # No discussion links for special pages
791 $linkOptions = array();
793 if ( $this->getSkin()->getTitle()->isTalkPage() ) {
794 $link = $this->getSkin()->getTitle()->getSubjectPage();
795 switch( $link->getNamespace() ) {
797 $text = wfMsg( 'articlepage' );
800 $text = wfMsg( 'userpage' );
803 $text = wfMsg( 'projectpage' );
806 $text = wfMsg( 'imagepage' );
807 # Make link known if image exists, even if the desc. page doesn't.
808 if ( wfFindFile( $link ) )
809 $linkOptions[] = 'known';
812 $text = wfMsg( 'mediawikipage' );
815 $text = wfMsg( 'templatepage' );
818 $text = wfMsg( 'viewhelppage' );
821 $text = wfMsg( 'categorypage' );
824 $text = wfMsg( 'articlepage' );
827 $link = $this->getSkin()->getTitle()->getTalkPage();
828 $text = wfMsg( 'talkpage' );
831 $s = Linker
::link( $link, $text, array(), array(), $linkOptions );
836 function commentLink() {
839 if ( $this->getSkin()->getTitle()->getNamespace() == NS_SPECIAL
) {
843 # __NEWSECTIONLINK___ changes behaviour here
844 # If it is present, the link points to this page, otherwise
845 # it points to the talk page
846 if ( $this->getSkin()->getTitle()->isTalkPage() ) {
847 $title = $this->getSkin()->getTitle();
848 } elseif ( $wgOut->showNewSectionLink() ) {
849 $title = $this->getSkin()->getTitle();
851 $title = $this->getSkin()->getTitle()->getTalkPage();
856 wfMsg( 'postcomment' ),
862 array( 'known', 'noclasses' )
866 function getUploadLink() {
867 global $wgUploadNavigationUrl;
869 if ( $wgUploadNavigationUrl ) {
870 # Using an empty class attribute to avoid automatic setting of "external" class
871 return Linker
::makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) );
874 SpecialPage
::getTitleFor( 'Upload' ),
875 wfMsgHtml( 'upload' ),
878 array( 'known', 'noclasses' )
883 function nameAndLogin() {
884 global $wgUser, $wgLang, $wgRequest, $wgContLang;
886 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
890 if ( $wgUser->isAnon() ) {
891 if ( $this->getSkin()->showIPinHeader() ) {
892 $name = $wgRequest->getIP();
894 $talkLink = Linker
::link( $wgUser->getTalkPage(),
895 $wgLang->getNsText( NS_TALK
) );
897 $ret .= "$name ($talkLink)";
899 $ret .= wfMsg( 'notloggedin' );
902 $returnTo = $this->getSkin()->getTitle()->getPrefixedDBkey();
905 if ( $logoutPage != $returnTo ) {
906 $query['returnto'] = $returnTo;
909 $loginlink = $wgUser->isAllowed( 'createaccount' )
910 ?
'nav-login-createaccount'
912 $ret .= "\n<br />" . Linker
::link(
913 SpecialPage
::getTitleFor( 'Userlogin' ),
914 wfMsg( $loginlink ), array(), $query
917 $returnTo = $this->getSkin()->getTitle()->getPrefixedDBkey();
918 $talkLink = Linker
::link( $wgUser->getTalkPage(),
919 $wgLang->getNsText( NS_TALK
) );
921 $ret .= Linker
::link( $wgUser->getUserPage(),
922 htmlspecialchars( $wgUser->getName() ) );
923 $ret .= " ($talkLink)<br />";
924 $ret .= $wgLang->pipeList( array(
926 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
927 array(), array( 'returnto' => $returnTo )
929 Linker
::specialLink( 'Preferences' ),
933 $ret = $wgLang->pipeList( array(
936 Title
::newFromText( wfMsgForContent( 'helppage' ) ),