Meaningful error message when all servers are busy
[lhc/web/wiklou.git] / includes / Skin.php
1 <?php
2
3 /**
4 *
5 * @package MediaWiki
6 * @subpackage Skins
7 */
8
9 /**
10 * This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
11 */
12 if( defined( "MEDIAWIKI" ) ) {
13
14 # See skin.txt
15 require_once( 'Linker.php' );
16 require_once( 'Image.php' );
17
18 # Get a list of all skins available in /skins/
19 # Build using the regular expression '^(.*).php$'
20 # Array keys are all lower case, array value keep the case used by filename
21 #
22
23 $skinDir = dir($IP.'/skins');
24
25 # while code from www.php.net
26 while (false !== ($file = $skinDir->read())) {
27 if(preg_match('/^([^.].*)\.php$/',$file, $matches)) {
28 $aSkin = $matches[1];
29 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
30 }
31 }
32 $skinDir->close();
33 unset($matches);
34
35 require_once( 'RecentChange.php' );
36
37 /**
38 * @todo document
39 * @package MediaWiki
40 */
41 class RCCacheEntry extends RecentChange
42 {
43 var $secureName, $link;
44 var $curlink , $difflink, $lastlink , $usertalklink , $versionlink ;
45 var $userlink, $timestamp, $watched;
46
47 function newFromParent( $rc )
48 {
49 $rc2 = new RCCacheEntry;
50 $rc2->mAttribs = $rc->mAttribs;
51 $rc2->mExtra = $rc->mExtra;
52 return $rc2;
53 }
54 } ;
55
56
57 /**
58 * The main skin class that provide methods and properties for all other skins
59 * including PHPTal skins.
60 * This base class is also the "Standard" skin.
61 * @package MediaWiki
62 */
63 class Skin extends Linker {
64 /**#@+
65 * @access private
66 */
67 var $lastdate, $lastline;
68 var $rc_cache ; # Cache for Enhanced Recent Changes
69 var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle
70 var $rcMoveIndex;
71 /**#@-*/
72
73 /** Constructor, call parent constructor */
74 function Skin() { parent::Linker(); }
75
76 function getSkinNames() {
77 global $wgValidSkinNames;
78 return $wgValidSkinNames;
79 }
80
81 /** @return string path to the skin stylesheet */
82 function getStylesheet() { return 'common/wikistandard.css'; }
83
84 /** @return string skin name */
85 function getSkinName() {
86 return 'standard';
87 }
88
89 function qbSetting() {
90 global $wgOut, $wgUser;
91
92 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
93 $q = $wgUser->getOption( 'quickbar' );
94 if ( '' == $q ) { $q = 0; }
95 return $q;
96 }
97
98 function initPage( &$out ) {
99 $fname = 'Skin::initPage';
100 wfProfileIn( $fname );
101
102 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => '/favicon.ico' ) );
103
104 $this->addMetadataLinks($out);
105
106 wfProfileOut( $fname );
107 }
108
109 function addMetadataLinks( &$out ) {
110 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf, $wgRdfMimeType, $action;
111 global $wgRightsPage, $wgRightsUrl, $wgUseTrackbacks;
112
113 if( $out->isArticleRelated() ) {
114 # note: buggy CC software only reads first "meta" link
115 if( $wgEnableCreativeCommonsRdf ) {
116 $out->addMetadataLink( array(
117 'title' => 'Creative Commons',
118 'type' => 'application/rdf+xml',
119 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
120 }
121 if( $wgEnableDublinCoreRdf ) {
122 $out->addMetadataLink( array(
123 'title' => 'Dublin Core',
124 'type' => 'application/rdf+xml',
125 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
126 }
127 }
128 $copyright = '';
129 if( $wgRightsPage ) {
130 $copy = Title::newFromText( $wgRightsPage );
131 if( $copy ) {
132 $copyright = $copy->getLocalURL();
133 }
134 }
135 if( !$copyright && $wgRightsUrl ) {
136 $copyright = $wgRightsUrl;
137 }
138 if( $copyright ) {
139 $out->addLink( array(
140 'rel' => 'copyright',
141 'href' => $copyright ) );
142 }
143 }
144
145 function outputPage( &$out ) {
146 global $wgDebugComments;
147
148 wfProfileIn( 'Skin::outputPage' );
149 $this->initPage( $out );
150
151 $out->out( $out->headElement() );
152
153 $out->out( "\n<body" );
154 $ops = $this->getBodyOptions();
155 foreach ( $ops as $name => $val ) {
156 $out->out( " $name='$val'" );
157 }
158 $out->out( ">\n" );
159 if ( $wgDebugComments ) {
160 $out->out( "<!-- Wiki debugging output:\n" .
161 $out->mDebugtext . "-->\n" );
162 }
163
164 $out->out( $this->beforeContent() );
165
166 $out->out( $out->mBodytext . "\n" );
167
168 $out->out( $this->afterContent() );
169
170 wfProfileClose();
171 $out->out( $out->reportTime() );
172
173 $out->out( "\n</body></html>" );
174 }
175
176 function getHeadScripts() {
177 global $wgStylePath, $wgUser, $wgContLang, $wgAllowUserJs, $wgJsMimeType;
178 $r = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
179 if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
180 $userpage = $wgUser->getUserPage();
181 $userjs = htmlspecialchars( $this->makeUrl(
182 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
183 'action=raw&ctype='.$wgJsMimeType));
184 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
185 }
186 return $r;
187 }
188
189 /**
190 * To make it harder for someone to slip a user a fake
191 * user-JavaScript or user-CSS preview, a random token
192 * is associated with the login session. If it's not
193 * passed back with the preview request, we won't render
194 * the code.
195 *
196 * @param string $action
197 * @return bool
198 * @access private
199 */
200 function userCanPreview( $action ) {
201 global $wgTitle, $wgRequest, $wgUser;
202
203 if( $action != 'submit' )
204 return false;
205 if( !$wgRequest->wasPosted() )
206 return false;
207 if( !$wgTitle->userCanEditCssJsSubpage() )
208 return false;
209 return $wgUser->matchEditToken(
210 $wgRequest->getVal( 'wpEditToken' ) );
211 }
212
213 # get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way)
214 function getUserStylesheet() {
215 global $wgOut, $wgStylePath, $wgContLang, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
216 $sheet = $this->getStylesheet();
217 $action = $wgRequest->getText('action');
218 $s = "@import \"$wgStylePath/$sheet\";\n";
219 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css\";\n";
220 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
221 if($wgTitle->isCssSubpage() && $this->userCanPreview( $action ) ) {
222 $s .= $wgRequest->getText('wpTextbox1');
223 } else {
224 $userpage = $wgUser->getUserPage();
225 $s.= '@import "'.$this->makeUrl(
226 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
227 'action=raw&ctype=text/css').'";'."\n";
228 }
229 }
230 $s .= $this->doGetUserStyles();
231 return $s."\n";
232 }
233
234 /**
235 * placeholder, returns generated js in monobook
236 */
237 function getUserJs() { return; }
238
239 /**
240 * Return html code that include User stylesheets
241 */
242 function getUserStyles() {
243 global $wgOut, $wgStylePath, $wgLang;
244 $s = "<style type='text/css'>\n";
245 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
246 $s .= $this->getUserStylesheet();
247 $s .= "/*]]>*/ /* */\n";
248 $s .= "</style>\n";
249 return $s;
250 }
251
252 /**
253 * Some styles that are set by user through the user settings interface.
254 */
255 function doGetUserStyles() {
256 global $wgUser, $wgContLang, $wgSquidMaxage;
257
258 $query = "action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
259 $s = '@import "' . $this->makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI ) . "\";\n" .
260 '@import "'.$this->makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI ) . "\";\n";
261
262 return $s . $this->reallyDoGetUserStyles();
263 }
264
265 function reallyDoGetUserStyles() {
266 global $wgUser;
267 $s = '';
268 if (($undopt = $wgUser->getOption("underline")) != 2) {
269 $underline = $undopt ? 'underline' : 'none';
270 $s .= "a { text-decoration: $underline; }\n";
271 }
272 if( $wgUser->getOption( 'highlightbroken' ) ) {
273 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
274 } else {
275 $s .= <<<END
276 a.new, #quickbar a.new,
277 a.stub, #quickbar a.stub {
278 color: inherit;
279 text-decoration: inherit;
280 }
281 a.new:after, #quickbar a.new:after {
282 content: "?";
283 color: #CC2200;
284 text-decoration: $underline;
285 }
286 a.stub:after, #quickbar a.stub:after {
287 content: "!";
288 color: #772233;
289 text-decoration: $underline;
290 }
291 END;
292 }
293 if( $wgUser->getOption( 'justify' ) ) {
294 $s .= "#article, #bodyContent { text-align: justify; }\n";
295 }
296 if( !$wgUser->getOption( 'showtoc' ) ) {
297 $s .= "#toc { display: none; }\n";
298 }
299 if( !$wgUser->getOption( 'editsection' ) ) {
300 $s .= ".editsection { display: none; }\n";
301 }
302 return $s;
303 }
304
305 function getBodyOptions() {
306 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
307
308 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
309
310 if ( 0 != $wgTitle->getNamespace() ) {
311 $a = array( 'bgcolor' => '#ffffec' );
312 }
313 else $a = array( 'bgcolor' => '#FFFFFF' );
314 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
315 $wgTitle->userCanEdit() ) {
316 $t = wfMsg( 'editthispage' );
317 $oid = $red = '';
318 if ( !empty($redirect) && $redirect == 'no' ) {
319 $red = "&redirect={$redirect}";
320 }
321 if ( !empty($oldid) && ! isset( $diff ) ) {
322 $oid = "&oldid=" . intval( $oldid );
323 }
324 $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
325 $s = 'document.location = "' .$s .'";';
326 $a += array ('ondblclick' => $s);
327
328 }
329 $a['onload'] = $wgOut->getOnloadHandler();
330 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
331 if( $a['onload'] != '' ) {
332 $a['onload'] .= ';';
333 }
334 $a['onload'] .= 'setupRightClickEdit()';
335 }
336 return $a;
337 }
338
339 /**
340 * URL to the logo
341 */
342 function getLogo() {
343 global $wgLogo;
344 return $wgLogo;
345 }
346
347 /**
348 * This will be called immediately after the <body> tag. Split into
349 * two functions to make it easier to subclass.
350 */
351 function beforeContent() {
352 return $this->doBeforeContent();
353 }
354
355 function doBeforeContent() {
356 global $wgOut, $wgTitle, $wgContLang;
357 $fname = 'Skin::doBeforeContent';
358 wfProfileIn( $fname );
359
360 $s = '';
361 $qb = $this->qbSetting();
362
363 if( $langlinks = $this->otherLanguages() ) {
364 $rows = 2;
365 $borderhack = '';
366 } else {
367 $rows = 1;
368 $langlinks = false;
369 $borderhack = 'class="top"';
370 }
371
372 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
373 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
374
375 $shove = ($qb != 0);
376 $left = ($qb == 1 || $qb == 3);
377 if($wgContLang->isRTL()) $left = !$left;
378
379 if ( !$shove ) {
380 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
381 $this->logoText() . '</td>';
382 } elseif( $left ) {
383 $s .= $this->getQuickbarCompensator( $rows );
384 }
385 $l = $wgContLang->isRTL() ? 'right' : 'left';
386 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
387
388 $s .= $this->topLinks() ;
389 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
390
391 $r = $wgContLang->isRTL() ? "left" : "right";
392 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
393 $s .= $this->nameAndLogin();
394 $s .= "\n<br />" . $this->searchForm() . "</td>";
395
396 if ( $langlinks ) {
397 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
398 }
399
400 if ( $shove && !$left ) { # Right
401 $s .= $this->getQuickbarCompensator( $rows );
402 }
403 $s .= "</tr>\n</table>\n</div>\n";
404 $s .= "\n<div id='article'>\n";
405
406 $notice = wfGetSiteNotice();
407 if( $notice ) {
408 $s .= "\n<div id='siteNotice'>$notice</div>\n";
409 }
410 $s .= $this->pageTitle();
411 $s .= $this->pageSubtitle() ;
412 $s .= $this->getCategories();
413 wfProfileOut( $fname );
414 return $s;
415 }
416
417
418 function getCategoryLinks () {
419 global $wgOut, $wgTitle, $wgParser;
420 global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang;
421
422 if( !$wgUseCategoryMagic ) return '' ;
423 if( count( $wgOut->mCategoryLinks ) == 0 ) return '';
424
425 # Taken out so that they will be displayed in previews -- TS
426 #if( !$wgOut->isArticle() ) return '';
427
428 $t = implode ( ' | ' , $wgOut->mCategoryLinks ) ;
429 $s = $this->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Categories' ),
430 wfMsg( 'categories' ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
431 . ': ' . $t;
432
433 # optional 'dmoz-like' category browser. Will be shown under the list
434 # of categories an article belong to
435 if($wgUseCategoryBrowser) {
436 $s .= '<br /><hr />';
437
438 # get a big array of the parents tree
439 $parenttree = $wgTitle->getParentCategoryTree();
440 # Skin object passed by reference cause it can not be
441 # accessed under the method subfunction drawCategoryBrowser
442 $tempout = explode("\n", Skin::drawCategoryBrowser($parenttree, $this) );
443 # Clean out bogus first entry and sort them
444 unset($tempout[0]);
445 asort($tempout);
446 # Output one per line
447 $s .= implode("<br />\n", $tempout);
448 }
449
450 return $s;
451 }
452
453 /** Render the array as a serie of links.
454 * @param array $tree Categories tree returned by Title::getParentCategoryTree
455 * @param object &skin Skin passed by reference
456 * @return string separated by &gt;, terminate with "\n"
457 */
458 function drawCategoryBrowser($tree, &$skin) {
459 $return = '';
460 foreach ($tree as $element => $parent) {
461 if (empty($parent)) {
462 # element start a new list
463 $return .= "\n";
464 } else {
465 # grab the others elements
466 $return .= Skin::drawCategoryBrowser($parent, $skin) . ' &gt; ';
467 }
468 # add our current element to the list
469 $eltitle = Title::NewFromText($element);
470 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
471 }
472 return $return;
473 }
474
475 function getCategories() {
476 $catlinks=$this->getCategoryLinks();
477 if(!empty($catlinks)) {
478 return "<p class='catlinks'>{$catlinks}</p>";
479 }
480 }
481
482 function getQuickbarCompensator( $rows = 1 ) {
483 return "<td width='152' rowspan='{$rows}'>&nbsp;</td>";
484 }
485
486 /**
487 * This gets called immediately before the </body> tag.
488 * @return string HTML to be put after </body> ???
489 */
490 function afterContent() {
491 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
492 return $printfooter . $this->doAfterContent();
493 }
494
495 /** @return string Retrievied from HTML text */
496 function printSource() {
497 global $wgTitle;
498 $url = htmlspecialchars( $wgTitle->getFullURL() );
499 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
500 }
501
502 function printFooter() {
503 return "<p>" . $this->printSource() .
504 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
505 }
506
507 /** overloaded by derived classes */
508 function doAfterContent() { }
509
510 function pageTitleLinks() {
511 global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgRequest;
512
513 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
514 $action = $wgRequest->getText( 'action' );
515
516 $s = $this->printableLink();
517 $disclaimer = $this->disclaimerLink(); # may be empty
518 if( $disclaimer ) {
519 $s .= ' | ' . $disclaimer;
520 }
521
522 if ( $wgOut->isArticleRelated() ) {
523 if ( $wgTitle->getNamespace() == NS_IMAGE ) {
524 $name = $wgTitle->getDBkey();
525 $image = new Image( $wgTitle );
526 if( $image->exists() ) {
527 $link = htmlspecialchars( $image->getURL() );
528 $style = $this->getInternalLinkAttributes( $link, $name );
529 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
530 }
531 }
532 }
533 if ( 'history' == $action || isset( $diff ) || isset( $oldid ) ) {
534 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
535 wfMsg( 'currentrev' ) );
536 }
537
538 if ( $wgUser->getNewtalk() ) {
539 # do not show "You have new messages" text when we are viewing our
540 # own talk page
541
542 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
543 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
544 wfMsg('newmessageslink') );
545 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
546 # disable caching
547 $wgOut->setSquidMaxage(0);
548 $wgOut->enableClientCache(false);
549 }
550 }
551
552 $undelete = $this->getUndeleteLink();
553 if( !empty( $undelete ) ) {
554 $s .= ' | '.$undelete;
555 }
556 return $s;
557 }
558
559 function getUndeleteLink() {
560 global $wgUser, $wgTitle, $wgContLang, $action;
561 if( (($wgTitle->getArticleId() == 0) || ($action == "history")) &&
562 ($n = $wgTitle->isDeleted() ) )
563 {
564 if ( $wgUser->isAllowed( 'delete' ) ) {
565 $msg = 'thisisdeleted';
566 } else {
567 $msg = 'viewdeleted';
568 }
569 return wfMsg( $msg,
570 $this->makeKnownLink(
571 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
572 wfMsg( 'restorelink' . ($n == 1 ? '1' : ''), $n ) ) );
573 }
574 return '';
575 }
576
577 function printableLink() {
578 global $wgOut, $wgFeedClasses, $wgRequest;
579
580 $baseurl = $_SERVER['REQUEST_URI'];
581 if( strpos( '?', $baseurl ) == false ) {
582 $baseurl .= '?';
583 } else {
584 $baseurl .= '&';
585 }
586 $baseurl = htmlspecialchars( $baseurl );
587 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
588
589 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
590 if( $wgOut->isSyndicated() ) {
591 foreach( $wgFeedClasses as $format => $class ) {
592 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
593 $s .= " | <a href=\"$feedurl\">{$format}</a>";
594 }
595 }
596 return $s;
597 }
598
599 function pageTitle() {
600 global $wgOut, $wgTitle, $wgUser;
601
602 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
603 return $s;
604 }
605
606 function pageSubtitle() {
607 global $wgOut;
608
609 $sub = $wgOut->getSubtitle();
610 if ( '' == $sub ) {
611 global $wgExtraSubtitle;
612 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
613 }
614 $subpages = $this->subPageSubtitle();
615 $sub .= !empty($subpages)?"</p><p class='subpages'>$subpages":'';
616 $s = "<p class='subtitle'>{$sub}</p>\n";
617 return $s;
618 }
619
620 function subPageSubtitle() {
621 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
622 $subpages = '';
623 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
624 $ptext=$wgTitle->getPrefixedText();
625 if(preg_match('/\//',$ptext)) {
626 $links = explode('/',$ptext);
627 $c = 0;
628 $growinglink = '';
629 foreach($links as $link) {
630 $c++;
631 if ($c<count($links)) {
632 $growinglink .= $link;
633 $getlink = $this->makeLink( $growinglink, $link );
634 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
635 if ($c>1) {
636 $subpages .= ' | ';
637 } else {
638 $subpages .= '&lt; ';
639 }
640 $subpages .= $getlink;
641 $growinglink .= '/';
642 }
643 }
644 }
645 }
646 return $subpages;
647 }
648
649 function nameAndLogin() {
650 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader;
651
652 $li = $wgContLang->specialPage( 'Userlogin' );
653 $lo = $wgContLang->specialPage( 'Userlogout' );
654
655 $s = '';
656 if ( $wgUser->isAnon() ) {
657 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
658 $n = wfGetIP();
659
660 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
661 $wgLang->getNsText( NS_TALK ) );
662
663 $s .= $n . ' ('.$tl.')';
664 } else {
665 $s .= wfMsg('notloggedin');
666 }
667
668 $rt = $wgTitle->getPrefixedURL();
669 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
670 $q = '';
671 } else { $q = "returnto={$rt}"; }
672
673 $s .= "\n<br />" . $this->makeKnownLinkObj(
674 Title::makeTitle( NS_SPECIAL, 'Userlogin' ),
675 wfMsg( 'login' ), $q );
676 } else {
677 $n = $wgUser->getName();
678 $rt = $wgTitle->getPrefixedURL();
679 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
680 $wgLang->getNsText( NS_TALK ) );
681
682 $tl = " ({$tl})";
683
684 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
685 $n ) . "{$tl}<br />" .
686 $this->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Userlogout' ), wfMsg( 'logout' ),
687 "returnto={$rt}" ) . ' | ' .
688 $this->specialLink( 'preferences' );
689 }
690 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
691 wfMsg( 'help' ) );
692
693 return $s;
694 }
695
696 function getSearchLink() {
697 $searchPage =& Title::makeTitle( NS_SPECIAL, 'Search' );
698 return $searchPage->getLocalURL();
699 }
700
701 function escapeSearchLink() {
702 return htmlspecialchars( $this->getSearchLink() );
703 }
704
705 function searchForm() {
706 global $wgRequest;
707 $search = $wgRequest->getText( 'search' );
708
709 $s = '<form name="search" class="inline" method="post" action="'
710 . $this->escapeSearchLink() . "\">\n"
711 . '<input type="text" name="search" size="19" value="'
712 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
713 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" />&nbsp;'
714 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
715
716 return $s;
717 }
718
719 function topLinks() {
720 global $wgOut;
721 $sep = " |\n";
722
723 $s = $this->mainPageLink() . $sep
724 . $this->specialLink( 'recentchanges' );
725
726 if ( $wgOut->isArticleRelated() ) {
727 $s .= $sep . $this->editThisPage()
728 . $sep . $this->historyLink();
729 }
730 # Many people don't like this dropdown box
731 #$s .= $sep . $this->specialPagesList();
732
733 /* show links to different language variants */
734 global $wgDisableLangConversion, $wgContLang, $wgTitle;
735 $variants = $wgContLang->getVariants();
736 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
737 foreach( $variants as $code ) {
738 $varname = $wgContLang->getVariantname( $code );
739 if( $varname == 'disable' )
740 continue;
741 $s .= ' | <a href="' . $wgTitle->getLocalUrl( 'variant=' . $code ) . '">' . $varname . '</a>';
742 }
743 }
744
745 return $s;
746 }
747
748 function bottomLinks() {
749 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
750 $sep = " |\n";
751
752 $s = '';
753 if ( $wgOut->isArticleRelated() ) {
754 $s .= '<strong>' . $this->editThisPage() . '</strong>';
755 if ( $wgUser->isLoggedIn() ) {
756 $s .= $sep . $this->watchThisPage();
757 }
758 $s .= $sep . $this->talkLink()
759 . $sep . $this->historyLink()
760 . $sep . $this->whatLinksHere()
761 . $sep . $this->watchPageLinksLink();
762
763 if ($wgUseTrackbacks)
764 $s .= $sep . $this->trackbackLink();
765
766 if ( $wgTitle->getNamespace() == NS_USER
767 || $wgTitle->getNamespace() == NS_USER_TALK )
768
769 {
770 $id=User::idFromName($wgTitle->getText());
771 $ip=User::isIP($wgTitle->getText());
772
773 if($id || $ip) { # both anons and non-anons have contri list
774 $s .= $sep . $this->userContribsLink();
775 }
776 if( $this->showEmailUser( $id ) ) {
777 $s .= $sep . $this->emailUserLink();
778 }
779 }
780 if ( $wgTitle->getArticleId() ) {
781 $s .= "\n<br />";
782 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
783 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
784 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
785 }
786 $s .= "<br />\n" . $this->otherLanguages();
787 }
788 return $s;
789 }
790
791 function pageStats() {
792 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
793 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
794
795 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
796 if ( ! $wgOut->isArticle() ) { return ''; }
797 if ( isset( $oldid ) || isset( $diff ) ) { return ''; }
798 if ( 0 == $wgArticle->getID() ) { return ''; }
799
800 $s = '';
801 if ( !$wgDisableCounters ) {
802 $count = $wgLang->formatNum( $wgArticle->getCount() );
803 if ( $count ) {
804 $s = wfMsg( 'viewcount', $count );
805 }
806 }
807
808 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
809 require_once('Credits.php');
810 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
811 } else {
812 $s .= $this->lastModified();
813 }
814
815 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
816 $dbr =& wfGetDB( DB_SLAVE );
817 extract( $dbr->tableNames( 'watchlist' ) );
818 $sql = "SELECT COUNT(*) AS n FROM $watchlist
819 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
820 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
821 $res = $dbr->query( $sql, 'Skin::pageStats');
822 $x = $dbr->fetchObject( $res );
823 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n );
824 }
825
826 return $s . ' ' . $this->getCopyright();
827 }
828
829 function getCopyright() {
830 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
831
832
833 $oldid = $wgRequest->getVal( 'oldid' );
834 $diff = $wgRequest->getVal( 'diff' );
835
836 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
837 $msg = 'history_copyright';
838 } else {
839 $msg = 'copyright';
840 }
841
842 $out = '';
843 if( $wgRightsPage ) {
844 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
845 } elseif( $wgRightsUrl ) {
846 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
847 } else {
848 # Give up now
849 return $out;
850 }
851 $out .= wfMsgForContent( $msg, $link );
852 return $out;
853 }
854
855 function getCopyrightIcon() {
856 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
857 $out = '';
858 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
859 $out = $wgCopyrightIcon;
860 } else if ( $wgRightsIcon ) {
861 $icon = htmlspecialchars( $wgRightsIcon );
862 if ( $wgRightsUrl ) {
863 $url = htmlspecialchars( $wgRightsUrl );
864 $out .= '<a href="'.$url.'">';
865 }
866 $text = htmlspecialchars( $wgRightsText );
867 $out .= "<img src=\"$icon\" alt='$text' />";
868 if ( $wgRightsUrl ) {
869 $out .= '</a>';
870 }
871 }
872 return $out;
873 }
874
875 function getPoweredBy() {
876 global $wgStylePath;
877 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
878 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
879 return $img;
880 }
881
882 function lastModified() {
883 global $wgLang, $wgArticle, $wgLoadBalancer;
884
885 $timestamp = $wgArticle->getTimestamp();
886 if ( $timestamp ) {
887 $d = $wgLang->timeanddate( $timestamp, true );
888 $s = ' ' . wfMsg( 'lastmodified', $d );
889 } else {
890 $s = '';
891 }
892 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
893 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
894 }
895 return $s;
896 }
897
898 function logoText( $align = '' ) {
899 if ( '' != $align ) { $a = " align='{$align}'"; }
900 else { $a = ''; }
901
902 $mp = wfMsg( 'mainpage' );
903 $titleObj = Title::newFromText( $mp );
904 if ( is_object( $titleObj ) ) {
905 $url = $titleObj->escapeLocalURL();
906 } else {
907 $url = '';
908 }
909
910 $logourl = $this->getLogo();
911 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
912 return $s;
913 }
914
915 /**
916 * show a drop-down box of special pages
917 * @TODO crash bug913. Need to be rewrote completly.
918 */
919 function specialPagesList() {
920 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript, $wgAvailableRights;
921 require_once('SpecialPage.php');
922 $a = array();
923 $pages = SpecialPage::getPages();
924
925 // special pages without access restriction
926 foreach ( $pages[''] as $name => $page ) {
927 $a[$name] = $page->getDescription();
928 }
929
930 // Other special pages that are restricted.
931 // Copied from SpecialSpecialpages.php
932 foreach($wgAvailableRights as $right) {
933 if( $wgUser->isAllowed($right) ) {
934 /** Add all pages for this right */
935 if(isset($pages[$right])) {
936 foreach($pages[$right] as $name => $page) {
937 $a[$name] = $page->getDescription();
938 }
939 }
940 }
941 }
942
943 $go = wfMsg( 'go' );
944 $sp = wfMsg( 'specialpages' );
945 $spp = $wgContLang->specialPage( 'Specialpages' );
946
947 $s = '<form id="specialpages" method="get" class="inline" ' .
948 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
949 $s .= "<select name=\"wpDropdown\">\n";
950 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
951
952
953 foreach ( $a as $name => $desc ) {
954 $p = $wgContLang->specialPage( $name );
955 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
956 }
957 $s .= "</select>\n";
958 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
959 $s .= "</form>\n";
960 return $s;
961 }
962
963 function mainPageLink() {
964 $mp = wfMsgForContent( 'mainpage' );
965 $mptxt = wfMsg( 'mainpage');
966 $s = $this->makeKnownLink( $mp, $mptxt );
967 return $s;
968 }
969
970 function copyrightLink() {
971 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
972 wfMsg( 'copyrightpagename' ) );
973 return $s;
974 }
975
976 function aboutLink() {
977 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
978 wfMsg( 'aboutsite' ) );
979 return $s;
980 }
981
982
983 function disclaimerLink() {
984 $disclaimers = wfMsg( 'disclaimers' );
985 if ($disclaimers == '-') {
986 return '';
987 } else {
988 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
989 $disclaimers );
990 }
991 }
992
993 function editThisPage() {
994 global $wgOut, $wgTitle, $wgRequest;
995
996 $oldid = $wgRequest->getVal( 'oldid' );
997 $diff = $wgRequest->getVal( 'diff' );
998 $redirect = $wgRequest->getVal( 'redirect' );
999
1000 if ( ! $wgOut->isArticleRelated() ) {
1001 $s = wfMsg( 'protectedpage' );
1002 } else {
1003 if ( $wgTitle->userCanEdit() ) {
1004 $t = wfMsg( 'editthispage' );
1005 } else {
1006 $t = wfMsg( 'viewsource' );
1007 }
1008 $oid = $red = '';
1009
1010 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
1011 if ( $oldid && ! isset( $diff ) ) {
1012 $oid = '&oldid='.$oldid;
1013 }
1014 $s = $this->makeKnownLinkObj( $wgTitle, $t, "action=edit{$oid}{$red}" );
1015 }
1016 return $s;
1017 }
1018
1019 function deleteThisPage() {
1020 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1021
1022 $diff = $wgRequest->getVal( 'diff' );
1023 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1024 $t = wfMsg( 'deletethispage' );
1025
1026 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1027 } else {
1028 $s = '';
1029 }
1030 return $s;
1031 }
1032
1033 function protectThisPage() {
1034 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1035
1036 $diff = $wgRequest->getVal( 'diff' );
1037 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1038 if ( $wgTitle->isProtected() ) {
1039 $t = wfMsg( 'unprotectthispage' );
1040 $q = 'action=unprotect';
1041 } else {
1042 $t = wfMsg( 'protectthispage' );
1043 $q = 'action=protect';
1044 }
1045 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1046 } else {
1047 $s = '';
1048 }
1049 return $s;
1050 }
1051
1052 function watchThisPage() {
1053 global $wgUser, $wgOut, $wgTitle;
1054
1055 if ( $wgOut->isArticleRelated() ) {
1056 if ( $wgTitle->userIsWatching() ) {
1057 $t = wfMsg( 'unwatchthispage' );
1058 $q = 'action=unwatch';
1059 } else {
1060 $t = wfMsg( 'watchthispage' );
1061 $q = 'action=watch';
1062 }
1063 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1064 } else {
1065 $s = wfMsg( 'notanarticle' );
1066 }
1067 return $s;
1068 }
1069
1070 function moveThisPage() {
1071 global $wgTitle;
1072
1073 if ( $wgTitle->userCanMove() ) {
1074 return $this->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Movepage' ),
1075 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1076 } else {
1077 // no message if page is protected - would be redundant
1078 return '';
1079 }
1080 }
1081
1082 function historyLink() {
1083 global $wgTitle;
1084
1085 return $this->makeKnownLinkObj( $wgTitle,
1086 wfMsg( 'history' ), 'action=history' );
1087 }
1088
1089 function whatLinksHere() {
1090 global $wgTitle;
1091
1092 return $this->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Whatlinkshere' ),
1093 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1094 }
1095
1096 function userContribsLink() {
1097 global $wgTitle;
1098
1099 return $this->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Contributions' ),
1100 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1101 }
1102
1103 function showEmailUser( $id ) {
1104 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1105 return $wgEnableEmail &&
1106 $wgEnableUserEmail &&
1107 $wgUser->isLoggedIn() && # show only to signed in users
1108 0 != $id; # we can only email to non-anons ..
1109 # '' != $id->getEmail() && # who must have an email address stored ..
1110 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1111 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1112 }
1113
1114 function emailUserLink() {
1115 global $wgTitle;
1116
1117 return $this->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Emailuser' ),
1118 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1119 }
1120
1121 function watchPageLinksLink() {
1122 global $wgOut, $wgTitle;
1123
1124 if ( ! $wgOut->isArticleRelated() ) {
1125 return '(' . wfMsg( 'notanarticle' ) . ')';
1126 } else {
1127 return $this->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL,
1128 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1129 'target=' . $wgTitle->getPrefixedURL() );
1130 }
1131 }
1132
1133 function trackbackLink() {
1134 global $wgTitle;
1135
1136 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1137 . wfMsg('trackbacklink') . "</a>";
1138 }
1139
1140 function otherLanguages() {
1141 global $wgOut, $wgContLang, $wgTitle, $wgHideInterlanguageLinks;
1142
1143 if ( $wgHideInterlanguageLinks ) {
1144 return '';
1145 }
1146
1147 $a = $wgOut->getLanguageLinks();
1148 if ( 0 == count( $a ) ) {
1149 return '';
1150 }
1151
1152 $s = wfMsg( 'otherlanguages' ) . ': ';
1153 $first = true;
1154 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1155 foreach( $a as $l ) {
1156 if ( ! $first ) { $s .= ' | '; }
1157 $first = false;
1158
1159 $nt = Title::newFromText( $l );
1160 $url = $nt->escapeFullURL();
1161 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1162
1163 if ( '' == $text ) { $text = $l; }
1164 $style = $this->getExternalLinkAttributes( $l, $text );
1165 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1166 }
1167 if($wgContLang->isRTL()) $s .= '</span>';
1168 return $s;
1169 }
1170
1171 function bugReportsLink() {
1172 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1173 wfMsg( 'bugreports' ) );
1174 return $s;
1175 }
1176
1177 function dateLink() {
1178 global $wgLinkCache;
1179 $t1 = Title::newFromText( gmdate( 'F j' ) );
1180 $t2 = Title::newFromText( gmdate( 'Y' ) );
1181
1182 $wgLinkCache->suspend();
1183 $id = $t1->getArticleID();
1184 $wgLinkCache->resume();
1185
1186 if ( 0 == $id ) {
1187 $s = $this->makeBrokenLink( $t1->getText() );
1188 } else {
1189 $s = $this->makeKnownLink( $t1->getText() );
1190 }
1191 $s .= ', ';
1192
1193 $wgLinkCache->suspend();
1194 $id = $t2->getArticleID();
1195 $wgLinkCache->resume();
1196
1197 if ( 0 == $id ) {
1198 $s .= $this->makeBrokenLink( $t2->getText() );
1199 } else {
1200 $s .= $this->makeKnownLink( $t2->getText() );
1201 }
1202 return $s;
1203 }
1204
1205 function talkLink() {
1206 global $wgTitle, $wgLinkCache;
1207
1208 if ( NS_SPECIAL == $wgTitle->getNamespace() ) {
1209 # No discussion links for special pages
1210 return '';
1211 }
1212
1213 if( $wgTitle->isTalkPage() ) {
1214 $link = $wgTitle->getSubjectPage();
1215 switch( $link->getNamespace() ) {
1216 case NS_MAIN:
1217 $text = wfMsg('articlepage');
1218 break;
1219 case NS_USER:
1220 $text = wfMsg('userpage');
1221 break;
1222 case NS_PROJECT:
1223 $text = wfMsg('wikipediapage');
1224 break;
1225 case NS_IMAGE:
1226 $text = wfMsg('imagepage');
1227 break;
1228 default:
1229 $text= wfMsg('articlepage');
1230 }
1231 } else {
1232 $link = $wgTitle->getTalkPage();
1233 $text = wfMsg( 'talkpage' );
1234 }
1235
1236 $wgLinkCache->suspend();
1237 $s = $this->makeLinkObj( $link, $text );
1238 $wgLinkCache->resume();
1239
1240 return $s;
1241 }
1242
1243 function commentLink() {
1244 global $wgContLang, $wgTitle, $wgLinkCache;
1245
1246 if ( $wgTitle->getNamespace() == NS_SPECIAL ) {
1247 return '';
1248 }
1249 return $this->makeKnownLinkObj( $wgTitle->getTalkPage(),
1250 wfMsg( 'postcomment' ), 'action=edit&section=new' );
1251 }
1252
1253 /* these are used extensively in SkinPHPTal, but also some other places */
1254 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1255 $title = Title::makeTitle( NS_SPECIAL, $name );
1256 return $title->getLocalURL( $urlaction );
1257 }
1258
1259 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1260 $title = Title::newFromText( wfMsgForContent($name) );
1261 $this->checkTitle($title, $name);
1262 return $title->getLocalURL( $urlaction );
1263 }
1264
1265 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1266 $title = Title::newFromText( $name );
1267 $this->checkTitle($title, $name);
1268 return $title->getLocalURL( $urlaction );
1269 }
1270
1271 # If url string starts with http, consider as external URL, else
1272 # internal
1273 /*static*/ function makeInternalOrExternalUrl( $name ) {
1274 global $wgUrlProtocols;
1275 if ( preg_match( '/^(?:' . $wgUrlProtocols . ')/', $name ) ) {
1276 return $name;
1277 } else {
1278 return $this->makeUrl( $name );
1279 }
1280 }
1281
1282 # this can be passed the NS number as defined in Language.php
1283 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN ) {
1284 $title = Title::makeTitleSafe( $namespace, $name );
1285 $this->checkTitle($title, $name);
1286 return $title->getLocalURL( $urlaction );
1287 }
1288
1289 /* these return an array with the 'href' and boolean 'exists' */
1290 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1291 $title = Title::newFromText( $name );
1292 $this->checkTitle($title, $name);
1293 return array(
1294 'href' => $title->getLocalURL( $urlaction ),
1295 'exists' => $title->getArticleID() != 0?true:false
1296 );
1297 }
1298
1299 /**
1300 * Make URL details where the article exists (or at least it's convenient to think so)
1301 */
1302 function makeKnownUrlDetails( $name, $urlaction='' ) {
1303 $title = Title::newFromText( $name );
1304 $this->checkTitle($title, $name);
1305 return array(
1306 'href' => $title->getLocalURL( $urlaction ),
1307 'exists' => true
1308 );
1309 }
1310
1311 # make sure we have some title to operate on
1312 /*static*/ function checkTitle ( &$title, &$name ) {
1313 if(!is_object($title)) {
1314 $title = Title::newFromText( $name );
1315 if(!is_object($title)) {
1316 $title = Title::newFromText( '--error: link target missing--' );
1317 }
1318 }
1319 }
1320
1321 /**
1322 * Build an array that represents the sidebar(s), the navigation bar among them
1323 *
1324 * @return array
1325 * @access private
1326 */
1327 function buildSidebar() {
1328 global $wgTitle, $action;
1329
1330 $fname = 'SkinTemplate::buildSidebar';
1331 $pageurl = $wgTitle->getLocalURL();
1332 wfProfileIn( $fname );
1333
1334 $bar = array();
1335 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1336 foreach ($lines as $line) {
1337 if (strpos($line, '*') !== 0)
1338 continue;
1339 if (strpos($line, '**') !== 0) {
1340 $line = trim($line, '* ');
1341 $heading = $line;
1342 } else {
1343 if (strpos($line, '|') !== false) { // sanity check
1344 $line = explode( '|' , trim($line, '* '), 2 );
1345 $link = wfMsgForContent( $line[0] );
1346 if ($link == '-')
1347 continue;
1348 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1349 $text = $line[1];
1350 if (wfEmptyMsg($line[0], $link))
1351 $link = $line[0];
1352 $href = $this->makeInternalOrExternalUrl( $link );
1353 $bar[$heading][] = array(
1354 'text' => $text,
1355 'href' => $href,
1356 'id' => 'n-' . strtr($line[1], ' ', '-'),
1357 'active' => $pageurl == $href
1358 );
1359 } else { continue; }
1360 }
1361 }
1362
1363 wfProfileOut( $fname );
1364 return $bar;
1365 }
1366 }
1367
1368 }
1369 ?>