3 * Cologne Blue: A nicer-looking alternative to Standard.
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
25 if( !defined( 'MEDIAWIKI' ) ) {
33 class SkinCologneBlue
extends SkinTemplate
{
34 var $skinname = 'cologneblue', $stylename = 'cologneblue',
35 $template = 'CologneBlueTemplate';
36 var $useHeadElement = true;
39 * @param $out OutputPage
41 function setupSkinUserCss( OutputPage
$out ){
42 $out->addModuleStyles( 'mediawiki.legacy.shared' );
43 $out->addModuleStyles( 'mediawiki.legacy.oldshared' );
44 $out->addModuleStyles( 'skins.cologneblue' );
49 class CologneBlueTemplate
extends BaseTemplate
{
50 protected $mWatchLinkNum = 0; // Appended to end of watch link id's
53 $this->html( 'headelement' );
54 echo $this->beforeContent();
55 $this->html( 'bodytext' );
57 echo $this->afterContent();
58 $this->html( 'dataAfterContent' );
60 echo "\n</body></html>";
65 * Language/charset variant links for classic-style skins
68 function variantLinks() {
71 /* show links to different language variants */
72 global $wgDisableLangConversion, $wgLang;
74 $title = $this->getSkin()->getTitle();
75 $lang = $title->getPageLanguage();
76 $variants = $lang->getVariants();
78 if ( !$wgDisableLangConversion && sizeof( $variants ) > 1
79 && !$title->isSpecialPage() ) {
80 foreach ( $variants as $code ) {
81 $varname = $lang->getVariantname( $code );
83 if ( $varname == 'disable' ) {
86 $s = $wgLang->pipeList( array(
88 '<a href="' . htmlspecialchars( $title->getLocalURL( 'variant=' . $code ) ) . '" lang="' . $code . '" hreflang="' . $code . '">' . htmlspecialchars( $varname ) . '</a>'
97 * Compatibility for extensions adding functionality through tabs.
98 * Eventually these old skins should be replaced with SkinTemplate-based
101 * @todo Exterminate! ...that, and replace it with normal SkinTemplate stuff
103 function extensionTabLinks() {
107 wfRunHooks( 'SkinTemplateTabs', array( $this->getSkin(), &$tabs ) );
108 foreach ( $tabs as $tab ) {
109 $s[] = Xml
::element( 'a',
110 array( 'href' => $tab['href'] ),
117 $out = wfMessage( 'pipe-separator' )->escaped();
118 $out .= $wgLang->pipeList( $s );
124 function otherLanguages() {
125 global $wgOut, $wgLang, $wgHideInterlanguageLinks;
127 if ( $wgHideInterlanguageLinks ) {
131 $a = $wgOut->getLanguageLinks();
133 if ( 0 == count( $a ) ) {
137 $s = wfMessage( 'otherlanguages' )->text() . wfMessage( 'colon-separator' )->text();
140 if ( $wgLang->isRTL() ) {
141 $s .= '<span dir="ltr">';
144 foreach ( $a as $l ) {
146 $s .= wfMessage( 'pipe-separator' )->escaped();
151 $nt = Title
::newFromText( $l );
152 $text = Language
::fetchLanguageName( $nt->getInterwiki() );
154 $s .= Html
::element( 'a',
155 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
156 $text == '' ?
$l : $text );
159 if ( $wgLang->isRTL() ) {
166 function pageTitleLinks() {
167 global $wgOut, $wgUser, $wgRequest, $wgLang;
169 $oldid = $wgRequest->getVal( 'oldid' );
170 $diff = $wgRequest->getVal( 'diff' );
171 $action = $wgRequest->getText( 'action' );
173 $skin = $this->getSkin();
174 $title = $skin->getTitle();
176 $s[] = $this->printableLink();
177 $disclaimer = $skin->disclaimerLink(); # may be empty
183 $privacy = $skin->privacyLink(); # may be empty too
189 if ( $wgOut->isArticleRelated() ) {
190 if ( $title->getNamespace() == NS_FILE
) {
191 $image = wfFindFile( $title );
194 $href = $image->getURL();
195 $s[] = Html
::element( 'a', array( 'href' => $href,
196 'title' => $href ), $title->getText() );
202 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
203 $s[] .= Linker
::linkKnown(
205 wfMessage( 'currentrev' )->text()
209 if ( $wgUser->getNewtalk() ) {
210 # do not show "You have new messages" text when we are viewing our
212 if ( !$title->equals( $wgUser->getTalkPage() ) ) {
213 $tl = Linker
::linkKnown(
214 $wgUser->getTalkPage(),
215 wfMessage( 'newmessageslink' )->escaped(),
217 array( 'redirect' => 'no' )
220 $dl = Linker
::linkKnown(
221 $wgUser->getTalkPage(),
222 wfMessage( 'newmessagesdifflink' )->escaped(),
224 array( 'diff' => 'cur' )
226 $s[] = '<strong>' . wfMessage( 'youhavenewmessages', $tl, $dl )->text() . '</strong>';
228 $wgOut->setSquidMaxage( 0 );
229 $wgOut->enableClientCache( false );
233 $undelete = $skin->getUndeleteLink();
235 if ( !empty( $undelete ) ) {
239 return $wgLang->pipeList( $s );
242 function printableLink() {
243 global $wgOut, $wgRequest, $wgLang;
247 if ( !$wgOut->isPrintable() ) {
248 $printurl = htmlspecialchars( $this->getSkin()->getTitle()->getLocalUrl(
249 $wgRequest->appendQueryValue( 'printable', 'yes', true ) ) );
250 $s[] = "<a href=\"$printurl\" rel=\"alternate\">"
251 . wfMessage( 'printableversion' )->text() . '</a>';
254 if ( $wgOut->isSyndicated() ) {
255 foreach ( $wgOut->getSyndicationLinks() as $format => $link ) {
256 $feedurl = htmlspecialchars( $link );
257 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
258 . " class=\"feedlink\">" . wfMessage( "feed-$format" )->escaped() . "</a>";
261 return $wgLang->pipeList( $s );
265 * Gets the h1 element with the page title.
268 function pageTitle() {
270 $s = '<h1 class="pagetitle"><span dir="auto">' . $wgOut->getPageTitle() . '</span></h1>';
274 function pageSubtitle() {
277 $sub = $wgOut->getSubtitle();
280 global $wgExtraSubtitle;
281 $sub = wfMessage( 'tagline' )->parse() . $wgExtraSubtitle;
284 $subpages = $this->getSkin()->subPageSubtitle();
285 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
286 $s = "<p class='subtitle'>{$sub}</p>\n";
291 function bottomLinks() {
292 global $wgOut, $wgUser;
293 $sep = wfMessage( 'pipe-separator' )->escaped() . "\n";
296 if ( $wgOut->isArticleRelated() ) {
297 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
299 if ( $wgUser->isLoggedIn() ) {
300 $element[] = $this->watchThisPage();
303 $element[] = $this->talkLink();
304 $element[] = $this->historyLink();
305 $element[] = $this->whatLinksHere();
306 $element[] = $this->watchPageLinksLink();
308 $title = $this->getSkin()->getTitle();
311 $title->getNamespace() == NS_USER ||
312 $title->getNamespace() == NS_USER_TALK
314 $id = User
::idFromName( $title->getText() );
315 $ip = User
::isIP( $title->getText() );
317 # Both anons and non-anons have contributions list
319 $element[] = $this->userContribsLink();
322 if ( $this->getSkin()->showEmailUser( $id ) ) {
323 $element[] = $this->emailUserLink();
327 $s = implode( $element, $sep );
329 if ( $title->getArticleID() ) {
332 // Delete/protect/move links for privileged users
333 if ( $wgUser->isAllowed( 'delete' ) ) {
334 $s .= $this->deleteThisPage();
337 if ( $wgUser->isAllowed( 'protect' ) ) {
338 $s .= $sep . $this->protectThisPage();
341 if ( $wgUser->isAllowed( 'move' ) ) {
342 $s .= $sep . $this->moveThisPage();
346 $s .= "<br />\n" . $this->otherLanguages();
352 function editThisPage() {
355 if ( !$wgOut->isArticleRelated() ) {
356 $s = wfMessage( 'protectedpage' )->text();
358 $title = $this->getSkin()->getTitle();
359 if ( $title->quickUserCan( 'edit' ) && $title->exists() ) {
360 $t = wfMessage( 'editthispage' )->text();
361 } elseif ( $title->quickUserCan( 'create' ) && !$title->exists() ) {
362 $t = wfMessage( 'create-this-page' )->text();
364 $t = wfMessage( 'viewsource' )->text();
367 $s = Linker
::linkKnown(
371 $this->getSkin()->editUrlOptions()
378 function deleteThisPage() {
379 global $wgUser, $wgRequest;
381 $diff = $wgRequest->getVal( 'diff' );
382 $title = $this->getSkin()->getTitle();
384 if ( $title->getArticleID() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
385 $t = wfMessage( 'deletethispage' )->text();
387 $s = Linker
::linkKnown(
391 array( 'action' => 'delete' )
400 function protectThisPage() {
401 global $wgUser, $wgRequest;
403 $diff = $wgRequest->getVal( 'diff' );
404 $title = $this->getSkin()->getTitle();
406 if ( $title->getArticleID() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
407 if ( $title->isProtected() ) {
408 $text = wfMessage( 'unprotectthispage' )->text();
409 $query = array( 'action' => 'unprotect' );
411 $text = wfMessage( 'protectthispage' )->text();
412 $query = array( 'action' => 'protect' );
415 $s = Linker
::linkKnown(
428 function watchThisPage() {
429 global $wgOut, $wgUser;
430 ++
$this->mWatchLinkNum
;
433 $title = $this->getSkin()->getTitle();
435 if ( $wgOut->isArticleRelated() ) {
436 if ( $wgUser->isWatched( $title ) ) {
437 $text = wfMessage( 'unwatchthispage' )->text();
439 'action' => 'unwatch',
440 'token' => UnwatchAction
::getUnwatchToken( $title, $wgUser ),
442 $id = 'mw-unwatch-link' . $this->mWatchLinkNum
;
444 $text = wfMessage( 'watchthispage' )->text();
447 'token' => WatchAction
::getWatchToken( $title, $wgUser ),
449 $id = 'mw-watch-link' . $this->mWatchLinkNum
;
452 $s = Linker
::linkKnown(
455 array( 'id' => $id ),
459 $s = wfMessage( 'notanarticle' )->text();
465 function moveThisPage() {
466 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
467 return Linker
::linkKnown(
468 SpecialPage
::getTitleFor( 'Movepage' ),
469 wfMessage( 'movethispage' )->text(),
471 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() )
474 // no message if page is protected - would be redundant
479 function historyLink() {
481 $this->getSkin()->getTitle(),
482 wfMessage( 'history' )->escaped(),
483 array( 'rel' => 'archives' ),
484 array( 'action' => 'history' )
488 function whatLinksHere() {
489 return Linker
::linkKnown(
490 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
491 wfMessage( 'whatlinkshere' )->escaped()
495 function userContribsLink() {
496 return Linker
::linkKnown(
497 SpecialPage
::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
498 wfMessage( 'contributions' )->escaped()
502 function emailUserLink() {
503 return Linker
::linkKnown(
504 SpecialPage
::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
505 wfMessage( 'emailuser' )->escaped()
509 function watchPageLinksLink() {
512 if ( !$wgOut->isArticleRelated() ) {
513 return wfMessage( 'parentheses', wfMessage( 'notanarticle' )->text() )->escaped();
515 return Linker
::linkKnown(
516 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
517 wfMessage( 'recentchangeslinked-toolbox' )->escaped()
522 function talkLink() {
523 $title = $this->getSkin()->getTitle();
524 if ( NS_SPECIAL
== $title->getNamespace() ) {
525 # No discussion links for special pages
529 $linkOptions = array();
531 if ( $title->isTalkPage() ) {
532 $link = $title->getSubjectPage();
533 switch( $link->getNamespace() ) {
535 $text = wfMessage( 'articlepage' );
538 $text = wfMessage( 'userpage' );
541 $text = wfMessage( 'projectpage' );
544 $text = wfMessage( 'imagepage' );
545 # Make link known if image exists, even if the desc. page doesn't.
546 if ( wfFindFile( $link ) )
547 $linkOptions[] = 'known';
550 $text = wfMessage( 'mediawikipage' );
553 $text = wfMessage( 'templatepage' );
556 $text = wfMessage( 'viewhelppage' );
559 $text = wfMessage( 'categorypage' );
562 $text = wfMessage( 'articlepage' );
565 $link = $title->getTalkPage();
566 $text = wfMessage( 'talkpage' );
569 $s = Linker
::link( $link, $text->text(), array(), array(), $linkOptions );
574 function pageStats() {
576 $items = array( 'viewcount', 'credits', 'lastmod', 'numberofwatchingusers', 'copyright' );
578 foreach( $items as $item ) {
579 if ( $this->data
[$item] !== false ) {
580 $ret[] = $this->data
[$item];
584 return implode( ' ', $ret );
594 function beforeContent() {
595 $mainPageObj = Title
::newMainPage();
597 $s = "\n<div id='content'>\n<div id='topbar'>" .
598 '<table style="width: 100%;" cellspacing="0" cellpadding="8"><tr>';
600 $s .= '<td class="top" nowrap="nowrap">';
601 $s .= '<a href="' . htmlspecialchars( $mainPageObj->getLocalURL() ) . '">';
602 $s .= '<span id="sitetitle">' . wfMessage( 'sitetitle' )->escaped() . '</span></a>';
604 $s .= '</td><td class="top" id="top-syslinks" style="width: 100%;">';
605 $s .= $this->sysLinks();
606 $s .= '</td></tr><tr><td class="top-subheader">';
608 $s .= '<font size="-1"><span id="sitesub">';
609 $s .= wfMessage( 'sitesubtitle' )->escaped() . '</span></font>';
610 $s .= '</td><td class="top-linkcollection">';
612 $s .= '<font size="-1"><span id="langlinks">';
613 $s .= str_replace( '<br />', '', $this->otherLanguages() );
615 $s .= $this->getSkin()->getCategories();
617 $s .= '<br />' . $this->pageTitleLinks();
618 $s .= '</span></font>';
620 $s .= "</td></tr></table>\n";
622 $s .= "\n</div>\n<div id='article'>";
624 $notice = $this->getSkin()->getSiteNotice();
626 $s .= "\n<div id='siteNotice'>$notice</div>\n";
628 $s .= $this->pageTitle();
629 $s .= $this->pageSubtitle() . "\n";
636 function afterContent(){
637 $s = "\n</div><br clear='all' />\n";
639 $s .= "\n<div id='footer'>";
640 $s .= '<table style="width: 98%;" cellspacing="0"><tr>';
642 $s .= '<td class="bottom">';
644 $s .= $this->bottomLinks();
645 $s .= $this->getSkin()->getLanguage()->pipeList( array(
646 "\n<br />" . Linker
::linkKnown(
649 $this->getSkin()->aboutLink(),
650 $this->searchForm( 'afterContent' )
653 $s .= "\n<br />" . $this->pageStats();
656 $s .= "</tr></table>\n</div>\n</div>\n";
658 $s .= $this->quickBar();
665 function sysLinks() {
666 $li = SpecialPage
::getTitleFor( 'Userlogin' );
667 $lo = SpecialPage
::getTitleFor( 'Userlogout' );
669 $rt = $this->getSkin()->getTitle()->getPrefixedURL();
670 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
673 $q = array( 'returnto' => $rt );
677 $this->getSkin()->mainPageLink(),
679 Title
::newFromText( wfMessage( 'aboutpage' )->inContentLanguage()->text() ),
680 wfMessage( 'about' )->text()
683 Title
::newFromText( wfMessage( 'helppage' )->inContentLanguage()->text() ),
684 wfMessage( 'help' )->text()
687 Title
::newFromText( wfMessage( 'faqpage' )->inContentLanguage()->text() ),
688 wfMessage( 'faq' )->text()
690 Linker
::specialLink( 'Specialpages' )
693 /* show links to different language variants */
694 if( $this->variantLinks() ) {
695 $s[] = $this->variantLinks();
697 if( $this->extensionTabLinks() ) {
698 $s[] = $this->extensionTabLinks();
700 if ( $this->data
['loggedin'] ) {
701 $s[] = Linker
::linkKnown(
703 wfMessage( 'logout' )->text(),
708 $s[] = Linker
::linkKnown(
710 wfMessage( 'login' )->text(),
716 return $this->getSkin()->getLanguage()->pipeList( $s );
723 * @param $heading string
728 function menuHead( $heading ) {
729 return "\n<h6>" . htmlspecialchars( $heading ) . "</h6>";
733 * Compute the sidebar
741 $s = "\n<div id='quickbar'>";
745 $plain_bar = $this->data
['sidebar'];
748 // Massage the sidebar
749 // We want to place SEARCH at the beginning and a lot of stuff before TOOLBOX (or at the end, if it's missing)
750 $additions_done = false;
751 while ( !$additions_done ) {
752 $bar = array(); // Empty it out
754 // Always display search on top
755 $bar['SEARCH'] = true;
757 foreach ( $plain_bar as $heading => $links ) {
758 if ( $heading == 'TOOLBOX' ) {
759 if( $links !== NULL ) {
760 // If this is not a toolbox prosthetic we inserted outselves, fill it out
761 $plain_bar['TOOLBOX'] = $this->getToolbox();
764 // And insert the stuff
766 // "This page" and "Edit" menus
767 // We need to do some massaging here... we reuse all of the items, except for $...['views']['view'],
768 // as $...['namespaces']['main'] and $...['namespaces']['talk'] together serve the same purpose.
769 // We also don't use $...['variants'], these are displayed in the top menu.
770 $content_navigation = $this->data
['content_navigation'];
771 $qbpageoptions = array_merge(
772 $content_navigation['namespaces'],
774 'history' => $content_navigation['views']['history'],
775 'watch' => $content_navigation['actions']['watch'],
776 'unwatch' => $content_navigation['actions']['unwatch'],
779 $content_navigation['actions']['watch'] = null;
780 $content_navigation['actions']['unwatch'] = null;
781 $qbedit = array_merge(
783 'edit' => $content_navigation['views']['edit'],
784 'addsection' => $content_navigation['views']['addsection'],
786 $content_navigation['actions']
788 $bar['qbedit'] = $qbedit;
789 $bar['qbpageoptions'] = $qbpageoptions;
791 // Personal tools ("My pages")
792 $bar['qbmyoptions'] = $this->getPersonalTools();
794 $additions_done = true;
797 // Re-insert current heading, unless it's SEARCH
798 if ( $heading != 'SEARCH' ) {
799 $bar[$heading] = $plain_bar[$heading];
803 // If TOOLBOX is missing, $additions_done is still false
804 if ( !$additions_done ) {
805 $plain_bar['TOOLBOX'] = false;
809 foreach ( $bar as $heading => $links ) {
810 if ( $heading == 'SEARCH' ) {
811 $s .= $this->menuHead( wfMessage( 'qbfind' )->text() );
812 $s .= $this->searchForm( 'sidebar' );
813 } elseif ( $heading == 'LANGUAGES' ) {
814 // discard these; we display languages below page content
817 // Use the navigation heading from standard sidebar as the "browse" section
818 if ( $heading == 'navigation' ) {
819 $heading = 'qbbrowse';
821 if ( $heading == 'TOOLBOX' ) {
822 $heading = 'toolbox';
825 $headingMsg = wfMessage( $heading );
827 $t = $this->menuHead( $headingMsg->exists() ?
$headingMsg->text() : $heading );
829 foreach ( $links as $key => $link ) {
830 // Can be empty due to rampant sidebar massaging we're doing above
833 $t .= $this->makeListItem( $key, $link, array( 'tag' => 'span' ) ) . $sep;
844 $s .= $sep . "\n</div>\n";
849 * @param $label string
854 function searchForm( $which ) {
855 global $wgUseTwoButtonsSearchForm;
857 $search = $this->getSkin()->getRequest()->getText( 'search' );
858 $action = $this->data
['searchaction'];
859 $s = "<form id=\"searchform-" . htmlspecialchars($which) . "\" method=\"get\" class=\"inline\" action=\"$action\">";
860 if( $which == 'afterContent' ) {
861 $s .= wfMessage( 'qbfind' )->text() . ": ";
864 $s .= "<input type='text' class=\"mw-searchInput\" name=\"search\" size=\"14\" value=\""
865 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />"
866 . ($which == 'afterContent' ?
" " : "<br />")
867 . "<input type='submit' class=\"searchButton\" name=\"go\" value=\"" . wfMessage( 'searcharticle' )->escaped() . "\" />";
869 if( $wgUseTwoButtonsSearchForm ) {
870 $s .= " <input type='submit' class=\"searchButton\" name=\"fulltext\" value=\"" . wfMessage( 'search' )->escaped() . "\" />\n";
872 $s .= '<div><a href="' . $action . '" rel="search">' . wfMessage( 'powersearch-legend' )->escaped() . "</a></div>\n";