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>";
72 * Language/charset variant links for classic-style skins
77 function variantLinks() {
80 $variants = $this->data
['content_navigation']['variants'];
82 foreach ( $variants as $key => $link ) {
83 $s[] = $this->makeListItem( $key, $link, array( 'tag' => 'span' ) );
86 return $this->getSkin()->getLanguage()->pipeList( $s );
90 function otherLanguages() {
91 global $wgHideInterlanguageLinks;
92 if ( $wgHideInterlanguageLinks ) {
96 // We override SkinTemplate->formatLanguageName() in SkinCologneBlue
97 // not to capitalize the language names.
98 $language_urls = $this->data
['language_urls'];
99 if ( empty( $language_urls ) ) {
104 foreach ( $language_urls as $key => $data ) {
105 $s[] = $this->makeListItem( $key, $data, array( 'tag' => 'span' ) );
108 return wfMessage( 'otherlanguages' )->text()
109 . wfMessage( 'colon-separator' )->text()
110 . $this->getSkin()->getLanguage()->pipeList( $s );
114 function pageTitleLinks() {
116 $footlinks = $this->getFooterLinks();
118 foreach ( $footlinks['places'] as $item ) {
119 $s[] = $this->data
[$item];
122 return $this->getSkin()->getLanguage()->pipeList( $s );
125 function bottomLinks() {
126 $sep = wfMessage( 'pipe-separator' )->escaped() . "\n";
129 if ( $this->getSkin()->getOutput()->isArticleRelated() ) {
130 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
132 if ( $this->getSkin()->getUser()->isLoggedIn() ) {
133 $element[] = $this->watchThisPage();
136 $element[] = $this->talkLink();
137 $element[] = $this->historyLink();
138 $element[] = $this->whatLinksHere();
139 $element[] = $this->watchPageLinksLink();
141 $title = $this->getSkin()->getTitle();
144 $title->getNamespace() == NS_USER ||
145 $title->getNamespace() == NS_USER_TALK
147 $id = User
::idFromName( $title->getText() );
148 $ip = User
::isIP( $title->getText() );
150 # Both anons and non-anons have contributions list
152 $element[] = $this->userContribsLink();
155 if ( $this->getSkin()->showEmailUser( $id ) ) {
156 $element[] = $this->emailUserLink();
160 $s = implode( $element, $sep );
162 if ( $title->getArticleID() ) {
165 // Delete/protect/move links for privileged users
166 if ( $this->getSkin()->getUser()->isAllowed( 'delete' ) ) {
167 $s .= $this->deleteThisPage();
170 if ( $this->getSkin()->getUser()->isAllowed( 'protect' ) ) {
171 $s .= $sep . $this->protectThisPage();
174 if ( $this->getSkin()->getUser()->isAllowed( 'move' ) ) {
175 $s .= $sep . $this->moveThisPage();
179 $s .= "<br />\n" . $this->otherLanguages();
185 function editThisPage() {
186 if ( !$this->getSkin()->getOutput()->isArticleRelated() ) {
187 $s = wfMessage( 'protectedpage' )->text();
189 $title = $this->getSkin()->getTitle();
190 if ( $title->quickUserCan( 'edit' ) && $title->exists() ) {
191 $t = wfMessage( 'editthispage' )->text();
192 } elseif ( $title->quickUserCan( 'create' ) && !$title->exists() ) {
193 $t = wfMessage( 'create-this-page' )->text();
195 $t = wfMessage( 'viewsource' )->text();
198 $s = Linker
::linkKnown(
202 $this->getSkin()->editUrlOptions()
209 function deleteThisPage() {
210 $diff = $this->getSkin()->getRequest()->getVal( 'diff' );
211 $title = $this->getSkin()->getTitle();
213 if ( $title->getArticleID() && ( !$diff ) && $this->getSkin()->getUser()->isAllowed( 'delete' ) ) {
214 $t = wfMessage( 'deletethispage' )->text();
216 $s = Linker
::linkKnown(
220 array( 'action' => 'delete' )
229 function protectThisPage() {
230 $diff = $this->getSkin()->getRequest()->getVal( 'diff' );
231 $title = $this->getSkin()->getTitle();
233 if ( $title->getArticleID() && ( ! $diff ) && $this->getSkin()->getUser()->isAllowed( 'protect' ) ) {
234 if ( $title->isProtected() ) {
235 $text = wfMessage( 'unprotectthispage' )->text();
236 $query = array( 'action' => 'unprotect' );
238 $text = wfMessage( 'protectthispage' )->text();
239 $query = array( 'action' => 'protect' );
242 $s = Linker
::linkKnown(
255 function watchThisPage() {
257 $title = $this->getSkin()->getTitle();
259 if ( $this->getSkin()->getOutput()->isArticleRelated() ) {
260 if ( $this->getSkin()->getUser()->isWatched( $title ) ) {
261 $text = wfMessage( 'unwatchthispage' )->text();
263 'action' => 'unwatch',
264 'token' => UnwatchAction
::getUnwatchToken( $title, $this->getSkin()->getUser() ),
266 $id = 'mw-unwatch-link';
268 $text = wfMessage( 'watchthispage' )->text();
271 'token' => WatchAction
::getWatchToken( $title, $this->getSkin()->getUser() ),
273 $id = 'mw-watch-link';
276 $s = Linker
::linkKnown(
279 array( 'id' => $id ),
283 $s = wfMessage( 'notanarticle' )->text();
289 function moveThisPage() {
290 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
291 return Linker
::linkKnown(
292 SpecialPage
::getTitleFor( 'Movepage' ),
293 wfMessage( 'movethispage' )->text(),
295 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() )
298 // no message if page is protected - would be redundant
303 function historyLink() {
305 $this->getSkin()->getTitle(),
306 wfMessage( 'history' )->escaped(),
307 array( 'rel' => 'archives' ),
308 array( 'action' => 'history' )
312 function whatLinksHere() {
313 return Linker
::linkKnown(
314 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
315 wfMessage( 'whatlinkshere' )->escaped()
319 function userContribsLink() {
320 return Linker
::linkKnown(
321 SpecialPage
::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
322 wfMessage( 'contributions' )->escaped()
326 function emailUserLink() {
327 return Linker
::linkKnown(
328 SpecialPage
::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
329 wfMessage( 'emailuser' )->escaped()
333 function watchPageLinksLink() {
334 if ( !$this->getSkin()->getOutput()->isArticleRelated() ) {
335 return wfMessage( 'parentheses', wfMessage( 'notanarticle' )->text() )->escaped();
337 return Linker
::linkKnown(
338 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
339 wfMessage( 'recentchangeslinked-toolbox' )->escaped()
345 function talkLink() {
346 $title = $this->getSkin()->getTitle();
348 if ( $title->getNamespace() == NS_SPECIAL
) {
349 // No discussion links for special pages
353 $companionTitle = $title->isTalkPage() ?
$title->getSubjectPage() : $title->getTalkPage();
354 $companionNamespace = $companionTitle->getNamespace();
356 // TODO these messages appear to only be used by CologneBlue and legacy skins,
357 // kill and replace with something more sensibly named?
358 $nsToMessage = array(
359 NS_MAIN
=> 'articlepage',
360 NS_USER
=> 'userpage',
361 NS_PROJECT
=> 'projectpage',
362 NS_FILE
=> 'imagepage',
363 NS_MEDIAWIKI
=> 'mediawikipage',
364 NS_TEMPLATE
=> 'templatepage',
365 NS_HELP
=> 'viewhelppage',
366 NS_CATEGORY
=> 'categorypage',
367 NS_FILE
=> 'imagepage',
370 // Find out the message to use for link text. Use either the array above or,
371 // for non-talk pages, a generic "discuss this" message.
372 // Default is the same as for main namespace.
373 if ( isset( $nsToMessage[$companionNamespace] ) ) {
374 $message = $nsToMessage[$companionNamespace];
376 $message = $companionTitle->isTalkPage() ?
'talkpage' : 'articlepage';
379 // Obviously this can't be reasonable and just return the key for talk namespace, only for content ones.
380 // Thus we have to mangle it in exactly the same way SkinTemplate does. (bug 40805)
381 $key = $companionTitle->getNamespaceKey( '' );
382 if ( $companionTitle->isTalkPage() ) {
383 $key = ( $key == 'main' ?
'talk' : $key . "_talk" );
386 // Use the regular navigational link, but replace its text. Everything else stays unmodified.
387 $namespacesLinks = $this->data
['content_navigation']['namespaces'];
388 $link = $this->processNavlinkForDocument( $namespacesLinks[ $key ] );
389 $link['text'] = wfMessage( $message )->text();
391 return $this->makeListItem( $message, $link, array( 'tag' => 'span' ) );
395 * Takes a navigational link generated by SkinTemplate in whichever way
396 * and mangles attributes unsuitable for repeated use. In particular, this modifies the ids
397 * and removes the accesskeys. This is necessary to be able to use the same navlink twice,
398 * e.g. in sidebar and in footer.
400 * @param $navlink array Navigational link generated by SkinTemplate
401 * @param $idPrefix mixed Prefix to add to id of this navlink. If false, id is removed entirely. Default is 'cb-'.
403 function processNavlinkForDocument( $navlink, $idPrefix='cb-' ) {
404 if ( $navlink['id'] ) {
405 $navlink['single-id'] = $navlink['id']; // to allow for tooltip generation
406 $navlink['tooltiponly'] = true; // but no accesskeys
408 // mangle or remove the id
409 if ( $idPrefix === false ) {
410 unset( $navlink['id'] );
412 $navlink['id'] = $idPrefix . $navlink['id'];
424 function beforeContent() {
430 <a href
="<?php echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] ) ?>">
431 <?php
echo wfMessage( 'sitetitle' )->escaped() ?
>
434 <p id
="sitesub"><?php
echo wfMessage( 'sitesubtitle' )->escaped() ?
></p
>
436 <p id
="syslinks"><?php
echo $this->sysLinks() ?
></p
>
437 <p id
="variantlinks"><?php
echo $this->variantLinks() ?
></p
>
439 <div id
="linkcollection">
440 <div id
="langlinks"><?php
echo str_replace( '<br />', '', $this->otherLanguages() ) ?
></div
>
441 <?php
echo $this->getSkin()->getCategories() ?
>
442 <div id
="titlelinks"><?php
echo $this->pageTitleLinks() ?
></div
>
443 <?php
if ( $this->data
['newtalk'] ) { ?
>
444 <div
class="usermessage"><strong
><?php
echo $this->data
['newtalk'] ?
></strong
></div
>
449 <?php
if ( $this->getSkin()->getSiteNotice() ) { ?
>
450 <div id
="siteNotice"><?php
echo $this->getSkin()->getSiteNotice() ?
></div
>
452 <h1 id
="firstHeading"><span dir
="auto"><?php
echo $this->data
['title'] ?
></span
></h1
>
453 <?php
if ( $this->translator
->translate( 'tagline' ) ) { ?
>
454 <p
class="tagline"><?php
echo htmlspecialchars( $this->translator
->translate( 'tagline' ) ) ?
></p
>
456 <?php
if ( $this->getSkin()->getOutput()->getSubtitle() ) { ?
>
457 <p
class="subtitle"><?php
echo $this->getSkin()->getOutput()->getSubtitle() ?
></p
>
459 <?php
if ( $this->getSkin()->subPageSubtitle() ) { ?
>
460 <p
class="subpages"><?php
echo $this->getSkin()->subPageSubtitle() ?
></p
>
463 $s = ob_get_contents();
474 function afterContent() {
480 // Page-related links
481 echo $this->bottomLinks();
484 // Footer and second searchbox
485 echo $this->getSkin()->getLanguage()->pipeList( array(
486 $this->getSkin()->mainPageLink(),
487 $this->getSkin()->aboutLink(),
488 $this->searchForm( 'footer' )
492 // Standard footer info
493 $footlinks = $this->getFooterLinks();
494 if ( $footlinks['info'] ) {
495 foreach ( $footlinks['info'] as $item ) {
496 echo $this->data
[$item] . ' ';
502 <?php
echo $this->quickBar() ?
>
504 $s = ob_get_contents();
515 function sysLinks() {
517 $this->getSkin()->mainPageLink(),
519 Title
::newFromText( wfMessage( 'aboutpage' )->inContentLanguage()->text() ),
520 wfMessage( 'about' )->text()
523 Title
::newFromText( wfMessage( 'helppage' )->inContentLanguage()->text() ),
524 wfMessage( 'help' )->text()
527 Title
::newFromText( wfMessage( 'faqpage' )->inContentLanguage()->text() ),
528 wfMessage( 'faq' )->text()
532 $personalUrls = $this->getPersonalTools();
533 foreach ( array ( 'logout', 'createaccount', 'login', 'anonlogin' ) as $key ) {
534 if ( $personalUrls[$key] ) {
535 $s[] = $this->makeListItem( $key, $personalUrls[$key], array( 'tag' => 'span' ) );
539 return $this->getSkin()->getLanguage()->pipeList( $s );
543 * @param $heading string
548 function menuHead( $heading ) {
549 return "\n<h6>" . htmlspecialchars( $heading ) . "</h6>";
553 * Compute the sidebar
561 $s = "\n<div id='quickbar'>";
565 $plain_bar = $this->data
['sidebar'];
568 // Massage the sidebar
569 // We want to place SEARCH at the beginning and a lot of stuff before TOOLBOX (or at the end, if it's missing)
570 $additions_done = false;
571 while ( !$additions_done ) {
572 $bar = array(); // Empty it out
574 // Always display search on top
575 $bar['SEARCH'] = true;
577 foreach ( $plain_bar as $heading => $links ) {
578 if ( $heading == 'TOOLBOX' ) {
579 if( $links !== NULL ) {
580 // If this is not a toolbox prosthetic we inserted outselves, fill it out
581 $plain_bar['TOOLBOX'] = $this->getToolbox();
584 // And insert the stuff
586 // "This page" and "Edit" menus
587 // We need to do some massaging here... we reuse all of the items, except for $...['views']['view'],
588 // as $...['namespaces']['main'] and $...['namespaces']['talk'] together serve the same purpose.
589 // We also don't use $...['variants'], these are displayed in the top menu.
590 $content_navigation = $this->data
['content_navigation'];
591 $qbpageoptions = array_merge(
592 $content_navigation['namespaces'],
594 'history' => $content_navigation['views']['history'],
595 'watch' => $content_navigation['actions']['watch'],
596 'unwatch' => $content_navigation['actions']['unwatch'],
599 $content_navigation['actions']['watch'] = null;
600 $content_navigation['actions']['unwatch'] = null;
601 $qbedit = array_merge(
603 'edit' => $content_navigation['views']['edit'],
604 'addsection' => $content_navigation['views']['addsection'],
606 $content_navigation['actions']
608 $bar['qbedit'] = $qbedit;
609 $bar['qbpageoptions'] = $qbpageoptions;
611 // Personal tools ("My pages")
612 $bar['qbmyoptions'] = $this->getPersonalTools();
613 foreach ( array ( 'logout', 'createaccount', 'login', 'anonlogin' ) as $key ) {
614 $bar['qbmyoptions'][$key] = null;
617 $additions_done = true;
620 // Re-insert current heading, unless it's SEARCH
621 if ( $heading != 'SEARCH' ) {
622 $bar[$heading] = $plain_bar[$heading];
626 // If TOOLBOX is missing, $additions_done is still false
627 if ( !$additions_done ) {
628 $plain_bar['TOOLBOX'] = false;
632 foreach ( $bar as $heading => $links ) {
633 if ( $heading == 'SEARCH' ) {
634 $s .= $this->menuHead( wfMessage( 'qbfind' )->text() );
635 $s .= $this->searchForm( 'sidebar' );
636 } elseif ( $heading == 'LANGUAGES' ) {
637 // discard these; we display languages below page content
638 } elseif ( $links ) {
639 if ( is_array( $links ) ) {
640 // Use the navigation heading from standard sidebar as the "browse" section
641 if ( $heading == 'navigation' ) {
642 $heading = 'qbbrowse';
644 if ( $heading == 'TOOLBOX' ) {
645 $heading = 'toolbox';
648 $headingMsg = wfMessage( $heading );
650 $t = $this->menuHead( $headingMsg->exists() ?
$headingMsg->escaped() : htmlspecialchars( $heading ) );
652 foreach ( $links as $key => $link ) {
653 // Can be empty due to rampant sidebar massaging we're doing above
656 $t .= $this->makeListItem( $key, $link, array( 'tag' => 'span' ) ) . $sep;
664 // $links can be a HTML string
670 $s .= $sep . "\n</div>\n";
675 * @param $label string
680 function searchForm( $which ) {
681 global $wgUseTwoButtonsSearchForm;
683 $search = $this->getSkin()->getRequest()->getText( 'search' );
684 $action = $this->data
['searchaction'];
685 $s = "<form id=\"searchform-" . htmlspecialchars($which) . "\" method=\"get\" class=\"inline\" action=\"$action\">";
686 if( $which == 'footer' ) {
687 $s .= wfMessage( 'qbfind' )->text() . ": ";
690 $s .= "<input type='text' class=\"mw-searchInput\" name=\"search\" size=\"14\" value=\""
691 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />"
692 . ($which == 'footer' ?
" " : "<br />")
693 . "<input type='submit' class=\"searchButton\" name=\"go\" value=\"" . wfMessage( 'searcharticle' )->escaped() . "\" />";
695 if( $wgUseTwoButtonsSearchForm ) {
696 $s .= " <input type='submit' class=\"searchButton\" name=\"fulltext\" value=\"" . wfMessage( 'searchbutton' )->escaped() . "\" />\n";
698 $s .= '<div><a href="' . $action . '" rel="search">' . wfMessage( 'powersearch-legend' )->escaped() . "</a></div>\n";