3 * Base class for legacy skins.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
23 class SkinLegacy
extends SkinTemplate
{
24 var $useHeadElement = true;
25 protected $mWatchLinkNum = 0; // Appended to end of watch link id's
28 * Add skin specific stylesheets
29 * @param $out OutputPage
31 function setupSkinUserCss( OutputPage
$out ) {
32 $out->addModuleStyles( 'mediawiki.legacy.shared' );
33 $out->addModuleStyles( 'mediawiki.legacy.oldshared' );
36 public function commonPrintStylesheet() {
41 * This was for the old skins and for users with 640x480 screen.
42 * Please note old skins are still used and might prove useful for
43 * users having old computers or visually impaired.
45 var $mSuppressQuickbar = false;
48 * Suppress the quickbar from the output, only for skin supporting
51 public function suppressQuickbar() {
52 $this->mSuppressQuickbar
= true;
56 * Return whether the quickbar should be suppressed from the output
60 public function isQuickbarSuppressed() {
61 return $this->mSuppressQuickbar
;
64 function qbSetting() {
66 if ( $this->isQuickbarSuppressed() ) {
69 $q = $wgUser->getOption( 'quickbar', 0 );
71 # 5 is the default, which chooses the setting
72 # depending on the directionality of your interface language
74 return $wgLang->isRTL() ?
2 : 1;
81 class LegacyTemplate
extends BaseTemplate
{
83 // How many search boxes have we made? Avoid duplicate id's.
84 protected $searchboxes = '';
87 $this->html( 'headelement' );
88 echo $this->beforeContent();
89 $this->html( 'bodytext' );
91 echo $this->afterContent();
92 $this->html( 'dataAfterContent' );
94 echo "\n</body></html>";
98 * This will be called immediately after the <body> tag. Split into
99 * two functions to make it easier to subclass.
102 function beforeContent() {
103 return $this->doBeforeContent();
106 function doBeforeContent() {
108 wfProfileIn( __METHOD__
);
112 $langlinks = $this->otherLanguages();
119 $borderhack = 'class="top"';
122 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
123 "<table border='0' cellspacing='0' width='100%'>\n<tr>\n";
125 if ( $this->getSkin()->qbSetting() == 0 ) {
126 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
127 $this->getSkin()->logoText( $wgLang->alignStart() ) . '</td>';
130 $l = $wgLang->alignStart();
131 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
133 $s .= $this->topLinks();
134 $s .= '<p class="subtitle">' . $this->pageTitleLinks() . "</p>\n";
136 $r = $wgLang->alignEnd();
137 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
138 $s .= $this->nameAndLogin();
139 $s .= "\n<br />" . $this->searchForm() . '</td>';
142 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
145 $s .= "</tr>\n</table>\n</div>\n";
146 $s .= "\n<div id='article'>\n";
148 $notice = $this->getSkin()->getSiteNotice();
151 $s .= "\n<div id='siteNotice'>$notice</div>\n";
153 $s .= $this->pageTitle();
154 $s .= $this->pageSubtitle();
155 $s .= $this->getSkin()->getCategories();
157 wfProfileOut( __METHOD__
);
162 * This gets called shortly before the </body> tag.
163 * @return String HTML to be put before </body>
165 function afterContent() {
166 return $this->doAfterContent();
169 /** overloaded by derived classes
172 function doAfterContent() {
173 return '</div></div>';
176 function searchForm() {
177 global $wgRequest, $wgUseTwoButtonsSearchForm;
179 $search = $wgRequest->getText( 'search' );
181 $s = '<form id="searchform' . $this->searchboxes
. '" name="search" class="inline" method="post" action="'
182 . $this->getSkin()->escapeSearchLink() . "\">\n"
183 . '<input type="text" id="searchInput' . $this->searchboxes
. '" name="search" size="19" value="'
184 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
185 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
187 if ( $wgUseTwoButtonsSearchForm ) {
188 $s .= ' <input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
190 $s .= ' <a href="' . $this->getSkin()->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
195 // Ensure unique id's for search boxes made after the first
196 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
201 function pageStats() {
203 $items = array( 'viewcount', 'credits', 'lastmod', 'numberofwatchingusers', 'copyright' );
205 foreach( $items as $item ) {
206 if ( $this->data
[$item] !== false ) {
207 $ret[] = $this->data
[$item];
211 return implode( ' ', $ret );
214 function topLinks() {
218 $this->getSkin()->mainPageLink(),
219 Linker
::specialLink( 'Recentchanges' )
222 if ( $wgOut->isArticleRelated() ) {
223 $s[] = $this->editThisPage();
224 $s[] = $this->historyLink();
227 # Many people don't like this dropdown box
228 # $s[] = $this->specialPagesList();
230 if ( $this->variantLinks() ) {
231 $s[] = $this->variantLinks();
234 if ( $this->extensionTabLinks() ) {
235 $s[] = $this->extensionTabLinks();
238 // @todo FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
239 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
243 * Language/charset variant links for classic-style skins
246 function variantLinks() {
249 /* show links to different language variants */
250 global $wgDisableLangConversion, $wgLang;
252 $title = $this->getSkin()->getTitle();
253 $lang = $title->getPageLanguage();
254 $variants = $lang->getVariants();
256 if ( !$wgDisableLangConversion && sizeof( $variants ) > 1
257 && !$title->isSpecialPage() ) {
258 foreach ( $variants as $code ) {
259 $varname = $lang->getVariantname( $code );
261 if ( $varname == 'disable' ) {
264 $s = $wgLang->pipeList( array(
266 '<a href="' . htmlspecialchars( $title->getLocalURL( 'variant=' . $code ) ) . '" lang="' . $code . '" hreflang="' . $code . '">' . htmlspecialchars( $varname ) . '</a>'
275 * Compatibility for extensions adding functionality through tabs.
276 * Eventually these old skins should be replaced with SkinTemplate-based
279 * @todo Exterminate! ...that, and replace it with normal SkinTemplate stuff
281 function extensionTabLinks() {
285 wfRunHooks( 'SkinTemplateTabs', array( $this->getSkin(), &$tabs ) );
286 foreach ( $tabs as $tab ) {
287 $s[] = Xml
::element( 'a',
288 array( 'href' => $tab['href'] ),
295 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
296 $out .= $wgLang->pipeList( $s );
302 function bottomLinks() {
303 global $wgOut, $wgUser;
304 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
307 if ( $wgOut->isArticleRelated() ) {
308 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
310 if ( $wgUser->isLoggedIn() ) {
311 $element[] = $this->watchThisPage();
314 $element[] = $this->talkLink();
315 $element[] = $this->historyLink();
316 $element[] = $this->whatLinksHere();
317 $element[] = $this->watchPageLinksLink();
319 $title = $this->getSkin()->getTitle();
322 $title->getNamespace() == NS_USER ||
323 $title->getNamespace() == NS_USER_TALK
325 $id = User
::idFromName( $title->getText() );
326 $ip = User
::isIP( $title->getText() );
328 # Both anons and non-anons have contributions list
330 $element[] = $this->userContribsLink();
333 if ( $this->getSkin()->showEmailUser( $id ) ) {
334 $element[] = $this->emailUserLink();
338 $s = implode( $element, $sep );
340 if ( $title->getArticleID() ) {
343 // Delete/protect/move links for privileged users
344 if ( $wgUser->isAllowed( 'delete' ) ) {
345 $s .= $this->deleteThisPage();
348 if ( $wgUser->isAllowed( 'protect' ) ) {
349 $s .= $sep . $this->protectThisPage();
352 if ( $wgUser->isAllowed( 'move' ) ) {
353 $s .= $sep . $this->moveThisPage();
357 $s .= "<br />\n" . $this->otherLanguages();
363 function otherLanguages() {
364 global $wgOut, $wgLang, $wgHideInterlanguageLinks;
366 if ( $wgHideInterlanguageLinks ) {
370 $a = $wgOut->getLanguageLinks();
372 if ( 0 == count( $a ) ) {
376 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
379 if ( $wgLang->isRTL() ) {
380 $s .= '<span dir="ltr">';
383 foreach ( $a as $l ) {
385 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
390 $nt = Title
::newFromText( $l );
391 $text = Language
::fetchLanguageName( $nt->getInterwiki() );
393 $s .= Html
::element( 'a',
394 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
395 $text == '' ?
$l : $text );
398 if ( $wgLang->isRTL() ) {
406 * Show a drop-down box of special pages
409 function specialPagesList() {
412 $select = new XmlSelect( 'title' );
413 $pages = SpecialPageFactory
::getUsablePages();
414 array_unshift( $pages, SpecialPageFactory
::getPage( 'SpecialPages' ) );
415 foreach ( $pages as $obj ) {
416 $select->addOption( $obj->getDescription(),
417 $obj->getTitle()->getPrefixedDBkey() );
420 return Html
::rawElement( 'form', array( 'id' => 'specialpages', 'method' => 'get',
421 'action' => $wgScript ), $select->getHTML() . Xml
::submitButton( wfMsg( 'go' ) ) );
424 function pageTitleLinks() {
425 global $wgOut, $wgUser, $wgRequest, $wgLang;
427 $oldid = $wgRequest->getVal( 'oldid' );
428 $diff = $wgRequest->getVal( 'diff' );
429 $action = $wgRequest->getText( 'action' );
431 $skin = $this->getSkin();
432 $title = $skin->getTitle();
434 $s[] = $this->printableLink();
435 $disclaimer = $skin->disclaimerLink(); # may be empty
441 $privacy = $skin->privacyLink(); # may be empty too
447 if ( $wgOut->isArticleRelated() ) {
448 if ( $title->getNamespace() == NS_FILE
) {
449 $name = $title->getDBkey();
450 $image = wfFindFile( $title );
453 $link = htmlspecialchars( $image->getURL() );
454 $style = Linker
::getInternalLinkAttributes( $link, $name );
455 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
460 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
461 $s[] .= Linker
::linkKnown(
463 wfMsg( 'currentrev' )
467 if ( $wgUser->getNewtalk() ) {
468 # do not show "You have new messages" text when we are viewing our
470 if ( !$title->equals( $wgUser->getTalkPage() ) ) {
471 $tl = Linker
::linkKnown(
472 $wgUser->getTalkPage(),
473 wfMsgHtml( 'newmessageslink' ),
475 array( 'redirect' => 'no' )
478 $dl = Linker
::linkKnown(
479 $wgUser->getTalkPage(),
480 wfMsgHtml( 'newmessagesdifflink' ),
482 array( 'diff' => 'cur' )
484 $s[] = '<strong>' . wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
486 $wgOut->setSquidMaxage( 0 );
487 $wgOut->enableClientCache( false );
491 $undelete = $skin->getUndeleteLink();
493 if ( !empty( $undelete ) ) {
497 return $wgLang->pipeList( $s );
501 * Gets the h1 element with the page title.
504 function pageTitle() {
506 $s = '<h1 class="pagetitle"><span dir="auto">' . $wgOut->getPageTitle() . '</span></h1>';
510 function pageSubtitle() {
513 $sub = $wgOut->getSubtitle();
516 global $wgExtraSubtitle;
517 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
520 $subpages = $this->getSkin()->subPageSubtitle();
521 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
522 $s = "<p class='subtitle'>{$sub}</p>\n";
527 function printableLink() {
528 global $wgOut, $wgRequest, $wgLang;
532 if ( !$wgOut->isPrintable() ) {
533 $printurl = htmlspecialchars( $this->getSkin()->getTitle()->getLocalUrl(
534 $wgRequest->appendQueryValue( 'printable', 'yes', true ) ) );
535 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
538 if ( $wgOut->isSyndicated() ) {
539 foreach ( $wgOut->getSyndicationLinks() as $format => $link ) {
540 $feedurl = htmlspecialchars( $link );
541 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
542 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
545 return $wgLang->pipeList( $s );
549 * @deprecated in 1.19
552 function getQuickbarCompensator( $rows = 1 ) {
553 wfDeprecated( __METHOD__
, '1.19' );
554 return "<td width='152' rowspan='{$rows}'> </td>";
557 function editThisPage() {
560 if ( !$wgOut->isArticleRelated() ) {
561 $s = wfMsg( 'protectedpage' );
563 $title = $this->getSkin()->getTitle();
564 if ( $title->quickUserCan( 'edit' ) && $title->exists() ) {
565 $t = wfMsg( 'editthispage' );
566 } elseif ( $title->quickUserCan( 'create' ) && !$title->exists() ) {
567 $t = wfMsg( 'create-this-page' );
569 $t = wfMsg( 'viewsource' );
572 $s = Linker
::linkKnown(
576 $this->getSkin()->editUrlOptions()
583 function deleteThisPage() {
584 global $wgUser, $wgRequest;
586 $diff = $wgRequest->getVal( 'diff' );
587 $title = $this->getSkin()->getTitle();
589 if ( $title->getArticleID() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
590 $t = wfMsg( 'deletethispage' );
592 $s = Linker
::linkKnown(
596 array( 'action' => 'delete' )
605 function protectThisPage() {
606 global $wgUser, $wgRequest;
608 $diff = $wgRequest->getVal( 'diff' );
609 $title = $this->getSkin()->getTitle();
611 if ( $title->getArticleID() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
612 if ( $title->isProtected() ) {
613 $text = wfMsg( 'unprotectthispage' );
614 $query = array( 'action' => 'unprotect' );
616 $text = wfMsg( 'protectthispage' );
617 $query = array( 'action' => 'protect' );
620 $s = Linker
::linkKnown(
633 function watchThisPage() {
634 global $wgOut, $wgUser;
635 ++
$this->mWatchLinkNum
;
638 $title = $this->getSkin()->getTitle();
640 if ( $wgOut->isArticleRelated() ) {
641 if ( $title->userIsWatching() ) {
642 $text = wfMsg( 'unwatchthispage' );
644 'action' => 'unwatch',
645 'token' => UnwatchAction
::getUnwatchToken( $title, $wgUser ),
647 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
649 $text = wfMsg( 'watchthispage' );
652 'token' => WatchAction
::getWatchToken( $title, $wgUser ),
654 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
657 $s = Linker
::linkKnown(
660 array( 'id' => $id ),
664 $s = wfMsg( 'notanarticle' );
670 function moveThisPage() {
671 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
672 return Linker
::linkKnown(
673 SpecialPage
::getTitleFor( 'Movepage' ),
674 wfMsg( 'movethispage' ),
676 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() )
679 // no message if page is protected - would be redundant
684 function historyLink() {
686 $this->getSkin()->getTitle(),
687 wfMsgHtml( 'history' ),
688 array( 'rel' => 'archives' ),
689 array( 'action' => 'history' )
693 function whatLinksHere() {
694 return Linker
::linkKnown(
695 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
696 wfMsgHtml( 'whatlinkshere' )
700 function userContribsLink() {
701 return Linker
::linkKnown(
702 SpecialPage
::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
703 wfMsgHtml( 'contributions' )
707 function emailUserLink() {
708 return Linker
::linkKnown(
709 SpecialPage
::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
710 wfMsgHtml( 'emailuser' )
714 function watchPageLinksLink() {
717 if ( !$wgOut->isArticleRelated() ) {
718 return wfMessage( 'parentheses', wfMessage( 'notanarticle' )->text() )->escaped();
720 return Linker
::linkKnown(
721 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
722 wfMsgHtml( 'recentchangeslinked-toolbox' )
727 function talkLink() {
728 $title = $this->getSkin()->getTitle();
729 if ( NS_SPECIAL
== $title->getNamespace() ) {
730 # No discussion links for special pages
734 $linkOptions = array();
736 if ( $title->isTalkPage() ) {
737 $link = $title->getSubjectPage();
738 switch( $link->getNamespace() ) {
740 $text = wfMsg( 'articlepage' );
743 $text = wfMsg( 'userpage' );
746 $text = wfMsg( 'projectpage' );
749 $text = wfMsg( 'imagepage' );
750 # Make link known if image exists, even if the desc. page doesn't.
751 if ( wfFindFile( $link ) )
752 $linkOptions[] = 'known';
755 $text = wfMsg( 'mediawikipage' );
758 $text = wfMsg( 'templatepage' );
761 $text = wfMsg( 'viewhelppage' );
764 $text = wfMsg( 'categorypage' );
767 $text = wfMsg( 'articlepage' );
770 $link = $title->getTalkPage();
771 $text = wfMsg( 'talkpage' );
774 $s = Linker
::link( $link, $text, array(), array(), $linkOptions );
779 function commentLink() {
782 $title = $this->getSkin()->getTitle();
783 if ( $title->isSpecialPage() ) {
787 # __NEWSECTIONLINK___ changes behaviour here
788 # If it is present, the link points to this page, otherwise
789 # it points to the talk page
790 if ( !$title->isTalkPage() && !$wgOut->showNewSectionLink() ) {
791 $title = $title->getTalkPage();
794 return Linker
::linkKnown(
796 wfMsg( 'postcomment' ),
805 function getUploadLink() {
806 global $wgUploadNavigationUrl;
808 if ( $wgUploadNavigationUrl ) {
809 # Using an empty class attribute to avoid automatic setting of "external" class
810 return Linker
::makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) );
812 return Linker
::linkKnown(
813 SpecialPage
::getTitleFor( 'Upload' ),
814 wfMsgHtml( 'upload' )
819 function nameAndLogin() {
820 global $wgUser, $wgLang, $wgRequest;
822 $returnTo = $this->getSkin()->getTitle();
825 if ( $wgUser->isAnon() ) {
826 if ( $this->getSkin()->showIPinHeader() ) {
827 $name = $wgRequest->getIP();
829 $talkLink = Linker
::link( $wgUser->getTalkPage(),
830 $wgLang->getNsText( NS_TALK
) );
831 $talkLink = wfMessage( 'parentheses' )->rawParams( $talkLink )->escaped();
833 $ret .= "$name $talkLink";
835 $ret .= wfMsg( 'notloggedin' );
840 if ( !$returnTo->isSpecial( 'Userlogout' ) ) {
841 $query['returnto'] = $returnTo->getPrefixedDBkey();
844 $loginlink = $wgUser->isAllowed( 'createaccount' )
845 ?
'nav-login-createaccount'
847 $ret .= "\n<br />" . Linker
::link(
848 SpecialPage
::getTitleFor( 'Userlogin' ),
849 wfMsg( $loginlink ), array(), $query
852 $talkLink = Linker
::link( $wgUser->getTalkPage(),
853 $wgLang->getNsText( NS_TALK
) );
854 $talkLink = wfMessage( 'parentheses' )->rawParams( $talkLink )->escaped();
856 $ret .= Linker
::link( $wgUser->getUserPage(),
857 htmlspecialchars( $wgUser->getName() ) );
858 $ret .= " $talkLink<br />";
859 $ret .= $wgLang->pipeList( array(
861 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
862 array(), array( 'returnto' => $returnTo->getPrefixedDBkey() )
864 Linker
::specialLink( 'Preferences' ),
868 $ret = $wgLang->pipeList( array(
871 Title
::newFromText( wfMsgForContent( 'helppage' ) ),