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() ) {
165 function pageTitleLinks() {
169 $footlinks = $this->getFooterLinks();
171 foreach ( $footlinks['places'] as $item ) {
172 $s[] = $this->data
[$item];
175 return $wgLang->pipeList( $s );
178 function bottomLinks() {
179 global $wgOut, $wgUser;
180 $sep = wfMessage( 'pipe-separator' )->escaped() . "\n";
183 if ( $wgOut->isArticleRelated() ) {
184 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
186 if ( $wgUser->isLoggedIn() ) {
187 $element[] = $this->watchThisPage();
190 $element[] = $this->talkLink();
191 $element[] = $this->historyLink();
192 $element[] = $this->whatLinksHere();
193 $element[] = $this->watchPageLinksLink();
195 $title = $this->getSkin()->getTitle();
198 $title->getNamespace() == NS_USER ||
199 $title->getNamespace() == NS_USER_TALK
201 $id = User
::idFromName( $title->getText() );
202 $ip = User
::isIP( $title->getText() );
204 # Both anons and non-anons have contributions list
206 $element[] = $this->userContribsLink();
209 if ( $this->getSkin()->showEmailUser( $id ) ) {
210 $element[] = $this->emailUserLink();
214 $s = implode( $element, $sep );
216 if ( $title->getArticleID() ) {
219 // Delete/protect/move links for privileged users
220 if ( $wgUser->isAllowed( 'delete' ) ) {
221 $s .= $this->deleteThisPage();
224 if ( $wgUser->isAllowed( 'protect' ) ) {
225 $s .= $sep . $this->protectThisPage();
228 if ( $wgUser->isAllowed( 'move' ) ) {
229 $s .= $sep . $this->moveThisPage();
233 $s .= "<br />\n" . $this->otherLanguages();
239 function editThisPage() {
242 if ( !$wgOut->isArticleRelated() ) {
243 $s = wfMessage( 'protectedpage' )->text();
245 $title = $this->getSkin()->getTitle();
246 if ( $title->quickUserCan( 'edit' ) && $title->exists() ) {
247 $t = wfMessage( 'editthispage' )->text();
248 } elseif ( $title->quickUserCan( 'create' ) && !$title->exists() ) {
249 $t = wfMessage( 'create-this-page' )->text();
251 $t = wfMessage( 'viewsource' )->text();
254 $s = Linker
::linkKnown(
258 $this->getSkin()->editUrlOptions()
265 function deleteThisPage() {
266 global $wgUser, $wgRequest;
268 $diff = $wgRequest->getVal( 'diff' );
269 $title = $this->getSkin()->getTitle();
271 if ( $title->getArticleID() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
272 $t = wfMessage( 'deletethispage' )->text();
274 $s = Linker
::linkKnown(
278 array( 'action' => 'delete' )
287 function protectThisPage() {
288 global $wgUser, $wgRequest;
290 $diff = $wgRequest->getVal( 'diff' );
291 $title = $this->getSkin()->getTitle();
293 if ( $title->getArticleID() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
294 if ( $title->isProtected() ) {
295 $text = wfMessage( 'unprotectthispage' )->text();
296 $query = array( 'action' => 'unprotect' );
298 $text = wfMessage( 'protectthispage' )->text();
299 $query = array( 'action' => 'protect' );
302 $s = Linker
::linkKnown(
315 function watchThisPage() {
316 global $wgOut, $wgUser;
319 $title = $this->getSkin()->getTitle();
321 if ( $wgOut->isArticleRelated() ) {
322 if ( $wgUser->isWatched( $title ) ) {
323 $text = wfMessage( 'unwatchthispage' )->text();
325 'action' => 'unwatch',
326 'token' => UnwatchAction
::getUnwatchToken( $title, $wgUser ),
328 $id = 'mw-unwatch-link';
330 $text = wfMessage( 'watchthispage' )->text();
333 'token' => WatchAction
::getWatchToken( $title, $wgUser ),
335 $id = 'mw-watch-link';
338 $s = Linker
::linkKnown(
341 array( 'id' => $id ),
345 $s = wfMessage( 'notanarticle' )->text();
351 function moveThisPage() {
352 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
353 return Linker
::linkKnown(
354 SpecialPage
::getTitleFor( 'Movepage' ),
355 wfMessage( 'movethispage' )->text(),
357 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() )
360 // no message if page is protected - would be redundant
365 function historyLink() {
367 $this->getSkin()->getTitle(),
368 wfMessage( 'history' )->escaped(),
369 array( 'rel' => 'archives' ),
370 array( 'action' => 'history' )
374 function whatLinksHere() {
375 return Linker
::linkKnown(
376 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
377 wfMessage( 'whatlinkshere' )->escaped()
381 function userContribsLink() {
382 return Linker
::linkKnown(
383 SpecialPage
::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
384 wfMessage( 'contributions' )->escaped()
388 function emailUserLink() {
389 return Linker
::linkKnown(
390 SpecialPage
::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
391 wfMessage( 'emailuser' )->escaped()
395 function watchPageLinksLink() {
398 if ( !$wgOut->isArticleRelated() ) {
399 return wfMessage( 'parentheses', wfMessage( 'notanarticle' )->text() )->escaped();
401 return Linker
::linkKnown(
402 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
403 wfMessage( 'recentchangeslinked-toolbox' )->escaped()
408 function talkLink() {
409 $title = $this->getSkin()->getTitle();
410 if ( NS_SPECIAL
== $title->getNamespace() ) {
411 # No discussion links for special pages
415 $linkOptions = array();
417 if ( $title->isTalkPage() ) {
418 $link = $title->getSubjectPage();
419 switch( $link->getNamespace() ) {
421 $text = wfMessage( 'articlepage' );
424 $text = wfMessage( 'userpage' );
427 $text = wfMessage( 'projectpage' );
430 $text = wfMessage( 'imagepage' );
431 # Make link known if image exists, even if the desc. page doesn't.
432 if ( wfFindFile( $link ) )
433 $linkOptions[] = 'known';
436 $text = wfMessage( 'mediawikipage' );
439 $text = wfMessage( 'templatepage' );
442 $text = wfMessage( 'viewhelppage' );
445 $text = wfMessage( 'categorypage' );
448 $text = wfMessage( 'articlepage' );
451 $link = $title->getTalkPage();
452 $text = wfMessage( 'talkpage' );
455 $s = Linker
::link( $link, $text->text(), array(), array(), $linkOptions );
463 function beforeContent() {
464 $mainPageObj = Title
::newMainPage();
466 $s = "\n<div id='content'>\n";
471 <a href
="<?php echo htmlspecialchars( $mainPageObj->getLocalURL() ) ?>">
472 <?php
echo wfMessage( 'sitetitle' )->escaped() ?
>
476 <?php
echo wfMessage( 'sitesubtitle' )->escaped() ?
>
480 <span
><?php
echo $this->sysLinks() ?
></span
>
482 <div id
="linkcollection">
483 <div id
="langlinks"><?php
echo str_replace( '<br />', '', $this->otherLanguages() ) ?
></div
>
484 <?php
echo $this->getSkin()->getCategories() ?
>
485 <div id
="titlelinks"><?php
echo $this->pageTitleLinks() ?
></div
>
486 <?php
if ( $this->data
['newtalk'] ) { ?
>
487 <div
class="usermessage"><strong
><?php
echo $this->data
['newtalk'] ?
></strong
></div
>
492 $s .= ob_get_contents();
495 $s .= "\n<div id='article'>";
497 $notice = $this->getSkin()->getSiteNotice();
499 $s .= "\n<div id='siteNotice'>$notice</div>\n";
502 $s .= '<h1 id="firstHeading"><span dir="auto">' . $this->data
['title'] . '</span></h1>';
504 if ( $this->translator
->translate( 'tagline' ) ) {
505 $s .= "<p class='tagline'>" . htmlspecialchars( $this->translator
->translate( 'tagline' ) ) . "</p>";
507 if ( $this->getSkin()->getOutput()->getSubtitle() ) {
508 $s .= "<p class='subtitle'>" . $this->getSkin()->getOutput()->getSubtitle() . "</p>";
510 if ( $this->getSkin()->subPageSubtitle() ) {
511 $s .= "<p class='subpages'>" . $this->getSkin()->subPageSubtitle() . "</p>";
520 function afterContent(){
523 $s .= "\n<div id='footer'>";
525 $s .= $this->bottomLinks();
526 $s .= $this->getSkin()->getLanguage()->pipeList( array(
527 "\n<br />" . Linker
::linkKnown(
530 $this->getSkin()->aboutLink(),
531 $this->searchForm( 'afterContent' )
535 $footlinks = $this->getFooterLinks();
536 if ( $footlinks['info'] ) {
537 foreach ( $footlinks['info'] as $item ) {
538 $s .= $this->data
[$item] . ' ';
542 $s .= "\n</div>\n</div>\n";
544 $s .= $this->quickBar();
551 function sysLinks() {
552 $personalUrls = $this->data
['personal_urls'];
555 $this->getSkin()->mainPageLink(),
557 Title
::newFromText( wfMessage( 'aboutpage' )->inContentLanguage()->text() ),
558 wfMessage( 'about' )->text()
561 Title
::newFromText( wfMessage( 'helppage' )->inContentLanguage()->text() ),
562 wfMessage( 'help' )->text()
565 Title
::newFromText( wfMessage( 'faqpage' )->inContentLanguage()->text() ),
566 wfMessage( 'faq' )->text()
568 Linker
::specialLink( 'Specialpages' )
571 /* show links to different language variants */
572 if( $this->variantLinks() ) {
573 $s[] = $this->variantLinks();
575 if( $this->extensionTabLinks() ) {
576 $s[] = $this->extensionTabLinks();
578 if ( $this->data
['loggedin'] ) {
579 $s[] = $this->makeLink( 'logout', $personalUrls['logout'] );
581 if ( $personalUrls['createaccount'] ) { // Controlled by $wgUseCombinedLoginLink
582 $s[] = $this->makeLink( 'createaccount', $personalUrls['createaccount'] );
584 if ( $personalUrls['login'] ) {
585 $s[] = $this->makeLink( 'login', $personalUrls['login'] );
587 if ( $personalUrls['anonlogin'] ) {
588 $s[] = $this->makeLink( 'anonlogin', $personalUrls['anonlogin'] );
592 return $this->getSkin()->getLanguage()->pipeList( $s );
599 * @param $heading string
604 function menuHead( $heading ) {
605 return "\n<h6>" . htmlspecialchars( $heading ) . "</h6>";
609 * Compute the sidebar
617 $s = "\n<div id='quickbar'>";
621 $plain_bar = $this->data
['sidebar'];
624 // Massage the sidebar
625 // We want to place SEARCH at the beginning and a lot of stuff before TOOLBOX (or at the end, if it's missing)
626 $additions_done = false;
627 while ( !$additions_done ) {
628 $bar = array(); // Empty it out
630 // Always display search on top
631 $bar['SEARCH'] = true;
633 foreach ( $plain_bar as $heading => $links ) {
634 if ( $heading == 'TOOLBOX' ) {
635 if( $links !== NULL ) {
636 // If this is not a toolbox prosthetic we inserted outselves, fill it out
637 $plain_bar['TOOLBOX'] = $this->getToolbox();
640 // And insert the stuff
642 // "This page" and "Edit" menus
643 // We need to do some massaging here... we reuse all of the items, except for $...['views']['view'],
644 // as $...['namespaces']['main'] and $...['namespaces']['talk'] together serve the same purpose.
645 // We also don't use $...['variants'], these are displayed in the top menu.
646 $content_navigation = $this->data
['content_navigation'];
647 $qbpageoptions = array_merge(
648 $content_navigation['namespaces'],
650 'history' => $content_navigation['views']['history'],
651 'watch' => $content_navigation['actions']['watch'],
652 'unwatch' => $content_navigation['actions']['unwatch'],
655 $content_navigation['actions']['watch'] = null;
656 $content_navigation['actions']['unwatch'] = null;
657 $qbedit = array_merge(
659 'edit' => $content_navigation['views']['edit'],
660 'addsection' => $content_navigation['views']['addsection'],
662 $content_navigation['actions']
664 $bar['qbedit'] = $qbedit;
665 $bar['qbpageoptions'] = $qbpageoptions;
667 // Personal tools ("My pages")
668 $bar['qbmyoptions'] = $this->getPersonalTools();
669 $bar['qbmyoptions']['login'] = false;
670 $bar['qbmyoptions']['anonlogin'] = false;
671 $bar['qbmyoptions']['logout'] = false;
672 $bar['qbmyoptions']['createaccount'] = false;
674 $additions_done = true;
677 // Re-insert current heading, unless it's SEARCH
678 if ( $heading != 'SEARCH' ) {
679 $bar[$heading] = $plain_bar[$heading];
683 // If TOOLBOX is missing, $additions_done is still false
684 if ( !$additions_done ) {
685 $plain_bar['TOOLBOX'] = false;
689 foreach ( $bar as $heading => $links ) {
690 if ( $heading == 'SEARCH' ) {
691 $s .= $this->menuHead( wfMessage( 'qbfind' )->text() );
692 $s .= $this->searchForm( 'sidebar' );
693 } elseif ( $heading == 'LANGUAGES' ) {
694 // discard these; we display languages below page content
697 // Use the navigation heading from standard sidebar as the "browse" section
698 if ( $heading == 'navigation' ) {
699 $heading = 'qbbrowse';
701 if ( $heading == 'TOOLBOX' ) {
702 $heading = 'toolbox';
705 $headingMsg = wfMessage( $heading );
707 $t = $this->menuHead( $headingMsg->exists() ?
$headingMsg->text() : $heading );
709 foreach ( $links as $key => $link ) {
710 // Can be empty due to rampant sidebar massaging we're doing above
713 $t .= $this->makeListItem( $key, $link, array( 'tag' => 'span' ) ) . $sep;
724 $s .= $sep . "\n</div>\n";
729 * @param $label string
734 function searchForm( $which ) {
735 global $wgUseTwoButtonsSearchForm;
737 $search = $this->getSkin()->getRequest()->getText( 'search' );
738 $action = $this->data
['searchaction'];
739 $s = "<form id=\"searchform-" . htmlspecialchars($which) . "\" method=\"get\" class=\"inline\" action=\"$action\">";
740 if( $which == 'afterContent' ) {
741 $s .= wfMessage( 'qbfind' )->text() . ": ";
744 $s .= "<input type='text' class=\"mw-searchInput\" name=\"search\" size=\"14\" value=\""
745 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />"
746 . ($which == 'afterContent' ?
" " : "<br />")
747 . "<input type='submit' class=\"searchButton\" name=\"go\" value=\"" . wfMessage( 'searcharticle' )->escaped() . "\" />";
749 if( $wgUseTwoButtonsSearchForm ) {
750 $s .= " <input type='submit' class=\"searchButton\" name=\"fulltext\" value=\"" . wfMessage( 'search' )->escaped() . "\" />\n";
752 $s .= '<div><a href="' . $action . '" rel="search">' . wfMessage( 'powersearch-legend' )->escaped() . "</a></div>\n";