Merge "CologneBlue rewrite: kill mWatchLinkNum, watchThisPage() is only called once...
[lhc/web/wiklou.git] / skins / CologneBlue.php
1 <?php
2 /**
3 * Cologne Blue: A nicer-looking alternative to Standard.
4 *
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.
9 *
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.
14 *
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
19 *
20 * @todo document
21 * @file
22 * @ingroup Skins
23 */
24
25 if( !defined( 'MEDIAWIKI' ) ) {
26 die( -1 );
27 }
28
29 /**
30 * @todo document
31 * @ingroup Skins
32 */
33 class SkinCologneBlue extends SkinTemplate {
34 var $skinname = 'cologneblue', $stylename = 'cologneblue',
35 $template = 'CologneBlueTemplate';
36 var $useHeadElement = true;
37
38 /**
39 * @param $out OutputPage
40 */
41 function setupSkinUserCss( OutputPage $out ){
42 $out->addModuleStyles( 'mediawiki.legacy.shared' );
43 $out->addModuleStyles( 'mediawiki.legacy.oldshared' );
44 $out->addModuleStyles( 'skins.cologneblue' );
45 }
46
47 }
48
49 class CologneBlueTemplate extends BaseTemplate {
50 function execute() {
51 $this->html( 'headelement' );
52 echo $this->beforeContent();
53 $this->html( 'bodytext' );
54 echo "\n";
55 echo $this->afterContent();
56 $this->html( 'dataAfterContent' );
57 $this->printTrail();
58 echo "\n</body></html>";
59 }
60
61
62 /**
63 * Language/charset variant links for classic-style skins
64 * @return string
65 */
66 function variantLinks() {
67 $s = '';
68
69 /* show links to different language variants */
70 global $wgDisableLangConversion, $wgLang;
71
72 $title = $this->getSkin()->getTitle();
73 $lang = $title->getPageLanguage();
74 $variants = $lang->getVariants();
75
76 if ( !$wgDisableLangConversion && sizeof( $variants ) > 1
77 && !$title->isSpecialPage() ) {
78 foreach ( $variants as $code ) {
79 $varname = $lang->getVariantname( $code );
80
81 if ( $varname == 'disable' ) {
82 continue;
83 }
84 $s = $wgLang->pipeList( array(
85 $s,
86 '<a href="' . htmlspecialchars( $title->getLocalURL( 'variant=' . $code ) ) . '" lang="' . $code . '" hreflang="' . $code . '">' . htmlspecialchars( $varname ) . '</a>'
87 ) );
88 }
89 }
90
91 return $s;
92 }
93
94 /**
95 * Compatibility for extensions adding functionality through tabs.
96 * Eventually these old skins should be replaced with SkinTemplate-based
97 * versions, sigh...
98 * @return string
99 * @todo Exterminate! ...that, and replace it with normal SkinTemplate stuff
100 */
101 function extensionTabLinks() {
102 $tabs = array();
103 $out = '';
104 $s = array();
105 wfRunHooks( 'SkinTemplateTabs', array( $this->getSkin(), &$tabs ) );
106 foreach ( $tabs as $tab ) {
107 $s[] = Xml::element( 'a',
108 array( 'href' => $tab['href'] ),
109 $tab['text'] );
110 }
111
112 if ( count( $s ) ) {
113 global $wgLang;
114
115 $out = wfMessage( 'pipe-separator' )->escaped();
116 $out .= $wgLang->pipeList( $s );
117 }
118
119 return $out;
120 }
121
122 function otherLanguages() {
123 global $wgOut, $wgLang, $wgHideInterlanguageLinks;
124
125 if ( $wgHideInterlanguageLinks ) {
126 return '';
127 }
128
129 $a = $wgOut->getLanguageLinks();
130
131 if ( 0 == count( $a ) ) {
132 return '';
133 }
134
135 $s = wfMessage( 'otherlanguages' )->text() . wfMessage( 'colon-separator' )->text();
136 $first = true;
137
138 if ( $wgLang->isRTL() ) {
139 $s .= '<span dir="ltr">';
140 }
141
142 foreach ( $a as $l ) {
143 if ( !$first ) {
144 $s .= wfMessage( 'pipe-separator' )->escaped();
145 }
146
147 $first = false;
148
149 $nt = Title::newFromText( $l );
150 $text = Language::fetchLanguageName( $nt->getInterwiki() );
151
152 $s .= Html::element( 'a',
153 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
154 $text == '' ? $l : $text );
155 }
156
157 if ( $wgLang->isRTL() ) {
158 $s .= '</span>';
159 }
160
161 return $s;
162 }
163
164 function pageTitleLinks() {
165 global $wgOut, $wgUser, $wgRequest, $wgLang;
166
167 $oldid = $wgRequest->getVal( 'oldid' );
168 $diff = $wgRequest->getVal( 'diff' );
169 $action = $wgRequest->getText( 'action' );
170
171 $skin = $this->getSkin();
172 $title = $skin->getTitle();
173
174 $s[] = $this->printableLink();
175 $disclaimer = $skin->disclaimerLink(); # may be empty
176
177 if ( $disclaimer ) {
178 $s[] = $disclaimer;
179 }
180
181 $privacy = $skin->privacyLink(); # may be empty too
182
183 if ( $privacy ) {
184 $s[] = $privacy;
185 }
186
187 if ( $wgOut->isArticleRelated() ) {
188 if ( $title->getNamespace() == NS_FILE ) {
189 $image = wfFindFile( $title );
190
191 if ( $image ) {
192 $href = $image->getURL();
193 $s[] = Html::element( 'a', array( 'href' => $href,
194 'title' => $href ), $title->getText() );
195
196 }
197 }
198 }
199
200 if ( 'history' == $action || isset( $diff ) || isset( $oldid ) ) {
201 $s[] .= Linker::linkKnown(
202 $title,
203 wfMessage( 'currentrev' )->text()
204 );
205 }
206
207 if ( $wgUser->getNewtalk() ) {
208 # do not show "You have new messages" text when we are viewing our
209 # own talk page
210 if ( !$title->equals( $wgUser->getTalkPage() ) ) {
211 $tl = Linker::linkKnown(
212 $wgUser->getTalkPage(),
213 wfMessage( 'newmessageslink' )->escaped(),
214 array(),
215 array( 'redirect' => 'no' )
216 );
217
218 $dl = Linker::linkKnown(
219 $wgUser->getTalkPage(),
220 wfMessage( 'newmessagesdifflink' )->escaped(),
221 array(),
222 array( 'diff' => 'cur' )
223 );
224 $s[] = '<strong>' . wfMessage( 'youhavenewmessages', $tl, $dl )->text() . '</strong>';
225 # disable caching
226 $wgOut->setSquidMaxage( 0 );
227 $wgOut->enableClientCache( false );
228 }
229 }
230
231 $undelete = $skin->getUndeleteLink();
232
233 if ( !empty( $undelete ) ) {
234 $s[] = $undelete;
235 }
236
237 return $wgLang->pipeList( $s );
238 }
239
240 function printableLink() {
241 global $wgOut, $wgRequest, $wgLang;
242
243 $s = array();
244
245 if ( !$wgOut->isPrintable() ) {
246 $printurl = htmlspecialchars( $this->getSkin()->getTitle()->getLocalUrl(
247 $wgRequest->appendQueryValue( 'printable', 'yes', true ) ) );
248 $s[] = "<a href=\"$printurl\" rel=\"alternate\">"
249 . wfMessage( 'printableversion' )->text() . '</a>';
250 }
251
252 if ( $wgOut->isSyndicated() ) {
253 foreach ( $wgOut->getSyndicationLinks() as $format => $link ) {
254 $feedurl = htmlspecialchars( $link );
255 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
256 . " class=\"feedlink\">" . wfMessage( "feed-$format" )->escaped() . "</a>";
257 }
258 }
259 return $wgLang->pipeList( $s );
260 }
261
262 /**
263 * Gets the h1 element with the page title.
264 * @return string
265 */
266 function pageTitle() {
267 global $wgOut;
268 $s = '<h1 class="pagetitle"><span dir="auto">' . $wgOut->getPageTitle() . '</span></h1>';
269 return $s;
270 }
271
272 function pageSubtitle() {
273 global $wgOut;
274
275 $sub = $wgOut->getSubtitle();
276
277 if ( $sub == '' ) {
278 global $wgExtraSubtitle;
279 $sub = wfMessage( 'tagline' )->parse() . $wgExtraSubtitle;
280 }
281
282 $subpages = $this->getSkin()->subPageSubtitle();
283 $sub .= !empty( $subpages ) ? "</p><p class='subpages'>$subpages" : '';
284 $s = "<p class='subtitle'>{$sub}</p>\n";
285
286 return $s;
287 }
288
289 function bottomLinks() {
290 global $wgOut, $wgUser;
291 $sep = wfMessage( 'pipe-separator' )->escaped() . "\n";
292
293 $s = '';
294 if ( $wgOut->isArticleRelated() ) {
295 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
296
297 if ( $wgUser->isLoggedIn() ) {
298 $element[] = $this->watchThisPage();
299 }
300
301 $element[] = $this->talkLink();
302 $element[] = $this->historyLink();
303 $element[] = $this->whatLinksHere();
304 $element[] = $this->watchPageLinksLink();
305
306 $title = $this->getSkin()->getTitle();
307
308 if (
309 $title->getNamespace() == NS_USER ||
310 $title->getNamespace() == NS_USER_TALK
311 ) {
312 $id = User::idFromName( $title->getText() );
313 $ip = User::isIP( $title->getText() );
314
315 # Both anons and non-anons have contributions list
316 if ( $id || $ip ) {
317 $element[] = $this->userContribsLink();
318 }
319
320 if ( $this->getSkin()->showEmailUser( $id ) ) {
321 $element[] = $this->emailUserLink();
322 }
323 }
324
325 $s = implode( $element, $sep );
326
327 if ( $title->getArticleID() ) {
328 $s .= "\n<br />";
329
330 // Delete/protect/move links for privileged users
331 if ( $wgUser->isAllowed( 'delete' ) ) {
332 $s .= $this->deleteThisPage();
333 }
334
335 if ( $wgUser->isAllowed( 'protect' ) ) {
336 $s .= $sep . $this->protectThisPage();
337 }
338
339 if ( $wgUser->isAllowed( 'move' ) ) {
340 $s .= $sep . $this->moveThisPage();
341 }
342 }
343
344 $s .= "<br />\n" . $this->otherLanguages();
345 }
346
347 return $s;
348 }
349
350 function editThisPage() {
351 global $wgOut;
352
353 if ( !$wgOut->isArticleRelated() ) {
354 $s = wfMessage( 'protectedpage' )->text();
355 } else {
356 $title = $this->getSkin()->getTitle();
357 if ( $title->quickUserCan( 'edit' ) && $title->exists() ) {
358 $t = wfMessage( 'editthispage' )->text();
359 } elseif ( $title->quickUserCan( 'create' ) && !$title->exists() ) {
360 $t = wfMessage( 'create-this-page' )->text();
361 } else {
362 $t = wfMessage( 'viewsource' )->text();
363 }
364
365 $s = Linker::linkKnown(
366 $title,
367 $t,
368 array(),
369 $this->getSkin()->editUrlOptions()
370 );
371 }
372
373 return $s;
374 }
375
376 function deleteThisPage() {
377 global $wgUser, $wgRequest;
378
379 $diff = $wgRequest->getVal( 'diff' );
380 $title = $this->getSkin()->getTitle();
381
382 if ( $title->getArticleID() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
383 $t = wfMessage( 'deletethispage' )->text();
384
385 $s = Linker::linkKnown(
386 $title,
387 $t,
388 array(),
389 array( 'action' => 'delete' )
390 );
391 } else {
392 $s = '';
393 }
394
395 return $s;
396 }
397
398 function protectThisPage() {
399 global $wgUser, $wgRequest;
400
401 $diff = $wgRequest->getVal( 'diff' );
402 $title = $this->getSkin()->getTitle();
403
404 if ( $title->getArticleID() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
405 if ( $title->isProtected() ) {
406 $text = wfMessage( 'unprotectthispage' )->text();
407 $query = array( 'action' => 'unprotect' );
408 } else {
409 $text = wfMessage( 'protectthispage' )->text();
410 $query = array( 'action' => 'protect' );
411 }
412
413 $s = Linker::linkKnown(
414 $title,
415 $text,
416 array(),
417 $query
418 );
419 } else {
420 $s = '';
421 }
422
423 return $s;
424 }
425
426 function watchThisPage() {
427 global $wgOut, $wgUser;
428
429 // Cache
430 $title = $this->getSkin()->getTitle();
431
432 if ( $wgOut->isArticleRelated() ) {
433 if ( $wgUser->isWatched( $title ) ) {
434 $text = wfMessage( 'unwatchthispage' )->text();
435 $query = array(
436 'action' => 'unwatch',
437 'token' => UnwatchAction::getUnwatchToken( $title, $wgUser ),
438 );
439 $id = 'mw-unwatch-link';
440 } else {
441 $text = wfMessage( 'watchthispage' )->text();
442 $query = array(
443 'action' => 'watch',
444 'token' => WatchAction::getWatchToken( $title, $wgUser ),
445 );
446 $id = 'mw-watch-link';
447 }
448
449 $s = Linker::linkKnown(
450 $title,
451 $text,
452 array( 'id' => $id ),
453 $query
454 );
455 } else {
456 $s = wfMessage( 'notanarticle' )->text();
457 }
458
459 return $s;
460 }
461
462 function moveThisPage() {
463 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
464 return Linker::linkKnown(
465 SpecialPage::getTitleFor( 'Movepage' ),
466 wfMessage( 'movethispage' )->text(),
467 array(),
468 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() )
469 );
470 } else {
471 // no message if page is protected - would be redundant
472 return '';
473 }
474 }
475
476 function historyLink() {
477 return Linker::link(
478 $this->getSkin()->getTitle(),
479 wfMessage( 'history' )->escaped(),
480 array( 'rel' => 'archives' ),
481 array( 'action' => 'history' )
482 );
483 }
484
485 function whatLinksHere() {
486 return Linker::linkKnown(
487 SpecialPage::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
488 wfMessage( 'whatlinkshere' )->escaped()
489 );
490 }
491
492 function userContribsLink() {
493 return Linker::linkKnown(
494 SpecialPage::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
495 wfMessage( 'contributions' )->escaped()
496 );
497 }
498
499 function emailUserLink() {
500 return Linker::linkKnown(
501 SpecialPage::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
502 wfMessage( 'emailuser' )->escaped()
503 );
504 }
505
506 function watchPageLinksLink() {
507 global $wgOut;
508
509 if ( !$wgOut->isArticleRelated() ) {
510 return wfMessage( 'parentheses', wfMessage( 'notanarticle' )->text() )->escaped();
511 } else {
512 return Linker::linkKnown(
513 SpecialPage::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
514 wfMessage( 'recentchangeslinked-toolbox' )->escaped()
515 );
516 }
517 }
518
519 function talkLink() {
520 $title = $this->getSkin()->getTitle();
521 if ( NS_SPECIAL == $title->getNamespace() ) {
522 # No discussion links for special pages
523 return '';
524 }
525
526 $linkOptions = array();
527
528 if ( $title->isTalkPage() ) {
529 $link = $title->getSubjectPage();
530 switch( $link->getNamespace() ) {
531 case NS_MAIN:
532 $text = wfMessage( 'articlepage' );
533 break;
534 case NS_USER:
535 $text = wfMessage( 'userpage' );
536 break;
537 case NS_PROJECT:
538 $text = wfMessage( 'projectpage' );
539 break;
540 case NS_FILE:
541 $text = wfMessage( 'imagepage' );
542 # Make link known if image exists, even if the desc. page doesn't.
543 if ( wfFindFile( $link ) )
544 $linkOptions[] = 'known';
545 break;
546 case NS_MEDIAWIKI:
547 $text = wfMessage( 'mediawikipage' );
548 break;
549 case NS_TEMPLATE:
550 $text = wfMessage( 'templatepage' );
551 break;
552 case NS_HELP:
553 $text = wfMessage( 'viewhelppage' );
554 break;
555 case NS_CATEGORY:
556 $text = wfMessage( 'categorypage' );
557 break;
558 default:
559 $text = wfMessage( 'articlepage' );
560 }
561 } else {
562 $link = $title->getTalkPage();
563 $text = wfMessage( 'talkpage' );
564 }
565
566 $s = Linker::link( $link, $text->text(), array(), array(), $linkOptions );
567
568 return $s;
569 }
570
571 function pageStats() {
572 $ret = array();
573 $items = array( 'viewcount', 'credits', 'lastmod', 'numberofwatchingusers', 'copyright' );
574
575 foreach( $items as $item ) {
576 if ( $this->data[$item] !== false ) {
577 $ret[] = $this->data[$item];
578 }
579 }
580
581 return implode( ' ', $ret );
582 }
583
584
585
586
587
588 /**
589 * @return string
590 */
591 function beforeContent() {
592 $mainPageObj = Title::newMainPage();
593
594 $s = "\n<div id='content'>\n<div id='topbar'>" .
595 '<table style="width: 100%;" cellspacing="0" cellpadding="8"><tr>';
596
597 $s .= '<td class="top" nowrap="nowrap">';
598 $s .= '<a href="' . htmlspecialchars( $mainPageObj->getLocalURL() ) . '">';
599 $s .= '<span id="sitetitle">' . wfMessage( 'sitetitle' )->escaped() . '</span></a>';
600
601 $s .= '</td><td class="top" id="top-syslinks" style="width: 100%;">';
602 $s .= $this->sysLinks();
603 $s .= '</td></tr><tr><td class="top-subheader">';
604
605 $s .= '<font size="-1"><span id="sitesub">';
606 $s .= wfMessage( 'sitesubtitle' )->escaped() . '</span></font>';
607 $s .= '</td><td class="top-linkcollection">';
608
609 $s .= '<font size="-1"><span id="langlinks">';
610 $s .= str_replace( '<br />', '', $this->otherLanguages() );
611
612 $s .= $this->getSkin()->getCategories();
613
614 $s .= '<br />' . $this->pageTitleLinks();
615 $s .= '</span></font>';
616
617 $s .= "</td></tr></table>\n";
618
619 $s .= "\n</div>\n<div id='article'>";
620
621 $notice = $this->getSkin()->getSiteNotice();
622 if( $notice ) {
623 $s .= "\n<div id='siteNotice'>$notice</div>\n";
624 }
625 $s .= $this->pageTitle();
626 $s .= $this->pageSubtitle() . "\n";
627 return $s;
628 }
629
630 /**
631 * @return string
632 */
633 function afterContent(){
634 $s = "\n</div><br clear='all' />\n";
635
636 $s .= "\n<div id='footer'>";
637 $s .= '<table style="width: 98%;" cellspacing="0"><tr>';
638
639 $s .= '<td class="bottom">';
640
641 $s .= $this->bottomLinks();
642 $s .= $this->getSkin()->getLanguage()->pipeList( array(
643 "\n<br />" . Linker::linkKnown(
644 Title::newMainPage()
645 ),
646 $this->getSkin()->aboutLink(),
647 $this->searchForm( 'afterContent' )
648 ) );
649
650 $s .= "\n<br />" . $this->pageStats();
651
652 $s .= '</td>';
653 $s .= "</tr></table>\n</div>\n</div>\n";
654
655 $s .= $this->quickBar();
656 return $s;
657 }
658
659 /**
660 * @return string
661 */
662 function sysLinks() {
663 $li = SpecialPage::getTitleFor( 'Userlogin' );
664 $lo = SpecialPage::getTitleFor( 'Userlogout' );
665
666 $rt = $this->getSkin()->getTitle()->getPrefixedURL();
667 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
668 $q = array();
669 } else {
670 $q = array( 'returnto' => $rt );
671 }
672
673 $s = array(
674 $this->getSkin()->mainPageLink(),
675 Linker::linkKnown(
676 Title::newFromText( wfMessage( 'aboutpage' )->inContentLanguage()->text() ),
677 wfMessage( 'about' )->text()
678 ),
679 Linker::linkKnown(
680 Title::newFromText( wfMessage( 'helppage' )->inContentLanguage()->text() ),
681 wfMessage( 'help' )->text()
682 ),
683 Linker::linkKnown(
684 Title::newFromText( wfMessage( 'faqpage' )->inContentLanguage()->text() ),
685 wfMessage( 'faq' )->text()
686 ),
687 Linker::specialLink( 'Specialpages' )
688 );
689
690 /* show links to different language variants */
691 if( $this->variantLinks() ) {
692 $s[] = $this->variantLinks();
693 }
694 if( $this->extensionTabLinks() ) {
695 $s[] = $this->extensionTabLinks();
696 }
697 if ( $this->data['loggedin'] ) {
698 $s[] = Linker::linkKnown(
699 $lo,
700 wfMessage( 'logout' )->text(),
701 array(),
702 $q
703 );
704 } else {
705 $s[] = Linker::linkKnown(
706 $li,
707 wfMessage( 'login' )->text(),
708 array(),
709 $q
710 );
711 }
712
713 return $this->getSkin()->getLanguage()->pipeList( $s );
714 }
715
716
717
718
719 /**
720 * @param $heading string
721 * @return string
722 *
723 * @fixed
724 */
725 function menuHead( $heading ) {
726 return "\n<h6>" . htmlspecialchars( $heading ) . "</h6>";
727 }
728
729 /**
730 * Compute the sidebar
731 * @access private
732 *
733 * @return string
734 *
735 * @fixed
736 */
737 function quickBar(){
738 $s = "\n<div id='quickbar'>";
739
740 $sep = "<br />\n";
741
742 $plain_bar = $this->data['sidebar'];
743 $bar = array();
744
745 // Massage the sidebar
746 // We want to place SEARCH at the beginning and a lot of stuff before TOOLBOX (or at the end, if it's missing)
747 $additions_done = false;
748 while ( !$additions_done ) {
749 $bar = array(); // Empty it out
750
751 // Always display search on top
752 $bar['SEARCH'] = true;
753
754 foreach ( $plain_bar as $heading => $links ) {
755 if ( $heading == 'TOOLBOX' ) {
756 if( $links !== NULL ) {
757 // If this is not a toolbox prosthetic we inserted outselves, fill it out
758 $plain_bar['TOOLBOX'] = $this->getToolbox();
759 }
760
761 // And insert the stuff
762
763 // "This page" and "Edit" menus
764 // We need to do some massaging here... we reuse all of the items, except for $...['views']['view'],
765 // as $...['namespaces']['main'] and $...['namespaces']['talk'] together serve the same purpose.
766 // We also don't use $...['variants'], these are displayed in the top menu.
767 $content_navigation = $this->data['content_navigation'];
768 $qbpageoptions = array_merge(
769 $content_navigation['namespaces'],
770 array(
771 'history' => $content_navigation['views']['history'],
772 'watch' => $content_navigation['actions']['watch'],
773 'unwatch' => $content_navigation['actions']['unwatch'],
774 )
775 );
776 $content_navigation['actions']['watch'] = null;
777 $content_navigation['actions']['unwatch'] = null;
778 $qbedit = array_merge(
779 array(
780 'edit' => $content_navigation['views']['edit'],
781 'addsection' => $content_navigation['views']['addsection'],
782 ),
783 $content_navigation['actions']
784 );
785 $bar['qbedit'] = $qbedit;
786 $bar['qbpageoptions'] = $qbpageoptions;
787
788 // Personal tools ("My pages")
789 $bar['qbmyoptions'] = $this->getPersonalTools();
790
791 $additions_done = true;
792 }
793
794 // Re-insert current heading, unless it's SEARCH
795 if ( $heading != 'SEARCH' ) {
796 $bar[$heading] = $plain_bar[$heading];
797 }
798 }
799
800 // If TOOLBOX is missing, $additions_done is still false
801 if ( !$additions_done ) {
802 $plain_bar['TOOLBOX'] = false;
803 }
804 }
805
806 foreach ( $bar as $heading => $links ) {
807 if ( $heading == 'SEARCH' ) {
808 $s .= $this->menuHead( wfMessage( 'qbfind' )->text() );
809 $s .= $this->searchForm( 'sidebar' );
810 } elseif ( $heading == 'LANGUAGES' ) {
811 // discard these; we display languages below page content
812 } else {
813 if ( $links ) {
814 // Use the navigation heading from standard sidebar as the "browse" section
815 if ( $heading == 'navigation' ) {
816 $heading = 'qbbrowse';
817 }
818 if ( $heading == 'TOOLBOX' ) {
819 $heading = 'toolbox';
820 }
821
822 $headingMsg = wfMessage( $heading );
823 $any_link = false;
824 $t = $this->menuHead( $headingMsg->exists() ? $headingMsg->text() : $heading );
825
826 foreach ( $links as $key => $link ) {
827 // Can be empty due to rampant sidebar massaging we're doing above
828 if ( $link ) {
829 $any_link = true;
830 $t .= $this->makeListItem( $key, $link, array( 'tag' => 'span' ) ) . $sep;
831 }
832 }
833
834 if ( $any_link ) {
835 $s .= $t;
836 }
837 }
838 }
839 }
840
841 $s .= $sep . "\n</div>\n";
842 return $s;
843 }
844
845 /**
846 * @param $label string
847 * @return string
848 *
849 * @fixed
850 */
851 function searchForm( $which ) {
852 global $wgUseTwoButtonsSearchForm;
853
854 $search = $this->getSkin()->getRequest()->getText( 'search' );
855 $action = $this->data['searchaction'];
856 $s = "<form id=\"searchform-" . htmlspecialchars($which) . "\" method=\"get\" class=\"inline\" action=\"$action\">";
857 if( $which == 'afterContent' ) {
858 $s .= wfMessage( 'qbfind' )->text() . ": ";
859 }
860
861 $s .= "<input type='text' class=\"mw-searchInput\" name=\"search\" size=\"14\" value=\""
862 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />"
863 . ($which == 'afterContent' ? " " : "<br />")
864 . "<input type='submit' class=\"searchButton\" name=\"go\" value=\"" . wfMessage( 'searcharticle' )->escaped() . "\" />";
865
866 if( $wgUseTwoButtonsSearchForm ) {
867 $s .= " <input type='submit' class=\"searchButton\" name=\"fulltext\" value=\"" . wfMessage( 'search' )->escaped() . "\" />\n";
868 } else {
869 $s .= '<div><a href="' . $action . '" rel="search">' . wfMessage( 'powersearch-legend' )->escaped() . "</a></div>\n";
870 }
871
872 $s .= '</form>';
873
874 return $s;
875 }
876 }