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
68 function variantLinks() {
71 $variants = $this->data
['content_navigation']['variants'];
73 foreach ( $variants as $key => $link ) {
74 $s[] = $this->makeListItem( $key, $link, array( 'tag' => 'span' ) );
77 return $this->getSkin()->getLanguage()->pipeList( $s );
80 function otherLanguages() {
81 global $wgHideInterlanguageLinks;
83 if ( $wgHideInterlanguageLinks ) {
87 $a = $this->getSkin()->getOutput()->getLanguageLinks();
89 if ( 0 == count( $a ) ) {
93 $s = wfMessage( 'otherlanguages' )->text() . wfMessage( 'colon-separator' )->text();
96 if ( $this->getSkin()->getLanguage()->isRTL() ) {
97 $s .= '<span dir="ltr">';
100 foreach ( $a as $l ) {
102 $s .= wfMessage( 'pipe-separator' )->escaped();
107 $nt = Title
::newFromText( $l );
108 $text = Language
::fetchLanguageName( $nt->getInterwiki() );
110 $s .= Html
::element( 'a',
111 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
112 $text == '' ?
$l : $text );
115 if ( $this->getSkin()->getLanguage()->isRTL() ) {
123 function pageTitleLinks() {
125 $footlinks = $this->getFooterLinks();
127 foreach ( $footlinks['places'] as $item ) {
128 $s[] = $this->data
[$item];
131 return $this->getSkin()->getLanguage()->pipeList( $s );
134 function bottomLinks() {
135 $sep = wfMessage( 'pipe-separator' )->escaped() . "\n";
138 if ( $this->getSkin()->getOutput()->isArticleRelated() ) {
139 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
141 if ( $this->getSkin()->getUser()->isLoggedIn() ) {
142 $element[] = $this->watchThisPage();
145 $element[] = $this->talkLink();
146 $element[] = $this->historyLink();
147 $element[] = $this->whatLinksHere();
148 $element[] = $this->watchPageLinksLink();
150 $title = $this->getSkin()->getTitle();
153 $title->getNamespace() == NS_USER ||
154 $title->getNamespace() == NS_USER_TALK
156 $id = User
::idFromName( $title->getText() );
157 $ip = User
::isIP( $title->getText() );
159 # Both anons and non-anons have contributions list
161 $element[] = $this->userContribsLink();
164 if ( $this->getSkin()->showEmailUser( $id ) ) {
165 $element[] = $this->emailUserLink();
169 $s = implode( $element, $sep );
171 if ( $title->getArticleID() ) {
174 // Delete/protect/move links for privileged users
175 if ( $this->getSkin()->getUser()->isAllowed( 'delete' ) ) {
176 $s .= $this->deleteThisPage();
179 if ( $this->getSkin()->getUser()->isAllowed( 'protect' ) ) {
180 $s .= $sep . $this->protectThisPage();
183 if ( $this->getSkin()->getUser()->isAllowed( 'move' ) ) {
184 $s .= $sep . $this->moveThisPage();
188 $s .= "<br />\n" . $this->otherLanguages();
194 function editThisPage() {
195 if ( !$this->getSkin()->getOutput()->isArticleRelated() ) {
196 $s = wfMessage( 'protectedpage' )->text();
198 $title = $this->getSkin()->getTitle();
199 if ( $title->quickUserCan( 'edit' ) && $title->exists() ) {
200 $t = wfMessage( 'editthispage' )->text();
201 } elseif ( $title->quickUserCan( 'create' ) && !$title->exists() ) {
202 $t = wfMessage( 'create-this-page' )->text();
204 $t = wfMessage( 'viewsource' )->text();
207 $s = Linker
::linkKnown(
211 $this->getSkin()->editUrlOptions()
218 function deleteThisPage() {
219 $diff = $this->getSkin()->getRequest()->getVal( 'diff' );
220 $title = $this->getSkin()->getTitle();
222 if ( $title->getArticleID() && ( !$diff ) && $this->getSkin()->getUser()->isAllowed( 'delete' ) ) {
223 $t = wfMessage( 'deletethispage' )->text();
225 $s = Linker
::linkKnown(
229 array( 'action' => 'delete' )
238 function protectThisPage() {
239 $diff = $this->getSkin()->getRequest()->getVal( 'diff' );
240 $title = $this->getSkin()->getTitle();
242 if ( $title->getArticleID() && ( ! $diff ) && $this->getSkin()->getUser()->isAllowed( 'protect' ) ) {
243 if ( $title->isProtected() ) {
244 $text = wfMessage( 'unprotectthispage' )->text();
245 $query = array( 'action' => 'unprotect' );
247 $text = wfMessage( 'protectthispage' )->text();
248 $query = array( 'action' => 'protect' );
251 $s = Linker
::linkKnown(
264 function watchThisPage() {
266 $title = $this->getSkin()->getTitle();
268 if ( $this->getSkin()->getOutput()->isArticleRelated() ) {
269 if ( $this->getSkin()->getUser()->isWatched( $title ) ) {
270 $text = wfMessage( 'unwatchthispage' )->text();
272 'action' => 'unwatch',
273 'token' => UnwatchAction
::getUnwatchToken( $title, $this->getSkin()->getUser() ),
275 $id = 'mw-unwatch-link';
277 $text = wfMessage( 'watchthispage' )->text();
280 'token' => WatchAction
::getWatchToken( $title, $this->getSkin()->getUser() ),
282 $id = 'mw-watch-link';
285 $s = Linker
::linkKnown(
288 array( 'id' => $id ),
292 $s = wfMessage( 'notanarticle' )->text();
298 function moveThisPage() {
299 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
300 return Linker
::linkKnown(
301 SpecialPage
::getTitleFor( 'Movepage' ),
302 wfMessage( 'movethispage' )->text(),
304 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() )
307 // no message if page is protected - would be redundant
312 function historyLink() {
314 $this->getSkin()->getTitle(),
315 wfMessage( 'history' )->escaped(),
316 array( 'rel' => 'archives' ),
317 array( 'action' => 'history' )
321 function whatLinksHere() {
322 return Linker
::linkKnown(
323 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
324 wfMessage( 'whatlinkshere' )->escaped()
328 function userContribsLink() {
329 return Linker
::linkKnown(
330 SpecialPage
::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
331 wfMessage( 'contributions' )->escaped()
335 function emailUserLink() {
336 return Linker
::linkKnown(
337 SpecialPage
::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
338 wfMessage( 'emailuser' )->escaped()
342 function watchPageLinksLink() {
343 if ( !$this->getSkin()->getOutput()->isArticleRelated() ) {
344 return wfMessage( 'parentheses', wfMessage( 'notanarticle' )->text() )->escaped();
346 return Linker
::linkKnown(
347 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
348 wfMessage( 'recentchangeslinked-toolbox' )->escaped()
353 function talkLink() {
354 $title = $this->getSkin()->getTitle();
355 if ( NS_SPECIAL
== $title->getNamespace() ) {
356 # No discussion links for special pages
360 $linkOptions = array();
362 if ( $title->isTalkPage() ) {
363 $link = $title->getSubjectPage();
364 switch( $link->getNamespace() ) {
366 $text = wfMessage( 'articlepage' );
369 $text = wfMessage( 'userpage' );
372 $text = wfMessage( 'projectpage' );
375 $text = wfMessage( 'imagepage' );
376 # Make link known if image exists, even if the desc. page doesn't.
377 if ( wfFindFile( $link ) )
378 $linkOptions[] = 'known';
381 $text = wfMessage( 'mediawikipage' );
384 $text = wfMessage( 'templatepage' );
387 $text = wfMessage( 'viewhelppage' );
390 $text = wfMessage( 'categorypage' );
393 $text = wfMessage( 'articlepage' );
396 $link = $title->getTalkPage();
397 $text = wfMessage( 'talkpage' );
400 $s = Linker
::link( $link, $text->text(), array(), array(), $linkOptions );
410 function beforeContent() {
416 <a href
="<?php echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] ) ?>">
417 <?php
echo wfMessage( 'sitetitle' )->escaped() ?
>
420 <p id
="sitesub"><?php
echo wfMessage( 'sitesubtitle' )->escaped() ?
></p
>
423 <p id
="syslinks"><?php
echo $this->sysLinks() ?
></p
>
424 <p id
="variantlinks"><?php
echo $this->variantLinks() ?
></p
>
426 <div id
="linkcollection">
427 <div id
="langlinks"><?php
echo str_replace( '<br />', '', $this->otherLanguages() ) ?
></div
>
428 <?php
echo $this->getSkin()->getCategories() ?
>
429 <div id
="titlelinks"><?php
echo $this->pageTitleLinks() ?
></div
>
430 <?php
if ( $this->data
['newtalk'] ) { ?
>
431 <div
class="usermessage"><strong
><?php
echo $this->data
['newtalk'] ?
></strong
></div
>
436 <?php
if ( $this->getSkin()->getSiteNotice() ) { ?
>
437 <div id
="siteNotice"><?php
echo $this->getSkin()->getSiteNotice() ?
></div
>
439 <h1 id
="firstHeading"><span dir
="auto"><?php
echo $this->data
['title'] ?
></span
></h1
>
440 <?php
if ( $this->translator
->translate( 'tagline' ) ) { ?
>
441 <p
class="tagline"><?php
echo htmlspecialchars( $this->translator
->translate( 'tagline' ) ) ?
></p
>
443 <?php
if ( $this->getSkin()->getOutput()->getSubtitle() ) { ?
>
444 <p
class="subtitle"><?php
echo $this->getSkin()->getOutput()->getSubtitle() ?
></p
>
446 <?php
if ( $this->getSkin()->subPageSubtitle() ) { ?
>
447 <p
class="subpages"><?php
echo $this->getSkin()->subPageSubtitle() ?
></p
>
450 $s = ob_get_contents();
461 function afterContent() {
467 // Page-related links
468 echo $this->bottomLinks();
471 // Footer and second searchbox
472 echo $this->getSkin()->getLanguage()->pipeList( array(
473 $this->getSkin()->mainPageLink(),
474 $this->getSkin()->aboutLink(),
475 $this->searchForm( 'footer' )
479 // Standard footer info
480 $footlinks = $this->getFooterLinks();
481 if ( $footlinks['info'] ) {
482 foreach ( $footlinks['info'] as $item ) {
483 echo $this->data
[$item] . ' ';
489 <?php
echo $this->quickBar() ?
>
491 $s = ob_get_contents();
502 function sysLinks() {
504 $this->getSkin()->mainPageLink(),
506 Title
::newFromText( wfMessage( 'aboutpage' )->inContentLanguage()->text() ),
507 wfMessage( 'about' )->text()
510 Title
::newFromText( wfMessage( 'helppage' )->inContentLanguage()->text() ),
511 wfMessage( 'help' )->text()
514 Title
::newFromText( wfMessage( 'faqpage' )->inContentLanguage()->text() ),
515 wfMessage( 'faq' )->text()
519 $personalUrls = $this->getPersonalTools();
520 foreach ( array ( 'logout', 'createaccount', 'login', 'anonlogin' ) as $key ) {
521 if ( $personalUrls[$key] ) {
522 $s[] = $this->makeListItem( $key, $personalUrls[$key], array( 'tag' => 'span' ) );
526 return $this->getSkin()->getLanguage()->pipeList( $s );
533 * @param $heading string
538 function menuHead( $heading ) {
539 return "\n<h6>" . htmlspecialchars( $heading ) . "</h6>";
543 * Compute the sidebar
551 $s = "\n<div id='quickbar'>";
555 $plain_bar = $this->data
['sidebar'];
558 // Massage the sidebar
559 // We want to place SEARCH at the beginning and a lot of stuff before TOOLBOX (or at the end, if it's missing)
560 $additions_done = false;
561 while ( !$additions_done ) {
562 $bar = array(); // Empty it out
564 // Always display search on top
565 $bar['SEARCH'] = true;
567 foreach ( $plain_bar as $heading => $links ) {
568 if ( $heading == 'TOOLBOX' ) {
569 if( $links !== NULL ) {
570 // If this is not a toolbox prosthetic we inserted outselves, fill it out
571 $plain_bar['TOOLBOX'] = $this->getToolbox();
574 // And insert the stuff
576 // "This page" and "Edit" menus
577 // We need to do some massaging here... we reuse all of the items, except for $...['views']['view'],
578 // as $...['namespaces']['main'] and $...['namespaces']['talk'] together serve the same purpose.
579 // We also don't use $...['variants'], these are displayed in the top menu.
580 $content_navigation = $this->data
['content_navigation'];
581 $qbpageoptions = array_merge(
582 $content_navigation['namespaces'],
584 'history' => $content_navigation['views']['history'],
585 'watch' => $content_navigation['actions']['watch'],
586 'unwatch' => $content_navigation['actions']['unwatch'],
589 $content_navigation['actions']['watch'] = null;
590 $content_navigation['actions']['unwatch'] = null;
591 $qbedit = array_merge(
593 'edit' => $content_navigation['views']['edit'],
594 'addsection' => $content_navigation['views']['addsection'],
596 $content_navigation['actions']
598 $bar['qbedit'] = $qbedit;
599 $bar['qbpageoptions'] = $qbpageoptions;
601 // Personal tools ("My pages")
602 $bar['qbmyoptions'] = $this->getPersonalTools();
603 foreach ( array ( 'logout', 'createaccount', 'login', 'anonlogin' ) as $key ) {
604 $bar['qbmyoptions'][$key] = false;
607 $additions_done = true;
610 // Re-insert current heading, unless it's SEARCH
611 if ( $heading != 'SEARCH' ) {
612 $bar[$heading] = $plain_bar[$heading];
616 // If TOOLBOX is missing, $additions_done is still false
617 if ( !$additions_done ) {
618 $plain_bar['TOOLBOX'] = false;
622 foreach ( $bar as $heading => $links ) {
623 if ( $heading == 'SEARCH' ) {
624 $s .= $this->menuHead( wfMessage( 'qbfind' )->text() );
625 $s .= $this->searchForm( 'sidebar' );
626 } elseif ( $heading == 'LANGUAGES' ) {
627 // discard these; we display languages below page content
630 // Use the navigation heading from standard sidebar as the "browse" section
631 if ( $heading == 'navigation' ) {
632 $heading = 'qbbrowse';
634 if ( $heading == 'TOOLBOX' ) {
635 $heading = 'toolbox';
638 $headingMsg = wfMessage( $heading );
640 $t = $this->menuHead( $headingMsg->exists() ?
$headingMsg->text() : $heading );
642 foreach ( $links as $key => $link ) {
643 // Can be empty due to rampant sidebar massaging we're doing above
646 $t .= $this->makeListItem( $key, $link, array( 'tag' => 'span' ) ) . $sep;
657 $s .= $sep . "\n</div>\n";
662 * @param $label string
667 function searchForm( $which ) {
668 global $wgUseTwoButtonsSearchForm;
670 $search = $this->getSkin()->getRequest()->getText( 'search' );
671 $action = $this->data
['searchaction'];
672 $s = "<form id=\"searchform-" . htmlspecialchars($which) . "\" method=\"get\" class=\"inline\" action=\"$action\">";
673 if( $which == 'footer' ) {
674 $s .= wfMessage( 'qbfind' )->text() . ": ";
677 $s .= "<input type='text' class=\"mw-searchInput\" name=\"search\" size=\"14\" value=\""
678 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />"
679 . ($which == 'footer' ?
" " : "<br />")
680 . "<input type='submit' class=\"searchButton\" name=\"go\" value=\"" . wfMessage( 'searcharticle' )->escaped() . "\" />";
682 if( $wgUseTwoButtonsSearchForm ) {
683 $s .= " <input type='submit' class=\"searchButton\" name=\"fulltext\" value=\"" . wfMessage( 'search' )->escaped() . "\" />\n";
685 $s .= '<div><a href="' . $action . '" rel="search">' . wfMessage( 'powersearch-legend' )->escaped() . "</a></div>\n";