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
{
51 $this->html( 'headelement' );
52 echo $this->beforeContent();
53 $this->html( 'bodytext' );
55 echo $this->afterContent();
56 $this->html( 'dataAfterContent' );
58 echo "\n</body></html>";
63 * Language/charset variant links for classic-style skins
66 function variantLinks() {
69 /* show links to different language variants */
70 global $wgDisableLangConversion, $wgLang;
72 $title = $this->getSkin()->getTitle();
73 $lang = $title->getPageLanguage();
74 $variants = $lang->getVariants();
76 if ( !$wgDisableLangConversion && sizeof( $variants ) > 1
77 && !$title->isSpecialPage() ) {
78 foreach ( $variants as $code ) {
79 $varname = $lang->getVariantname( $code );
81 if ( $varname == 'disable' ) {
84 $s = $wgLang->pipeList( array(
86 '<a href="' . htmlspecialchars( $title->getLocalURL( 'variant=' . $code ) ) . '" lang="' . $code . '" hreflang="' . $code . '">' . htmlspecialchars( $varname ) . '</a>'
95 * Compatibility for extensions adding functionality through tabs.
96 * Eventually these old skins should be replaced with SkinTemplate-based
99 * @todo Exterminate! ...that, and replace it with normal SkinTemplate stuff
101 function extensionTabLinks() {
105 wfRunHooks( 'SkinTemplateTabs', array( $this->getSkin(), &$tabs ) );
106 foreach ( $tabs as $tab ) {
107 $s[] = Xml
::element( 'a',
108 array( 'href' => $tab['href'] ),
115 $out = wfMessage( 'pipe-separator' )->escaped();
116 $out .= $wgLang->pipeList( $s );
122 function otherLanguages() {
123 global $wgOut, $wgLang, $wgHideInterlanguageLinks;
125 if ( $wgHideInterlanguageLinks ) {
129 $a = $wgOut->getLanguageLinks();
131 if ( 0 == count( $a ) ) {
135 $s = wfMessage( 'otherlanguages' )->text() . wfMessage( 'colon-separator' )->text();
138 if ( $wgLang->isRTL() ) {
139 $s .= '<span dir="ltr">';
142 foreach ( $a as $l ) {
144 $s .= wfMessage( 'pipe-separator' )->escaped();
149 $nt = Title
::newFromText( $l );
150 $text = Language
::fetchLanguageName( $nt->getInterwiki() );
152 $s .= Html
::element( 'a',
153 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
154 $text == '' ?
$l : $text );
157 if ( $wgLang->isRTL() ) {
164 function pageTitleLinks() {
165 global $wgOut, $wgUser, $wgRequest, $wgLang;
167 $oldid = $wgRequest->getVal( 'oldid' );
168 $diff = $wgRequest->getVal( 'diff' );
169 $action = $wgRequest->getText( 'action' );
171 $skin = $this->getSkin();
172 $title = $skin->getTitle();
174 $s[] = $this->printableLink();
175 $disclaimer = $skin->disclaimerLink(); # may be empty
181 $privacy = $skin->privacyLink(); # may be empty too
187 if ( $wgOut->isArticleRelated() ) {
188 if ( $title->getNamespace() == NS_FILE
) {
189 $image = wfFindFile( $title );
192 $href = $image->getURL();
193 $s[] = Html
::element( 'a', array( 'href' => $href,
194 'title' => $href ), $title->getText() );
200 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
201 $s[] .= Linker
::linkKnown(
203 wfMessage( 'currentrev' )->text()
207 if ( $wgUser->getNewtalk() ) {
208 # do not show "You have new messages" text when we are viewing our
210 if ( !$title->equals( $wgUser->getTalkPage() ) ) {
211 $tl = Linker
::linkKnown(
212 $wgUser->getTalkPage(),
213 wfMessage( 'newmessageslink' )->escaped(),
215 array( 'redirect' => 'no' )
218 $dl = Linker
::linkKnown(
219 $wgUser->getTalkPage(),
220 wfMessage( 'newmessagesdifflink' )->escaped(),
222 array( 'diff' => 'cur' )
224 $s[] = '<strong>' . wfMessage( 'youhavenewmessages', $tl, $dl )->text() . '</strong>';
226 $wgOut->setSquidMaxage( 0 );
227 $wgOut->enableClientCache( false );
231 $undelete = $skin->getUndeleteLink();
233 if ( !empty( $undelete ) ) {
237 return $wgLang->pipeList( $s );
240 function printableLink() {
241 global $wgOut, $wgRequest, $wgLang;
245 if ( !$wgOut->isPrintable() ) {
246 $printurl = htmlspecialchars( $this->getSkin()->getTitle()->getLocalUrl(
247 $wgRequest->appendQueryValue( 'printable', 'yes', true ) ) );
248 $s[] = "<a href=\"$printurl\" rel=\"alternate\">"
249 . wfMessage( 'printableversion' )->text() . '</a>';
252 if ( $wgOut->isSyndicated() ) {
253 foreach ( $wgOut->getSyndicationLinks() as $format => $link ) {
254 $feedurl = htmlspecialchars( $link );
255 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
256 . " class=\"feedlink\">" . wfMessage( "feed-$format" )->escaped() . "</a>";
259 return $wgLang->pipeList( $s );
263 * Gets the h1 element with the page title.
266 function pageTitle() {
268 $s = '<h1 class="pagetitle"><span dir="auto">' . $wgOut->getPageTitle() . '</span></h1>';
272 function pageSubtitle() {
275 $sub = $wgOut->getSubtitle();
278 global $wgExtraSubtitle;
279 $sub = wfMessage( 'tagline' )->parse() . $wgExtraSubtitle;
282 $subpages = $this->getSkin()->subPageSubtitle();
283 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
284 $s = "<p class='subtitle'>{$sub}</p>\n";
289 function bottomLinks() {
290 global $wgOut, $wgUser;
291 $sep = wfMessage( 'pipe-separator' )->escaped() . "\n";
294 if ( $wgOut->isArticleRelated() ) {
295 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
297 if ( $wgUser->isLoggedIn() ) {
298 $element[] = $this->watchThisPage();
301 $element[] = $this->talkLink();
302 $element[] = $this->historyLink();
303 $element[] = $this->whatLinksHere();
304 $element[] = $this->watchPageLinksLink();
306 $title = $this->getSkin()->getTitle();
309 $title->getNamespace() == NS_USER ||
310 $title->getNamespace() == NS_USER_TALK
312 $id = User
::idFromName( $title->getText() );
313 $ip = User
::isIP( $title->getText() );
315 # Both anons and non-anons have contributions list
317 $element[] = $this->userContribsLink();
320 if ( $this->getSkin()->showEmailUser( $id ) ) {
321 $element[] = $this->emailUserLink();
325 $s = implode( $element, $sep );
327 if ( $title->getArticleID() ) {
330 // Delete/protect/move links for privileged users
331 if ( $wgUser->isAllowed( 'delete' ) ) {
332 $s .= $this->deleteThisPage();
335 if ( $wgUser->isAllowed( 'protect' ) ) {
336 $s .= $sep . $this->protectThisPage();
339 if ( $wgUser->isAllowed( 'move' ) ) {
340 $s .= $sep . $this->moveThisPage();
344 $s .= "<br />\n" . $this->otherLanguages();
350 function editThisPage() {
353 if ( !$wgOut->isArticleRelated() ) {
354 $s = wfMessage( 'protectedpage' )->text();
356 $title = $this->getSkin()->getTitle();
357 if ( $title->quickUserCan( 'edit' ) && $title->exists() ) {
358 $t = wfMessage( 'editthispage' )->text();
359 } elseif ( $title->quickUserCan( 'create' ) && !$title->exists() ) {
360 $t = wfMessage( 'create-this-page' )->text();
362 $t = wfMessage( 'viewsource' )->text();
365 $s = Linker
::linkKnown(
369 $this->getSkin()->editUrlOptions()
376 function deleteThisPage() {
377 global $wgUser, $wgRequest;
379 $diff = $wgRequest->getVal( 'diff' );
380 $title = $this->getSkin()->getTitle();
382 if ( $title->getArticleID() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
383 $t = wfMessage( 'deletethispage' )->text();
385 $s = Linker
::linkKnown(
389 array( 'action' => 'delete' )
398 function protectThisPage() {
399 global $wgUser, $wgRequest;
401 $diff = $wgRequest->getVal( 'diff' );
402 $title = $this->getSkin()->getTitle();
404 if ( $title->getArticleID() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
405 if ( $title->isProtected() ) {
406 $text = wfMessage( 'unprotectthispage' )->text();
407 $query = array( 'action' => 'unprotect' );
409 $text = wfMessage( 'protectthispage' )->text();
410 $query = array( 'action' => 'protect' );
413 $s = Linker
::linkKnown(
426 function watchThisPage() {
427 global $wgOut, $wgUser;
430 $title = $this->getSkin()->getTitle();
432 if ( $wgOut->isArticleRelated() ) {
433 if ( $wgUser->isWatched( $title ) ) {
434 $text = wfMessage( 'unwatchthispage' )->text();
436 'action' => 'unwatch',
437 'token' => UnwatchAction
::getUnwatchToken( $title, $wgUser ),
439 $id = 'mw-unwatch-link';
441 $text = wfMessage( 'watchthispage' )->text();
444 'token' => WatchAction
::getWatchToken( $title, $wgUser ),
446 $id = 'mw-watch-link';
449 $s = Linker
::linkKnown(
452 array( 'id' => $id ),
456 $s = wfMessage( 'notanarticle' )->text();
462 function moveThisPage() {
463 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
464 return Linker
::linkKnown(
465 SpecialPage
::getTitleFor( 'Movepage' ),
466 wfMessage( 'movethispage' )->text(),
468 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() )
471 // no message if page is protected - would be redundant
476 function historyLink() {
478 $this->getSkin()->getTitle(),
479 wfMessage( 'history' )->escaped(),
480 array( 'rel' => 'archives' ),
481 array( 'action' => 'history' )
485 function whatLinksHere() {
486 return Linker
::linkKnown(
487 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
488 wfMessage( 'whatlinkshere' )->escaped()
492 function userContribsLink() {
493 return Linker
::linkKnown(
494 SpecialPage
::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
495 wfMessage( 'contributions' )->escaped()
499 function emailUserLink() {
500 return Linker
::linkKnown(
501 SpecialPage
::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
502 wfMessage( 'emailuser' )->escaped()
506 function watchPageLinksLink() {
509 if ( !$wgOut->isArticleRelated() ) {
510 return wfMessage( 'parentheses', wfMessage( 'notanarticle' )->text() )->escaped();
512 return Linker
::linkKnown(
513 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
514 wfMessage( 'recentchangeslinked-toolbox' )->escaped()
519 function talkLink() {
520 $title = $this->getSkin()->getTitle();
521 if ( NS_SPECIAL
== $title->getNamespace() ) {
522 # No discussion links for special pages
526 $linkOptions = array();
528 if ( $title->isTalkPage() ) {
529 $link = $title->getSubjectPage();
530 switch( $link->getNamespace() ) {
532 $text = wfMessage( 'articlepage' );
535 $text = wfMessage( 'userpage' );
538 $text = wfMessage( 'projectpage' );
541 $text = wfMessage( 'imagepage' );
542 # Make link known if image exists, even if the desc. page doesn't.
543 if ( wfFindFile( $link ) )
544 $linkOptions[] = 'known';
547 $text = wfMessage( 'mediawikipage' );
550 $text = wfMessage( 'templatepage' );
553 $text = wfMessage( 'viewhelppage' );
556 $text = wfMessage( 'categorypage' );
559 $text = wfMessage( 'articlepage' );
562 $link = $title->getTalkPage();
563 $text = wfMessage( 'talkpage' );
566 $s = Linker
::link( $link, $text->text(), array(), array(), $linkOptions );
571 function pageStats() {
573 $items = array( 'viewcount', 'credits', 'lastmod', 'numberofwatchingusers', 'copyright' );
575 foreach( $items as $item ) {
576 if ( $this->data
[$item] !== false ) {
577 $ret[] = $this->data
[$item];
581 return implode( ' ', $ret );
591 function beforeContent() {
592 $mainPageObj = Title
::newMainPage();
594 $s = "\n<div id='content'>\n<div id='topbar'>" .
595 '<table style="width: 100%;" cellspacing="0" cellpadding="8"><tr>';
597 $s .= '<td class="top" nowrap="nowrap">';
598 $s .= '<a href="' . htmlspecialchars( $mainPageObj->getLocalURL() ) . '">';
599 $s .= '<span id="sitetitle">' . wfMessage( 'sitetitle' )->escaped() . '</span></a>';
601 $s .= '</td><td class="top" id="top-syslinks" style="width: 100%;">';
602 $s .= $this->sysLinks();
603 $s .= '</td></tr><tr><td class="top-subheader">';
605 $s .= '<font size="-1"><span id="sitesub">';
606 $s .= wfMessage( 'sitesubtitle' )->escaped() . '</span></font>';
607 $s .= '</td><td class="top-linkcollection">';
609 $s .= '<font size="-1"><span id="langlinks">';
610 $s .= str_replace( '<br />', '', $this->otherLanguages() );
612 $s .= $this->getSkin()->getCategories();
614 $s .= '<br />' . $this->pageTitleLinks();
615 $s .= '</span></font>';
617 $s .= "</td></tr></table>\n";
619 $s .= "\n</div>\n<div id='article'>";
621 $notice = $this->getSkin()->getSiteNotice();
623 $s .= "\n<div id='siteNotice'>$notice</div>\n";
625 $s .= $this->pageTitle();
626 $s .= $this->pageSubtitle() . "\n";
633 function afterContent(){
634 $s = "\n</div><br clear='all' />\n";
636 $s .= "\n<div id='footer'>";
637 $s .= '<table style="width: 98%;" cellspacing="0"><tr>';
639 $s .= '<td class="bottom">';
641 $s .= $this->bottomLinks();
642 $s .= $this->getSkin()->getLanguage()->pipeList( array(
643 "\n<br />" . Linker
::linkKnown(
646 $this->getSkin()->aboutLink(),
647 $this->searchForm( 'afterContent' )
650 $s .= "\n<br />" . $this->pageStats();
653 $s .= "</tr></table>\n</div>\n</div>\n";
655 $s .= $this->quickBar();
662 function sysLinks() {
663 $li = SpecialPage
::getTitleFor( 'Userlogin' );
664 $lo = SpecialPage
::getTitleFor( 'Userlogout' );
666 $rt = $this->getSkin()->getTitle()->getPrefixedURL();
667 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
670 $q = array( 'returnto' => $rt );
674 $this->getSkin()->mainPageLink(),
676 Title
::newFromText( wfMessage( 'aboutpage' )->inContentLanguage()->text() ),
677 wfMessage( 'about' )->text()
680 Title
::newFromText( wfMessage( 'helppage' )->inContentLanguage()->text() ),
681 wfMessage( 'help' )->text()
684 Title
::newFromText( wfMessage( 'faqpage' )->inContentLanguage()->text() ),
685 wfMessage( 'faq' )->text()
687 Linker
::specialLink( 'Specialpages' )
690 /* show links to different language variants */
691 if( $this->variantLinks() ) {
692 $s[] = $this->variantLinks();
694 if( $this->extensionTabLinks() ) {
695 $s[] = $this->extensionTabLinks();
697 if ( $this->data
['loggedin'] ) {
698 $s[] = Linker
::linkKnown(
700 wfMessage( 'logout' )->text(),
705 $s[] = Linker
::linkKnown(
707 wfMessage( 'login' )->text(),
713 return $this->getSkin()->getLanguage()->pipeList( $s );
720 * @param $heading string
725 function menuHead( $heading ) {
726 return "\n<h6>" . htmlspecialchars( $heading ) . "</h6>";
730 * Compute the sidebar
738 $s = "\n<div id='quickbar'>";
742 $plain_bar = $this->data
['sidebar'];
745 // Massage the sidebar
746 // We want to place SEARCH at the beginning and a lot of stuff before TOOLBOX (or at the end, if it's missing)
747 $additions_done = false;
748 while ( !$additions_done ) {
749 $bar = array(); // Empty it out
751 // Always display search on top
752 $bar['SEARCH'] = true;
754 foreach ( $plain_bar as $heading => $links ) {
755 if ( $heading == 'TOOLBOX' ) {
756 if( $links !== NULL ) {
757 // If this is not a toolbox prosthetic we inserted outselves, fill it out
758 $plain_bar['TOOLBOX'] = $this->getToolbox();
761 // And insert the stuff
763 // "This page" and "Edit" menus
764 // We need to do some massaging here... we reuse all of the items, except for $...['views']['view'],
765 // as $...['namespaces']['main'] and $...['namespaces']['talk'] together serve the same purpose.
766 // We also don't use $...['variants'], these are displayed in the top menu.
767 $content_navigation = $this->data
['content_navigation'];
768 $qbpageoptions = array_merge(
769 $content_navigation['namespaces'],
771 'history' => $content_navigation['views']['history'],
772 'watch' => $content_navigation['actions']['watch'],
773 'unwatch' => $content_navigation['actions']['unwatch'],
776 $content_navigation['actions']['watch'] = null;
777 $content_navigation['actions']['unwatch'] = null;
778 $qbedit = array_merge(
780 'edit' => $content_navigation['views']['edit'],
781 'addsection' => $content_navigation['views']['addsection'],
783 $content_navigation['actions']
785 $bar['qbedit'] = $qbedit;
786 $bar['qbpageoptions'] = $qbpageoptions;
788 // Personal tools ("My pages")
789 $bar['qbmyoptions'] = $this->getPersonalTools();
791 $additions_done = true;
794 // Re-insert current heading, unless it's SEARCH
795 if ( $heading != 'SEARCH' ) {
796 $bar[$heading] = $plain_bar[$heading];
800 // If TOOLBOX is missing, $additions_done is still false
801 if ( !$additions_done ) {
802 $plain_bar['TOOLBOX'] = false;
806 foreach ( $bar as $heading => $links ) {
807 if ( $heading == 'SEARCH' ) {
808 $s .= $this->menuHead( wfMessage( 'qbfind' )->text() );
809 $s .= $this->searchForm( 'sidebar' );
810 } elseif ( $heading == 'LANGUAGES' ) {
811 // discard these; we display languages below page content
814 // Use the navigation heading from standard sidebar as the "browse" section
815 if ( $heading == 'navigation' ) {
816 $heading = 'qbbrowse';
818 if ( $heading == 'TOOLBOX' ) {
819 $heading = 'toolbox';
822 $headingMsg = wfMessage( $heading );
824 $t = $this->menuHead( $headingMsg->exists() ?
$headingMsg->text() : $heading );
826 foreach ( $links as $key => $link ) {
827 // Can be empty due to rampant sidebar massaging we're doing above
830 $t .= $this->makeListItem( $key, $link, array( 'tag' => 'span' ) ) . $sep;
841 $s .= $sep . "\n</div>\n";
846 * @param $label string
851 function searchForm( $which ) {
852 global $wgUseTwoButtonsSearchForm;
854 $search = $this->getSkin()->getRequest()->getText( 'search' );
855 $action = $this->data
['searchaction'];
856 $s = "<form id=\"searchform-" . htmlspecialchars($which) . "\" method=\"get\" class=\"inline\" action=\"$action\">";
857 if( $which == 'afterContent' ) {
858 $s .= wfMessage( 'qbfind' )->text() . ": ";
861 $s .= "<input type='text' class=\"mw-searchInput\" name=\"search\" size=\"14\" value=\""
862 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />"
863 . ($which == 'afterContent' ?
" " : "<br />")
864 . "<input type='submit' class=\"searchButton\" name=\"go\" value=\"" . wfMessage( 'searcharticle' )->escaped() . "\" />";
866 if( $wgUseTwoButtonsSearchForm ) {
867 $s .= " <input type='submit' class=\"searchButton\" name=\"fulltext\" value=\"" . wfMessage( 'search' )->escaped() . "\" />\n";
869 $s .= '<div><a href="' . $action . '" rel="search">' . wfMessage( 'powersearch-legend' )->escaped() . "</a></div>\n";