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 return $wgLang->pipeList( $s );
190 function printableLink() {
191 global $wgOut, $wgRequest, $wgLang;
195 if ( !$wgOut->isPrintable() ) {
196 $printurl = htmlspecialchars( $this->getSkin()->getTitle()->getLocalUrl(
197 $wgRequest->appendQueryValue( 'printable', 'yes', true ) ) );
198 $s[] = "<a href=\"$printurl\" rel=\"alternate\">"
199 . wfMessage( 'printableversion' )->text() . '</a>';
202 if ( $wgOut->isSyndicated() ) {
203 foreach ( $wgOut->getSyndicationLinks() as $format => $link ) {
204 $feedurl = htmlspecialchars( $link );
205 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
206 . " class=\"feedlink\">" . wfMessage( "feed-$format" )->escaped() . "</a>";
209 return $wgLang->pipeList( $s );
213 * Gets the h1 element with the page title.
216 function pageTitle() {
218 $s = '<h1 class="pagetitle"><span dir="auto">' . $wgOut->getPageTitle() . '</span></h1>';
222 function pageSubtitle() {
225 $sub = $wgOut->getSubtitle();
228 global $wgExtraSubtitle;
229 $sub = wfMessage( 'tagline' )->parse() . $wgExtraSubtitle;
232 $subpages = $this->getSkin()->subPageSubtitle();
233 $sub .= !empty( $subpages ) ?
"</p><p class='subpages'>$subpages" : '';
234 $s = "<p class='subtitle'>{$sub}</p>\n";
239 function bottomLinks() {
240 global $wgOut, $wgUser;
241 $sep = wfMessage( 'pipe-separator' )->escaped() . "\n";
244 if ( $wgOut->isArticleRelated() ) {
245 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
247 if ( $wgUser->isLoggedIn() ) {
248 $element[] = $this->watchThisPage();
251 $element[] = $this->talkLink();
252 $element[] = $this->historyLink();
253 $element[] = $this->whatLinksHere();
254 $element[] = $this->watchPageLinksLink();
256 $title = $this->getSkin()->getTitle();
259 $title->getNamespace() == NS_USER ||
260 $title->getNamespace() == NS_USER_TALK
262 $id = User
::idFromName( $title->getText() );
263 $ip = User
::isIP( $title->getText() );
265 # Both anons and non-anons have contributions list
267 $element[] = $this->userContribsLink();
270 if ( $this->getSkin()->showEmailUser( $id ) ) {
271 $element[] = $this->emailUserLink();
275 $s = implode( $element, $sep );
277 if ( $title->getArticleID() ) {
280 // Delete/protect/move links for privileged users
281 if ( $wgUser->isAllowed( 'delete' ) ) {
282 $s .= $this->deleteThisPage();
285 if ( $wgUser->isAllowed( 'protect' ) ) {
286 $s .= $sep . $this->protectThisPage();
289 if ( $wgUser->isAllowed( 'move' ) ) {
290 $s .= $sep . $this->moveThisPage();
294 $s .= "<br />\n" . $this->otherLanguages();
300 function editThisPage() {
303 if ( !$wgOut->isArticleRelated() ) {
304 $s = wfMessage( 'protectedpage' )->text();
306 $title = $this->getSkin()->getTitle();
307 if ( $title->quickUserCan( 'edit' ) && $title->exists() ) {
308 $t = wfMessage( 'editthispage' )->text();
309 } elseif ( $title->quickUserCan( 'create' ) && !$title->exists() ) {
310 $t = wfMessage( 'create-this-page' )->text();
312 $t = wfMessage( 'viewsource' )->text();
315 $s = Linker
::linkKnown(
319 $this->getSkin()->editUrlOptions()
326 function deleteThisPage() {
327 global $wgUser, $wgRequest;
329 $diff = $wgRequest->getVal( 'diff' );
330 $title = $this->getSkin()->getTitle();
332 if ( $title->getArticleID() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
333 $t = wfMessage( 'deletethispage' )->text();
335 $s = Linker
::linkKnown(
339 array( 'action' => 'delete' )
348 function protectThisPage() {
349 global $wgUser, $wgRequest;
351 $diff = $wgRequest->getVal( 'diff' );
352 $title = $this->getSkin()->getTitle();
354 if ( $title->getArticleID() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
355 if ( $title->isProtected() ) {
356 $text = wfMessage( 'unprotectthispage' )->text();
357 $query = array( 'action' => 'unprotect' );
359 $text = wfMessage( 'protectthispage' )->text();
360 $query = array( 'action' => 'protect' );
363 $s = Linker
::linkKnown(
376 function watchThisPage() {
377 global $wgOut, $wgUser;
380 $title = $this->getSkin()->getTitle();
382 if ( $wgOut->isArticleRelated() ) {
383 if ( $wgUser->isWatched( $title ) ) {
384 $text = wfMessage( 'unwatchthispage' )->text();
386 'action' => 'unwatch',
387 'token' => UnwatchAction
::getUnwatchToken( $title, $wgUser ),
389 $id = 'mw-unwatch-link';
391 $text = wfMessage( 'watchthispage' )->text();
394 'token' => WatchAction
::getWatchToken( $title, $wgUser ),
396 $id = 'mw-watch-link';
399 $s = Linker
::linkKnown(
402 array( 'id' => $id ),
406 $s = wfMessage( 'notanarticle' )->text();
412 function moveThisPage() {
413 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
414 return Linker
::linkKnown(
415 SpecialPage
::getTitleFor( 'Movepage' ),
416 wfMessage( 'movethispage' )->text(),
418 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() )
421 // no message if page is protected - would be redundant
426 function historyLink() {
428 $this->getSkin()->getTitle(),
429 wfMessage( 'history' )->escaped(),
430 array( 'rel' => 'archives' ),
431 array( 'action' => 'history' )
435 function whatLinksHere() {
436 return Linker
::linkKnown(
437 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
438 wfMessage( 'whatlinkshere' )->escaped()
442 function userContribsLink() {
443 return Linker
::linkKnown(
444 SpecialPage
::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
445 wfMessage( 'contributions' )->escaped()
449 function emailUserLink() {
450 return Linker
::linkKnown(
451 SpecialPage
::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
452 wfMessage( 'emailuser' )->escaped()
456 function watchPageLinksLink() {
459 if ( !$wgOut->isArticleRelated() ) {
460 return wfMessage( 'parentheses', wfMessage( 'notanarticle' )->text() )->escaped();
462 return Linker
::linkKnown(
463 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
464 wfMessage( 'recentchangeslinked-toolbox' )->escaped()
469 function talkLink() {
470 $title = $this->getSkin()->getTitle();
471 if ( NS_SPECIAL
== $title->getNamespace() ) {
472 # No discussion links for special pages
476 $linkOptions = array();
478 if ( $title->isTalkPage() ) {
479 $link = $title->getSubjectPage();
480 switch( $link->getNamespace() ) {
482 $text = wfMessage( 'articlepage' );
485 $text = wfMessage( 'userpage' );
488 $text = wfMessage( 'projectpage' );
491 $text = wfMessage( 'imagepage' );
492 # Make link known if image exists, even if the desc. page doesn't.
493 if ( wfFindFile( $link ) )
494 $linkOptions[] = 'known';
497 $text = wfMessage( 'mediawikipage' );
500 $text = wfMessage( 'templatepage' );
503 $text = wfMessage( 'viewhelppage' );
506 $text = wfMessage( 'categorypage' );
509 $text = wfMessage( 'articlepage' );
512 $link = $title->getTalkPage();
513 $text = wfMessage( 'talkpage' );
516 $s = Linker
::link( $link, $text->text(), array(), array(), $linkOptions );
521 function pageStats() {
523 $items = array( 'viewcount', 'credits', 'lastmod', 'numberofwatchingusers', 'copyright' );
525 foreach( $items as $item ) {
526 if ( $this->data
[$item] !== false ) {
527 $ret[] = $this->data
[$item];
531 return implode( ' ', $ret );
541 function beforeContent() {
542 $mainPageObj = Title
::newMainPage();
544 $s = "\n<div id='content'>\n";
549 <a href
="<?php echo htmlspecialchars( $mainPageObj->getLocalURL() ) ?>">
550 <?php
echo wfMessage( 'sitetitle' )->escaped() ?
>
554 <?php
echo wfMessage( 'sitesubtitle' )->escaped() ?
>
558 <span
><?php
echo $this->sysLinks() ?
></span
>
560 <div id
="linkcollection">
561 <div id
="langlinks"><?php
echo str_replace( '<br />', '', $this->otherLanguages() ) ?
></div
>
562 <?php
echo $this->getSkin()->getCategories() ?
>
563 <div id
="titlelinks"><?php
echo $this->pageTitleLinks() ?
></div
>
564 <?php
if ( $this->data
['newtalk'] ) { ?
>
565 <div
class="usermessage"><strong
><?php
echo $this->data
['newtalk'] ?
></strong
></div
>
570 $s .= ob_get_contents();
573 $s .= "\n<div id='article'>";
575 $notice = $this->getSkin()->getSiteNotice();
577 $s .= "\n<div id='siteNotice'>$notice</div>\n";
579 $s .= $this->pageTitle();
580 $s .= $this->pageSubtitle() . "\n";
587 function afterContent(){
590 $s .= "\n<div id='footer'>";
592 $s .= $this->bottomLinks();
593 $s .= $this->getSkin()->getLanguage()->pipeList( array(
594 "\n<br />" . Linker
::linkKnown(
597 $this->getSkin()->aboutLink(),
598 $this->searchForm( 'afterContent' )
601 $s .= "\n<br />" . $this->pageStats();
603 $s .= "\n</div>\n</div>\n";
605 $s .= $this->quickBar();
612 function sysLinks() {
613 $li = SpecialPage
::getTitleFor( 'Userlogin' );
614 $lo = SpecialPage
::getTitleFor( 'Userlogout' );
616 $rt = $this->getSkin()->getTitle()->getPrefixedURL();
617 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
620 $q = array( 'returnto' => $rt );
624 $this->getSkin()->mainPageLink(),
626 Title
::newFromText( wfMessage( 'aboutpage' )->inContentLanguage()->text() ),
627 wfMessage( 'about' )->text()
630 Title
::newFromText( wfMessage( 'helppage' )->inContentLanguage()->text() ),
631 wfMessage( 'help' )->text()
634 Title
::newFromText( wfMessage( 'faqpage' )->inContentLanguage()->text() ),
635 wfMessage( 'faq' )->text()
637 Linker
::specialLink( 'Specialpages' )
640 /* show links to different language variants */
641 if( $this->variantLinks() ) {
642 $s[] = $this->variantLinks();
644 if( $this->extensionTabLinks() ) {
645 $s[] = $this->extensionTabLinks();
647 if ( $this->data
['loggedin'] ) {
648 $s[] = Linker
::linkKnown(
650 wfMessage( 'logout' )->text(),
655 $s[] = Linker
::linkKnown(
657 wfMessage( 'login' )->text(),
663 return $this->getSkin()->getLanguage()->pipeList( $s );
670 * @param $heading string
675 function menuHead( $heading ) {
676 return "\n<h6>" . htmlspecialchars( $heading ) . "</h6>";
680 * Compute the sidebar
688 $s = "\n<div id='quickbar'>";
692 $plain_bar = $this->data
['sidebar'];
695 // Massage the sidebar
696 // We want to place SEARCH at the beginning and a lot of stuff before TOOLBOX (or at the end, if it's missing)
697 $additions_done = false;
698 while ( !$additions_done ) {
699 $bar = array(); // Empty it out
701 // Always display search on top
702 $bar['SEARCH'] = true;
704 foreach ( $plain_bar as $heading => $links ) {
705 if ( $heading == 'TOOLBOX' ) {
706 if( $links !== NULL ) {
707 // If this is not a toolbox prosthetic we inserted outselves, fill it out
708 $plain_bar['TOOLBOX'] = $this->getToolbox();
711 // And insert the stuff
713 // "This page" and "Edit" menus
714 // We need to do some massaging here... we reuse all of the items, except for $...['views']['view'],
715 // as $...['namespaces']['main'] and $...['namespaces']['talk'] together serve the same purpose.
716 // We also don't use $...['variants'], these are displayed in the top menu.
717 $content_navigation = $this->data
['content_navigation'];
718 $qbpageoptions = array_merge(
719 $content_navigation['namespaces'],
721 'history' => $content_navigation['views']['history'],
722 'watch' => $content_navigation['actions']['watch'],
723 'unwatch' => $content_navigation['actions']['unwatch'],
726 $content_navigation['actions']['watch'] = null;
727 $content_navigation['actions']['unwatch'] = null;
728 $qbedit = array_merge(
730 'edit' => $content_navigation['views']['edit'],
731 'addsection' => $content_navigation['views']['addsection'],
733 $content_navigation['actions']
735 $bar['qbedit'] = $qbedit;
736 $bar['qbpageoptions'] = $qbpageoptions;
738 // Personal tools ("My pages")
739 $bar['qbmyoptions'] = $this->getPersonalTools();
741 $additions_done = true;
744 // Re-insert current heading, unless it's SEARCH
745 if ( $heading != 'SEARCH' ) {
746 $bar[$heading] = $plain_bar[$heading];
750 // If TOOLBOX is missing, $additions_done is still false
751 if ( !$additions_done ) {
752 $plain_bar['TOOLBOX'] = false;
756 foreach ( $bar as $heading => $links ) {
757 if ( $heading == 'SEARCH' ) {
758 $s .= $this->menuHead( wfMessage( 'qbfind' )->text() );
759 $s .= $this->searchForm( 'sidebar' );
760 } elseif ( $heading == 'LANGUAGES' ) {
761 // discard these; we display languages below page content
764 // Use the navigation heading from standard sidebar as the "browse" section
765 if ( $heading == 'navigation' ) {
766 $heading = 'qbbrowse';
768 if ( $heading == 'TOOLBOX' ) {
769 $heading = 'toolbox';
772 $headingMsg = wfMessage( $heading );
774 $t = $this->menuHead( $headingMsg->exists() ?
$headingMsg->text() : $heading );
776 foreach ( $links as $key => $link ) {
777 // Can be empty due to rampant sidebar massaging we're doing above
780 $t .= $this->makeListItem( $key, $link, array( 'tag' => 'span' ) ) . $sep;
791 $s .= $sep . "\n</div>\n";
796 * @param $label string
801 function searchForm( $which ) {
802 global $wgUseTwoButtonsSearchForm;
804 $search = $this->getSkin()->getRequest()->getText( 'search' );
805 $action = $this->data
['searchaction'];
806 $s = "<form id=\"searchform-" . htmlspecialchars($which) . "\" method=\"get\" class=\"inline\" action=\"$action\">";
807 if( $which == 'afterContent' ) {
808 $s .= wfMessage( 'qbfind' )->text() . ": ";
811 $s .= "<input type='text' class=\"mw-searchInput\" name=\"search\" size=\"14\" value=\""
812 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />"
813 . ($which == 'afterContent' ?
" " : "<br />")
814 . "<input type='submit' class=\"searchButton\" name=\"go\" value=\"" . wfMessage( 'searcharticle' )->escaped() . "\" />";
816 if( $wgUseTwoButtonsSearchForm ) {
817 $s .= " <input type='submit' class=\"searchButton\" name=\"fulltext\" value=\"" . wfMessage( 'search' )->escaped() . "\" />\n";
819 $s .= '<div><a href="' . $action . '" rel="search">' . wfMessage( 'powersearch-legend' )->escaped() . "</a></div>\n";