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 $title = $this->getSkin()->getTitle();
195 if ( !$wgOut->isArticle() ||
!$title->exists() ) {
199 $article = new Article( $title, 0 );
203 if ( !$wgDisableCounters ) {
204 $count = $wgLang->formatNum( $article->getCount() );
207 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
211 if ( $wgMaxCredits != 0 ) {
212 $s .= ' ' . Action
::factory( 'credits', $article )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax );
214 $s .= $this->data
['lastmod'];
217 if ( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
218 $dbr = wfGetDB( DB_SLAVE
);
221 array( 'COUNT(*) AS n' ),
223 'wl_title' => $dbr->strencode( $title->getDBkey() ),
224 'wl_namespace' => $title->getNamespace()
228 $x = $dbr->fetchObject( $res );
230 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
231 array( 'parseinline' ), $wgLang->formatNum( $x->n
)
235 return $s . ' ' . $this->getSkin()->getCopyright();
238 function topLinks() {
242 $this->getSkin()->mainPageLink(),
243 Linker
::specialLink( 'Recentchanges' )
246 if ( $wgOut->isArticleRelated() ) {
247 $s[] = $this->editThisPage();
248 $s[] = $this->historyLink();
251 # Many people don't like this dropdown box
252 # $s[] = $this->specialPagesList();
254 if ( $this->variantLinks() ) {
255 $s[] = $this->variantLinks();
258 if ( $this->extensionTabLinks() ) {
259 $s[] = $this->extensionTabLinks();
262 // @todo FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
263 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
267 * Language/charset variant links for classic-style skins
270 function variantLinks() {
273 /* show links to different language variants */
274 global $wgDisableLangConversion, $wgLang;
276 $title = $this->getSkin()->getTitle();
277 $lang = $title->getPageLanguage();
278 $variants = $lang->getVariants();
280 if ( !$wgDisableLangConversion && sizeof( $variants ) > 1
281 && $title->getNamespace() != NS_SPECIAL
) {
282 foreach ( $variants as $code ) {
283 $varname = $lang->getVariantname( $code );
285 if ( $varname == 'disable' ) {
288 $s = $wgLang->pipeList( array(
290 '<a href="' . $title->escapeLocalURL( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
299 * Compatibility for extensions adding functionality through tabs.
300 * Eventually these old skins should be replaced with SkinTemplate-based
303 * @todo Exterminate! ...that, and replace it with normal SkinTemplate stuff
305 function extensionTabLinks() {
309 wfRunHooks( 'SkinTemplateTabs', array( $this->getSkin(), &$tabs ) );
310 foreach ( $tabs as $tab ) {
311 $s[] = Xml
::element( 'a',
312 array( 'href' => $tab['href'] ),
319 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
320 $out .= $wgLang->pipeList( $s );
326 function bottomLinks() {
327 global $wgOut, $wgUser, $wgUseTrackbacks;
328 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
331 if ( $wgOut->isArticleRelated() ) {
332 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
334 if ( $wgUser->isLoggedIn() ) {
335 $element[] = $this->watchThisPage();
338 $element[] = $this->talkLink();
339 $element[] = $this->historyLink();
340 $element[] = $this->whatLinksHere();
341 $element[] = $this->watchPageLinksLink();
343 if ( $wgUseTrackbacks ) {
344 $element[] = $this->trackbackLink();
347 $title = $this->getSkin()->getTitle();
350 $title->getNamespace() == NS_USER ||
351 $title->getNamespace() == NS_USER_TALK
353 $id = User
::idFromName( $title->getText() );
354 $ip = User
::isIP( $title->getText() );
356 # Both anons and non-anons have contributions list
358 $element[] = $this->userContribsLink();
361 if ( $this->getSkin()->showEmailUser( $id ) ) {
362 $element[] = $this->emailUserLink();
366 $s = implode( $element, $sep );
368 if ( $title->getArticleId() ) {
371 // Delete/protect/move links for privileged users
372 if ( $wgUser->isAllowed( 'delete' ) ) {
373 $s .= $this->deleteThisPage();
376 if ( $wgUser->isAllowed( 'protect' ) ) {
377 $s .= $sep . $this->protectThisPage();
380 if ( $wgUser->isAllowed( 'move' ) ) {
381 $s .= $sep . $this->moveThisPage();
385 $s .= "<br />\n" . $this->otherLanguages();
391 function otherLanguages() {
392 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
394 if ( $wgHideInterlanguageLinks ) {
398 $a = $wgOut->getLanguageLinks();
400 if ( 0 == count( $a ) ) {
404 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
407 if ( $wgContLang->isRTL() ) {
408 $s .= '<span dir="LTR">';
411 foreach ( $a as $l ) {
413 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
418 $nt = Title
::newFromText( $l );
419 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
421 $s .= Html
::element( 'a',
422 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
423 $text == '' ?
$l : $text );
426 if ( $wgContLang->isRTL() ) {
434 * Show a drop-down box of special pages
436 function specialPagesList() {
439 $select = new XmlSelect( 'title' );
440 $pages = SpecialPageFactory
::getUsablePages();
441 array_unshift( $pages, SpecialPageFactory
::getPage( 'SpecialPages' ) );
442 foreach ( $pages as $obj ) {
443 $select->addOption( $obj->getDescription(),
444 $obj->getTitle()->getPrefixedDBkey() );
447 return Html
::rawElement( 'form', array( 'id' => 'specialpages', 'method' => 'get',
448 'action' => $wgScript ), $select->getHTML() . Xml
::submitButton( wfMsg( 'go' ) ) );
451 function pageTitleLinks() {
452 global $wgOut, $wgUser, $wgRequest, $wgLang;
454 $oldid = $wgRequest->getVal( 'oldid' );
455 $diff = $wgRequest->getVal( 'diff' );
456 $action = $wgRequest->getText( 'action' );
458 $skin = $this->getSkin();
459 $title = $skin->getTitle();
461 $s[] = $this->printableLink();
462 $disclaimer = $skin->disclaimerLink(); # may be empty
468 $privacy = $skin->privacyLink(); # may be empty too
474 if ( $wgOut->isArticleRelated() ) {
475 if ( $title->getNamespace() == NS_FILE
) {
476 $name = $title->getDBkey();
477 $image = wfFindFile( $title );
480 $link = htmlspecialchars( $image->getURL() );
481 $style = Linker
::getInternalLinkAttributes( $link, $name );
482 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
487 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
488 $s[] .= Linker
::linkKnown(
490 wfMsg( 'currentrev' )
494 if ( $wgUser->getNewtalk() ) {
495 # do not show "You have new messages" text when we are viewing our
497 if ( !$title->equals( $wgUser->getTalkPage() ) ) {
498 $tl = Linker
::linkKnown(
499 $wgUser->getTalkPage(),
500 wfMsgHtml( 'newmessageslink' ),
502 array( 'redirect' => 'no' )
505 $dl = Linker
::linkKnown(
506 $wgUser->getTalkPage(),
507 wfMsgHtml( 'newmessagesdifflink' ),
509 array( 'diff' => 'cur' )
511 $s[] = '<strong>' . wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
513 $wgOut->setSquidMaxage( 0 );
514 $wgOut->enableClientCache( false );
518 $undelete = $skin->getUndeleteLink();
520 if ( !empty( $undelete ) ) {
524 return $wgLang->pipeList( $s );
528 * Gets the h1 element with the page title.
531 function pageTitle() {
533 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
537 function pageSubtitle() {
540 $sub = $wgOut->getSubtitle();
543 global $wgExtraSubtitle;
544 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
547 $subpages = $this->getSkin()->subPageSubtitle();
548 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
549 $s = "<p class='subtitle'>{$sub}</p>\n";
554 function printableLink() {
555 global $wgOut, $wgRequest, $wgLang;
559 if ( !$wgOut->isPrintable() ) {
560 $printurl = htmlspecialchars( $this->getSkin()->getTitle()->getLocalUrl(
561 $wgRequest->appendQueryValue( 'printable', 'yes', true ) ) );
562 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
565 if ( $wgOut->isSyndicated() ) {
566 foreach ( $wgOut->getSyndicationLinks() as $format => $link ) {
567 $feedurl = htmlspecialchars( $link );
568 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
569 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
572 return $wgLang->pipeList( $s );
576 * @deprecated in 1.19
578 function getQuickbarCompensator( $rows = 1 ) {
579 return "<td width='152' rowspan='{$rows}'> </td>";
582 function editThisPage() {
585 if ( !$wgOut->isArticleRelated() ) {
586 $s = wfMsg( 'protectedpage' );
588 $title = $this->getSkin()->getTitle();
589 if ( $title->quickUserCan( 'edit' ) && $title->exists() ) {
590 $t = wfMsg( 'editthispage' );
591 } elseif ( $title->quickUserCan( 'create' ) && !$title->exists() ) {
592 $t = wfMsg( 'create-this-page' );
594 $t = wfMsg( 'viewsource' );
597 $s = Linker
::linkKnown(
601 $this->getSkin()->editUrlOptions()
608 function deleteThisPage() {
609 global $wgUser, $wgRequest;
611 $diff = $wgRequest->getVal( 'diff' );
612 $title = $this->getSkin()->getTitle();
614 if ( $title->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
615 $t = wfMsg( 'deletethispage' );
617 $s = Linker
::linkKnown(
621 array( 'action' => 'delete' )
630 function protectThisPage() {
631 global $wgUser, $wgRequest;
633 $diff = $wgRequest->getVal( 'diff' );
634 $title = $this->getSkin()->getTitle();
636 if ( $title->getArticleId() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
637 if ( $title->isProtected() ) {
638 $text = wfMsg( 'unprotectthispage' );
639 $query = array( 'action' => 'unprotect' );
641 $text = wfMsg( 'protectthispage' );
642 $query = array( 'action' => 'protect' );
645 $s = Linker
::linkKnown(
658 function watchThisPage() {
659 global $wgOut, $wgUser;
660 ++
$this->mWatchLinkNum
;
663 $title = $this->getSkin()->getTitle();
665 if ( $wgOut->isArticleRelated() ) {
666 if ( $title->userIsWatching() ) {
667 $text = wfMsg( 'unwatchthispage' );
669 'action' => 'unwatch',
670 'token' => UnwatchAction
::getUnwatchToken( $title, $wgUser ),
672 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
674 $text = wfMsg( 'watchthispage' );
677 'token' => WatchAction
::getWatchToken( $title, $wgUser ),
679 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
682 $s = Linker
::linkKnown(
685 array( 'id' => $id ),
689 $s = wfMsg( 'notanarticle' );
695 function moveThisPage() {
696 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
697 return Linker
::linkKnown(
698 SpecialPage
::getTitleFor( 'Movepage' ),
699 wfMsg( 'movethispage' ),
701 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() )
704 // no message if page is protected - would be redundant
709 function historyLink() {
711 $this->getSkin()->getTitle(),
712 wfMsgHtml( 'history' ),
713 array( 'rel' => 'archives' ),
714 array( 'action' => 'history' )
718 function whatLinksHere() {
719 return Linker
::linkKnown(
720 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
721 wfMsgHtml( 'whatlinkshere' )
725 function userContribsLink() {
726 return Linker
::linkKnown(
727 SpecialPage
::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
728 wfMsgHtml( 'contributions' )
732 function emailUserLink() {
733 return Linker
::linkKnown(
734 SpecialPage
::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
735 wfMsgHtml( 'emailuser' )
739 function watchPageLinksLink() {
742 if ( !$wgOut->isArticleRelated() ) {
743 return '(' . wfMsg( 'notanarticle' ) . ')';
745 return Linker
::linkKnown(
746 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
747 wfMsgHtml( 'recentchangeslinked-toolbox' )
752 function trackbackLink() {
753 return '<a href="' . $this->getSkin()->getTitle()->trackbackURL() . '">'
754 . wfMsg( 'trackbacklink' ) . '</a>';
757 function talkLink() {
758 $title = $this->getSkin()->getTitle();
759 if ( NS_SPECIAL
== $title->getNamespace() ) {
760 # No discussion links for special pages
764 $linkOptions = array();
766 if ( $title->isTalkPage() ) {
767 $link = $title->getSubjectPage();
768 switch( $link->getNamespace() ) {
770 $text = wfMsg( 'articlepage' );
773 $text = wfMsg( 'userpage' );
776 $text = wfMsg( 'projectpage' );
779 $text = wfMsg( 'imagepage' );
780 # Make link known if image exists, even if the desc. page doesn't.
781 if ( wfFindFile( $link ) )
782 $linkOptions[] = 'known';
785 $text = wfMsg( 'mediawikipage' );
788 $text = wfMsg( 'templatepage' );
791 $text = wfMsg( 'viewhelppage' );
794 $text = wfMsg( 'categorypage' );
797 $text = wfMsg( 'articlepage' );
800 $link = $title->getTalkPage();
801 $text = wfMsg( 'talkpage' );
804 $s = Linker
::link( $link, $text, array(), array(), $linkOptions );
809 function commentLink() {
812 $title = $this->getSkin()->getTitle();
813 if ( $title->getNamespace() == NS_SPECIAL
) {
817 # __NEWSECTIONLINK___ changes behaviour here
818 # If it is present, the link points to this page, otherwise
819 # it points to the talk page
820 if ( !$title->isTalkPage() && !$wgOut->showNewSectionLink() ) {
821 $title = $title->getTalkPage();
824 return Linker
::linkKnown(
826 wfMsg( 'postcomment' ),
835 function getUploadLink() {
836 global $wgUploadNavigationUrl;
838 if ( $wgUploadNavigationUrl ) {
839 # Using an empty class attribute to avoid automatic setting of "external" class
840 return Linker
::makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) );
842 return Linker
::linkKnown(
843 SpecialPage
::getTitleFor( 'Upload' ),
844 wfMsgHtml( 'upload' )
849 function nameAndLogin() {
850 global $wgUser, $wgLang, $wgRequest;
852 $returnTo = $this->getSkin()->getTitle();
855 if ( $wgUser->isAnon() ) {
856 if ( $this->getSkin()->showIPinHeader() ) {
857 $name = $wgRequest->getIP();
859 $talkLink = Linker
::link( $wgUser->getTalkPage(),
860 $wgLang->getNsText( NS_TALK
) );
862 $ret .= "$name ($talkLink)";
864 $ret .= wfMsg( 'notloggedin' );
869 if ( !$returnTo->isSpecial( 'Userlogout' ) ) {
870 $query['returnto'] = $returnTo->getPrefixedDBkey();
873 $loginlink = $wgUser->isAllowed( 'createaccount' )
874 ?
'nav-login-createaccount'
876 $ret .= "\n<br />" . Linker
::link(
877 SpecialPage
::getTitleFor( 'Userlogin' ),
878 wfMsg( $loginlink ), array(), $query
881 $talkLink = Linker
::link( $wgUser->getTalkPage(),
882 $wgLang->getNsText( NS_TALK
) );
884 $ret .= Linker
::link( $wgUser->getUserPage(),
885 htmlspecialchars( $wgUser->getName() ) );
886 $ret .= " ($talkLink)<br />";
887 $ret .= $wgLang->pipeList( array(
889 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
890 array(), array( 'returnto' => $returnTo->getPrefixedDBkey() )
892 Linker
::specialLink( 'Preferences' ),
896 $ret = $wgLang->pipeList( array(
899 Title
::newFromText( wfMsgForContent( 'helppage' ) ),