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 // Suppress warnings to prevent notices about missing indexes in $this->data
60 $this->html( 'headelement' );
61 echo $this->beforeContent();
62 $this->html( 'bodytext' );
64 echo $this->afterContent();
65 $this->html( 'dataAfterContent' );
67 echo "\n</body></html>";
73 * Language/charset variant links for classic-style skins
78 function variantLinks() {
81 $variants = $this->data
['content_navigation']['variants'];
83 foreach ( $variants as $key => $link ) {
84 $s[] = $this->makeListItem( $key, $link, array( 'tag' => 'span' ) );
87 return $this->getSkin()->getLanguage()->pipeList( $s );
91 function otherLanguages() {
92 global $wgHideInterlanguageLinks;
93 if ( $wgHideInterlanguageLinks ) {
97 // We override SkinTemplate->formatLanguageName() in SkinCologneBlue
98 // not to capitalize the language names.
99 $language_urls = $this->data
['language_urls'];
100 if ( empty( $language_urls ) ) {
105 foreach ( $language_urls as $key => $data ) {
106 $s[] = $this->makeListItem( $key, $data, array( 'tag' => 'span' ) );
109 return wfMessage( 'otherlanguages' )->text()
110 . wfMessage( 'colon-separator' )->text()
111 . $this->getSkin()->getLanguage()->pipeList( $s );
115 function pageTitleLinks() {
117 $footlinks = $this->getFooterLinks();
119 foreach ( $footlinks['places'] as $item ) {
120 $s[] = $this->data
[$item];
123 return $this->getSkin()->getLanguage()->pipeList( $s );
126 function bottomLinks() {
127 $sep = wfMessage( 'pipe-separator' )->escaped() . "\n";
130 if ( $this->getSkin()->getOutput()->isArticleRelated() ) {
131 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
133 if ( $this->getSkin()->getUser()->isLoggedIn() ) {
134 $element[] = $this->watchThisPage();
137 $element[] = $this->talkLink();
138 $element[] = $this->historyLink();
139 $element[] = $this->whatLinksHere();
140 $element[] = $this->watchPageLinksLink();
142 $title = $this->getSkin()->getTitle();
145 $title->getNamespace() == NS_USER ||
146 $title->getNamespace() == NS_USER_TALK
148 $id = User
::idFromName( $title->getText() );
149 $ip = User
::isIP( $title->getText() );
151 # Both anons and non-anons have contributions list
153 $element[] = $this->userContribsLink();
156 if ( $this->getSkin()->showEmailUser( $id ) ) {
157 $element[] = $this->emailUserLink();
161 $s = implode( $element, $sep );
163 if ( $title->getArticleID() ) {
166 // Delete/protect/move links for privileged users
167 if ( $this->getSkin()->getUser()->isAllowed( 'delete' ) ) {
168 $s .= $this->deleteThisPage();
171 if ( $this->getSkin()->getUser()->isAllowed( 'protect' ) ) {
172 $s .= $sep . $this->protectThisPage();
175 if ( $this->getSkin()->getUser()->isAllowed( 'move' ) ) {
176 $s .= $sep . $this->moveThisPage();
180 $s .= "<br />\n" . $this->otherLanguages();
186 function editThisPage() {
187 if ( !$this->getSkin()->getOutput()->isArticleRelated() ) {
188 $s = wfMessage( 'protectedpage' )->text();
190 $title = $this->getSkin()->getTitle();
191 if ( $title->quickUserCan( 'edit' ) && $title->exists() ) {
192 $t = wfMessage( 'editthispage' )->text();
193 } elseif ( $title->quickUserCan( 'create' ) && !$title->exists() ) {
194 $t = wfMessage( 'create-this-page' )->text();
196 $t = wfMessage( 'viewsource' )->text();
199 $s = Linker
::linkKnown(
203 $this->getSkin()->editUrlOptions()
210 function deleteThisPage() {
211 $diff = $this->getSkin()->getRequest()->getVal( 'diff' );
212 $title = $this->getSkin()->getTitle();
214 if ( $title->getArticleID() && ( !$diff ) && $this->getSkin()->getUser()->isAllowed( 'delete' ) ) {
215 $t = wfMessage( 'deletethispage' )->text();
217 $s = Linker
::linkKnown(
221 array( 'action' => 'delete' )
230 function protectThisPage() {
231 $diff = $this->getSkin()->getRequest()->getVal( 'diff' );
232 $title = $this->getSkin()->getTitle();
234 if ( $title->getArticleID() && ( ! $diff ) && $this->getSkin()->getUser()->isAllowed( 'protect' ) ) {
235 if ( $title->isProtected() ) {
236 $text = wfMessage( 'unprotectthispage' )->text();
237 $query = array( 'action' => 'unprotect' );
239 $text = wfMessage( 'protectthispage' )->text();
240 $query = array( 'action' => 'protect' );
243 $s = Linker
::linkKnown(
256 function watchThisPage() {
258 $title = $this->getSkin()->getTitle();
260 if ( $this->getSkin()->getOutput()->isArticleRelated() ) {
261 if ( $this->getSkin()->getUser()->isWatched( $title ) ) {
262 $text = wfMessage( 'unwatchthispage' )->text();
264 'action' => 'unwatch',
265 'token' => UnwatchAction
::getUnwatchToken( $title, $this->getSkin()->getUser() ),
267 $id = 'mw-unwatch-link';
269 $text = wfMessage( 'watchthispage' )->text();
272 'token' => WatchAction
::getWatchToken( $title, $this->getSkin()->getUser() ),
274 $id = 'mw-watch-link';
277 $s = Linker
::linkKnown(
280 array( 'id' => $id ),
284 $s = wfMessage( 'notanarticle' )->text();
290 function moveThisPage() {
291 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
292 return Linker
::linkKnown(
293 SpecialPage
::getTitleFor( 'Movepage' ),
294 wfMessage( 'movethispage' )->text(),
296 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() )
299 // no message if page is protected - would be redundant
304 function historyLink() {
306 $this->getSkin()->getTitle(),
307 wfMessage( 'history' )->escaped(),
308 array( 'rel' => 'archives' ),
309 array( 'action' => 'history' )
313 function whatLinksHere() {
314 return Linker
::linkKnown(
315 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
316 wfMessage( 'whatlinkshere' )->escaped()
320 function userContribsLink() {
321 return Linker
::linkKnown(
322 SpecialPage
::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
323 wfMessage( 'contributions' )->escaped()
327 function emailUserLink() {
328 return Linker
::linkKnown(
329 SpecialPage
::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
330 wfMessage( 'emailuser' )->escaped()
334 function watchPageLinksLink() {
335 if ( !$this->getSkin()->getOutput()->isArticleRelated() ) {
336 return wfMessage( 'parentheses', wfMessage( 'notanarticle' )->text() )->escaped();
338 return Linker
::linkKnown(
339 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
340 wfMessage( 'recentchangeslinked-toolbox' )->escaped()
345 function talkLink() {
346 $title = $this->getSkin()->getTitle();
347 if ( NS_SPECIAL
== $title->getNamespace() ) {
348 # No discussion links for special pages
352 $linkOptions = array();
354 if ( $title->isTalkPage() ) {
355 $link = $title->getSubjectPage();
356 switch( $link->getNamespace() ) {
358 $text = wfMessage( 'articlepage' );
361 $text = wfMessage( 'userpage' );
364 $text = wfMessage( 'projectpage' );
367 $text = wfMessage( 'imagepage' );
368 # Make link known if image exists, even if the desc. page doesn't.
369 if ( wfFindFile( $link ) )
370 $linkOptions[] = 'known';
373 $text = wfMessage( 'mediawikipage' );
376 $text = wfMessage( 'templatepage' );
379 $text = wfMessage( 'viewhelppage' );
382 $text = wfMessage( 'categorypage' );
385 $text = wfMessage( 'articlepage' );
388 $link = $title->getTalkPage();
389 $text = wfMessage( 'talkpage' );
392 $s = Linker
::link( $link, $text->text(), array(), array(), $linkOptions );
402 function beforeContent() {
408 <a href
="<?php echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] ) ?>">
409 <?php
echo wfMessage( 'sitetitle' )->escaped() ?
>
412 <p id
="sitesub"><?php
echo wfMessage( 'sitesubtitle' )->escaped() ?
></p
>
415 <p id
="syslinks"><?php
echo $this->sysLinks() ?
></p
>
416 <p id
="variantlinks"><?php
echo $this->variantLinks() ?
></p
>
418 <div id
="linkcollection">
419 <div id
="langlinks"><?php
echo str_replace( '<br />', '', $this->otherLanguages() ) ?
></div
>
420 <?php
echo $this->getSkin()->getCategories() ?
>
421 <div id
="titlelinks"><?php
echo $this->pageTitleLinks() ?
></div
>
422 <?php
if ( $this->data
['newtalk'] ) { ?
>
423 <div
class="usermessage"><strong
><?php
echo $this->data
['newtalk'] ?
></strong
></div
>
428 <?php
if ( $this->getSkin()->getSiteNotice() ) { ?
>
429 <div id
="siteNotice"><?php
echo $this->getSkin()->getSiteNotice() ?
></div
>
431 <h1 id
="firstHeading"><span dir
="auto"><?php
echo $this->data
['title'] ?
></span
></h1
>
432 <?php
if ( $this->translator
->translate( 'tagline' ) ) { ?
>
433 <p
class="tagline"><?php
echo htmlspecialchars( $this->translator
->translate( 'tagline' ) ) ?
></p
>
435 <?php
if ( $this->getSkin()->getOutput()->getSubtitle() ) { ?
>
436 <p
class="subtitle"><?php
echo $this->getSkin()->getOutput()->getSubtitle() ?
></p
>
438 <?php
if ( $this->getSkin()->subPageSubtitle() ) { ?
>
439 <p
class="subpages"><?php
echo $this->getSkin()->subPageSubtitle() ?
></p
>
442 $s = ob_get_contents();
453 function afterContent() {
459 // Page-related links
460 echo $this->bottomLinks();
463 // Footer and second searchbox
464 echo $this->getSkin()->getLanguage()->pipeList( array(
465 $this->getSkin()->mainPageLink(),
466 $this->getSkin()->aboutLink(),
467 $this->searchForm( 'footer' )
471 // Standard footer info
472 $footlinks = $this->getFooterLinks();
473 if ( $footlinks['info'] ) {
474 foreach ( $footlinks['info'] as $item ) {
475 echo $this->data
[$item] . ' ';
481 <?php
echo $this->quickBar() ?
>
483 $s = ob_get_contents();
494 function sysLinks() {
496 $this->getSkin()->mainPageLink(),
498 Title
::newFromText( wfMessage( 'aboutpage' )->inContentLanguage()->text() ),
499 wfMessage( 'about' )->text()
502 Title
::newFromText( wfMessage( 'helppage' )->inContentLanguage()->text() ),
503 wfMessage( 'help' )->text()
506 Title
::newFromText( wfMessage( 'faqpage' )->inContentLanguage()->text() ),
507 wfMessage( 'faq' )->text()
511 $personalUrls = $this->getPersonalTools();
512 foreach ( array ( 'logout', 'createaccount', 'login', 'anonlogin' ) as $key ) {
513 if ( $personalUrls[$key] ) {
514 $s[] = $this->makeListItem( $key, $personalUrls[$key], array( 'tag' => 'span' ) );
518 return $this->getSkin()->getLanguage()->pipeList( $s );
525 * @param $heading string
530 function menuHead( $heading ) {
531 return "\n<h6>" . htmlspecialchars( $heading ) . "</h6>";
535 * Compute the sidebar
543 $s = "\n<div id='quickbar'>";
547 $plain_bar = $this->data
['sidebar'];
550 // Massage the sidebar
551 // We want to place SEARCH at the beginning and a lot of stuff before TOOLBOX (or at the end, if it's missing)
552 $additions_done = false;
553 while ( !$additions_done ) {
554 $bar = array(); // Empty it out
556 // Always display search on top
557 $bar['SEARCH'] = true;
559 foreach ( $plain_bar as $heading => $links ) {
560 if ( $heading == 'TOOLBOX' ) {
561 if( $links !== NULL ) {
562 // If this is not a toolbox prosthetic we inserted outselves, fill it out
563 $plain_bar['TOOLBOX'] = $this->getToolbox();
566 // And insert the stuff
568 // "This page" and "Edit" menus
569 // We need to do some massaging here... we reuse all of the items, except for $...['views']['view'],
570 // as $...['namespaces']['main'] and $...['namespaces']['talk'] together serve the same purpose.
571 // We also don't use $...['variants'], these are displayed in the top menu.
572 $content_navigation = $this->data
['content_navigation'];
573 $qbpageoptions = array_merge(
574 $content_navigation['namespaces'],
576 'history' => $content_navigation['views']['history'],
577 'watch' => $content_navigation['actions']['watch'],
578 'unwatch' => $content_navigation['actions']['unwatch'],
581 $content_navigation['actions']['watch'] = null;
582 $content_navigation['actions']['unwatch'] = null;
583 $qbedit = array_merge(
585 'edit' => $content_navigation['views']['edit'],
586 'addsection' => $content_navigation['views']['addsection'],
588 $content_navigation['actions']
590 $bar['qbedit'] = $qbedit;
591 $bar['qbpageoptions'] = $qbpageoptions;
593 // Personal tools ("My pages")
594 $bar['qbmyoptions'] = $this->getPersonalTools();
595 foreach ( array ( 'logout', 'createaccount', 'login', 'anonlogin' ) as $key ) {
596 $bar['qbmyoptions'][$key] = false;
599 $additions_done = true;
602 // Re-insert current heading, unless it's SEARCH
603 if ( $heading != 'SEARCH' ) {
604 $bar[$heading] = $plain_bar[$heading];
608 // If TOOLBOX is missing, $additions_done is still false
609 if ( !$additions_done ) {
610 $plain_bar['TOOLBOX'] = false;
614 foreach ( $bar as $heading => $links ) {
615 if ( $heading == 'SEARCH' ) {
616 $s .= $this->menuHead( wfMessage( 'qbfind' )->text() );
617 $s .= $this->searchForm( 'sidebar' );
618 } elseif ( $heading == 'LANGUAGES' ) {
619 // discard these; we display languages below page content
622 // Use the navigation heading from standard sidebar as the "browse" section
623 if ( $heading == 'navigation' ) {
624 $heading = 'qbbrowse';
626 if ( $heading == 'TOOLBOX' ) {
627 $heading = 'toolbox';
630 $headingMsg = wfMessage( $heading );
632 $t = $this->menuHead( $headingMsg->exists() ?
$headingMsg->text() : $heading );
634 foreach ( $links as $key => $link ) {
635 // Can be empty due to rampant sidebar massaging we're doing above
638 $t .= $this->makeListItem( $key, $link, array( 'tag' => 'span' ) ) . $sep;
649 $s .= $sep . "\n</div>\n";
654 * @param $label string
659 function searchForm( $which ) {
660 global $wgUseTwoButtonsSearchForm;
662 $search = $this->getSkin()->getRequest()->getText( 'search' );
663 $action = $this->data
['searchaction'];
664 $s = "<form id=\"searchform-" . htmlspecialchars($which) . "\" method=\"get\" class=\"inline\" action=\"$action\">";
665 if( $which == 'footer' ) {
666 $s .= wfMessage( 'qbfind' )->text() . ": ";
669 $s .= "<input type='text' class=\"mw-searchInput\" name=\"search\" size=\"14\" value=\""
670 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />"
671 . ($which == 'footer' ?
" " : "<br />")
672 . "<input type='submit' class=\"searchButton\" name=\"go\" value=\"" . wfMessage( 'searcharticle' )->escaped() . "\" />";
674 if( $wgUseTwoButtonsSearchForm ) {
675 $s .= " <input type='submit' class=\"searchButton\" name=\"fulltext\" value=\"" . wfMessage( 'search' )->escaped() . "\" />\n";
677 $s .= '<div><a href="' . $action . '" rel="search">' . wfMessage( 'powersearch-legend' )->escaped() . "</a></div>\n";