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
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 );
87 function otherLanguages() {
88 global $wgHideInterlanguageLinks;
89 if ( $wgHideInterlanguageLinks ) {
93 // We override SkinTemplate->formatLanguageName() in SkinCologneBlue
94 // not to capitalize the language names.
95 $language_urls = $this->data
['language_urls'];
96 if ( empty( $language_urls ) ) {
101 foreach ( $language_urls as $key => $data ) {
102 $s[] = $this->makeListItem( $key, $data, array( 'tag' => 'span' ) );
105 return wfMessage( 'otherlanguages' )->text()
106 . wfMessage( 'colon-separator' )->text()
107 . $this->getSkin()->getLanguage()->pipeList( $s );
110 function pageTitleLinks() {
112 $footlinks = $this->getFooterLinks();
114 foreach ( $footlinks['places'] as $item ) {
115 $s[] = $this->data
[$item];
118 return $this->getSkin()->getLanguage()->pipeList( $s );
122 * Used in bottomLinks() to eliminate repetitive code.
124 * @param $key string Key to be passed to makeListItem()
125 * @param $navlink array Navlink suitable for processNavlinkForDocument()
126 * @param $message string Key of the message to use in place of standard text
130 function processBottomLink( $key, $navlink, $message = null ) {
132 // Empty navlinks might be passed.
137 $navlink['text'] = wfMessage( $message )->escaped();
140 return $this->makeListItem( $key, $this->processNavlinkForDocument( $navlink ), array( 'tag' => 'span' ) );
143 function bottomLinks() {
144 $toolbox = $this->getToolbox();
145 $content_nav = $this->data
['content_navigation'];
149 if ( $this->getSkin()->getOutput()->isArticleRelated() ) {
150 // First row. Regular actions.
153 $editLinkMessage = $this->getSkin()->getTitle()->exists() ?
'editthispage' : 'create-this-page';
154 $element[] = $this->processBottomLink( 'edit', $content_nav['views']['edit'], $editLinkMessage );
155 $element[] = $this->processBottomLink( 'viewsource', $content_nav['views']['viewsource'], 'viewsource' );
157 $element[] = $this->processBottomLink( 'watch', $content_nav['actions']['watch'], 'watchthispage' );
158 $element[] = $this->processBottomLink( 'unwatch', $content_nav['actions']['unwatch'], 'unwatchthispage' );
160 $element[] = $this->talkLink();
162 $element[] = $this->processBottomLink( 'history', $content_nav['views']['history'], 'history' );
163 $element[] = $this->processBottomLink( 'info', $toolbox['info'] );
164 $element[] = $this->processBottomLink( 'whatlinkshere', $toolbox['whatlinkshere'] );
165 $element[] = $this->processBottomLink( 'recentchangeslinked', $toolbox['recentchangeslinked'] );
167 $element[] = $this->processBottomLink( 'contributions', $toolbox['contributions'] );
168 $element[] = $this->processBottomLink( 'emailuser', $toolbox['emailuser'] );
170 $lines[] = $this->getSkin()->getLanguage()->pipeList( array_filter( $element ) );
173 // Second row. Privileged actions.
176 $element[] = $this->processBottomLink( 'delete', $content_nav['actions']['delete'], 'deletethispage' );
177 $element[] = $this->processBottomLink( 'undelete', $content_nav['actions']['undelete'], 'undeletethispage' );
179 $element[] = $this->processBottomLink( 'protect', $content_nav['actions']['protect'], 'protectthispage' );
180 $element[] = $this->processBottomLink( 'unprotect', $content_nav['actions']['unprotect'], 'unprotectthispage' );
182 $element[] = $this->processBottomLink( 'move', $content_nav['actions']['move'], 'movethispage' );
184 $lines[] = $this->getSkin()->getLanguage()->pipeList( array_filter( $element ) );
187 // Third row. Language links.
188 $lines[] = $this->otherLanguages();
191 return implode( array_filter( $lines ), "<br />\n" ) . "<br />\n";
194 function talkLink() {
195 $title = $this->getSkin()->getTitle();
197 if ( $title->getNamespace() == NS_SPECIAL
) {
198 // No discussion links for special pages
202 $companionTitle = $title->isTalkPage() ?
$title->getSubjectPage() : $title->getTalkPage();
203 $companionNamespace = $companionTitle->getNamespace();
205 // TODO these messages are only be used by CologneBlue,
206 // kill and replace with something more sensibly named?
207 $nsToMessage = array(
208 NS_MAIN
=> 'articlepage',
209 NS_USER
=> 'userpage',
210 NS_PROJECT
=> 'projectpage',
211 NS_FILE
=> 'imagepage',
212 NS_MEDIAWIKI
=> 'mediawikipage',
213 NS_TEMPLATE
=> 'templatepage',
214 NS_HELP
=> 'viewhelppage',
215 NS_CATEGORY
=> 'categorypage',
216 NS_FILE
=> 'imagepage',
219 // Find out the message to use for link text. Use either the array above or,
220 // for non-talk pages, a generic "discuss this" message.
221 // Default is the same as for main namespace.
222 if ( isset( $nsToMessage[$companionNamespace] ) ) {
223 $message = $nsToMessage[$companionNamespace];
225 $message = $companionTitle->isTalkPage() ?
'talkpage' : 'articlepage';
228 // Obviously this can't be reasonable and just return the key for talk namespace, only for content ones.
229 // Thus we have to mangle it in exactly the same way SkinTemplate does. (bug 40805)
230 $key = $companionTitle->getNamespaceKey( '' );
231 if ( $companionTitle->isTalkPage() ) {
232 $key = ( $key == 'main' ?
'talk' : $key . "_talk" );
235 // Use the regular navigational link, but replace its text. Everything else stays unmodified.
236 $namespacesLinks = $this->data
['content_navigation']['namespaces'];
237 return $this->processBottomLink( $message, $namespacesLinks[$key], $message );
241 * Takes a navigational link generated by SkinTemplate in whichever way
242 * and mangles attributes unsuitable for repeated use. In particular, this modifies the ids
243 * and removes the accesskeys. This is necessary to be able to use the same navlink twice,
244 * e.g. in sidebar and in footer.
246 * @param $navlink array Navigational link generated by SkinTemplate
247 * @param $idPrefix mixed Prefix to add to id of this navlink. If false, id is removed entirely. Default is 'cb-'.
249 function processNavlinkForDocument( $navlink, $idPrefix = 'cb-' ) {
250 if ( $navlink['id'] ) {
251 $navlink['single-id'] = $navlink['id']; // to allow for tooltip generation
252 $navlink['tooltiponly'] = true; // but no accesskeys
254 // mangle or remove the id
255 if ( $idPrefix === false ) {
256 unset( $navlink['id'] );
258 $navlink['id'] = $idPrefix . $navlink['id'];
268 function beforeContent() {
273 <p id
="sitetitle" role
="banner">
274 <a href
="<?php echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] ) ?>">
275 <?php
echo wfMessage( 'sitetitle' )->escaped() ?
>
278 <p id
="sitesub"><?php
echo wfMessage( 'sitesubtitle' )->escaped() ?
></p
>
279 <div id
="linkcollection" role
="navigation">
280 <div id
="langlinks"><?php
echo str_replace( '<br />', '', $this->otherLanguages() ) ?
></div
>
281 <?php
echo $this->getSkin()->getCategories() ?
>
282 <div id
="titlelinks"><?php
echo $this->pageTitleLinks() ?
></div
>
283 <?php
if ( $this->data
['newtalk'] ) { ?
>
284 <div
class="usermessage"><strong
><?php
echo $this->data
['newtalk'] ?
></strong
></div
>
288 <div id
="article" role
="main">
289 <?php
if ( $this->getSkin()->getSiteNotice() ) { ?
>
290 <div id
="siteNotice"><?php
echo $this->getSkin()->getSiteNotice() ?
></div
>
292 <h1 id
="firstHeading" lang
="<?php
293 $this->data['pageLanguage'] = $this->getSkin()->getTitle()->getPageViewLanguage()->getCode();
294 $this->html( 'pageLanguage' );
295 ?>"><span dir
="auto"><?php
echo $this->data
['title'] ?
></span
></h1
>
296 <?php
if ( $this->translator
->translate( 'tagline' ) ) { ?
>
297 <p
class="tagline"><?php
echo htmlspecialchars( $this->translator
->translate( 'tagline' ) ) ?
></p
>
299 <?php
if ( $this->getSkin()->getOutput()->getSubtitle() ) { ?
>
300 <p
class="subtitle"><?php
echo $this->getSkin()->getOutput()->getSubtitle() ?
></p
>
302 <?php
if ( $this->getSkin()->subPageSubtitle() ) { ?
>
303 <p
class="subpages"><?php
echo $this->getSkin()->subPageSubtitle() ?
></p
>
306 $s = ob_get_contents();
315 function afterContent() {
319 <div id
="footer" role
="contentinfo">
321 // Page-related links
322 echo $this->bottomLinks();
325 // Footer and second searchbox
326 echo $this->getSkin()->getLanguage()->pipeList( array(
327 $this->getSkin()->mainPageLink(),
328 $this->getSkin()->aboutLink(),
329 $this->searchForm( 'footer' )
333 // Standard footer info
334 $footlinks = $this->getFooterLinks();
335 if ( $footlinks['info'] ) {
336 foreach ( $footlinks['info'] as $item ) {
337 echo $this->data
[$item] . ' ';
343 <div id
="mw-navigation">
344 <h2
><?php
echo wfMessage( 'navigation-heading' )->escaped() ?
></h2
>
345 <div id
="toplinks" role
="navigation">
346 <p id
="syslinks"><?php
echo $this->sysLinks() ?
></p
>
347 <p id
="variantlinks"><?php
echo $this->variantLinks() ?
></p
>
349 <?php
echo $this->quickBar() ?
>
352 $s = ob_get_contents();
361 function sysLinks() {
363 $this->getSkin()->mainPageLink(),
365 Title
::newFromText( wfMessage( 'aboutpage' )->inContentLanguage()->text() ),
366 wfMessage( 'about' )->text()
369 Title
::newFromText( wfMessage( 'helppage' )->inContentLanguage()->text() ),
370 wfMessage( 'help' )->text()
373 Title
::newFromText( wfMessage( 'faqpage' )->inContentLanguage()->text() ),
374 wfMessage( 'faq' )->text()
378 $personalUrls = $this->getPersonalTools();
379 foreach ( array( 'logout', 'createaccount', 'login', 'anonlogin' ) as $key ) {
380 if ( $personalUrls[$key] ) {
381 $s[] = $this->makeListItem( $key, $personalUrls[$key], array( 'tag' => 'span' ) );
385 return $this->getSkin()->getLanguage()->pipeList( $s );
389 * Adds CologneBlue-specific items to the sidebar: qbedit, qbpageoptions and qbmyoptions menus.
391 * @param $bar sidebar data
392 * @return array modified sidebar data
394 function sidebarAdditions( $bar ) {
395 // "This page" and "Edit" menus
396 // We need to do some massaging here... we reuse all of the items, except for $...['views']['view'],
397 // as $...['namespaces']['main'] and $...['namespaces']['talk'] together serve the same purpose.
398 // We also don't use $...['variants'], these are displayed in the top menu.
399 $content_navigation = $this->data
['content_navigation'];
400 $qbpageoptions = array_merge(
401 $content_navigation['namespaces'],
403 'history' => $content_navigation['views']['history'],
404 'watch' => $content_navigation['actions']['watch'],
405 'unwatch' => $content_navigation['actions']['unwatch'],
408 $content_navigation['actions']['watch'] = null;
409 $content_navigation['actions']['unwatch'] = null;
410 $qbedit = array_merge(
412 'edit' => $content_navigation['views']['edit'],
413 'addsection' => $content_navigation['views']['addsection'],
415 $content_navigation['actions']
418 // Personal tools ("My pages")
419 $qbmyoptions = $this->getPersonalTools();
420 foreach ( array( 'logout', 'createaccount', 'login', 'anonlogin' ) as $key ) {
421 $qbmyoptions[$key] = null;
424 // Use the closest reasonable name
425 $bar['cactions'] = $qbedit;
426 $bar['pageoptions'] = $qbpageoptions; // this is a non-standard portlet name, but nothing fits
427 $bar['personal'] = $qbmyoptions;
433 * Compute the sidebar
438 function quickBar() {
439 // Massage the sidebar. We want to:
440 // * place SEARCH at the beginning
441 // * add new portlets before TOOLBOX (or at the end, if it's missing)
442 // * remove LANGUAGES (langlinks are displayed elsewhere)
443 $orig_bar = $this->data
['sidebar'];
447 // Always display search first
448 $bar['SEARCH'] = true;
449 // Copy everything except for langlinks, inserting new items before toolbox
450 foreach ( $orig_bar as $heading => $data ) {
451 if ( $heading == 'TOOLBOX' ) {
453 $bar = $this->sidebarAdditions( $bar );
457 if ( $heading != 'LANGUAGES' ) {
458 $bar[$heading] = $data;
461 // If toolbox is missing, add our items at the end
462 if ( !$hasToolbox ) {
463 $bar = $this->sidebarAdditions( $bar );
467 // Fill out special sidebar items with content
470 foreach ( $orig_bar as $heading => $data ) {
471 if ( $heading == 'SEARCH' ) {
472 $bar['search'] = $this->searchForm( 'sidebar' );
473 } elseif ( $heading == 'TOOLBOX' ) {
474 $bar['tb'] = $this->getToolbox();
476 $bar[$heading] = $data;
481 // Output the sidebar
482 // CologneBlue uses custom messages for some portlets, but we should keep the ids for consistency
483 $idToMessage = array(
484 'search' => 'qbfind',
485 'navigation' => 'qbbrowse',
487 'cactions' => 'qbedit',
488 'personal' => 'qbmyoptions',
489 'pageoptions' => 'qbpageoptions',
492 $s = "<div id='quickbar'>\n";
494 foreach ( $bar as $heading => $data ) {
495 $portletId = Sanitizer
::escapeId( "p-$heading" );
496 $headingMsg = wfMessage( $idToMessage[$heading] ?
$idToMessage[$heading] : $heading );
497 $headingHTML = "<h3>" . ( $headingMsg->exists() ?
$headingMsg->escaped() : htmlspecialchars( $heading ) ) . "</h3>";
500 if ( is_array( $data ) ) {
501 // $data is an array of links
502 foreach ( $data as $key => $link ) {
503 // Can be empty due to how the sidebar additions are done
505 $listHTML .= $this->makeListItem( $key, $link );
509 $listHTML = "<ul>$listHTML</ul>";
512 // $data is a HTML <ul>-list string
517 $role = ( $heading == 'search' ) ?
'search' : 'navigation';
518 $s .= "<div class=\"portlet\" id=\"$portletId\" role=\"$role\">\n$headingHTML\n$listHTML\n</div>\n";
527 * @param $label string
530 function searchForm( $which ) {
531 global $wgUseTwoButtonsSearchForm;
533 $search = $this->getSkin()->getRequest()->getText( 'search' );
534 $action = $this->data
['searchaction'];
535 $s = "<form id=\"searchform-" . htmlspecialchars( $which ) . "\" method=\"get\" class=\"inline\" action=\"$action\">";
536 if ( $which == 'footer' ) {
537 $s .= wfMessage( 'qbfind' )->text() . ": ";
540 $s .= "<input type='text' class=\"mw-searchInput\" name=\"search\" size=\"14\" value=\""
541 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />"
542 . ( $which == 'footer' ?
" " : "<br />" )
543 . "<input type='submit' class=\"searchButton\" name=\"go\" value=\"" . wfMessage( 'searcharticle' )->escaped() . "\" />";
545 if ( $wgUseTwoButtonsSearchForm ) {
546 $s .= " <input type='submit' class=\"searchButton\" name=\"fulltext\" value=\"" . wfMessage( 'searchbutton' )->escaped() . "\" />\n";
548 $s .= '<div><a href="' . $action . '" rel="search">' . wfMessage( 'powersearch-legend' )->escaped() . "</a></div>\n";