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() {
435 $select = new XmlSelect( 'title' );
436 $pages = SpecialPageFactory
::getUsablePages();
437 array_unshift( $pages, SpecialPageFactory
::getPage( 'SpecialPages' ) );
438 foreach ( $pages as $obj ) {
439 $select->addOption( $obj->getDescription(),
440 $obj->getTitle()->getPrefixedDBkey() );
443 return Html
::rawElement( 'form', array( 'id' => 'specialpages', 'method' => 'get',
444 'action' => $wgScript ), $select->getHTML() . Xml
::submitButton( wfMsg( 'go' ) ) );
447 function pageTitleLinks() {
448 global $wgOut, $wgUser, $wgRequest, $wgLang;
450 $oldid = $wgRequest->getVal( 'oldid' );
451 $diff = $wgRequest->getVal( 'diff' );
452 $action = $wgRequest->getText( 'action' );
454 $s[] = $this->printableLink();
455 $disclaimer = $this->getSkin()->disclaimerLink(); # may be empty
461 $privacy = $this->getSkin()->privacyLink(); # may be empty too
467 if ( $wgOut->isArticleRelated() ) {
468 if ( $this->getSkin()->getTitle()->getNamespace() == NS_FILE
) {
469 $name = $this->getSkin()->getTitle()->getDBkey();
470 $image = wfFindFile( $this->getSkin()->getTitle() );
473 $link = htmlspecialchars( $image->getURL() );
474 $style = Linker
::getInternalLinkAttributes( $link, $name );
475 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
480 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
481 $s[] .= Linker
::link(
482 $this->getSkin()->getTitle(),
483 wfMsg( 'currentrev' ),
486 array( 'known', 'noclasses' )
490 if ( $wgUser->getNewtalk() ) {
491 # do not show "You have new messages" text when we are viewing our
493 if ( !$this->getSkin()->getTitle()->equals( $wgUser->getTalkPage() ) ) {
495 $wgUser->getTalkPage(),
496 wfMsgHtml( 'newmessageslink' ),
498 array( 'redirect' => 'no' ),
499 array( 'known', 'noclasses' )
503 $wgUser->getTalkPage(),
504 wfMsgHtml( 'newmessagesdifflink' ),
506 array( 'diff' => 'cur' ),
507 array( 'known', 'noclasses' )
509 $s[] = '<strong>' . wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
511 $wgOut->setSquidMaxage( 0 );
512 $wgOut->enableClientCache( false );
516 $undelete = $this->getSkin()->getUndeleteLink();
518 if ( !empty( $undelete ) ) {
522 return $wgLang->pipeList( $s );
526 * Gets the h1 element with the page title.
529 function pageTitle() {
531 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
535 function pageSubtitle() {
538 $sub = $wgOut->getSubtitle();
541 global $wgExtraSubtitle;
542 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
545 $subpages = $this->getSkin()->subPageSubtitle();
546 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
547 $s = "<p class='subtitle'>{$sub}</p>\n";
552 function printableLink() {
553 global $wgOut, $wgRequest, $wgLang;
557 if ( !$wgOut->isPrintable() ) {
558 $printurl = htmlspecialchars( $this->getSkin()->getTitle()->getLocalUrl(
559 $wgRequest->appendQueryValue( 'printable', 'yes', true ) ) );
560 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
563 if ( $wgOut->isSyndicated() ) {
564 foreach ( $wgOut->getSyndicationLinks() as $format => $link ) {
565 $feedurl = htmlspecialchars( $link );
566 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
567 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
570 return $wgLang->pipeList( $s );
574 * @deprecated in 1.19
576 function getQuickbarCompensator( $rows = 1 ) {
577 return "<td width='152' rowspan='{$rows}'> </td>";
580 function editThisPage() {
583 if ( !$wgOut->isArticleRelated() ) {
584 $s = wfMsg( 'protectedpage' );
586 if ( $this->getSkin()->getTitle()->quickUserCan( 'edit' ) && $this->getSkin()->getTitle()->exists() ) {
587 $t = wfMsg( 'editthispage' );
588 } elseif ( $this->getSkin()->getTitle()->quickUserCan( 'create' ) && !$this->getSkin()->getTitle()->exists() ) {
589 $t = wfMsg( 'create-this-page' );
591 $t = wfMsg( 'viewsource' );
595 $this->getSkin()->getTitle(),
598 $this->getSkin()->editUrlOptions(),
599 array( 'known', 'noclasses' )
606 function deleteThisPage() {
607 global $wgUser, $wgRequest;
609 $diff = $wgRequest->getVal( 'diff' );
611 if ( $this->getSkin()->getTitle()->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
612 $t = wfMsg( 'deletethispage' );
615 $this->getSkin()->getTitle(),
618 array( 'action' => 'delete' ),
619 array( 'known', 'noclasses' )
628 function protectThisPage() {
629 global $wgUser, $wgRequest;
631 $diff = $wgRequest->getVal( 'diff' );
633 if ( $this->getSkin()->getTitle()->getArticleId() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
634 if ( $this->getSkin()->getTitle()->isProtected() ) {
635 $text = wfMsg( 'unprotectthispage' );
636 $query = array( 'action' => 'unprotect' );
638 $text = wfMsg( 'protectthispage' );
639 $query = array( 'action' => 'protect' );
643 $this->getSkin()->getTitle(),
647 array( 'known', 'noclasses' )
656 function watchThisPage() {
657 global $wgOut, $wgUser;
658 ++
$this->mWatchLinkNum
;
661 $title = $this->getSkin()->getTitle();
663 if ( $wgOut->isArticleRelated() ) {
664 if ( $title->userIsWatching() ) {
665 $text = wfMsg( 'unwatchthispage' );
667 'action' => 'unwatch',
668 'token' => UnwatchAction
::getUnwatchToken( $title, $wgUser ),
670 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
672 $text = wfMsg( 'watchthispage' );
675 'token' => WatchAction
::getWatchToken( $title, $wgUser ),
677 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
683 array( 'id' => $id ),
685 array( 'known', 'noclasses' )
688 $s = wfMsg( 'notanarticle' );
694 function moveThisPage() {
695 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
697 SpecialPage
::getTitleFor( 'Movepage' ),
698 wfMsg( 'movethispage' ),
700 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() ),
701 array( 'known', 'noclasses' )
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() {
720 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
721 wfMsgHtml( 'whatlinkshere' ),
724 array( 'known', 'noclasses' )
728 function userContribsLink() {
730 SpecialPage
::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
731 wfMsgHtml( 'contributions' ),
734 array( 'known', 'noclasses' )
738 function emailUserLink() {
740 SpecialPage
::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
741 wfMsg( 'emailuser' ),
744 array( 'known', 'noclasses' )
748 function watchPageLinksLink() {
751 if ( !$wgOut->isArticleRelated() ) {
752 return '(' . wfMsg( 'notanarticle' ) . ')';
755 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
756 wfMsg( 'recentchangeslinked-toolbox' ),
759 array( 'known', 'noclasses' )
764 function trackbackLink() {
765 return '<a href="' . $this->getSkin()->getTitle()->trackbackURL() . '">'
766 . wfMsg( 'trackbacklink' ) . '</a>';
769 function talkLink() {
770 if ( NS_SPECIAL
== $this->getSkin()->getTitle()->getNamespace() ) {
771 # No discussion links for special pages
775 $linkOptions = array();
777 if ( $this->getSkin()->getTitle()->isTalkPage() ) {
778 $link = $this->getSkin()->getTitle()->getSubjectPage();
779 switch( $link->getNamespace() ) {
781 $text = wfMsg( 'articlepage' );
784 $text = wfMsg( 'userpage' );
787 $text = wfMsg( 'projectpage' );
790 $text = wfMsg( 'imagepage' );
791 # Make link known if image exists, even if the desc. page doesn't.
792 if ( wfFindFile( $link ) )
793 $linkOptions[] = 'known';
796 $text = wfMsg( 'mediawikipage' );
799 $text = wfMsg( 'templatepage' );
802 $text = wfMsg( 'viewhelppage' );
805 $text = wfMsg( 'categorypage' );
808 $text = wfMsg( 'articlepage' );
811 $link = $this->getSkin()->getTitle()->getTalkPage();
812 $text = wfMsg( 'talkpage' );
815 $s = Linker
::link( $link, $text, array(), array(), $linkOptions );
820 function commentLink() {
823 if ( $this->getSkin()->getTitle()->getNamespace() == NS_SPECIAL
) {
827 # __NEWSECTIONLINK___ changes behaviour here
828 # If it is present, the link points to this page, otherwise
829 # it points to the talk page
830 if ( $this->getSkin()->getTitle()->isTalkPage() ) {
831 $title = $this->getSkin()->getTitle();
832 } elseif ( $wgOut->showNewSectionLink() ) {
833 $title = $this->getSkin()->getTitle();
835 $title = $this->getSkin()->getTitle()->getTalkPage();
840 wfMsg( 'postcomment' ),
846 array( 'known', 'noclasses' )
850 function getUploadLink() {
851 global $wgUploadNavigationUrl;
853 if ( $wgUploadNavigationUrl ) {
854 # Using an empty class attribute to avoid automatic setting of "external" class
855 return Linker
::makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) );
858 SpecialPage
::getTitleFor( 'Upload' ),
859 wfMsgHtml( 'upload' ),
862 array( 'known', 'noclasses' )
867 function nameAndLogin() {
868 global $wgUser, $wgLang, $wgRequest, $wgContLang;
870 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
874 if ( $wgUser->isAnon() ) {
875 if ( $this->getSkin()->showIPinHeader() ) {
876 $name = $wgRequest->getIP();
878 $talkLink = Linker
::link( $wgUser->getTalkPage(),
879 $wgLang->getNsText( NS_TALK
) );
881 $ret .= "$name ($talkLink)";
883 $ret .= wfMsg( 'notloggedin' );
886 $returnTo = $this->getSkin()->getTitle()->getPrefixedDBkey();
889 if ( $logoutPage != $returnTo ) {
890 $query['returnto'] = $returnTo;
893 $loginlink = $wgUser->isAllowed( 'createaccount' )
894 ?
'nav-login-createaccount'
896 $ret .= "\n<br />" . Linker
::link(
897 SpecialPage
::getTitleFor( 'Userlogin' ),
898 wfMsg( $loginlink ), array(), $query
901 $returnTo = $this->getSkin()->getTitle()->getPrefixedDBkey();
902 $talkLink = Linker
::link( $wgUser->getTalkPage(),
903 $wgLang->getNsText( NS_TALK
) );
905 $ret .= Linker
::link( $wgUser->getUserPage(),
906 htmlspecialchars( $wgUser->getName() ) );
907 $ret .= " ($talkLink)<br />";
908 $ret .= $wgLang->pipeList( array(
910 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
911 array(), array( 'returnto' => $returnTo )
913 Linker
::specialLink( 'Preferences' ),
917 $ret = $wgLang->pipeList( array(
920 Title
::newFromText( wfMsgForContent( 'helppage' ) ),