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 if ( $varname == 'disable' ) {
224 $s = $wgLang->pipeList( array(
226 '<a href="' . htmlspecialchars( $title->getLocalURL( 'variant=' . $code ) ) . '" lang="' . $code . '" hreflang="' . $code . '">' . htmlspecialchars( $varname ) . '</a>'
235 * Compatibility for extensions adding functionality through tabs.
236 * Eventually these old skins should be replaced with SkinTemplate-based
239 * @todo Exterminate! ...that, and replace it with normal SkinTemplate stuff
241 function extensionTabLinks() {
245 wfRunHooks( 'SkinTemplateTabs', array( $this->getSkin(), &$tabs ) );
246 foreach ( $tabs as $tab ) {
247 $s[] = Xml
::element( 'a',
248 array( 'href' => $tab['href'] ),
255 $out = wfMessage( 'pipe-separator' )->escaped();
256 $out .= $wgLang->pipeList( $s );
262 function bottomLinks() {
263 global $wgOut, $wgUser;
264 $sep = wfMessage( 'pipe-separator' )->escaped() . "\n";
267 if ( $wgOut->isArticleRelated() ) {
268 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
270 if ( $wgUser->isLoggedIn() ) {
271 $element[] = $this->watchThisPage();
274 $element[] = $this->talkLink();
275 $element[] = $this->historyLink();
276 $element[] = $this->whatLinksHere();
277 $element[] = $this->watchPageLinksLink();
279 $title = $this->getSkin()->getTitle();
282 $title->getNamespace() == NS_USER ||
283 $title->getNamespace() == NS_USER_TALK
285 $id = User
::idFromName( $title->getText() );
286 $ip = User
::isIP( $title->getText() );
288 # Both anons and non-anons have contributions list
290 $element[] = $this->userContribsLink();
293 if ( $this->getSkin()->showEmailUser( $id ) ) {
294 $element[] = $this->emailUserLink();
298 $s = implode( $element, $sep );
300 if ( $title->getArticleID() ) {
303 // Delete/protect/move links for privileged users
304 if ( $wgUser->isAllowed( 'delete' ) ) {
305 $s .= $this->deleteThisPage();
308 if ( $wgUser->isAllowed( 'protect' ) && $title->getRestrictionTypes() ) {
309 $s .= $sep . $this->protectThisPage();
312 if ( $wgUser->isAllowed( 'move' ) ) {
313 $s .= $sep . $this->moveThisPage();
317 $s .= "<br />\n" . $this->otherLanguages();
323 function otherLanguages() {
324 global $wgOut, $wgLang, $wgHideInterlanguageLinks;
326 if ( $wgHideInterlanguageLinks ) {
330 $a = $wgOut->getLanguageLinks();
332 if ( 0 == count( $a ) ) {
336 $s = wfMessage( 'otherlanguages' )->text() . wfMessage( 'colon-separator' )->text();
339 if ( $wgLang->isRTL() ) {
340 $s .= '<span dir="ltr">';
343 foreach ( $a as $l ) {
345 $s .= wfMessage( 'pipe-separator' )->escaped();
350 $nt = Title
::newFromText( $l );
351 $text = Language
::fetchLanguageName( $nt->getInterwiki() );
353 $s .= Html
::element( 'a',
354 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
355 $text == '' ?
$l : $text );
358 if ( $wgLang->isRTL() ) {
366 * Show a drop-down box of special pages
369 function specialPagesList() {
372 $select = new XmlSelect( 'title' );
373 $pages = SpecialPageFactory
::getUsablePages();
374 array_unshift( $pages, SpecialPageFactory
::getPage( 'SpecialPages' ) );
375 foreach ( $pages as $obj ) {
376 $select->addOption( $obj->getDescription(),
377 $obj->getTitle()->getPrefixedDBkey() );
380 return Html
::rawElement( 'form',
381 array( 'id' => 'specialpages', 'method' => 'get', 'action' => $wgScript ),
382 $select->getHTML() . Xml
::submitButton( wfMessage( 'go' )->text() ) );
385 function pageTitleLinks() {
386 global $wgOut, $wgUser, $wgRequest, $wgLang;
388 $oldid = $wgRequest->getVal( 'oldid' );
389 $diff = $wgRequest->getVal( 'diff' );
390 $action = $wgRequest->getText( 'action' );
392 $skin = $this->getSkin();
393 $title = $skin->getTitle();
395 $s[] = $this->printableLink();
396 $disclaimer = $skin->disclaimerLink(); # may be empty
402 $privacy = $skin->privacyLink(); # may be empty too
408 if ( $wgOut->isArticleRelated() ) {
409 if ( $title->getNamespace() == NS_FILE
) {
410 $image = wfFindFile( $title );
413 $href = $image->getURL();
414 $s[] = Html
::element( 'a', array( 'href' => $href,
415 'title' => $href ), $title->getText() );
421 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
422 $s[] .= Linker
::linkKnown(
424 wfMessage( 'currentrev' )->text()
428 if ( $wgUser->getNewtalk() ) {
429 # do not show "You have new messages" text when we are viewing our
431 if ( !$title->equals( $wgUser->getTalkPage() ) ) {
432 $tl = Linker
::linkKnown(
433 $wgUser->getTalkPage(),
434 wfMessage( 'newmessageslink' )->escaped(),
436 array( 'redirect' => 'no' )
439 $dl = Linker
::linkKnown(
440 $wgUser->getTalkPage(),
441 wfMessage( 'newmessagesdifflink' )->escaped(),
443 array( 'diff' => 'cur' )
445 $s[] = '<strong>' . wfMessage( 'youhavenewmessages', $tl, $dl )->text() . '</strong>';
447 $wgOut->setSquidMaxage( 0 );
448 $wgOut->enableClientCache( false );
452 $undelete = $skin->getUndeleteLink();
454 if ( !empty( $undelete ) ) {
458 return $wgLang->pipeList( $s );
462 * Gets the h1 element with the page title.
465 function pageTitle() {
467 $s = '<h1 class="pagetitle"><span dir="auto">' . $wgOut->getPageTitle() . '</span></h1>';
471 function pageSubtitle() {
474 $sub = $wgOut->getSubtitle();
477 global $wgExtraSubtitle;
478 $sub = wfMessage( 'tagline' )->parse() . $wgExtraSubtitle;
481 $subpages = $this->getSkin()->subPageSubtitle();
482 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
483 $s = "<p class='subtitle'>{$sub}</p>\n";
488 function printableLink() {
489 global $wgOut, $wgRequest, $wgLang;
493 if ( !$wgOut->isPrintable() ) {
494 $printurl = htmlspecialchars( $this->getSkin()->getTitle()->getLocalURL(
495 $wgRequest->appendQueryValue( 'printable', 'yes', true ) ) );
496 $s[] = "<a href=\"$printurl\" rel=\"alternate\">"
497 . wfMessage( 'printableversion' )->text() . '</a>';
500 if ( $wgOut->isSyndicated() ) {
501 foreach ( $wgOut->getSyndicationLinks() as $format => $link ) {
502 $feedurl = htmlspecialchars( $link );
503 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
504 . " class=\"feedlink\">" . wfMessage( "feed-$format" )->escaped() . "</a>";
507 return $wgLang->pipeList( $s );
511 * @deprecated in 1.19
514 function getQuickbarCompensator( $rows = 1 ) {
515 wfDeprecated( __METHOD__
, '1.19' );
516 return "<td style='width: 152px;' rowspan='{$rows}'> </td>";
519 function editThisPage() {
522 if ( !$wgOut->isArticleRelated() ) {
523 $s = wfMessage( 'protectedpage' )->text();
525 $title = $this->getSkin()->getTitle();
526 if ( $title->quickUserCan( 'edit' ) && $title->exists() ) {
527 $t = wfMessage( 'editthispage' )->text();
528 } elseif ( $title->quickUserCan( 'create' ) && !$title->exists() ) {
529 $t = wfMessage( 'create-this-page' )->text();
531 $t = wfMessage( 'viewsource' )->text();
534 $s = Linker
::linkKnown(
538 $this->getSkin()->editUrlOptions()
545 function deleteThisPage() {
546 global $wgUser, $wgRequest;
548 $diff = $wgRequest->getVal( 'diff' );
549 $title = $this->getSkin()->getTitle();
551 if ( $title->getArticleID() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
552 $t = wfMessage( 'deletethispage' )->text();
554 $s = Linker
::linkKnown(
558 array( 'action' => 'delete' )
567 function protectThisPage() {
568 global $wgUser, $wgRequest;
570 $diff = $wgRequest->getVal( 'diff' );
571 $title = $this->getSkin()->getTitle();
573 if ( $title->getArticleID() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) && $title->getRestrictionTypes() ) {
574 if ( $title->isProtected() ) {
575 $text = wfMessage( 'unprotectthispage' )->text();
576 $query = array( 'action' => 'unprotect' );
578 $text = wfMessage( 'protectthispage' )->text();
579 $query = array( 'action' => 'protect' );
582 $s = Linker
::linkKnown(
595 function watchThisPage() {
596 global $wgOut, $wgUser;
597 ++
$this->mWatchLinkNum
;
600 $title = $this->getSkin()->getTitle();
602 if ( $wgOut->isArticleRelated() ) {
603 if ( $wgUser->isWatched( $title ) ) {
604 $text = wfMessage( 'unwatchthispage' )->text();
606 'action' => 'unwatch',
607 'token' => UnwatchAction
::getUnwatchToken( $title, $wgUser ),
609 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
611 $text = wfMessage( 'watchthispage' )->text();
614 'token' => WatchAction
::getWatchToken( $title, $wgUser ),
616 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
619 $s = Linker
::linkKnown(
622 array( 'id' => $id ),
626 $s = wfMessage( 'notanarticle' )->text();
632 function moveThisPage() {
633 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
634 return Linker
::linkKnown(
635 SpecialPage
::getTitleFor( 'Movepage' ),
636 wfMessage( 'movethispage' )->text(),
638 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() )
641 // no message if page is protected - would be redundant
646 function historyLink() {
648 $this->getSkin()->getTitle(),
649 wfMessage( 'history' )->escaped(),
650 array( 'rel' => 'archives' ),
651 array( 'action' => 'history' )
655 function whatLinksHere() {
656 return Linker
::linkKnown(
657 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
658 wfMessage( 'whatlinkshere' )->escaped()
662 function userContribsLink() {
663 return Linker
::linkKnown(
664 SpecialPage
::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
665 wfMessage( 'contributions' )->escaped()
669 function emailUserLink() {
670 return Linker
::linkKnown(
671 SpecialPage
::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
672 wfMessage( 'emailuser' )->escaped()
676 function watchPageLinksLink() {
679 if ( !$wgOut->isArticleRelated() ) {
680 return wfMessage( 'parentheses', wfMessage( 'notanarticle' )->text() )->escaped();
682 return Linker
::linkKnown(
683 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
684 wfMessage( 'recentchangeslinked-toolbox' )->escaped()
689 function talkLink() {
690 $title = $this->getSkin()->getTitle();
691 if ( NS_SPECIAL
== $title->getNamespace() ) {
692 # No discussion links for special pages
696 $linkOptions = array();
698 if ( $title->isTalkPage() ) {
699 $link = $title->getSubjectPage();
700 switch( $link->getNamespace() ) {
702 $text = wfMessage( 'articlepage' );
705 $text = wfMessage( 'userpage' );
708 $text = wfMessage( 'projectpage' );
711 $text = wfMessage( 'imagepage' );
712 # Make link known if image exists, even if the desc. page doesn't.
713 if ( wfFindFile( $link ) )
714 $linkOptions[] = 'known';
717 $text = wfMessage( 'mediawikipage' );
720 $text = wfMessage( 'templatepage' );
723 $text = wfMessage( 'viewhelppage' );
726 $text = wfMessage( 'categorypage' );
729 $text = wfMessage( 'articlepage' );
732 $link = $title->getTalkPage();
733 $text = wfMessage( 'talkpage' );
736 $s = Linker
::link( $link, $text->text(), array(), array(), $linkOptions );
741 function commentLink() {
744 $title = $this->getSkin()->getTitle();
745 if ( $title->isSpecialPage() ) {
749 # __NEWSECTIONLINK___ changes behavior here
750 # If it is present, the link points to this page, otherwise
751 # it points to the talk page
752 if ( !$title->isTalkPage() && !$wgOut->showNewSectionLink() ) {
753 $title = $title->getTalkPage();
756 return Linker
::linkKnown(
758 wfMessage( 'postcomment' )->text(),
767 function getUploadLink() {
768 global $wgUploadNavigationUrl;
770 if ( $wgUploadNavigationUrl ) {
771 # Using an empty class attribute to avoid automatic setting of "external" class
772 return Linker
::makeExternalLink( $wgUploadNavigationUrl,
773 wfMessage( 'upload' )->escaped(),
774 false, null, array( 'class' => '' ) );
776 return Linker
::linkKnown(
777 SpecialPage
::getTitleFor( 'Upload' ),
778 wfMessage( 'upload' )->escaped()
783 function nameAndLogin() {
784 global $wgUser, $wgLang, $wgRequest;
786 $returnTo = $this->getSkin()->getTitle();
789 if ( $wgUser->isAnon() ) {
790 if ( $this->getSkin()->showIPinHeader() ) {
791 $name = $wgRequest->getIP();
793 $talkLink = Linker
::link( $wgUser->getTalkPage(),
794 $wgLang->getNsText( NS_TALK
) );
795 $talkLink = wfMessage( 'parentheses' )->rawParams( $talkLink )->escaped();
797 $ret .= "$name $talkLink";
799 $ret .= wfMessage( 'notloggedin' )->text();
804 if ( !$returnTo->isSpecial( 'Userlogout' ) ) {
805 $query['returnto'] = $returnTo->getPrefixedDBkey();
808 $loginlink = $wgUser->isAllowed( 'createaccount' )
809 ?
'nav-login-createaccount'
811 $ret .= "\n<br />" . Linker
::link(
812 SpecialPage
::getTitleFor( 'Userlogin' ),
813 wfMessage( $loginlink )->text(), array(), $query
816 $talkLink = Linker
::link( $wgUser->getTalkPage(),
817 $wgLang->getNsText( NS_TALK
) );
818 $talkLink = wfMessage( 'parentheses' )->rawParams( $talkLink )->escaped();
820 $ret .= Linker
::link( $wgUser->getUserPage(),
821 htmlspecialchars( $wgUser->getName() ) );
822 $ret .= " $talkLink<br />";
823 $ret .= $wgLang->pipeList( array(
825 SpecialPage
::getTitleFor( 'Userlogout' ), wfMessage( 'logout' )->text(),
826 array(), array( 'returnto' => $returnTo->getPrefixedDBkey() )
828 Linker
::specialLink( 'Preferences' ),
832 $ret = $wgLang->pipeList( array(
835 Title
::newFromText( wfMessage( 'helppage' )->inContentLanguage()->text() ),
836 wfMessage( 'help' )->text()