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()
344 function talkLink() {
345 $title = $this->getSkin()->getTitle();
346 if ( NS_SPECIAL
== $title->getNamespace() ) {
347 # No discussion links for special pages
351 $linkOptions = array();
353 if ( $title->isTalkPage() ) {
354 $link = $title->getSubjectPage();
355 switch( $link->getNamespace() ) {
357 $text = wfMessage( 'articlepage' );
360 $text = wfMessage( 'userpage' );
363 $text = wfMessage( 'projectpage' );
366 $text = wfMessage( 'imagepage' );
367 # Make link known if image exists, even if the desc. page doesn't.
368 if ( wfFindFile( $link ) )
369 $linkOptions[] = 'known';
372 $text = wfMessage( 'mediawikipage' );
375 $text = wfMessage( 'templatepage' );
378 $text = wfMessage( 'viewhelppage' );
381 $text = wfMessage( 'categorypage' );
384 $text = wfMessage( 'articlepage' );
387 $link = $title->getTalkPage();
388 $text = wfMessage( 'talkpage' );
391 $s = Linker
::link( $link, $text->text(), array(), array(), $linkOptions );
401 function beforeContent() {
407 <a href
="<?php echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] ) ?>">
408 <?php
echo wfMessage( 'sitetitle' )->escaped() ?
>
411 <p id
="sitesub"><?php
echo wfMessage( 'sitesubtitle' )->escaped() ?
></p
>
413 <p id
="syslinks"><?php
echo $this->sysLinks() ?
></p
>
414 <p id
="variantlinks"><?php
echo $this->variantLinks() ?
></p
>
416 <div id
="linkcollection">
417 <div id
="langlinks"><?php
echo str_replace( '<br />', '', $this->otherLanguages() ) ?
></div
>
418 <?php
echo $this->getSkin()->getCategories() ?
>
419 <div id
="titlelinks"><?php
echo $this->pageTitleLinks() ?
></div
>
420 <?php
if ( $this->data
['newtalk'] ) { ?
>
421 <div
class="usermessage"><strong
><?php
echo $this->data
['newtalk'] ?
></strong
></div
>
426 <?php
if ( $this->getSkin()->getSiteNotice() ) { ?
>
427 <div id
="siteNotice"><?php
echo $this->getSkin()->getSiteNotice() ?
></div
>
429 <h1 id
="firstHeading"><span dir
="auto"><?php
echo $this->data
['title'] ?
></span
></h1
>
430 <?php
if ( $this->translator
->translate( 'tagline' ) ) { ?
>
431 <p
class="tagline"><?php
echo htmlspecialchars( $this->translator
->translate( 'tagline' ) ) ?
></p
>
433 <?php
if ( $this->getSkin()->getOutput()->getSubtitle() ) { ?
>
434 <p
class="subtitle"><?php
echo $this->getSkin()->getOutput()->getSubtitle() ?
></p
>
436 <?php
if ( $this->getSkin()->subPageSubtitle() ) { ?
>
437 <p
class="subpages"><?php
echo $this->getSkin()->subPageSubtitle() ?
></p
>
440 $s = ob_get_contents();
451 function afterContent() {
457 // Page-related links
458 echo $this->bottomLinks();
461 // Footer and second searchbox
462 echo $this->getSkin()->getLanguage()->pipeList( array(
463 $this->getSkin()->mainPageLink(),
464 $this->getSkin()->aboutLink(),
465 $this->searchForm( 'footer' )
469 // Standard footer info
470 $footlinks = $this->getFooterLinks();
471 if ( $footlinks['info'] ) {
472 foreach ( $footlinks['info'] as $item ) {
473 echo $this->data
[$item] . ' ';
479 <?php
echo $this->quickBar() ?
>
481 $s = ob_get_contents();
492 function sysLinks() {
494 $this->getSkin()->mainPageLink(),
496 Title
::newFromText( wfMessage( 'aboutpage' )->inContentLanguage()->text() ),
497 wfMessage( 'about' )->text()
500 Title
::newFromText( wfMessage( 'helppage' )->inContentLanguage()->text() ),
501 wfMessage( 'help' )->text()
504 Title
::newFromText( wfMessage( 'faqpage' )->inContentLanguage()->text() ),
505 wfMessage( 'faq' )->text()
509 $personalUrls = $this->getPersonalTools();
510 foreach ( array ( 'logout', 'createaccount', 'login', 'anonlogin' ) as $key ) {
511 if ( $personalUrls[$key] ) {
512 $s[] = $this->makeListItem( $key, $personalUrls[$key], array( 'tag' => 'span' ) );
516 return $this->getSkin()->getLanguage()->pipeList( $s );
520 * @param $heading string
525 function menuHead( $heading ) {
526 return "\n<h6>" . htmlspecialchars( $heading ) . "</h6>";
530 * Compute the sidebar
538 $s = "\n<div id='quickbar'>";
542 $plain_bar = $this->data
['sidebar'];
545 // Massage the sidebar
546 // We want to place SEARCH at the beginning and a lot of stuff before TOOLBOX (or at the end, if it's missing)
547 $additions_done = false;
548 while ( !$additions_done ) {
549 $bar = array(); // Empty it out
551 // Always display search on top
552 $bar['SEARCH'] = true;
554 foreach ( $plain_bar as $heading => $links ) {
555 if ( $heading == 'TOOLBOX' ) {
556 if( $links !== NULL ) {
557 // If this is not a toolbox prosthetic we inserted outselves, fill it out
558 $plain_bar['TOOLBOX'] = $this->getToolbox();
561 // And insert the stuff
563 // "This page" and "Edit" menus
564 // We need to do some massaging here... we reuse all of the items, except for $...['views']['view'],
565 // as $...['namespaces']['main'] and $...['namespaces']['talk'] together serve the same purpose.
566 // We also don't use $...['variants'], these are displayed in the top menu.
567 $content_navigation = $this->data
['content_navigation'];
568 $qbpageoptions = array_merge(
569 $content_navigation['namespaces'],
571 'history' => $content_navigation['views']['history'],
572 'watch' => $content_navigation['actions']['watch'],
573 'unwatch' => $content_navigation['actions']['unwatch'],
576 $content_navigation['actions']['watch'] = null;
577 $content_navigation['actions']['unwatch'] = null;
578 $qbedit = array_merge(
580 'edit' => $content_navigation['views']['edit'],
581 'addsection' => $content_navigation['views']['addsection'],
583 $content_navigation['actions']
585 $bar['qbedit'] = $qbedit;
586 $bar['qbpageoptions'] = $qbpageoptions;
588 // Personal tools ("My pages")
589 $bar['qbmyoptions'] = $this->getPersonalTools();
590 foreach ( array ( 'logout', 'createaccount', 'login', 'anonlogin' ) as $key ) {
591 $bar['qbmyoptions'][$key] = null;
594 $additions_done = true;
597 // Re-insert current heading, unless it's SEARCH
598 if ( $heading != 'SEARCH' ) {
599 $bar[$heading] = $plain_bar[$heading];
603 // If TOOLBOX is missing, $additions_done is still false
604 if ( !$additions_done ) {
605 $plain_bar['TOOLBOX'] = false;
609 foreach ( $bar as $heading => $links ) {
610 if ( $heading == 'SEARCH' ) {
611 $s .= $this->menuHead( wfMessage( 'qbfind' )->text() );
612 $s .= $this->searchForm( 'sidebar' );
613 } elseif ( $heading == 'LANGUAGES' ) {
614 // discard these; we display languages below page content
615 } elseif ( $links ) {
616 if ( is_array( $links ) ) {
617 // Use the navigation heading from standard sidebar as the "browse" section
618 if ( $heading == 'navigation' ) {
619 $heading = 'qbbrowse';
621 if ( $heading == 'TOOLBOX' ) {
622 $heading = 'toolbox';
625 $headingMsg = wfMessage( $heading );
627 $t = $this->menuHead( $headingMsg->exists() ?
$headingMsg->text() : $heading );
629 foreach ( $links as $key => $link ) {
630 // Can be empty due to rampant sidebar massaging we're doing above
633 $t .= $this->makeListItem( $key, $link, array( 'tag' => 'span' ) ) . $sep;
641 // $links can be a HTML string
647 $s .= $sep . "\n</div>\n";
652 * @param $label string
657 function searchForm( $which ) {
658 global $wgUseTwoButtonsSearchForm;
660 $search = $this->getSkin()->getRequest()->getText( 'search' );
661 $action = $this->data
['searchaction'];
662 $s = "<form id=\"searchform-" . htmlspecialchars($which) . "\" method=\"get\" class=\"inline\" action=\"$action\">";
663 if( $which == 'footer' ) {
664 $s .= wfMessage( 'qbfind' )->text() . ": ";
667 $s .= "<input type='text' class=\"mw-searchInput\" name=\"search\" size=\"14\" value=\""
668 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />"
669 . ($which == 'footer' ?
" " : "<br />")
670 . "<input type='submit' class=\"searchButton\" name=\"go\" value=\"" . wfMessage( 'searcharticle' )->escaped() . "\" />";
672 if( $wgUseTwoButtonsSearchForm ) {
673 $s .= " <input type='submit' class=\"searchButton\" name=\"fulltext\" value=\"" . wfMessage( 'searchbutton' )->escaped() . "\" />\n";
675 $s .= '<div><a href="' . $action . '" rel="search">' . wfMessage( 'powersearch-legend' )->escaped() . "</a></div>\n";