Fixed spacing in actions/cache/filebackend/filerepo/job folder
[mediawiki.git] / skins / CologneBlue.php
blob1669de78bb440c1230f57af95fb3fe4effbf390d
1 <?php
2 /**
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
20 * @todo document
21 * @file
22 * @ingroup Skins
25 if ( !defined( 'MEDIAWIKI' ) ) {
26 die( -1 );
29 /**
30 * @todo document
31 * @ingroup Skins
33 class SkinCologneBlue extends SkinTemplate {
34 var $skinname = 'cologneblue', $stylename = 'cologneblue',
35 $template = 'CologneBlueTemplate';
36 var $useHeadElement = true;
38 /**
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' );
47 /**
48 * Override langlink formatting behavior not to uppercase the language names.
49 * See otherLanguages() in CologneBlueTemplate.
51 function formatLanguageName( $name ) {
52 return $name;
56 class CologneBlueTemplate extends BaseTemplate {
57 function execute() {
58 // Suppress warnings to prevent notices about missing indexes in $this->data
59 wfSuppressWarnings();
60 $this->html( 'headelement' );
61 echo $this->beforeContent();
62 $this->html( 'bodytext' );
63 echo "\n";
64 echo $this->afterContent();
65 $this->html( 'dataAfterContent' );
66 $this->printTrail();
67 echo "\n</body></html>";
68 wfRestoreWarnings();
71 /**
72 * Language/charset variant links for classic-style skins
73 * @return string
75 function variantLinks() {
76 $s = array();
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 ) {
90 return "";
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 ) ) {
97 return "";
100 $s = array();
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() {
111 $s = array();
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
128 * @return string
130 function processBottomLink( $key, $navlink, $message = null ) {
131 if ( !$navlink ) {
132 // Empty navlinks might be passed.
133 return null;
136 if ( $message ) {
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'];
147 $lines = array();
149 if ( $this->getSkin()->getOutput()->isArticleRelated() ) {
150 // First row. Regular actions.
151 $element = array();
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.
174 $element = array();
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
199 return "";
202 $companionTitle = $title->isTalkPage() ? $title->getSubjectPage() : $title->getTalkPage();
203 $companionNamespace = $companionTitle->getNamespace();
205 // TODO these messages appear to only be used by CologneBlue and legacy skins,
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];
224 } else {
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'] );
257 } else {
258 $navlink['id'] = $idPrefix . $navlink['id'];
262 return $navlink;
266 * @return string
268 function beforeContent() {
269 ob_start();
271 <div id="content">
272 <div id="topbar">
273 <p id="sitetitle" role="banner">
274 <a href="<?php echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] ) ?>">
275 <?php echo wfMessage( 'sitetitle' )->escaped() ?>
276 </a>
277 </p>
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>
285 <?php } ?>
286 </div>
287 </div>
288 <div id="article" role="main">
289 <?php if ( $this->getSkin()->getSiteNotice() ) { ?>
290 <div id="siteNotice"><?php echo $this->getSkin()->getSiteNotice() ?></div>
291 <?php } ?>
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>
298 <?php } ?>
299 <?php if ( $this->getSkin()->getOutput()->getSubtitle() ) { ?>
300 <p class="subtitle"><?php echo $this->getSkin()->getOutput()->getSubtitle() ?></p>
301 <?php } ?>
302 <?php if ( $this->getSkin()->subPageSubtitle() ) { ?>
303 <p class="subpages"><?php echo $this->getSkin()->subPageSubtitle() ?></p>
304 <?php } ?>
305 <?php
306 $s = ob_get_contents();
307 ob_end_clean();
309 return $s;
313 * @return string
315 function afterContent() {
316 ob_start();
318 </div>
319 <div id="footer" role="contentinfo">
320 <?php
321 // Page-related links
322 echo $this->bottomLinks();
323 echo "\n<br />";
325 // Footer and second searchbox
326 echo $this->getSkin()->getLanguage()->pipeList( array(
327 $this->getSkin()->mainPageLink(),
328 $this->getSkin()->aboutLink(),
329 $this->searchForm( 'footer' )
330 ) );
331 echo "\n<br />";
333 // Standard footer info
334 $footlinks = $this->getFooterLinks();
335 if ( $footlinks['info'] ) {
336 foreach ( $footlinks['info'] as $item ) {
337 echo $this->data[$item] . ' ';
341 </div>
342 </div>
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>
348 </div>
349 <?php echo $this->quickBar() ?>
350 </div>
351 <?php
352 $s = ob_get_contents();
353 ob_end_clean();
355 return $s;
359 * @return string
361 function sysLinks() {
362 $s = array(
363 $this->getSkin()->mainPageLink(),
364 Linker::linkKnown(
365 Title::newFromText( wfMessage( 'aboutpage' )->inContentLanguage()->text() ),
366 wfMessage( 'about' )->text()
368 Linker::linkKnown(
369 Title::newFromText( wfMessage( 'helppage' )->inContentLanguage()->text() ),
370 wfMessage( 'help' )->text()
372 Linker::linkKnown(
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'],
402 array(
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(
411 array(
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;
429 return $bar;
433 * Compute the sidebar
434 * @access private
436 * @return string
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'];
444 $bar = array();
445 $hasToolbox = false;
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' ) {
452 // Insert the stuff
453 $bar = $this->sidebarAdditions( $bar );
454 $hasToolbox = true;
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
468 $orig_bar = $bar;
469 $bar = array();
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();
475 } else {
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',
486 'tb' => 'toolbox',
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>";
498 $listHTML = "";
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
504 if ( $link ) {
505 $listHTML .= $this->makeListItem( $key, $link );
508 if ( $listHTML ) {
509 $listHTML = "<ul>$listHTML</ul>";
511 } else {
512 // $data is a HTML <ul>-list string
513 $listHTML = $data;
516 if ( $listHTML ) {
517 $role = ( $heading == 'search' ) ? 'search' : 'navigation';
518 $s .= "<div class=\"portlet\" id=\"$portletId\" role=\"$role\">\n$headingHTML\n$listHTML\n</div>\n";
522 $s .= "</div>\n";
523 return $s;
527 * @param $label string
528 * @return 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";
547 } else {
548 $s .= '<div><a href="' . $action . '" rel="search">' . wfMessage( 'powersearch-legend' )->escaped() . "</a></div>\n";
551 $s .= '</form>';
553 return $s;