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' );
48 * Override langlink formatting behavior not to uppercase the language names.
49 * See otherLanguages() in CologneBlueTemplate.
51 function formatLanguageName( $name ) {
56 class CologneBlueTemplate
extends BaseTemplate
{
58 $this->html( 'headelement' );
59 echo $this->beforeContent();
60 $this->html( 'bodytext' );
62 echo $this->afterContent();
63 $this->html( 'dataAfterContent' );
65 echo "\n</body></html>";
70 * Language/charset variant links for classic-style skins
75 function variantLinks() {
78 $variants = $this->data
['content_navigation']['variants'];
80 foreach ( $variants as $key => $link ) {
81 $s[] = $this->makeListItem( $key, $link, array( 'tag' => 'span' ) );
84 return $this->getSkin()->getLanguage()->pipeList( $s );
88 function otherLanguages() {
89 global $wgHideInterlanguageLinks;
90 if ( $wgHideInterlanguageLinks ) {
94 // We override SkinTemplate->formatLanguageName() in SkinCologneBlue
95 // not to capitalize the language names.
96 $language_urls = $this->data
['language_urls'];
97 if ( empty( $language_urls ) ) {
102 foreach ( $language_urls as $key => $data ) {
103 $s[] = $this->makeListItem( $key, $data, array( 'tag' => 'span' ) );
106 return wfMessage( 'otherlanguages' )->text()
107 . wfMessage( 'colon-separator' )->text()
108 . $this->getSkin()->getLanguage()->pipeList( $s );
112 function pageTitleLinks() {
114 $footlinks = $this->getFooterLinks();
116 foreach ( $footlinks['places'] as $item ) {
117 $s[] = $this->data
[$item];
120 return $this->getSkin()->getLanguage()->pipeList( $s );
123 function bottomLinks() {
124 $sep = wfMessage( 'pipe-separator' )->escaped() . "\n";
127 if ( $this->getSkin()->getOutput()->isArticleRelated() ) {
128 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
130 if ( $this->getSkin()->getUser()->isLoggedIn() ) {
131 $element[] = $this->watchThisPage();
134 $element[] = $this->talkLink();
135 $element[] = $this->historyLink();
136 $element[] = $this->whatLinksHere();
137 $element[] = $this->watchPageLinksLink();
139 $title = $this->getSkin()->getTitle();
142 $title->getNamespace() == NS_USER ||
143 $title->getNamespace() == NS_USER_TALK
145 $id = User
::idFromName( $title->getText() );
146 $ip = User
::isIP( $title->getText() );
148 # Both anons and non-anons have contributions list
150 $element[] = $this->userContribsLink();
153 if ( $this->getSkin()->showEmailUser( $id ) ) {
154 $element[] = $this->emailUserLink();
158 $s = implode( $element, $sep );
160 if ( $title->getArticleID() ) {
163 // Delete/protect/move links for privileged users
164 if ( $this->getSkin()->getUser()->isAllowed( 'delete' ) ) {
165 $s .= $this->deleteThisPage();
168 if ( $this->getSkin()->getUser()->isAllowed( 'protect' ) ) {
169 $s .= $sep . $this->protectThisPage();
172 if ( $this->getSkin()->getUser()->isAllowed( 'move' ) ) {
173 $s .= $sep . $this->moveThisPage();
177 $s .= "<br />\n" . $this->otherLanguages();
183 function editThisPage() {
184 if ( !$this->getSkin()->getOutput()->isArticleRelated() ) {
185 $s = wfMessage( 'protectedpage' )->text();
187 $title = $this->getSkin()->getTitle();
188 if ( $title->quickUserCan( 'edit' ) && $title->exists() ) {
189 $t = wfMessage( 'editthispage' )->text();
190 } elseif ( $title->quickUserCan( 'create' ) && !$title->exists() ) {
191 $t = wfMessage( 'create-this-page' )->text();
193 $t = wfMessage( 'viewsource' )->text();
196 $s = Linker
::linkKnown(
200 $this->getSkin()->editUrlOptions()
207 function deleteThisPage() {
208 $diff = $this->getSkin()->getRequest()->getVal( 'diff' );
209 $title = $this->getSkin()->getTitle();
211 if ( $title->getArticleID() && ( !$diff ) && $this->getSkin()->getUser()->isAllowed( 'delete' ) ) {
212 $t = wfMessage( 'deletethispage' )->text();
214 $s = Linker
::linkKnown(
218 array( 'action' => 'delete' )
227 function protectThisPage() {
228 $diff = $this->getSkin()->getRequest()->getVal( 'diff' );
229 $title = $this->getSkin()->getTitle();
231 if ( $title->getArticleID() && ( ! $diff ) && $this->getSkin()->getUser()->isAllowed( 'protect' ) ) {
232 if ( $title->isProtected() ) {
233 $text = wfMessage( 'unprotectthispage' )->text();
234 $query = array( 'action' => 'unprotect' );
236 $text = wfMessage( 'protectthispage' )->text();
237 $query = array( 'action' => 'protect' );
240 $s = Linker
::linkKnown(
253 function watchThisPage() {
255 $title = $this->getSkin()->getTitle();
257 if ( $this->getSkin()->getOutput()->isArticleRelated() ) {
258 if ( $this->getSkin()->getUser()->isWatched( $title ) ) {
259 $text = wfMessage( 'unwatchthispage' )->text();
261 'action' => 'unwatch',
262 'token' => UnwatchAction
::getUnwatchToken( $title, $this->getSkin()->getUser() ),
264 $id = 'mw-unwatch-link';
266 $text = wfMessage( 'watchthispage' )->text();
269 'token' => WatchAction
::getWatchToken( $title, $this->getSkin()->getUser() ),
271 $id = 'mw-watch-link';
274 $s = Linker
::linkKnown(
277 array( 'id' => $id ),
281 $s = wfMessage( 'notanarticle' )->text();
287 function moveThisPage() {
288 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
289 return Linker
::linkKnown(
290 SpecialPage
::getTitleFor( 'Movepage' ),
291 wfMessage( 'movethispage' )->text(),
293 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() )
296 // no message if page is protected - would be redundant
301 function historyLink() {
303 $this->getSkin()->getTitle(),
304 wfMessage( 'history' )->escaped(),
305 array( 'rel' => 'archives' ),
306 array( 'action' => 'history' )
310 function whatLinksHere() {
311 return Linker
::linkKnown(
312 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
313 wfMessage( 'whatlinkshere' )->escaped()
317 function userContribsLink() {
318 return Linker
::linkKnown(
319 SpecialPage
::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
320 wfMessage( 'contributions' )->escaped()
324 function emailUserLink() {
325 return Linker
::linkKnown(
326 SpecialPage
::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
327 wfMessage( 'emailuser' )->escaped()
331 function watchPageLinksLink() {
332 if ( !$this->getSkin()->getOutput()->isArticleRelated() ) {
333 return wfMessage( 'parentheses', wfMessage( 'notanarticle' )->text() )->escaped();
335 return Linker
::linkKnown(
336 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
337 wfMessage( 'recentchangeslinked-toolbox' )->escaped()
342 function talkLink() {
343 $title = $this->getSkin()->getTitle();
344 if ( NS_SPECIAL
== $title->getNamespace() ) {
345 # No discussion links for special pages
349 $linkOptions = array();
351 if ( $title->isTalkPage() ) {
352 $link = $title->getSubjectPage();
353 switch( $link->getNamespace() ) {
355 $text = wfMessage( 'articlepage' );
358 $text = wfMessage( 'userpage' );
361 $text = wfMessage( 'projectpage' );
364 $text = wfMessage( 'imagepage' );
365 # Make link known if image exists, even if the desc. page doesn't.
366 if ( wfFindFile( $link ) )
367 $linkOptions[] = 'known';
370 $text = wfMessage( 'mediawikipage' );
373 $text = wfMessage( 'templatepage' );
376 $text = wfMessage( 'viewhelppage' );
379 $text = wfMessage( 'categorypage' );
382 $text = wfMessage( 'articlepage' );
385 $link = $title->getTalkPage();
386 $text = wfMessage( 'talkpage' );
389 $s = Linker
::link( $link, $text->text(), array(), array(), $linkOptions );
399 function beforeContent() {
405 <a href
="<?php echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] ) ?>">
406 <?php
echo wfMessage( 'sitetitle' )->escaped() ?
>
409 <p id
="sitesub"><?php
echo wfMessage( 'sitesubtitle' )->escaped() ?
></p
>
412 <p id
="syslinks"><?php
echo $this->sysLinks() ?
></p
>
413 <p id
="variantlinks"><?php
echo $this->variantLinks() ?
></p
>
415 <div id
="linkcollection">
416 <div id
="langlinks"><?php
echo str_replace( '<br />', '', $this->otherLanguages() ) ?
></div
>
417 <?php
echo $this->getSkin()->getCategories() ?
>
418 <div id
="titlelinks"><?php
echo $this->pageTitleLinks() ?
></div
>
419 <?php
if ( $this->data
['newtalk'] ) { ?
>
420 <div
class="usermessage"><strong
><?php
echo $this->data
['newtalk'] ?
></strong
></div
>
425 <?php
if ( $this->getSkin()->getSiteNotice() ) { ?
>
426 <div id
="siteNotice"><?php
echo $this->getSkin()->getSiteNotice() ?
></div
>
428 <h1 id
="firstHeading"><span dir
="auto"><?php
echo $this->data
['title'] ?
></span
></h1
>
429 <?php
if ( $this->translator
->translate( 'tagline' ) ) { ?
>
430 <p
class="tagline"><?php
echo htmlspecialchars( $this->translator
->translate( 'tagline' ) ) ?
></p
>
432 <?php
if ( $this->getSkin()->getOutput()->getSubtitle() ) { ?
>
433 <p
class="subtitle"><?php
echo $this->getSkin()->getOutput()->getSubtitle() ?
></p
>
435 <?php
if ( $this->getSkin()->subPageSubtitle() ) { ?
>
436 <p
class="subpages"><?php
echo $this->getSkin()->subPageSubtitle() ?
></p
>
439 $s = ob_get_contents();
450 function afterContent() {
456 // Page-related links
457 echo $this->bottomLinks();
460 // Footer and second searchbox
461 echo $this->getSkin()->getLanguage()->pipeList( array(
462 $this->getSkin()->mainPageLink(),
463 $this->getSkin()->aboutLink(),
464 $this->searchForm( 'footer' )
468 // Standard footer info
469 $footlinks = $this->getFooterLinks();
470 if ( $footlinks['info'] ) {
471 foreach ( $footlinks['info'] as $item ) {
472 echo $this->data
[$item] . ' ';
478 <?php
echo $this->quickBar() ?
>
480 $s = ob_get_contents();
491 function sysLinks() {
493 $this->getSkin()->mainPageLink(),
495 Title
::newFromText( wfMessage( 'aboutpage' )->inContentLanguage()->text() ),
496 wfMessage( 'about' )->text()
499 Title
::newFromText( wfMessage( 'helppage' )->inContentLanguage()->text() ),
500 wfMessage( 'help' )->text()
503 Title
::newFromText( wfMessage( 'faqpage' )->inContentLanguage()->text() ),
504 wfMessage( 'faq' )->text()
508 $personalUrls = $this->getPersonalTools();
509 foreach ( array ( 'logout', 'createaccount', 'login', 'anonlogin' ) as $key ) {
510 if ( $personalUrls[$key] ) {
511 $s[] = $this->makeListItem( $key, $personalUrls[$key], array( 'tag' => 'span' ) );
515 return $this->getSkin()->getLanguage()->pipeList( $s );
522 * @param $heading string
527 function menuHead( $heading ) {
528 return "\n<h6>" . htmlspecialchars( $heading ) . "</h6>";
532 * Compute the sidebar
540 $s = "\n<div id='quickbar'>";
544 $plain_bar = $this->data
['sidebar'];
547 // Massage the sidebar
548 // We want to place SEARCH at the beginning and a lot of stuff before TOOLBOX (or at the end, if it's missing)
549 $additions_done = false;
550 while ( !$additions_done ) {
551 $bar = array(); // Empty it out
553 // Always display search on top
554 $bar['SEARCH'] = true;
556 foreach ( $plain_bar as $heading => $links ) {
557 if ( $heading == 'TOOLBOX' ) {
558 if( $links !== NULL ) {
559 // If this is not a toolbox prosthetic we inserted outselves, fill it out
560 $plain_bar['TOOLBOX'] = $this->getToolbox();
563 // And insert the stuff
565 // "This page" and "Edit" menus
566 // We need to do some massaging here... we reuse all of the items, except for $...['views']['view'],
567 // as $...['namespaces']['main'] and $...['namespaces']['talk'] together serve the same purpose.
568 // We also don't use $...['variants'], these are displayed in the top menu.
569 $content_navigation = $this->data
['content_navigation'];
570 $qbpageoptions = array_merge(
571 $content_navigation['namespaces'],
573 'history' => $content_navigation['views']['history'],
574 'watch' => $content_navigation['actions']['watch'],
575 'unwatch' => $content_navigation['actions']['unwatch'],
578 $content_navigation['actions']['watch'] = null;
579 $content_navigation['actions']['unwatch'] = null;
580 $qbedit = array_merge(
582 'edit' => $content_navigation['views']['edit'],
583 'addsection' => $content_navigation['views']['addsection'],
585 $content_navigation['actions']
587 $bar['qbedit'] = $qbedit;
588 $bar['qbpageoptions'] = $qbpageoptions;
590 // Personal tools ("My pages")
591 $bar['qbmyoptions'] = $this->getPersonalTools();
592 foreach ( array ( 'logout', 'createaccount', 'login', 'anonlogin' ) as $key ) {
593 $bar['qbmyoptions'][$key] = false;
596 $additions_done = true;
599 // Re-insert current heading, unless it's SEARCH
600 if ( $heading != 'SEARCH' ) {
601 $bar[$heading] = $plain_bar[$heading];
605 // If TOOLBOX is missing, $additions_done is still false
606 if ( !$additions_done ) {
607 $plain_bar['TOOLBOX'] = false;
611 foreach ( $bar as $heading => $links ) {
612 if ( $heading == 'SEARCH' ) {
613 $s .= $this->menuHead( wfMessage( 'qbfind' )->text() );
614 $s .= $this->searchForm( 'sidebar' );
615 } elseif ( $heading == 'LANGUAGES' ) {
616 // discard these; we display languages below page content
619 // Use the navigation heading from standard sidebar as the "browse" section
620 if ( $heading == 'navigation' ) {
621 $heading = 'qbbrowse';
623 if ( $heading == 'TOOLBOX' ) {
624 $heading = 'toolbox';
627 $headingMsg = wfMessage( $heading );
629 $t = $this->menuHead( $headingMsg->exists() ?
$headingMsg->text() : $heading );
631 foreach ( $links as $key => $link ) {
632 // Can be empty due to rampant sidebar massaging we're doing above
635 $t .= $this->makeListItem( $key, $link, array( 'tag' => 'span' ) ) . $sep;
646 $s .= $sep . "\n</div>\n";
651 * @param $label string
656 function searchForm( $which ) {
657 global $wgUseTwoButtonsSearchForm;
659 $search = $this->getSkin()->getRequest()->getText( 'search' );
660 $action = $this->data
['searchaction'];
661 $s = "<form id=\"searchform-" . htmlspecialchars($which) . "\" method=\"get\" class=\"inline\" action=\"$action\">";
662 if( $which == 'footer' ) {
663 $s .= wfMessage( 'qbfind' )->text() . ": ";
666 $s .= "<input type='text' class=\"mw-searchInput\" name=\"search\" size=\"14\" value=\""
667 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />"
668 . ($which == 'footer' ?
" " : "<br />")
669 . "<input type='submit' class=\"searchButton\" name=\"go\" value=\"" . wfMessage( 'searcharticle' )->escaped() . "\" />";
671 if( $wgUseTwoButtonsSearchForm ) {
672 $s .= " <input type='submit' class=\"searchButton\" name=\"fulltext\" value=\"" . wfMessage( 'searchbutton' )->escaped() . "\" />\n";
674 $s .= '<div><a href="' . $action . '" rel="search">' . wfMessage( 'powersearch-legend' )->escaped() . "</a></div>\n";