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