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 public $skinname = 'cologneblue';
35 public $stylename = 'cologneblue';
36 public $template = 'CologneBlueTemplate';
37 public $useHeadElement = true;
40 * @param OutputPage $out
42 function setupSkinUserCss( OutputPage
$out ) {
43 parent
::setupSkinUserCss( $out );
44 $out->addModuleStyles( 'mediawiki.legacy.oldshared' );
45 $out->addModuleStyles( 'skins.cologneblue' );
49 * Override langlink formatting behavior not to uppercase the language names.
50 * See otherLanguages() in CologneBlueTemplate.
54 function formatLanguageName( $name ) {
59 class CologneBlueTemplate
extends BaseTemplate
{
61 // Suppress warnings to prevent notices about missing indexes in $this->data
63 $this->html( 'headelement' );
64 echo $this->beforeContent();
65 $this->html( 'bodytext' );
67 echo $this->afterContent();
68 $this->html( 'dataAfterContent' );
70 echo "\n</body></html>";
75 * 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 );
90 function otherLanguages() {
91 global $wgHideInterlanguageLinks;
92 if ( $wgHideInterlanguageLinks ) {
98 // We override SkinTemplate->formatLanguageName() in SkinCologneBlue
99 // not to capitalize the language names.
100 $language_urls = $this->data
['language_urls'];
101 if ( !empty( $language_urls ) ) {
103 foreach ( $language_urls as $key => $data ) {
104 $s[] = $this->makeListItem( $key, $data, array( 'tag' => 'span' ) );
107 $html = wfMessage( 'otherlanguages' )->text()
108 . wfMessage( 'colon-separator' )->text()
109 . $this->getSkin()->getLanguage()->pipeList( $s );
112 $html .= $this->renderAfterPortlet( 'lang' );
118 * @param string $name
120 protected function renderAfterPortlet( $name ) {
122 wfRunHooks( 'BaseTemplateAfterPortlet', array( $this, $name, &$content ) );
124 $html = $content !== '' ?
"<div class='after-portlet after-portlet-$name'>$content</div>" : '';
129 function pageTitleLinks() {
131 $footlinks = $this->getFooterLinks();
133 foreach ( $footlinks['places'] as $item ) {
134 $s[] = $this->data
[$item];
137 return $this->getSkin()->getLanguage()->pipeList( $s );
141 * Used in bottomLinks() to eliminate repetitive code.
143 * @param string $key Key to be passed to makeListItem()
144 * @param array $navlink Navlink suitable for processNavlinkForDocument()
145 * @param string $message Key of the message to use in place of standard text
149 function processBottomLink( $key, $navlink, $message = null ) {
151 // Empty navlinks might be passed.
156 $navlink['text'] = wfMessage( $message )->escaped();
159 return $this->makeListItem(
161 $this->processNavlinkForDocument( $navlink ),
162 array( 'tag' => 'span' )
166 function bottomLinks() {
167 $toolbox = $this->getToolbox();
168 $content_nav = $this->data
['content_navigation'];
172 if ( $this->getSkin()->getOutput()->isArticleRelated() ) {
173 // First row. Regular actions.
176 $editLinkMessage = $this->getSkin()->getTitle()->exists() ?
'editthispage' : 'create-this-page';
177 $element[] = $this->processBottomLink( 'edit', $content_nav['views']['edit'], $editLinkMessage );
178 $element[] = $this->processBottomLink(
180 $content_nav['views']['viewsource'],
184 $element[] = $this->processBottomLink(
186 $content_nav['actions']['watch'],
189 $element[] = $this->processBottomLink(
191 $content_nav['actions']['unwatch'],
195 $element[] = $this->talkLink();
197 $element[] = $this->processBottomLink( 'history', $content_nav['views']['history'], 'history' );
198 $element[] = $this->processBottomLink( 'info', $toolbox['info'] );
199 $element[] = $this->processBottomLink( 'whatlinkshere', $toolbox['whatlinkshere'] );
200 $element[] = $this->processBottomLink( 'recentchangeslinked', $toolbox['recentchangeslinked'] );
202 $element[] = $this->processBottomLink( 'contributions', $toolbox['contributions'] );
203 $element[] = $this->processBottomLink( 'emailuser', $toolbox['emailuser'] );
205 $lines[] = $this->getSkin()->getLanguage()->pipeList( array_filter( $element ) );
207 // Second row. Privileged actions.
210 $element[] = $this->processBottomLink(
212 $content_nav['actions']['delete'],
215 $element[] = $this->processBottomLink(
217 $content_nav['actions']['undelete'],
221 $element[] = $this->processBottomLink(
223 $content_nav['actions']['protect'],
226 $element[] = $this->processBottomLink(
228 $content_nav['actions']['unprotect'],
232 $element[] = $this->processBottomLink( 'move', $content_nav['actions']['move'], 'movethispage' );
234 $lines[] = $this->getSkin()->getLanguage()->pipeList( array_filter( $element ) );
236 // Third row. Language links.
237 $lines[] = $this->otherLanguages();
240 return implode( array_filter( $lines ), "<br />\n" ) . "<br />\n";
243 function talkLink() {
244 $title = $this->getSkin()->getTitle();
246 if ( $title->getNamespace() == NS_SPECIAL
) {
247 // No discussion links for special pages
251 $companionTitle = $title->isTalkPage() ?
$title->getSubjectPage() : $title->getTalkPage();
252 $companionNamespace = $companionTitle->getNamespace();
254 // TODO these messages are only be used by CologneBlue,
255 // kill and replace with something more sensibly named?
256 $nsToMessage = array(
257 NS_MAIN
=> 'articlepage',
258 NS_USER
=> 'userpage',
259 NS_PROJECT
=> 'projectpage',
260 NS_FILE
=> 'imagepage',
261 NS_MEDIAWIKI
=> 'mediawikipage',
262 NS_TEMPLATE
=> 'templatepage',
263 NS_HELP
=> 'viewhelppage',
264 NS_CATEGORY
=> 'categorypage',
265 NS_FILE
=> 'imagepage',
268 // Find out the message to use for link text. Use either the array above or,
269 // for non-talk pages, a generic "discuss this" message.
270 // Default is the same as for main namespace.
271 if ( isset( $nsToMessage[$companionNamespace] ) ) {
272 $message = $nsToMessage[$companionNamespace];
274 $message = $companionTitle->isTalkPage() ?
'talkpage' : 'articlepage';
277 // Obviously this can't be reasonable and just return the key for talk
278 // namespace, only for content ones. Thus we have to mangle it in
279 // exactly the same way SkinTemplate does. (bug 40805)
280 $key = $companionTitle->getNamespaceKey( '' );
281 if ( $companionTitle->isTalkPage() ) {
282 $key = ( $key == 'main' ?
'talk' : $key . "_talk" );
285 // Use the regular navigational link, but replace its text. Everything else stays unmodified.
286 $namespacesLinks = $this->data
['content_navigation']['namespaces'];
288 return $this->processBottomLink( $message, $namespacesLinks[$key], $message );
292 * Takes a navigational link generated by SkinTemplate in whichever way
293 * and mangles attributes unsuitable for repeated use. In particular, this
294 * modifies the ids and removes the accesskeys. This is necessary to be
295 * able to use the same navlink twice, e.g. in sidebar and in footer.
297 * @param array $navlink Navigational link generated by SkinTemplate
298 * @param mixed $idPrefix Prefix to add to id of this navlink. If false, id
299 * is removed entirely. Default is 'cb-'.
301 function processNavlinkForDocument( $navlink, $idPrefix = 'cb-' ) {
302 if ( $navlink['id'] ) {
303 $navlink['single-id'] = $navlink['id']; // to allow for tooltip generation
304 $navlink['tooltiponly'] = true; // but no accesskeys
306 // mangle or remove the id
307 if ( $idPrefix === false ) {
308 unset( $navlink['id'] );
310 $navlink['id'] = $idPrefix . $navlink['id'];
320 function beforeContent() {
325 <p id
="sitetitle" role
="banner">
326 <a href
="<?php echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] ) ?>">
327 <?php
echo wfMessage( 'sitetitle' )->escaped() ?
>
331 <p id
="sitesub"><?php
echo wfMessage( 'sitesubtitle' )->escaped() ?
></p
>
333 <div id
="linkcollection" role
="navigation">
334 <div id
="langlinks"><?php
echo str_replace( '<br />', '', $this->otherLanguages() ) ?
></div
>
335 <?php
echo $this->getSkin()->getCategories() ?
>
336 <div id
="titlelinks"><?php
echo $this->pageTitleLinks() ?
></div
>
338 if ( $this->data
['newtalk'] ) {
340 <div
class="usermessage"><strong
><?php
echo $this->data
['newtalk'] ?
></strong
></div
>
346 <div id
="article" class="mw-body" role
="main">
348 if ( $this->getSkin()->getSiteNotice() ) {
350 <div id
="siteNotice"><?php
echo $this->getSkin()->getSiteNotice() ?
></div
>
354 <h1 id
="firstHeading" lang
="<?php
355 $this->data['pageLanguage'] = $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode();
356 $this->text( 'pageLanguage' );
357 ?>"><span dir
="auto"><?php
echo $this->data
['title'] ?
></span
></h1
>
359 if ( $this->translator
->translate( 'tagline' ) ) {
361 <p
class="tagline"><?php
362 echo htmlspecialchars( $this->translator
->translate( 'tagline' ) )
368 if ( $this->getSkin()->getOutput()->getSubtitle() ) {
370 <p
class="subtitle"><?php
echo $this->getSkin()->getOutput()->getSubtitle() ?
></p
>
375 if ( $this->getSkin()->subPageSubtitle() ) {
377 <p
class="subpages"><?php
echo $this->getSkin()->subPageSubtitle() ?
></p
>
382 $s = ob_get_contents();
391 function afterContent() {
396 <div id
="footer-navigation" role
="navigation">
398 // Page-related links
399 echo $this->bottomLinks();
402 // Footer and second searchbox
403 echo $this->getSkin()->getLanguage()->pipeList( array(
404 $this->getSkin()->mainPageLink(),
405 $this->getSkin()->aboutLink(),
406 $this->searchForm( 'footer' )
410 <div id
="footer-info" role
="contentinfo">
412 // Standard footer info
413 $footlinks = $this->getFooterLinks();
414 if ( $footlinks['info'] ) {
415 foreach ( $footlinks['info'] as $item ) {
416 echo $this->data
[$item] . ' ';
423 <div id
="mw-navigation">
424 <h2
><?php
echo wfMessage( 'navigation-heading' )->escaped() ?
></h2
>
426 <div id
="toplinks" role
="navigation">
427 <p id
="syslinks"><?php
echo $this->sysLinks() ?
></p
>
429 <p id
="variantlinks"><?php
echo $this->variantLinks() ?
></p
>
431 <?php
echo $this->quickBar() ?
>
434 $s = ob_get_contents();
443 function sysLinks() {
445 $this->getSkin()->mainPageLink(),
447 Title
::newFromText( wfMessage( 'aboutpage' )->inContentLanguage()->text() ),
448 wfMessage( 'about' )->text()
450 Linker
::makeExternalLink(
451 Skin
::makeInternalOrExternalUrl( wfMessage( 'helppage' )->inContentLanguage()->text() ),
452 wfMessage( 'help' )->text(),
456 Title
::newFromText( wfMessage( 'faqpage' )->inContentLanguage()->text() ),
457 wfMessage( 'faq' )->text()
461 $personalUrls = $this->getPersonalTools();
462 foreach ( array( 'logout', 'createaccount', 'login' ) as $key ) {
463 if ( $personalUrls[$key] ) {
464 $s[] = $this->makeListItem( $key, $personalUrls[$key], array( 'tag' => 'span' ) );
468 return $this->getSkin()->getLanguage()->pipeList( $s );
472 * Adds CologneBlue-specific items to the sidebar: qbedit, qbpageoptions and qbmyoptions menus.
474 * @param array $bar Sidebar data
475 * @return array Modified sidebar data
477 function sidebarAdditions( $bar ) {
478 // "This page" and "Edit" menus
479 // We need to do some massaging here... we reuse all of the items,
480 // except for $...['views']['view'], as $...['namespaces']['main'] and
481 // $...['namespaces']['talk'] together serve the same purpose. We also
482 // don't use $...['variants'], these are displayed in the top menu.
483 $content_navigation = $this->data
['content_navigation'];
484 $qbpageoptions = array_merge(
485 $content_navigation['namespaces'],
487 'history' => $content_navigation['views']['history'],
488 'watch' => $content_navigation['actions']['watch'],
489 'unwatch' => $content_navigation['actions']['unwatch'],
492 $content_navigation['actions']['watch'] = null;
493 $content_navigation['actions']['unwatch'] = null;
494 $qbedit = array_merge(
496 'edit' => $content_navigation['views']['edit'],
497 'addsection' => $content_navigation['views']['addsection'],
499 $content_navigation['actions']
502 // Personal tools ("My pages")
503 $qbmyoptions = $this->getPersonalTools();
504 foreach ( array( 'logout', 'createaccount', 'login', ) as $key ) {
505 $qbmyoptions[$key] = null;
508 // Use the closest reasonable name
509 $bar['cactions'] = $qbedit;
510 $bar['pageoptions'] = $qbpageoptions; // this is a non-standard portlet name, but nothing fits
511 $bar['personal'] = $qbmyoptions;
517 * Compute the sidebar
522 function quickBar() {
523 // Massage the sidebar. We want to:
524 // * place SEARCH at the beginning
525 // * add new portlets before TOOLBOX (or at the end, if it's missing)
526 // * remove LANGUAGES (langlinks are displayed elsewhere)
527 $orig_bar = $this->data
['sidebar'];
531 // Always display search first
532 $bar['SEARCH'] = true;
533 // Copy everything except for langlinks, inserting new items before toolbox
534 foreach ( $orig_bar as $heading => $data ) {
535 if ( $heading == 'TOOLBOX' ) {
537 $bar = $this->sidebarAdditions( $bar );
541 if ( $heading != 'LANGUAGES' ) {
542 $bar[$heading] = $data;
545 // If toolbox is missing, add our items at the end
546 if ( !$hasToolbox ) {
547 $bar = $this->sidebarAdditions( $bar );
550 // Fill out special sidebar items with content
553 foreach ( $orig_bar as $heading => $data ) {
554 if ( $heading == 'SEARCH' ) {
555 $bar['search'] = $this->searchForm( 'sidebar' );
556 } elseif ( $heading == 'TOOLBOX' ) {
557 $bar['tb'] = $this->getToolbox();
559 $bar[$heading] = $data;
563 // Output the sidebar
564 // CologneBlue uses custom messages for some portlets, but we should keep the ids for consistency
565 $idToMessage = array(
566 'search' => 'qbfind',
567 'navigation' => 'qbbrowse',
569 'cactions' => 'qbedit',
570 'personal' => 'qbmyoptions',
571 'pageoptions' => 'qbpageoptions',
574 $s = "<div id='quickbar'>\n";
576 foreach ( $bar as $heading => $data ) {
577 $portletId = Sanitizer
::escapeId( "p-$heading" );
578 $headingMsg = wfMessage( $idToMessage[$heading] ?
$idToMessage[$heading] : $heading );
579 $headingHTML = "<h3>";
580 $headingHTML .= $headingMsg->exists()
581 ?
$headingMsg->escaped()
582 : htmlspecialchars( $heading );
583 $headingHTML .= "</h3>";
586 if ( is_array( $data ) ) {
587 // $data is an array of links
588 foreach ( $data as $key => $link ) {
589 // Can be empty due to how the sidebar additions are done
591 $listHTML .= $this->makeListItem( $key, $link );
595 $listHTML = "<ul>$listHTML</ul>";
598 // $data is a HTML <ul>-list string
603 $role = ( $heading == 'search' ) ?
'search' : 'navigation';
604 $s .= "<div class=\"portlet\" id=\"$portletId\" "
605 . "role=\"$role\">\n$headingHTML\n$listHTML\n</div>\n";
608 $s .= $this->renderAfterPortlet( $heading );
617 * @param string $label
620 function searchForm( $which ) {
621 global $wgUseTwoButtonsSearchForm;
623 $search = $this->getSkin()->getRequest()->getText( 'search' );
624 $action = $this->data
['searchaction'];
625 $s = "<form id=\"searchform-" . htmlspecialchars( $which )
626 . "\" method=\"get\" class=\"inline\" action=\"$action\">";
627 if ( $which == 'footer' ) {
628 $s .= wfMessage( 'qbfind' )->text() . ": ";
631 $s .= $this->makeSearchInput( array(
632 'class' => 'mw-searchInput',
636 $s .= ( $which == 'footer' ?
" " : "<br />" );
637 $s .= $this->makeSearchButton( 'go', array( 'class' => 'searchButton' ) );
639 if ( $wgUseTwoButtonsSearchForm ) {
640 $s .= $this->makeSearchButton( 'fulltext', array( 'class' => 'searchButton' ) );
642 $s .= '<div><a href="' . $action . '" rel="search">'
643 . wfMessage( 'powersearch-legend' )->escaped() . "</a></div>\n";