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 class LegacyTemplate
extends BaseTemplate
{
43 // How many search boxes have we made? Avoid duplicate id's.
44 protected $searchboxes = '';
47 $this->html( 'headelement' );
48 echo $this->beforeContent();
49 $this->html( 'bodytext' );
51 echo $this->afterContent();
52 $this->html( 'dataAfterContent' );
54 echo "\n</body></html>";
58 * This will be called immediately after the "<body>" tag. Split into
59 * two functions to make it easier to subclass.
62 function beforeContent() {
63 return $this->doBeforeContent();
66 function doBeforeContent() {
68 wfProfileIn( __METHOD__
);
72 $langlinks = $this->otherLanguages();
79 $borderhack = 'class="top"';
82 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
83 "<table cellspacing='0' style='width: 100%;'>\n<tr>\n";
85 if ( $this->getSkin()->qbSetting() == 0 ) {
86 $s .= "<td class='top' style='text-align: left; vertical-align: top;' rowspan='{$rows}'>\n" .
87 $this->getSkin()->logoText( $wgLang->alignStart() ) . '</td>';
90 $l = $wgLang->alignStart();
91 $s .= "<td {$borderhack} style='text-align: $l; vertical-align: top;'>\n";
93 $s .= $this->topLinks();
94 $s .= '<p class="subtitle">' . $this->pageTitleLinks() . "</p>\n";
96 $r = $wgLang->alignEnd();
97 $s .= "</td>\n<td {$borderhack} style='text-align: $r; vertical-align: top;' nowrap='nowrap'>";
98 $s .= $this->nameAndLogin();
99 $s .= "\n<br />" . $this->searchForm() . '</td>';
102 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
105 $s .= "</tr>\n</table>\n</div>\n";
106 $s .= "\n<div id='article'>\n";
108 $notice = $this->getSkin()->getSiteNotice();
111 $s .= "\n<div id='siteNotice'>$notice</div>\n";
113 $s .= $this->pageTitle();
114 $s .= $this->pageSubtitle();
115 $s .= $this->getSkin()->getCategories();
117 wfProfileOut( __METHOD__
);
122 * This gets called shortly before the "</body>" tag.
123 * @return String HTML to be put before "</body>"
125 function afterContent() {
126 return $this->doAfterContent();
129 /** overloaded by derived classes
132 function doAfterContent() {
133 return '</div></div>';
136 function searchForm() {
137 global $wgRequest, $wgUseTwoButtonsSearchForm;
139 $search = $wgRequest->getText( 'search' );
141 $s = '<form id="searchform' . $this->searchboxes
. '" name="search" class="inline" method="post" action="'
142 . $this->getSkin()->escapeSearchLink() . "\">\n"
143 . '<input type="text" id="searchInput' . $this->searchboxes
. '" name="search" size="19" value="'
144 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
145 . '<input type="submit" name="go" value="' . wfMessage( 'searcharticle' )->text() . '" />';
147 if ( $wgUseTwoButtonsSearchForm ) {
148 $s .= ' <input type="submit" name="fulltext" value="' . wfMessage( 'searchbutton' )->text() . "\" />\n";
150 $s .= ' <a href="' . $this->getSkin()->escapeSearchLink() . '" rel="search">' . wfMessage( 'powersearch-legend' )->text() . "</a>\n";
155 // Ensure unique id's for search boxes made after the first
156 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
161 function pageStats() {
163 $items = array( 'viewcount', 'credits', 'lastmod', 'numberofwatchingusers', 'copyright' );
165 foreach( $items as $item ) {
166 if ( $this->data
[$item] !== false ) {
167 $ret[] = $this->data
[$item];
171 return implode( ' ', $ret );
174 function topLinks() {
178 $this->getSkin()->mainPageLink(),
179 Linker
::specialLink( 'Recentchanges' )
182 if ( $wgOut->isArticleRelated() ) {
183 $s[] = $this->editThisPage();
184 $s[] = $this->historyLink();
187 # Many people don't like this dropdown box
188 # $s[] = $this->specialPagesList();
190 if ( $this->variantLinks() ) {
191 $s[] = $this->variantLinks();
194 if ( $this->extensionTabLinks() ) {
195 $s[] = $this->extensionTabLinks();
198 // @todo FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
199 return implode( $s, wfMessage( 'pipe-separator' )->escaped() . "\n" );
203 * Language/charset variant links for classic-style skins
206 function variantLinks() {
209 /* show links to different language variants */
210 global $wgDisableLangConversion, $wgLang;
212 $title = $this->getSkin()->getTitle();
213 $lang = $title->getPageLanguage();
214 $variants = $lang->getVariants();
216 if ( !$wgDisableLangConversion && count( $variants ) > 1
217 && !$title->isSpecialPage() ) {
218 foreach ( $variants as $code ) {
219 $varname = $lang->getVariantname( $code );
221 $s = $wgLang->pipeList( array(
223 '<a href="' . htmlspecialchars( $title->getLocalURL( 'variant=' . $code ) ) . '" lang="' . $code . '" hreflang="' . $code . '">' . htmlspecialchars( $varname ) . '</a>'
232 * Compatibility for extensions adding functionality through tabs.
233 * Eventually these old skins should be replaced with SkinTemplate-based
236 * @todo Exterminate! ...that, and replace it with normal SkinTemplate stuff
238 function extensionTabLinks() {
242 wfRunHooks( 'SkinTemplateTabs', array( $this->getSkin(), &$tabs ) );
243 foreach ( $tabs as $tab ) {
244 $s[] = Xml
::element( 'a',
245 array( 'href' => $tab['href'] ),
252 $out = wfMessage( 'pipe-separator' )->escaped();
253 $out .= $wgLang->pipeList( $s );
259 function bottomLinks() {
260 global $wgOut, $wgUser;
261 $sep = wfMessage( 'pipe-separator' )->escaped() . "\n";
264 if ( $wgOut->isArticleRelated() ) {
265 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
267 if ( $wgUser->isLoggedIn() ) {
268 $element[] = $this->watchThisPage();
271 $element[] = $this->talkLink();
272 $element[] = $this->historyLink();
273 $element[] = $this->whatLinksHere();
274 $element[] = $this->watchPageLinksLink();
276 $title = $this->getSkin()->getTitle();
279 $title->getNamespace() == NS_USER ||
280 $title->getNamespace() == NS_USER_TALK
282 $id = User
::idFromName( $title->getText() );
283 $ip = User
::isIP( $title->getText() );
285 # Both anons and non-anons have contributions list
287 $element[] = $this->userContribsLink();
290 if ( $this->getSkin()->showEmailUser( $id ) ) {
291 $element[] = $this->emailUserLink();
295 $s = implode( $element, $sep );
297 if ( $title->getArticleID() ) {
300 // Delete/protect/move links for privileged users
301 if ( $wgUser->isAllowed( 'delete' ) ) {
302 $s .= $this->deleteThisPage();
305 if ( $wgUser->isAllowed( 'protect' ) && $title->getRestrictionTypes() ) {
306 $s .= $sep . $this->protectThisPage();
309 if ( $wgUser->isAllowed( 'move' ) ) {
310 $s .= $sep . $this->moveThisPage();
314 $s .= "<br />\n" . $this->otherLanguages();
320 function otherLanguages() {
321 global $wgOut, $wgLang, $wgHideInterlanguageLinks;
323 if ( $wgHideInterlanguageLinks ) {
327 $a = $wgOut->getLanguageLinks();
329 if ( 0 == count( $a ) ) {
333 $s = wfMessage( 'otherlanguages' )->text() . wfMessage( 'colon-separator' )->text();
336 if ( $wgLang->isRTL() ) {
337 $s .= '<span dir="ltr">';
340 foreach ( $a as $l ) {
342 $s .= wfMessage( 'pipe-separator' )->escaped();
347 $nt = Title
::newFromText( $l );
348 $text = Language
::fetchLanguageName( $nt->getInterwiki() );
350 $s .= Html
::element( 'a',
351 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
352 $text == '' ?
$l : $text );
355 if ( $wgLang->isRTL() ) {
363 * Show a drop-down box of special pages
366 function specialPagesList() {
369 $select = new XmlSelect( 'title' );
370 $pages = SpecialPageFactory
::getUsablePages();
371 array_unshift( $pages, SpecialPageFactory
::getPage( 'SpecialPages' ) );
372 foreach ( $pages as $obj ) {
373 $select->addOption( $obj->getDescription(),
374 $obj->getTitle()->getPrefixedDBkey() );
377 return Html
::rawElement( 'form',
378 array( 'id' => 'specialpages', 'method' => 'get', 'action' => $wgScript ),
379 $select->getHTML() . Xml
::submitButton( wfMessage( 'go' )->text() ) );
382 function pageTitleLinks() {
383 global $wgOut, $wgUser, $wgRequest, $wgLang;
385 $oldid = $wgRequest->getVal( 'oldid' );
386 $diff = $wgRequest->getVal( 'diff' );
387 $action = $wgRequest->getText( 'action' );
389 $skin = $this->getSkin();
390 $title = $skin->getTitle();
392 $s[] = $this->printableLink();
393 $disclaimer = $skin->disclaimerLink(); # may be empty
399 $privacy = $skin->privacyLink(); # may be empty too
405 if ( $wgOut->isArticleRelated() ) {
406 if ( $title->getNamespace() == NS_FILE
) {
407 $image = wfFindFile( $title );
410 $href = $image->getURL();
411 $s[] = Html
::element( 'a', array( 'href' => $href,
412 'title' => $href ), $title->getText() );
418 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
419 $s[] .= Linker
::linkKnown(
421 wfMessage( 'currentrev' )->text()
425 if ( $wgUser->getNewtalk() ) {
426 # do not show "You have new messages" text when we are viewing our
428 if ( !$title->equals( $wgUser->getTalkPage() ) ) {
429 $tl = Linker
::linkKnown(
430 $wgUser->getTalkPage(),
431 wfMessage( 'newmessageslink' )->escaped(),
433 array( 'redirect' => 'no' )
436 $dl = Linker
::linkKnown(
437 $wgUser->getTalkPage(),
438 wfMessage( 'newmessagesdifflink' )->escaped(),
440 array( 'diff' => 'cur' )
442 $s[] = '<strong>' . wfMessage( 'youhavenewmessages', $tl, $dl )->text() . '</strong>';
444 $wgOut->setSquidMaxage( 0 );
445 $wgOut->enableClientCache( false );
449 $undelete = $skin->getUndeleteLink();
451 if ( !empty( $undelete ) ) {
455 return $wgLang->pipeList( $s );
459 * Gets the h1 element with the page title.
462 function pageTitle() {
464 $s = '<h1 class="pagetitle"><span dir="auto">' . $wgOut->getPageTitle() . '</span></h1>';
468 function pageSubtitle() {
471 $sub = $wgOut->getSubtitle();
474 global $wgExtraSubtitle;
475 $sub = wfMessage( 'tagline' )->parse() . $wgExtraSubtitle;
478 $subpages = $this->getSkin()->subPageSubtitle();
479 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
480 $s = "<p class='subtitle'>{$sub}</p>\n";
485 function printableLink() {
486 global $wgOut, $wgRequest, $wgLang;
490 if ( !$wgOut->isPrintable() ) {
491 $printurl = htmlspecialchars( $this->getSkin()->getTitle()->getLocalURL(
492 $wgRequest->appendQueryValue( 'printable', 'yes', true ) ) );
493 $s[] = "<a href=\"$printurl\" rel=\"alternate\">"
494 . wfMessage( 'printableversion' )->text() . '</a>';
497 if ( $wgOut->isSyndicated() ) {
498 foreach ( $wgOut->getSyndicationLinks() as $format => $link ) {
499 $feedurl = htmlspecialchars( $link );
500 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
501 . " class=\"feedlink\">" . wfMessage( "feed-$format" )->escaped() . "</a>";
504 return $wgLang->pipeList( $s );
508 * @deprecated in 1.19
511 function getQuickbarCompensator( $rows = 1 ) {
512 wfDeprecated( __METHOD__
, '1.19' );
513 return "<td style='width: 152px;' rowspan='{$rows}'> </td>";
516 function editThisPage() {
519 if ( !$wgOut->isArticleRelated() ) {
520 $s = wfMessage( 'protectedpage' )->text();
522 $title = $this->getSkin()->getTitle();
523 if ( $title->quickUserCan( 'edit' ) && $title->exists() ) {
524 $t = wfMessage( 'editthispage' )->text();
525 } elseif ( $title->quickUserCan( 'create' ) && !$title->exists() ) {
526 $t = wfMessage( 'create-this-page' )->text();
528 $t = wfMessage( 'viewsource' )->text();
531 $s = Linker
::linkKnown(
535 $this->getSkin()->editUrlOptions()
542 function deleteThisPage() {
543 global $wgUser, $wgRequest;
545 $diff = $wgRequest->getVal( 'diff' );
546 $title = $this->getSkin()->getTitle();
548 if ( $title->getArticleID() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
549 $t = wfMessage( 'deletethispage' )->text();
551 $s = Linker
::linkKnown(
555 array( 'action' => 'delete' )
564 function protectThisPage() {
565 global $wgUser, $wgRequest;
567 $diff = $wgRequest->getVal( 'diff' );
568 $title = $this->getSkin()->getTitle();
570 if ( $title->getArticleID() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) && $title->getRestrictionTypes() ) {
571 if ( $title->isProtected() ) {
572 $text = wfMessage( 'unprotectthispage' )->text();
573 $query = array( 'action' => 'unprotect' );
575 $text = wfMessage( 'protectthispage' )->text();
576 $query = array( 'action' => 'protect' );
579 $s = Linker
::linkKnown(
592 function watchThisPage() {
593 global $wgOut, $wgUser;
594 ++
$this->mWatchLinkNum
;
597 $title = $this->getSkin()->getTitle();
599 if ( $wgOut->isArticleRelated() ) {
600 if ( $wgUser->isWatched( $title ) ) {
601 $text = wfMessage( 'unwatchthispage' )->text();
603 'action' => 'unwatch',
604 'token' => UnwatchAction
::getUnwatchToken( $title, $wgUser ),
606 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
608 $text = wfMessage( 'watchthispage' )->text();
611 'token' => WatchAction
::getWatchToken( $title, $wgUser ),
613 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
616 $s = Linker
::linkKnown(
619 array( 'id' => $id ),
623 $s = wfMessage( 'notanarticle' )->text();
629 function moveThisPage() {
630 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
631 return Linker
::linkKnown(
632 SpecialPage
::getTitleFor( 'Movepage' ),
633 wfMessage( 'movethispage' )->text(),
635 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() )
638 // no message if page is protected - would be redundant
643 function historyLink() {
645 $this->getSkin()->getTitle(),
646 wfMessage( 'history' )->escaped(),
647 array( 'rel' => 'archives' ),
648 array( 'action' => 'history' )
652 function whatLinksHere() {
653 return Linker
::linkKnown(
654 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
655 wfMessage( 'whatlinkshere' )->escaped()
659 function userContribsLink() {
660 return Linker
::linkKnown(
661 SpecialPage
::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
662 wfMessage( 'contributions' )->escaped()
666 function emailUserLink() {
667 return Linker
::linkKnown(
668 SpecialPage
::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
669 wfMessage( 'emailuser' )->escaped()
673 function watchPageLinksLink() {
676 if ( !$wgOut->isArticleRelated() ) {
677 return wfMessage( 'parentheses', wfMessage( 'notanarticle' )->text() )->escaped();
679 return Linker
::linkKnown(
680 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
681 wfMessage( 'recentchangeslinked-toolbox' )->escaped()
686 function talkLink() {
687 $title = $this->getSkin()->getTitle();
688 if ( NS_SPECIAL
== $title->getNamespace() ) {
689 # No discussion links for special pages
693 $linkOptions = array();
695 if ( $title->isTalkPage() ) {
696 $link = $title->getSubjectPage();
697 switch( $link->getNamespace() ) {
699 $text = wfMessage( 'articlepage' );
702 $text = wfMessage( 'userpage' );
705 $text = wfMessage( 'projectpage' );
708 $text = wfMessage( 'imagepage' );
709 # Make link known if image exists, even if the desc. page doesn't.
710 if ( wfFindFile( $link ) )
711 $linkOptions[] = 'known';
714 $text = wfMessage( 'mediawikipage' );
717 $text = wfMessage( 'templatepage' );
720 $text = wfMessage( 'viewhelppage' );
723 $text = wfMessage( 'categorypage' );
726 $text = wfMessage( 'articlepage' );
729 $link = $title->getTalkPage();
730 $text = wfMessage( 'talkpage' );
733 $s = Linker
::link( $link, $text->text(), array(), array(), $linkOptions );
738 function commentLink() {
741 $title = $this->getSkin()->getTitle();
742 if ( $title->isSpecialPage() ) {
746 # __NEWSECTIONLINK___ changes behavior here
747 # If it is present, the link points to this page, otherwise
748 # it points to the talk page
749 if ( !$title->isTalkPage() && !$wgOut->showNewSectionLink() ) {
750 $title = $title->getTalkPage();
753 return Linker
::linkKnown(
755 wfMessage( 'postcomment' )->text(),
764 function getUploadLink() {
765 global $wgUploadNavigationUrl;
767 if ( $wgUploadNavigationUrl ) {
768 # Using an empty class attribute to avoid automatic setting of "external" class
769 return Linker
::makeExternalLink( $wgUploadNavigationUrl,
770 wfMessage( 'upload' )->escaped(),
771 false, null, array( 'class' => '' ) );
773 return Linker
::linkKnown(
774 SpecialPage
::getTitleFor( 'Upload' ),
775 wfMessage( 'upload' )->escaped()
780 function nameAndLogin() {
781 global $wgUser, $wgLang, $wgRequest;
783 $returnTo = $this->getSkin()->getTitle();
786 if ( $wgUser->isAnon() ) {
787 if ( $this->getSkin()->showIPinHeader() ) {
788 $name = $wgRequest->getIP();
790 $talkLink = Linker
::link( $wgUser->getTalkPage(),
791 $wgLang->getNsText( NS_TALK
) );
792 $talkLink = wfMessage( 'parentheses' )->rawParams( $talkLink )->escaped();
794 $ret .= "$name $talkLink";
796 $ret .= wfMessage( 'notloggedin' )->text();
801 if ( !$returnTo->isSpecial( 'Userlogout' ) ) {
802 $query['returnto'] = $returnTo->getPrefixedDBkey();
805 $loginlink = $wgUser->isAllowed( 'createaccount' )
806 ?
'nav-login-createaccount'
808 $ret .= "\n<br />" . Linker
::link(
809 SpecialPage
::getTitleFor( 'Userlogin' ),
810 wfMessage( $loginlink )->text(), array(), $query
813 $talkLink = Linker
::link( $wgUser->getTalkPage(),
814 $wgLang->getNsText( NS_TALK
) );
815 $talkLink = wfMessage( 'parentheses' )->rawParams( $talkLink )->escaped();
817 $ret .= Linker
::link( $wgUser->getUserPage(),
818 htmlspecialchars( $wgUser->getName() ) );
819 $ret .= " $talkLink<br />";
820 $ret .= $wgLang->pipeList( array(
822 SpecialPage
::getTitleFor( 'Userlogout' ), wfMessage( 'logout' )->text(),
823 array(), array( 'returnto' => $returnTo->getPrefixedDBkey() )
825 Linker
::specialLink( 'Preferences' ),
829 $ret = $wgLang->pipeList( array(
832 Title
::newFromText( wfMessage( 'helppage' )->inContentLanguage()->text() ),
833 wfMessage( 'help' )->text()