bd8a6776ac3005f9df92931ec68d2bf19f7bc410
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'];
287 return $this->processBottomLink( $message, $namespacesLinks[$key], $message );
291 * Takes a navigational link generated by SkinTemplate in whichever way
292 * and mangles attributes unsuitable for repeated use. In particular, this
293 * modifies the ids and removes the accesskeys. This is necessary to be
294 * able to use the same navlink twice, e.g. in sidebar and in footer.
296 * @param array $navlink Navigational link generated by SkinTemplate
297 * @param mixed $idPrefix Prefix to add to id of this navlink. If false, id
298 * is removed entirely. Default is 'cb-'.
300 function processNavlinkForDocument( $navlink, $idPrefix = 'cb-' ) {
301 if ( $navlink['id'] ) {
302 $navlink['single-id'] = $navlink['id']; // to allow for tooltip generation
303 $navlink['tooltiponly'] = true; // but no accesskeys
305 // mangle or remove the id
306 if ( $idPrefix === false ) {
307 unset( $navlink['id'] );
309 $navlink['id'] = $idPrefix . $navlink['id'];
319 function beforeContent() {
324 <p id
="sitetitle" role
="banner">
325 <a href
="<?php echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] ) ?>">
326 <?php
echo wfMessage( 'sitetitle' )->escaped() ?
>
329 <p id
="sitesub"><?php
echo wfMessage( 'sitesubtitle' )->escaped() ?
></p
>
330 <div id
="linkcollection" role
="navigation">
331 <div id
="langlinks"><?php
echo str_replace( '<br />', '', $this->otherLanguages() ) ?
></div
>
332 <?php
echo $this->getSkin()->getCategories() ?
>
333 <div id
="titlelinks"><?php
echo $this->pageTitleLinks() ?
></div
>
335 if ( $this->data
['newtalk'] ) {
337 <div
class="usermessage"><strong
><?php
echo $this->data
['newtalk'] ?
></strong
></div
>
343 <div id
="article" class="mw-body" role
="main">
345 if ( $this->getSkin()->getSiteNotice() ) {
347 <div id
="siteNotice"><?php
echo $this->getSkin()->getSiteNotice() ?
></div
>
351 <h1 id
="firstHeading" lang
="<?php
352 $this->data['pageLanguage'] = $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode();
353 $this->text( 'pageLanguage' );
354 ?>"><span dir
="auto"><?php
echo $this->data
['title'] ?
></span
></h1
>
356 if ( $this->translator
->translate( 'tagline' ) ) {
358 <p
class="tagline"><?php
359 echo htmlspecialchars( $this->translator
->translate( 'tagline' ) )
365 if ( $this->getSkin()->getOutput()->getSubtitle() ) {
367 <p
class="subtitle"><?php
echo $this->getSkin()->getOutput()->getSubtitle() ?
></p
>
372 if ( $this->getSkin()->subPageSubtitle() ) {
374 <p
class="subpages"><?php
echo $this->getSkin()->subPageSubtitle() ?
></p
>
379 $s = ob_get_contents();
388 function afterContent() {
393 <div id
="footer-navigation" role
="navigation">
395 // Page-related links
396 echo $this->bottomLinks();
399 // Footer and second searchbox
400 echo $this->getSkin()->getLanguage()->pipeList( array(
401 $this->getSkin()->mainPageLink(),
402 $this->getSkin()->aboutLink(),
403 $this->searchForm( 'footer' )
407 <div id
="footer-info" role
="contentinfo">
409 // Standard footer info
410 $footlinks = $this->getFooterLinks();
411 if ( $footlinks['info'] ) {
412 foreach ( $footlinks['info'] as $item ) {
413 echo $this->data
[$item] . ' ';
420 <div id
="mw-navigation">
421 <h2
><?php
echo wfMessage( 'navigation-heading' )->escaped() ?
></h2
>
422 <div id
="toplinks" role
="navigation">
423 <p id
="syslinks"><?php
echo $this->sysLinks() ?
></p
>
424 <p id
="variantlinks"><?php
echo $this->variantLinks() ?
></p
>
426 <?php
echo $this->quickBar() ?
>
429 $s = ob_get_contents();
438 function sysLinks() {
440 $this->getSkin()->mainPageLink(),
442 Title
::newFromText( wfMessage( 'aboutpage' )->inContentLanguage()->text() ),
443 wfMessage( 'about' )->text()
445 Linker
::makeExternalLink(
446 Skin
::makeInternalOrExternalUrl( wfMessage( 'helppage' )->inContentLanguage()->text() ),
447 wfMessage( 'help' )->text(),
451 Title
::newFromText( wfMessage( 'faqpage' )->inContentLanguage()->text() ),
452 wfMessage( 'faq' )->text()
456 $personalUrls = $this->getPersonalTools();
457 foreach ( array( 'logout', 'createaccount', 'login' ) as $key ) {
458 if ( $personalUrls[$key] ) {
459 $s[] = $this->makeListItem( $key, $personalUrls[$key], array( 'tag' => 'span' ) );
463 return $this->getSkin()->getLanguage()->pipeList( $s );
467 * Adds CologneBlue-specific items to the sidebar: qbedit, qbpageoptions and qbmyoptions menus.
469 * @param array $bar Sidebar data
470 * @return array Modified sidebar data
472 function sidebarAdditions( $bar ) {
473 // "This page" and "Edit" menus
474 // We need to do some massaging here... we reuse all of the items,
475 // except for $...['views']['view'], as $...['namespaces']['main'] and
476 // $...['namespaces']['talk'] together serve the same purpose. We also
477 // don't use $...['variants'], these are displayed in the top menu.
478 $content_navigation = $this->data
['content_navigation'];
479 $qbpageoptions = array_merge(
480 $content_navigation['namespaces'],
482 'history' => $content_navigation['views']['history'],
483 'watch' => $content_navigation['actions']['watch'],
484 'unwatch' => $content_navigation['actions']['unwatch'],
487 $content_navigation['actions']['watch'] = null;
488 $content_navigation['actions']['unwatch'] = null;
489 $qbedit = array_merge(
491 'edit' => $content_navigation['views']['edit'],
492 'addsection' => $content_navigation['views']['addsection'],
494 $content_navigation['actions']
497 // Personal tools ("My pages")
498 $qbmyoptions = $this->getPersonalTools();
499 foreach ( array( 'logout', 'createaccount', 'login', ) as $key ) {
500 $qbmyoptions[$key] = null;
503 // Use the closest reasonable name
504 $bar['cactions'] = $qbedit;
505 $bar['pageoptions'] = $qbpageoptions; // this is a non-standard portlet name, but nothing fits
506 $bar['personal'] = $qbmyoptions;
512 * Compute the sidebar
517 function quickBar() {
518 // Massage the sidebar. We want to:
519 // * place SEARCH at the beginning
520 // * add new portlets before TOOLBOX (or at the end, if it's missing)
521 // * remove LANGUAGES (langlinks are displayed elsewhere)
522 $orig_bar = $this->data
['sidebar'];
526 // Always display search first
527 $bar['SEARCH'] = true;
528 // Copy everything except for langlinks, inserting new items before toolbox
529 foreach ( $orig_bar as $heading => $data ) {
530 if ( $heading == 'TOOLBOX' ) {
532 $bar = $this->sidebarAdditions( $bar );
536 if ( $heading != 'LANGUAGES' ) {
537 $bar[$heading] = $data;
540 // If toolbox is missing, add our items at the end
541 if ( !$hasToolbox ) {
542 $bar = $this->sidebarAdditions( $bar );
545 // Fill out special sidebar items with content
548 foreach ( $orig_bar as $heading => $data ) {
549 if ( $heading == 'SEARCH' ) {
550 $bar['search'] = $this->searchForm( 'sidebar' );
551 } elseif ( $heading == 'TOOLBOX' ) {
552 $bar['tb'] = $this->getToolbox();
554 $bar[$heading] = $data;
558 // Output the sidebar
559 // CologneBlue uses custom messages for some portlets, but we should keep the ids for consistency
560 $idToMessage = array(
561 'search' => 'qbfind',
562 'navigation' => 'qbbrowse',
564 'cactions' => 'qbedit',
565 'personal' => 'qbmyoptions',
566 'pageoptions' => 'qbpageoptions',
569 $s = "<div id='quickbar'>\n";
571 foreach ( $bar as $heading => $data ) {
572 $portletId = Sanitizer
::escapeId( "p-$heading" );
573 $headingMsg = wfMessage( $idToMessage[$heading] ?
$idToMessage[$heading] : $heading );
574 $headingHTML = "<h3>";
575 $headingHTML .= $headingMsg->exists()
576 ?
$headingMsg->escaped()
577 : htmlspecialchars( $heading );
578 $headingHTML .= "</h3>";
581 if ( is_array( $data ) ) {
582 // $data is an array of links
583 foreach ( $data as $key => $link ) {
584 // Can be empty due to how the sidebar additions are done
586 $listHTML .= $this->makeListItem( $key, $link );
590 $listHTML = "<ul>$listHTML</ul>";
593 // $data is a HTML <ul>-list string
598 $role = ( $heading == 'search' ) ?
'search' : 'navigation';
599 $s .= "<div class=\"portlet\" id=\"$portletId\" "
600 . "role=\"$role\">\n$headingHTML\n$listHTML\n</div>\n";
603 $s .= $this->renderAfterPortlet( $heading );
611 * @param string $label
614 function searchForm( $which ) {
615 global $wgUseTwoButtonsSearchForm;
617 $search = $this->getSkin()->getRequest()->getText( 'search' );
618 $action = $this->data
['searchaction'];
619 $s = "<form id=\"searchform-" . htmlspecialchars( $which )
620 . "\" method=\"get\" class=\"inline\" action=\"$action\">";
621 if ( $which == 'footer' ) {
622 $s .= wfMessage( 'qbfind' )->text() . ": ";
625 $s .= $this->makeSearchInput( array(
626 'class' => 'mw-searchInput',
630 $s .= ( $which == 'footer' ?
" " : "<br />" );
631 $s .= $this->makeSearchButton( 'go', array( 'class' => 'searchButton' ) );
633 if ( $wgUseTwoButtonsSearchForm ) {
634 $s .= $this->makeSearchButton( 'fulltext', array( 'class' => 'searchButton' ) );
636 $s .= '<div><a href="' . $action . '" rel="search">'
637 . wfMessage( 'powersearch-legend' )->escaped() . "</a></div>\n";