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 );
126 * Used in bottomLinks() to eliminate repetitive code.
128 * @param $key string Key to be passed to makeListItem()
129 * @param $navlink array Navlink suitable for processNavlinkForDocument()
130 * @param $message string Key of the message to use in place of standard text
135 function processBottomLink( $key, $navlink, $message=null ) {
137 // Empty navlinks might be passed.
142 $navlink['text'] = wfMessage( $message )->escaped();
145 return $this->makeListItem( $key, $this->processNavlinkForDocument( $navlink ), array( 'tag' => 'span' ) );
149 function bottomLinks() {
150 $toolbox = $this->getToolbox();
151 $content_nav = $this->data
['content_navigation'];
155 if ( $this->getSkin()->getOutput()->isArticleRelated() ) {
156 // First row. Regular actions.
159 $editLinkMessage = $this->getSkin()->getTitle()->exists() ?
'editthispage' : 'create-this-page';
160 $element[] = $this->processBottomLink( 'edit', $content_nav['views']['edit'], $editLinkMessage );
161 $element[] = $this->processBottomLink( 'viewsource', $content_nav['views']['viewsource'], 'viewsource' );
163 $element[] = $this->processBottomLink( 'watch', $content_nav['actions']['watch'], 'watchthispage' );
164 $element[] = $this->processBottomLink( 'unwatch', $content_nav['actions']['unwatch'], 'unwatchthispage' );
166 $element[] = $this->talkLink();
168 $element[] = $this->processBottomLink( 'history', $content_nav['views']['history'], 'history' );
169 $element[] = $this->processBottomLink( 'info', $toolbox['info'] );
170 $element[] = $this->processBottomLink( 'whatlinkshere', $toolbox['whatlinkshere'] );
171 $element[] = $this->processBottomLink( 'recentchangeslinked', $toolbox['recentchangeslinked'] );
173 $element[] = $this->processBottomLink( 'contributions', $toolbox['contributions'] );
174 $element[] = $this->processBottomLink( 'emailuser', $toolbox['emailuser'] );
176 $lines[] = $this->getSkin()->getLanguage()->pipeList( array_filter( $element ) );
179 // Second row. Privileged actions.
182 $element[] = $this->processBottomLink( 'delete', $content_nav['actions']['delete'], 'deletethispage' );
183 $element[] = $this->processBottomLink( 'undelete', $content_nav['actions']['undelete'], 'undeletethispage' );
185 $element[] = $this->processBottomLink( 'protect', $content_nav['actions']['protect'], 'protectthispage' );
186 $element[] = $this->processBottomLink( 'unprotect', $content_nav['actions']['unprotect'], 'unprotectthispage' );
188 $element[] = $this->processBottomLink( 'move', $content_nav['actions']['move'], 'movethispage' );
190 $lines[] = $this->getSkin()->getLanguage()->pipeList( array_filter( $element ) );
193 // Third row. Language links.
194 $lines[] = $this->otherLanguages();
197 return implode( array_filter( $lines ), "<br />\n" ) . "<br />\n";
201 function talkLink() {
202 $title = $this->getSkin()->getTitle();
204 if ( $title->getNamespace() == NS_SPECIAL
) {
205 // No discussion links for special pages
209 $companionTitle = $title->isTalkPage() ?
$title->getSubjectPage() : $title->getTalkPage();
210 $companionNamespace = $companionTitle->getNamespace();
212 // TODO these messages appear to only be used by CologneBlue and legacy skins,
213 // kill and replace with something more sensibly named?
214 $nsToMessage = array(
215 NS_MAIN
=> 'articlepage',
216 NS_USER
=> 'userpage',
217 NS_PROJECT
=> 'projectpage',
218 NS_FILE
=> 'imagepage',
219 NS_MEDIAWIKI
=> 'mediawikipage',
220 NS_TEMPLATE
=> 'templatepage',
221 NS_HELP
=> 'viewhelppage',
222 NS_CATEGORY
=> 'categorypage',
223 NS_FILE
=> 'imagepage',
226 // Find out the message to use for link text. Use either the array above or,
227 // for non-talk pages, a generic "discuss this" message.
228 // Default is the same as for main namespace.
229 if ( isset( $nsToMessage[$companionNamespace] ) ) {
230 $message = $nsToMessage[$companionNamespace];
232 $message = $companionTitle->isTalkPage() ?
'talkpage' : 'articlepage';
235 // Obviously this can't be reasonable and just return the key for talk namespace, only for content ones.
236 // Thus we have to mangle it in exactly the same way SkinTemplate does. (bug 40805)
237 $key = $companionTitle->getNamespaceKey( '' );
238 if ( $companionTitle->isTalkPage() ) {
239 $key = ( $key == 'main' ?
'talk' : $key . "_talk" );
242 // Use the regular navigational link, but replace its text. Everything else stays unmodified.
243 $namespacesLinks = $this->data
['content_navigation']['namespaces'];
244 return $this->processBottomLink( $message, $namespacesLinks[$key], $message );
248 * Takes a navigational link generated by SkinTemplate in whichever way
249 * and mangles attributes unsuitable for repeated use. In particular, this modifies the ids
250 * and removes the accesskeys. This is necessary to be able to use the same navlink twice,
251 * e.g. in sidebar and in footer.
253 * @param $navlink array Navigational link generated by SkinTemplate
254 * @param $idPrefix mixed Prefix to add to id of this navlink. If false, id is removed entirely. Default is 'cb-'.
256 function processNavlinkForDocument( $navlink, $idPrefix='cb-' ) {
257 if ( $navlink['id'] ) {
258 $navlink['single-id'] = $navlink['id']; // to allow for tooltip generation
259 $navlink['tooltiponly'] = true; // but no accesskeys
261 // mangle or remove the id
262 if ( $idPrefix === false ) {
263 unset( $navlink['id'] );
265 $navlink['id'] = $idPrefix . $navlink['id'];
277 function beforeContent() {
283 <a href
="<?php echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] ) ?>">
284 <?php
echo wfMessage( 'sitetitle' )->escaped() ?
>
287 <p id
="sitesub"><?php
echo wfMessage( 'sitesubtitle' )->escaped() ?
></p
>
289 <p id
="syslinks"><?php
echo $this->sysLinks() ?
></p
>
290 <p id
="variantlinks"><?php
echo $this->variantLinks() ?
></p
>
292 <div id
="linkcollection">
293 <div id
="langlinks"><?php
echo str_replace( '<br />', '', $this->otherLanguages() ) ?
></div
>
294 <?php
echo $this->getSkin()->getCategories() ?
>
295 <div id
="titlelinks"><?php
echo $this->pageTitleLinks() ?
></div
>
296 <?php
if ( $this->data
['newtalk'] ) { ?
>
297 <div
class="usermessage"><strong
><?php
echo $this->data
['newtalk'] ?
></strong
></div
>
302 <?php
if ( $this->getSkin()->getSiteNotice() ) { ?
>
303 <div id
="siteNotice"><?php
echo $this->getSkin()->getSiteNotice() ?
></div
>
305 <h1 id
="firstHeading"><span dir
="auto"><?php
echo $this->data
['title'] ?
></span
></h1
>
306 <?php
if ( $this->translator
->translate( 'tagline' ) ) { ?
>
307 <p
class="tagline"><?php
echo htmlspecialchars( $this->translator
->translate( 'tagline' ) ) ?
></p
>
309 <?php
if ( $this->getSkin()->getOutput()->getSubtitle() ) { ?
>
310 <p
class="subtitle"><?php
echo $this->getSkin()->getOutput()->getSubtitle() ?
></p
>
312 <?php
if ( $this->getSkin()->subPageSubtitle() ) { ?
>
313 <p
class="subpages"><?php
echo $this->getSkin()->subPageSubtitle() ?
></p
>
316 $s = ob_get_contents();
327 function afterContent() {
333 // Page-related links
334 echo $this->bottomLinks();
337 // Footer and second searchbox
338 echo $this->getSkin()->getLanguage()->pipeList( array(
339 $this->getSkin()->mainPageLink(),
340 $this->getSkin()->aboutLink(),
341 $this->searchForm( 'footer' )
345 // Standard footer info
346 $footlinks = $this->getFooterLinks();
347 if ( $footlinks['info'] ) {
348 foreach ( $footlinks['info'] as $item ) {
349 echo $this->data
[$item] . ' ';
355 <?php
echo $this->quickBar() ?
>
357 $s = ob_get_contents();
368 function sysLinks() {
370 $this->getSkin()->mainPageLink(),
372 Title
::newFromText( wfMessage( 'aboutpage' )->inContentLanguage()->text() ),
373 wfMessage( 'about' )->text()
376 Title
::newFromText( wfMessage( 'helppage' )->inContentLanguage()->text() ),
377 wfMessage( 'help' )->text()
380 Title
::newFromText( wfMessage( 'faqpage' )->inContentLanguage()->text() ),
381 wfMessage( 'faq' )->text()
385 $personalUrls = $this->getPersonalTools();
386 foreach ( array ( 'logout', 'createaccount', 'login', 'anonlogin' ) as $key ) {
387 if ( $personalUrls[$key] ) {
388 $s[] = $this->makeListItem( $key, $personalUrls[$key], array( 'tag' => 'span' ) );
392 return $this->getSkin()->getLanguage()->pipeList( $s );
396 * Adds CologneBlue-specific items to the sidebar: qbedit, qbpageoptions and qbmyoptions menus.
398 * @param $bar sidebar data
399 * @return array modified sidebar data
403 function sidebarAdditions( $bar ) {
404 // "This page" and "Edit" menus
405 // We need to do some massaging here... we reuse all of the items, except for $...['views']['view'],
406 // as $...['namespaces']['main'] and $...['namespaces']['talk'] together serve the same purpose.
407 // We also don't use $...['variants'], these are displayed in the top menu.
408 $content_navigation = $this->data
['content_navigation'];
409 $qbpageoptions = array_merge(
410 $content_navigation['namespaces'],
412 'history' => $content_navigation['views']['history'],
413 'watch' => $content_navigation['actions']['watch'],
414 'unwatch' => $content_navigation['actions']['unwatch'],
417 $content_navigation['actions']['watch'] = null;
418 $content_navigation['actions']['unwatch'] = null;
419 $qbedit = array_merge(
421 'edit' => $content_navigation['views']['edit'],
422 'addsection' => $content_navigation['views']['addsection'],
424 $content_navigation['actions']
427 // Personal tools ("My pages")
428 $qbmyoptions = $this->getPersonalTools();
429 foreach ( array ( 'logout', 'createaccount', 'login', 'anonlogin' ) as $key ) {
430 $qbmyoptions[$key] = null;
433 $bar['qbedit'] = $qbedit;
434 $bar['qbpageoptions'] = $qbpageoptions;
435 $bar['qbmyoptions'] = $qbmyoptions;
441 * Compute the sidebar
448 function quickBar() {
449 // Massage the sidebar. We want to:
450 // * place SEARCH at the beginning
451 // * add new portlets before TOOLBOX (or at the end, if it's missing)
452 // * remove LANGUAGES (langlinks are displayed elsewhere)
453 $orig_bar = $this->data
['sidebar'];
457 // Always display search first
458 $bar['SEARCH'] = true;
459 // Copy everything except for langlinks, inserting new items before toolbox
460 foreach ( $orig_bar as $heading => $data ) {
461 if ( $heading == 'TOOLBOX' ) {
463 $bar = $this->sidebarAdditions( $bar );
467 if ( $heading != 'LANGUAGES' ) {
468 $bar[$heading] = $data;
471 // If toolbox is missing, add our items at the end
472 if ( !$hasToolbox ) {
473 $bar = $this->sidebarAdditions( $bar );
477 // Fill out special sidebar items with content
480 foreach ( $orig_bar as $heading => $data ) {
481 if ( $heading == 'SEARCH' ) {
482 $bar['qbfind'] = $this->searchForm( 'sidebar' );
483 } elseif ( $heading == 'TOOLBOX' ) {
484 $bar['toolbox'] = $this->getToolbox();
485 } elseif ( $heading == 'navigation' ) {
486 // Use the navigation heading from standard sidebar as the "browse" section
487 $bar['qbbrowse'] = $data;
489 $bar[$heading] = $data;
494 // Output the sidebar
495 $s = "<div id='quickbar'>\n";
497 foreach ( $bar as $heading => $data ) {
498 $headingMsg = wfMessage( $heading );
499 $headingHTML = "<h6>" . ( $headingMsg->exists() ?
$headingMsg->escaped() : htmlspecialchars( $heading ) ) . "</h6>";
500 $portletId = Sanitizer
::escapeId( "p-$heading" );
503 if ( is_array( $data ) ) {
504 // $data is an array of links
505 foreach ( $data as $key => $link ) {
506 // Can be empty due to how the sidebar additions are done
508 $listHTML .= $this->makeListItem( $key, $link );
512 $listHTML = "<ul>$listHTML</ul>";
515 // $data is a HTML <ul>-list string
520 $s .= "<div class=\"portlet\" id=\"$portletId\">\n$headingHTML\n$listHTML\n</div>\n";
529 * @param $label string
534 function searchForm( $which ) {
535 global $wgUseTwoButtonsSearchForm;
537 $search = $this->getSkin()->getRequest()->getText( 'search' );
538 $action = $this->data
['searchaction'];
539 $s = "<form id=\"searchform-" . htmlspecialchars($which) . "\" method=\"get\" class=\"inline\" action=\"$action\">";
540 if( $which == 'footer' ) {
541 $s .= wfMessage( 'qbfind' )->text() . ": ";
544 $s .= "<input type='text' class=\"mw-searchInput\" name=\"search\" size=\"14\" value=\""
545 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />"
546 . ($which == 'footer' ?
" " : "<br />")
547 . "<input type='submit' class=\"searchButton\" name=\"go\" value=\"" . wfMessage( 'searcharticle' )->escaped() . "\" />";
549 if( $wgUseTwoButtonsSearchForm ) {
550 $s .= " <input type='submit' class=\"searchButton\" name=\"fulltext\" value=\"" . wfMessage( 'searchbutton' )->escaped() . "\" />\n";
552 $s .= '<div><a href="' . $action . '" rel="search">' . wfMessage( 'powersearch-legend' )->escaped() . "</a></div>\n";