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>";
69 * Language/charset variant links for classic-style skins
74 function variantLinks() {
77 $variants = $this->data
['content_navigation']['variants'];
79 foreach ( $variants as $key => $link ) {
80 $s[] = $this->makeListItem( $key, $link, array( 'tag' => 'span' ) );
83 return $this->getSkin()->getLanguage()->pipeList( $s );
87 function otherLanguages() {
88 global $wgHideInterlanguageLinks;
89 if ( $wgHideInterlanguageLinks ) {
93 // We override SkinTemplate->formatLanguageName() in SkinCologneBlue
94 // not to capitalize the language names.
95 $language_urls = $this->data
['language_urls'];
96 if ( empty( $language_urls ) ) {
101 foreach ( $language_urls as $key => $data ) {
102 $s[] = $this->makeListItem( $key, $data, array( 'tag' => 'span' ) );
105 return wfMessage( 'otherlanguages' )->text()
106 . wfMessage( 'colon-separator' )->text()
107 . $this->getSkin()->getLanguage()->pipeList( $s );
111 function pageTitleLinks() {
113 $footlinks = $this->getFooterLinks();
115 foreach ( $footlinks['places'] as $item ) {
116 $s[] = $this->data
[$item];
119 return $this->getSkin()->getLanguage()->pipeList( $s );
122 function bottomLinks() {
123 $sep = wfMessage( 'pipe-separator' )->escaped() . "\n";
126 if ( $this->getSkin()->getOutput()->isArticleRelated() ) {
127 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
129 if ( $this->getSkin()->getUser()->isLoggedIn() ) {
130 $element[] = $this->watchThisPage();
133 $element[] = $this->talkLink();
134 $element[] = $this->historyLink();
135 $element[] = $this->whatLinksHere();
136 $element[] = $this->watchPageLinksLink();
138 $title = $this->getSkin()->getTitle();
141 $title->getNamespace() == NS_USER ||
142 $title->getNamespace() == NS_USER_TALK
144 $id = User
::idFromName( $title->getText() );
145 $ip = User
::isIP( $title->getText() );
147 # Both anons and non-anons have contributions list
149 $element[] = $this->userContribsLink();
152 if ( $this->getSkin()->showEmailUser( $id ) ) {
153 $element[] = $this->emailUserLink();
157 $s = implode( $element, $sep );
159 if ( $title->getArticleID() ) {
162 // Delete/protect/move links for privileged users
163 if ( $this->getSkin()->getUser()->isAllowed( 'delete' ) ) {
164 $s .= $this->deleteThisPage();
167 if ( $this->getSkin()->getUser()->isAllowed( 'protect' ) ) {
168 $s .= $sep . $this->protectThisPage();
171 if ( $this->getSkin()->getUser()->isAllowed( 'move' ) ) {
172 $s .= $sep . $this->moveThisPage();
176 $s .= "<br />\n" . $this->otherLanguages();
182 function editThisPage() {
183 if ( !$this->getSkin()->getOutput()->isArticleRelated() ) {
184 $s = wfMessage( 'protectedpage' )->text();
186 $title = $this->getSkin()->getTitle();
187 if ( $title->quickUserCan( 'edit' ) && $title->exists() ) {
188 $t = wfMessage( 'editthispage' )->text();
189 } elseif ( $title->quickUserCan( 'create' ) && !$title->exists() ) {
190 $t = wfMessage( 'create-this-page' )->text();
192 $t = wfMessage( 'viewsource' )->text();
195 $s = Linker
::linkKnown(
199 $this->getSkin()->editUrlOptions()
206 function deleteThisPage() {
207 $diff = $this->getSkin()->getRequest()->getVal( 'diff' );
208 $title = $this->getSkin()->getTitle();
210 if ( $title->getArticleID() && ( !$diff ) && $this->getSkin()->getUser()->isAllowed( 'delete' ) ) {
211 $t = wfMessage( 'deletethispage' )->text();
213 $s = Linker
::linkKnown(
217 array( 'action' => 'delete' )
226 function protectThisPage() {
227 $diff = $this->getSkin()->getRequest()->getVal( 'diff' );
228 $title = $this->getSkin()->getTitle();
230 if ( $title->getArticleID() && ( ! $diff ) && $this->getSkin()->getUser()->isAllowed( 'protect' ) ) {
231 if ( $title->isProtected() ) {
232 $text = wfMessage( 'unprotectthispage' )->text();
233 $query = array( 'action' => 'unprotect' );
235 $text = wfMessage( 'protectthispage' )->text();
236 $query = array( 'action' => 'protect' );
239 $s = Linker
::linkKnown(
252 function watchThisPage() {
254 $title = $this->getSkin()->getTitle();
256 if ( $this->getSkin()->getOutput()->isArticleRelated() ) {
257 if ( $this->getSkin()->getUser()->isWatched( $title ) ) {
258 $text = wfMessage( 'unwatchthispage' )->text();
260 'action' => 'unwatch',
261 'token' => UnwatchAction
::getUnwatchToken( $title, $this->getSkin()->getUser() ),
263 $id = 'mw-unwatch-link';
265 $text = wfMessage( 'watchthispage' )->text();
268 'token' => WatchAction
::getWatchToken( $title, $this->getSkin()->getUser() ),
270 $id = 'mw-watch-link';
273 $s = Linker
::linkKnown(
276 array( 'id' => $id ),
280 $s = wfMessage( 'notanarticle' )->text();
286 function moveThisPage() {
287 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
288 return Linker
::linkKnown(
289 SpecialPage
::getTitleFor( 'Movepage' ),
290 wfMessage( 'movethispage' )->text(),
292 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() )
295 // no message if page is protected - would be redundant
300 function historyLink() {
302 $this->getSkin()->getTitle(),
303 wfMessage( 'history' )->escaped(),
304 array( 'rel' => 'archives' ),
305 array( 'action' => 'history' )
309 function whatLinksHere() {
310 return Linker
::linkKnown(
311 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
312 wfMessage( 'whatlinkshere' )->escaped()
316 function userContribsLink() {
317 return Linker
::linkKnown(
318 SpecialPage
::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
319 wfMessage( 'contributions' )->escaped()
323 function emailUserLink() {
324 return Linker
::linkKnown(
325 SpecialPage
::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
326 wfMessage( 'emailuser' )->escaped()
330 function watchPageLinksLink() {
331 if ( !$this->getSkin()->getOutput()->isArticleRelated() ) {
332 return wfMessage( 'parentheses', wfMessage( 'notanarticle' )->text() )->escaped();
334 return Linker
::linkKnown(
335 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
336 wfMessage( 'recentchangeslinked-toolbox' )->escaped()
341 function talkLink() {
342 $title = $this->getSkin()->getTitle();
343 if ( NS_SPECIAL
== $title->getNamespace() ) {
344 # No discussion links for special pages
348 $linkOptions = array();
350 if ( $title->isTalkPage() ) {
351 $link = $title->getSubjectPage();
352 switch( $link->getNamespace() ) {
354 $text = wfMessage( 'articlepage' );
357 $text = wfMessage( 'userpage' );
360 $text = wfMessage( 'projectpage' );
363 $text = wfMessage( 'imagepage' );
364 # Make link known if image exists, even if the desc. page doesn't.
365 if ( wfFindFile( $link ) )
366 $linkOptions[] = 'known';
369 $text = wfMessage( 'mediawikipage' );
372 $text = wfMessage( 'templatepage' );
375 $text = wfMessage( 'viewhelppage' );
378 $text = wfMessage( 'categorypage' );
381 $text = wfMessage( 'articlepage' );
384 $link = $title->getTalkPage();
385 $text = wfMessage( 'talkpage' );
388 $s = Linker
::link( $link, $text->text(), array(), array(), $linkOptions );
398 function beforeContent() {
404 <a href
="<?php echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] ) ?>">
405 <?php
echo wfMessage( 'sitetitle' )->escaped() ?
>
408 <p id
="sitesub"><?php
echo wfMessage( 'sitesubtitle' )->escaped() ?
></p
>
410 <p id
="syslinks"><?php
echo $this->sysLinks() ?
></p
>
411 <p id
="variantlinks"><?php
echo $this->variantLinks() ?
></p
>
413 <div id
="linkcollection">
414 <div id
="langlinks"><?php
echo str_replace( '<br />', '', $this->otherLanguages() ) ?
></div
>
415 <?php
echo $this->getSkin()->getCategories() ?
>
416 <div id
="titlelinks"><?php
echo $this->pageTitleLinks() ?
></div
>
417 <?php
if ( $this->data
['newtalk'] ) { ?
>
418 <div
class="usermessage"><strong
><?php
echo $this->data
['newtalk'] ?
></strong
></div
>
423 <?php
if ( $this->getSkin()->getSiteNotice() ) { ?
>
424 <div id
="siteNotice"><?php
echo $this->getSkin()->getSiteNotice() ?
></div
>
426 <h1 id
="firstHeading"><span dir
="auto"><?php
echo $this->data
['title'] ?
></span
></h1
>
427 <?php
if ( $this->translator
->translate( 'tagline' ) ) { ?
>
428 <p
class="tagline"><?php
echo htmlspecialchars( $this->translator
->translate( 'tagline' ) ) ?
></p
>
430 <?php
if ( $this->getSkin()->getOutput()->getSubtitle() ) { ?
>
431 <p
class="subtitle"><?php
echo $this->getSkin()->getOutput()->getSubtitle() ?
></p
>
433 <?php
if ( $this->getSkin()->subPageSubtitle() ) { ?
>
434 <p
class="subpages"><?php
echo $this->getSkin()->subPageSubtitle() ?
></p
>
437 $s = ob_get_contents();
448 function afterContent() {
454 // Page-related links
455 echo $this->bottomLinks();
458 // Footer and second searchbox
459 echo $this->getSkin()->getLanguage()->pipeList( array(
460 $this->getSkin()->mainPageLink(),
461 $this->getSkin()->aboutLink(),
462 $this->searchForm( 'footer' )
466 // Standard footer info
467 $footlinks = $this->getFooterLinks();
468 if ( $footlinks['info'] ) {
469 foreach ( $footlinks['info'] as $item ) {
470 echo $this->data
[$item] . ' ';
476 <?php
echo $this->quickBar() ?
>
478 $s = ob_get_contents();
489 function sysLinks() {
491 $this->getSkin()->mainPageLink(),
493 Title
::newFromText( wfMessage( 'aboutpage' )->inContentLanguage()->text() ),
494 wfMessage( 'about' )->text()
497 Title
::newFromText( wfMessage( 'helppage' )->inContentLanguage()->text() ),
498 wfMessage( 'help' )->text()
501 Title
::newFromText( wfMessage( 'faqpage' )->inContentLanguage()->text() ),
502 wfMessage( 'faq' )->text()
506 $personalUrls = $this->getPersonalTools();
507 foreach ( array ( 'logout', 'createaccount', 'login', 'anonlogin' ) as $key ) {
508 if ( $personalUrls[$key] ) {
509 $s[] = $this->makeListItem( $key, $personalUrls[$key], array( 'tag' => 'span' ) );
513 return $this->getSkin()->getLanguage()->pipeList( $s );
517 * @param $heading string
522 function menuHead( $heading ) {
523 return "\n<h6>" . htmlspecialchars( $heading ) . "</h6>";
527 * Compute the sidebar
535 $s = "\n<div id='quickbar'>";
539 $plain_bar = $this->data
['sidebar'];
542 // Massage the sidebar
543 // We want to place SEARCH at the beginning and a lot of stuff before TOOLBOX (or at the end, if it's missing)
544 $additions_done = false;
545 while ( !$additions_done ) {
546 $bar = array(); // Empty it out
548 // Always display search on top
549 $bar['SEARCH'] = true;
551 foreach ( $plain_bar as $heading => $links ) {
552 if ( $heading == 'TOOLBOX' ) {
553 if( $links !== NULL ) {
554 // If this is not a toolbox prosthetic we inserted outselves, fill it out
555 $plain_bar['TOOLBOX'] = $this->getToolbox();
558 // And insert the stuff
560 // "This page" and "Edit" menus
561 // We need to do some massaging here... we reuse all of the items, except for $...['views']['view'],
562 // as $...['namespaces']['main'] and $...['namespaces']['talk'] together serve the same purpose.
563 // We also don't use $...['variants'], these are displayed in the top menu.
564 $content_navigation = $this->data
['content_navigation'];
565 $qbpageoptions = array_merge(
566 $content_navigation['namespaces'],
568 'history' => $content_navigation['views']['history'],
569 'watch' => $content_navigation['actions']['watch'],
570 'unwatch' => $content_navigation['actions']['unwatch'],
573 $content_navigation['actions']['watch'] = null;
574 $content_navigation['actions']['unwatch'] = null;
575 $qbedit = array_merge(
577 'edit' => $content_navigation['views']['edit'],
578 'addsection' => $content_navigation['views']['addsection'],
580 $content_navigation['actions']
582 $bar['qbedit'] = $qbedit;
583 $bar['qbpageoptions'] = $qbpageoptions;
585 // Personal tools ("My pages")
586 $bar['qbmyoptions'] = $this->getPersonalTools();
587 foreach ( array ( 'logout', 'createaccount', 'login', 'anonlogin' ) as $key ) {
588 $bar['qbmyoptions'][$key] = false;
591 $additions_done = true;
594 // Re-insert current heading, unless it's SEARCH
595 if ( $heading != 'SEARCH' ) {
596 $bar[$heading] = $plain_bar[$heading];
600 // If TOOLBOX is missing, $additions_done is still false
601 if ( !$additions_done ) {
602 $plain_bar['TOOLBOX'] = false;
606 foreach ( $bar as $heading => $links ) {
607 if ( $heading == 'SEARCH' ) {
608 $s .= $this->menuHead( wfMessage( 'qbfind' )->text() );
609 $s .= $this->searchForm( 'sidebar' );
610 } elseif ( $heading == 'LANGUAGES' ) {
611 // discard these; we display languages below page content
614 // Use the navigation heading from standard sidebar as the "browse" section
615 if ( $heading == 'navigation' ) {
616 $heading = 'qbbrowse';
618 if ( $heading == 'TOOLBOX' ) {
619 $heading = 'toolbox';
622 $headingMsg = wfMessage( $heading );
624 $t = $this->menuHead( $headingMsg->exists() ?
$headingMsg->text() : $heading );
626 foreach ( $links as $key => $link ) {
627 // Can be empty due to rampant sidebar massaging we're doing above
630 $t .= $this->makeListItem( $key, $link, array( 'tag' => 'span' ) ) . $sep;
641 $s .= $sep . "\n</div>\n";
646 * @param $label string
651 function searchForm( $which ) {
652 global $wgUseTwoButtonsSearchForm;
654 $search = $this->getSkin()->getRequest()->getText( 'search' );
655 $action = $this->data
['searchaction'];
656 $s = "<form id=\"searchform-" . htmlspecialchars($which) . "\" method=\"get\" class=\"inline\" action=\"$action\">";
657 if( $which == 'footer' ) {
658 $s .= wfMessage( 'qbfind' )->text() . ": ";
661 $s .= "<input type='text' class=\"mw-searchInput\" name=\"search\" size=\"14\" value=\""
662 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />"
663 . ($which == 'footer' ?
" " : "<br />")
664 . "<input type='submit' class=\"searchButton\" name=\"go\" value=\"" . wfMessage( 'searcharticle' )->escaped() . "\" />";
666 if( $wgUseTwoButtonsSearchForm ) {
667 $s .= " <input type='submit' class=\"searchButton\" name=\"fulltext\" value=\"" . wfMessage( 'searchbutton' )->escaped() . "\" />\n";
669 $s .= '<div><a href="' . $action . '" rel="search">' . wfMessage( 'powersearch-legend' )->escaped() . "</a></div>\n";