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()
343 function talkLink() {
344 $title = $this->getSkin()->getTitle();
346 if ( $title->getNamespace() == NS_SPECIAL
) {
347 // No discussion links for special pages
351 $companionTitle = $title->isTalkPage() ?
$title->getSubjectPage() : $title->getTalkPage();
352 $companionNamespace = $companionTitle->getNamespace();
354 // TODO these messages appear to only be used by CologneBlue and legacy skins,
355 // kill and replace with something more sensibly named?
356 $nsToMessage = array(
357 NS_MAIN
=> 'articlepage',
358 NS_USER
=> 'userpage',
359 NS_PROJECT
=> 'projectpage',
360 NS_FILE
=> 'imagepage',
361 NS_MEDIAWIKI
=> 'mediawikipage',
362 NS_TEMPLATE
=> 'templatepage',
363 NS_HELP
=> 'viewhelppage',
364 NS_CATEGORY
=> 'categorypage',
365 NS_FILE
=> 'imagepage',
368 // Find out the message to use for link text. Use either the array above or,
369 // for non-talk pages, a generic "discuss this" message.
370 // Default is the same as for main namespace.
371 if ( isset( $nsToMessage[$companionNamespace] ) ) {
372 $message = $nsToMessage[$companionNamespace];
374 $message = $companionTitle->isTalkPage() ?
'talkpage' : 'articlepage';
377 // Obviously this can't be reasonable and just return the key for talk namespace, only for content ones.
378 // Thus we have to mangle it in exactly the same way SkinTemplate does. (bug 40805)
379 $key = $companionTitle->getNamespaceKey( '' );
380 if ( $companionTitle->isTalkPage() ) {
381 $key = ( $key == 'main' ?
'talk' : $key . "_talk" );
384 // Use the regular navigational link, but replace its text. Everything else stays unmodified.
385 $namespacesLinks = $this->data
['content_navigation']['namespaces'];
386 $link = $this->processNavlinkForDocument( $namespacesLinks[ $key ] );
387 $link['text'] = wfMessage( $message )->text();
389 return $this->makeListItem( $message, $link, array( 'tag' => 'span' ) );
393 * Takes a navigational link generated by SkinTemplate in whichever way
394 * and mangles attributes unsuitable for repeated use. In particular, this modifies the ids
395 * and removes the accesskeys. This is necessary to be able to use the same navlink twice,
396 * e.g. in sidebar and in footer.
398 * @param $navlink array Navigational link generated by SkinTemplate
399 * @param $idPrefix mixed Prefix to add to id of this navlink. If false, id is removed entirely. Default is 'cb-'.
401 function processNavlinkForDocument( $navlink, $idPrefix='cb-' ) {
402 if ( $navlink['id'] ) {
403 $navlink['single-id'] = $navlink['id']; // to allow for tooltip generation
404 $navlink['tooltiponly'] = true; // but no accesskeys
406 // mangle or remove the id
407 if ( $idPrefix === false ) {
408 unset( $navlink['id'] );
410 $navlink['id'] = $idPrefix . $navlink['id'];
422 function beforeContent() {
428 <a href
="<?php echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] ) ?>">
429 <?php
echo wfMessage( 'sitetitle' )->escaped() ?
>
432 <p id
="sitesub"><?php
echo wfMessage( 'sitesubtitle' )->escaped() ?
></p
>
435 <p id
="syslinks"><?php
echo $this->sysLinks() ?
></p
>
436 <p id
="variantlinks"><?php
echo $this->variantLinks() ?
></p
>
438 <div id
="linkcollection">
439 <div id
="langlinks"><?php
echo str_replace( '<br />', '', $this->otherLanguages() ) ?
></div
>
440 <?php
echo $this->getSkin()->getCategories() ?
>
441 <div id
="titlelinks"><?php
echo $this->pageTitleLinks() ?
></div
>
442 <?php
if ( $this->data
['newtalk'] ) { ?
>
443 <div
class="usermessage"><strong
><?php
echo $this->data
['newtalk'] ?
></strong
></div
>
448 <?php
if ( $this->getSkin()->getSiteNotice() ) { ?
>
449 <div id
="siteNotice"><?php
echo $this->getSkin()->getSiteNotice() ?
></div
>
451 <h1 id
="firstHeading"><span dir
="auto"><?php
echo $this->data
['title'] ?
></span
></h1
>
452 <?php
if ( $this->translator
->translate( 'tagline' ) ) { ?
>
453 <p
class="tagline"><?php
echo htmlspecialchars( $this->translator
->translate( 'tagline' ) ) ?
></p
>
455 <?php
if ( $this->getSkin()->getOutput()->getSubtitle() ) { ?
>
456 <p
class="subtitle"><?php
echo $this->getSkin()->getOutput()->getSubtitle() ?
></p
>
458 <?php
if ( $this->getSkin()->subPageSubtitle() ) { ?
>
459 <p
class="subpages"><?php
echo $this->getSkin()->subPageSubtitle() ?
></p
>
462 $s = ob_get_contents();
473 function afterContent() {
479 // Page-related links
480 echo $this->bottomLinks();
483 // Footer and second searchbox
484 echo $this->getSkin()->getLanguage()->pipeList( array(
485 $this->getSkin()->mainPageLink(),
486 $this->getSkin()->aboutLink(),
487 $this->searchForm( 'footer' )
491 // Standard footer info
492 $footlinks = $this->getFooterLinks();
493 if ( $footlinks['info'] ) {
494 foreach ( $footlinks['info'] as $item ) {
495 echo $this->data
[$item] . ' ';
501 <?php
echo $this->quickBar() ?
>
503 $s = ob_get_contents();
514 function sysLinks() {
516 $this->getSkin()->mainPageLink(),
518 Title
::newFromText( wfMessage( 'aboutpage' )->inContentLanguage()->text() ),
519 wfMessage( 'about' )->text()
522 Title
::newFromText( wfMessage( 'helppage' )->inContentLanguage()->text() ),
523 wfMessage( 'help' )->text()
526 Title
::newFromText( wfMessage( 'faqpage' )->inContentLanguage()->text() ),
527 wfMessage( 'faq' )->text()
531 $personalUrls = $this->getPersonalTools();
532 foreach ( array ( 'logout', 'createaccount', 'login', 'anonlogin' ) as $key ) {
533 if ( $personalUrls[$key] ) {
534 $s[] = $this->makeListItem( $key, $personalUrls[$key], array( 'tag' => 'span' ) );
538 return $this->getSkin()->getLanguage()->pipeList( $s );
545 * @param $heading string
550 function menuHead( $heading ) {
551 return "\n<h6>" . htmlspecialchars( $heading ) . "</h6>";
555 * Compute the sidebar
563 $s = "\n<div id='quickbar'>";
567 $plain_bar = $this->data
['sidebar'];
570 // Massage the sidebar
571 // We want to place SEARCH at the beginning and a lot of stuff before TOOLBOX (or at the end, if it's missing)
572 $additions_done = false;
573 while ( !$additions_done ) {
574 $bar = array(); // Empty it out
576 // Always display search on top
577 $bar['SEARCH'] = true;
579 foreach ( $plain_bar as $heading => $links ) {
580 if ( $heading == 'TOOLBOX' ) {
581 if( $links !== NULL ) {
582 // If this is not a toolbox prosthetic we inserted outselves, fill it out
583 $plain_bar['TOOLBOX'] = $this->getToolbox();
586 // And insert the stuff
588 // "This page" and "Edit" menus
589 // We need to do some massaging here... we reuse all of the items, except for $...['views']['view'],
590 // as $...['namespaces']['main'] and $...['namespaces']['talk'] together serve the same purpose.
591 // We also don't use $...['variants'], these are displayed in the top menu.
592 $content_navigation = $this->data
['content_navigation'];
593 $qbpageoptions = array_merge(
594 $content_navigation['namespaces'],
596 'history' => $content_navigation['views']['history'],
597 'watch' => $content_navigation['actions']['watch'],
598 'unwatch' => $content_navigation['actions']['unwatch'],
601 $content_navigation['actions']['watch'] = null;
602 $content_navigation['actions']['unwatch'] = null;
603 $qbedit = array_merge(
605 'edit' => $content_navigation['views']['edit'],
606 'addsection' => $content_navigation['views']['addsection'],
608 $content_navigation['actions']
610 $bar['qbedit'] = $qbedit;
611 $bar['qbpageoptions'] = $qbpageoptions;
613 // Personal tools ("My pages")
614 $bar['qbmyoptions'] = $this->getPersonalTools();
615 foreach ( array ( 'logout', 'createaccount', 'login', 'anonlogin' ) as $key ) {
616 $bar['qbmyoptions'][$key] = false;
619 $additions_done = true;
622 // Re-insert current heading, unless it's SEARCH
623 if ( $heading != 'SEARCH' ) {
624 $bar[$heading] = $plain_bar[$heading];
628 // If TOOLBOX is missing, $additions_done is still false
629 if ( !$additions_done ) {
630 $plain_bar['TOOLBOX'] = false;
634 foreach ( $bar as $heading => $links ) {
635 if ( $heading == 'SEARCH' ) {
636 $s .= $this->menuHead( wfMessage( 'qbfind' )->text() );
637 $s .= $this->searchForm( 'sidebar' );
638 } elseif ( $heading == 'LANGUAGES' ) {
639 // discard these; we display languages below page content
642 // Use the navigation heading from standard sidebar as the "browse" section
643 if ( $heading == 'navigation' ) {
644 $heading = 'qbbrowse';
646 if ( $heading == 'TOOLBOX' ) {
647 $heading = 'toolbox';
650 $headingMsg = wfMessage( $heading );
652 $t = $this->menuHead( $headingMsg->exists() ?
$headingMsg->text() : $heading );
654 foreach ( $links as $key => $link ) {
655 // Can be empty due to rampant sidebar massaging we're doing above
658 $t .= $this->makeListItem( $key, $link, array( 'tag' => 'span' ) ) . $sep;
669 $s .= $sep . "\n</div>\n";
674 * @param $label string
679 function searchForm( $which ) {
680 global $wgUseTwoButtonsSearchForm;
682 $search = $this->getSkin()->getRequest()->getText( 'search' );
683 $action = $this->data
['searchaction'];
684 $s = "<form id=\"searchform-" . htmlspecialchars($which) . "\" method=\"get\" class=\"inline\" action=\"$action\">";
685 if( $which == 'footer' ) {
686 $s .= wfMessage( 'qbfind' )->text() . ": ";
689 $s .= "<input type='text' class=\"mw-searchInput\" name=\"search\" size=\"14\" value=\""
690 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />"
691 . ($which == 'footer' ?
" " : "<br />")
692 . "<input type='submit' class=\"searchButton\" name=\"go\" value=\"" . wfMessage( 'searcharticle' )->escaped() . "\" />";
694 if( $wgUseTwoButtonsSearchForm ) {
695 $s .= " <input type='submit' class=\"searchButton\" name=\"fulltext\" value=\"" . wfMessage( 'search' )->escaped() . "\" />\n";
697 $s .= '<div><a href="' . $action . '" rel="search">' . wfMessage( 'powersearch-legend' )->escaped() . "</a></div>\n";