Small updates
[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 $msg = count( $wgOut->mCategoryLinks ) === 1 ? 'categories1' : 'categories';
430 $s = $this->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Categories' ),
431 wfMsg( $msg ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
432 . ': ' . $t;
433
434 # optional 'dmoz-like' category browser. Will be shown under the list
435 # of categories an article belong to
436 if($wgUseCategoryBrowser) {
437 $s .= '<br /><hr />';
438
439 # get a big array of the parents tree
440 $parenttree = $wgTitle->getParentCategoryTree();
441 # Skin object passed by reference cause it can not be
442 # accessed under the method subfunction drawCategoryBrowser
443 $tempout = explode("\n", Skin::drawCategoryBrowser($parenttree, $this) );
444 # Clean out bogus first entry and sort them
445 unset($tempout[0]);
446 asort($tempout);
447 # Output one per line
448 $s .= implode("<br />\n", $tempout);
449 }
450
451 return $s;
452 }
453
454 /** Render the array as a serie of links.
455 * @param array $tree Categories tree returned by Title::getParentCategoryTree
456 * @param object &skin Skin passed by reference
457 * @return string separated by &gt;, terminate with "\n"
458 */
459 function drawCategoryBrowser($tree, &$skin) {
460 $return = '';
461 foreach ($tree as $element => $parent) {
462 if (empty($parent)) {
463 # element start a new list
464 $return .= "\n";
465 } else {
466 # grab the others elements
467 $return .= Skin::drawCategoryBrowser($parent, $skin) . ' &gt; ';
468 }
469 # add our current element to the list
470 $eltitle = Title::NewFromText($element);
471 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
472 }
473 return $return;
474 }
475
476 function getCategories() {
477 $catlinks=$this->getCategoryLinks();
478 if(!empty($catlinks)) {
479 return "<p class='catlinks'>{$catlinks}</p>";
480 }
481 }
482
483 function getQuickbarCompensator( $rows = 1 ) {
484 return "<td width='152' rowspan='{$rows}'>&nbsp;</td>";
485 }
486
487 /**
488 * This gets called immediately before the </body> tag.
489 * @return string HTML to be put after </body> ???
490 */
491 function afterContent() {
492 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
493 return $printfooter . $this->doAfterContent();
494 }
495
496 /** @return string Retrievied from HTML text */
497 function printSource() {
498 global $wgTitle;
499 $url = htmlspecialchars( $wgTitle->getFullURL() );
500 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
501 }
502
503 function printFooter() {
504 return "<p>" . $this->printSource() .
505 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
506 }
507
508 /** overloaded by derived classes */
509 function doAfterContent() { }
510
511 function pageTitleLinks() {
512 global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgRequest;
513
514 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
515 $action = $wgRequest->getText( 'action' );
516
517 $s = $this->printableLink();
518 $disclaimer = $this->disclaimerLink(); # may be empty
519 if( $disclaimer ) {
520 $s .= ' | ' . $disclaimer;
521 }
522
523 if ( $wgOut->isArticleRelated() ) {
524 if ( $wgTitle->getNamespace() == NS_IMAGE ) {
525 $name = $wgTitle->getDBkey();
526 $image = new Image( $wgTitle );
527 if( $image->exists() ) {
528 $link = htmlspecialchars( $image->getURL() );
529 $style = $this->getInternalLinkAttributes( $link, $name );
530 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
531 }
532 }
533 }
534 if ( 'history' == $action || isset( $diff ) || isset( $oldid ) ) {
535 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
536 wfMsg( 'currentrev' ) );
537 }
538
539 if ( $wgUser->getNewtalk() ) {
540 # do not show "You have new messages" text when we are viewing our
541 # own talk page
542
543 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
544 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
545 wfMsg('newmessageslink') );
546 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
547 # disable caching
548 $wgOut->setSquidMaxage(0);
549 $wgOut->enableClientCache(false);
550 }
551 }
552
553 $undelete = $this->getUndeleteLink();
554 if( !empty( $undelete ) ) {
555 $s .= ' | '.$undelete;
556 }
557 return $s;
558 }
559
560 function getUndeleteLink() {
561 global $wgUser, $wgTitle, $wgContLang, $action;
562 if( (($wgTitle->getArticleId() == 0) || ($action == "history")) &&
563 ($n = $wgTitle->isDeleted() ) )
564 {
565 if ( $wgUser->isAllowed( 'delete' ) ) {
566 $msg = 'thisisdeleted';
567 } else {
568 $msg = 'viewdeleted';
569 }
570 return wfMsg( $msg,
571 $this->makeKnownLink(
572 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
573 wfMsg( 'restorelink' . ($n == 1 ? '1' : ''), $n ) ) );
574 }
575 return '';
576 }
577
578 function printableLink() {
579 global $wgOut, $wgFeedClasses, $wgRequest;
580
581 $baseurl = $_SERVER['REQUEST_URI'];
582 if( strpos( '?', $baseurl ) == false ) {
583 $baseurl .= '?';
584 } else {
585 $baseurl .= '&';
586 }
587 $baseurl = htmlspecialchars( $baseurl );
588 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
589
590 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
591 if( $wgOut->isSyndicated() ) {
592 foreach( $wgFeedClasses as $format => $class ) {
593 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
594 $s .= " | <a href=\"$feedurl\">{$format}</a>";
595 }
596 }
597 return $s;
598 }
599
600 function pageTitle() {
601 global $wgOut, $wgTitle, $wgUser;
602
603 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
604 return $s;
605 }
606
607 function pageSubtitle() {
608 global $wgOut;
609
610 $sub = $wgOut->getSubtitle();
611 if ( '' == $sub ) {
612 global $wgExtraSubtitle;
613 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
614 }
615 $subpages = $this->subPageSubtitle();
616 $sub .= !empty($subpages)?"</p><p class='subpages'>$subpages":'';
617 $s = "<p class='subtitle'>{$sub}</p>\n";
618 return $s;
619 }
620
621 function subPageSubtitle() {
622 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
623 $subpages = '';
624 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
625 $ptext=$wgTitle->getPrefixedText();
626 if(preg_match('/\//',$ptext)) {
627 $links = explode('/',$ptext);
628 $c = 0;
629 $growinglink = '';
630 foreach($links as $link) {
631 $c++;
632 if ($c<count($links)) {
633 $growinglink .= $link;
634 $getlink = $this->makeLink( $growinglink, $link );
635 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
636 if ($c>1) {
637 $subpages .= ' | ';
638 } else {
639 $subpages .= '&lt; ';
640 }
641 $subpages .= $getlink;
642 $growinglink .= '/';
643 }
644 }
645 }
646 }
647 return $subpages;
648 }
649
650 function nameAndLogin() {
651 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader;
652
653 $li = $wgContLang->specialPage( 'Userlogin' );
654 $lo = $wgContLang->specialPage( 'Userlogout' );
655
656 $s = '';
657 if ( $wgUser->isAnon() ) {
658 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
659 $n = wfGetIP();
660
661 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
662 $wgLang->getNsText( NS_TALK ) );
663
664 $s .= $n . ' ('.$tl.')';
665 } else {
666 $s .= wfMsg('notloggedin');
667 }
668
669 $rt = $wgTitle->getPrefixedURL();
670 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
671 $q = '';
672 } else { $q = "returnto={$rt}"; }
673
674 $s .= "\n<br />" . $this->makeKnownLinkObj(
675 Title::makeTitle( NS_SPECIAL, 'Userlogin' ),
676 wfMsg( 'login' ), $q );
677 } else {
678 $n = $wgUser->getName();
679 $rt = $wgTitle->getPrefixedURL();
680 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
681 $wgLang->getNsText( NS_TALK ) );
682
683 $tl = " ({$tl})";
684
685 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
686 $n ) . "{$tl}<br />" .
687 $this->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Userlogout' ), wfMsg( 'logout' ),
688 "returnto={$rt}" ) . ' | ' .
689 $this->specialLink( 'preferences' );
690 }
691 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
692 wfMsg( 'help' ) );
693
694 return $s;
695 }
696
697 function getSearchLink() {
698 $searchPage =& Title::makeTitle( NS_SPECIAL, 'Search' );
699 return $searchPage->getLocalURL();
700 }
701
702 function escapeSearchLink() {
703 return htmlspecialchars( $this->getSearchLink() );
704 }
705
706 function searchForm() {
707 global $wgRequest;
708 $search = $wgRequest->getText( 'search' );
709
710 $s = '<form name="search" class="inline" method="post" action="'
711 . $this->escapeSearchLink() . "\">\n"
712 . '<input type="text" name="search" size="19" value="'
713 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
714 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" />&nbsp;'
715 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
716
717 return $s;
718 }
719
720 function topLinks() {
721 global $wgOut;
722 $sep = " |\n";
723
724 $s = $this->mainPageLink() . $sep
725 . $this->specialLink( 'recentchanges' );
726
727 if ( $wgOut->isArticleRelated() ) {
728 $s .= $sep . $this->editThisPage()
729 . $sep . $this->historyLink();
730 }
731 # Many people don't like this dropdown box
732 #$s .= $sep . $this->specialPagesList();
733
734 /* show links to different language variants */
735 global $wgDisableLangConversion, $wgContLang, $wgTitle;
736 $variants = $wgContLang->getVariants();
737 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
738 foreach( $variants as $code ) {
739 $varname = $wgContLang->getVariantname( $code );
740 if( $varname == 'disable' )
741 continue;
742 $s .= ' | <a href="' . $wgTitle->getLocalUrl( 'variant=' . $code ) . '">' . $varname . '</a>';
743 }
744 }
745
746 return $s;
747 }
748
749 function bottomLinks() {
750 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
751 $sep = " |\n";
752
753 $s = '';
754 if ( $wgOut->isArticleRelated() ) {
755 $s .= '<strong>' . $this->editThisPage() . '</strong>';
756 if ( $wgUser->isLoggedIn() ) {
757 $s .= $sep . $this->watchThisPage();
758 }
759 $s .= $sep . $this->talkLink()
760 . $sep . $this->historyLink()
761 . $sep . $this->whatLinksHere()
762 . $sep . $this->watchPageLinksLink();
763
764 if ($wgUseTrackbacks)
765 $s .= $sep . $this->trackbackLink();
766
767 if ( $wgTitle->getNamespace() == NS_USER
768 || $wgTitle->getNamespace() == NS_USER_TALK )
769
770 {
771 $id=User::idFromName($wgTitle->getText());
772 $ip=User::isIP($wgTitle->getText());
773
774 if($id || $ip) { # both anons and non-anons have contri list
775 $s .= $sep . $this->userContribsLink();
776 }
777 if( $this->showEmailUser( $id ) ) {
778 $s .= $sep . $this->emailUserLink();
779 }
780 }
781 if ( $wgTitle->getArticleId() ) {
782 $s .= "\n<br />";
783 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
784 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
785 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
786 }
787 $s .= "<br />\n" . $this->otherLanguages();
788 }
789 return $s;
790 }
791
792 function pageStats() {
793 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
794 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
795
796 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
797 if ( ! $wgOut->isArticle() ) { return ''; }
798 if ( isset( $oldid ) || isset( $diff ) ) { return ''; }
799 if ( 0 == $wgArticle->getID() ) { return ''; }
800
801 $s = '';
802 if ( !$wgDisableCounters ) {
803 $count = $wgLang->formatNum( $wgArticle->getCount() );
804 if ( $count ) {
805 $s = wfMsg( 'viewcount', $count );
806 }
807 }
808
809 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
810 require_once('Credits.php');
811 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
812 } else {
813 $s .= $this->lastModified();
814 }
815
816 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
817 $dbr =& wfGetDB( DB_SLAVE );
818 extract( $dbr->tableNames( 'watchlist' ) );
819 $sql = "SELECT COUNT(*) AS n FROM $watchlist
820 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
821 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
822 $res = $dbr->query( $sql, 'Skin::pageStats');
823 $x = $dbr->fetchObject( $res );
824 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n );
825 }
826
827 return $s . ' ' . $this->getCopyright();
828 }
829
830 function getCopyright() {
831 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
832
833
834 $oldid = $wgRequest->getVal( 'oldid' );
835 $diff = $wgRequest->getVal( 'diff' );
836
837 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
838 $msg = 'history_copyright';
839 } else {
840 $msg = 'copyright';
841 }
842
843 $out = '';
844 if( $wgRightsPage ) {
845 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
846 } elseif( $wgRightsUrl ) {
847 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
848 } else {
849 # Give up now
850 return $out;
851 }
852 $out .= wfMsgForContent( $msg, $link );
853 return $out;
854 }
855
856 function getCopyrightIcon() {
857 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
858 $out = '';
859 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
860 $out = $wgCopyrightIcon;
861 } else if ( $wgRightsIcon ) {
862 $icon = htmlspecialchars( $wgRightsIcon );
863 if ( $wgRightsUrl ) {
864 $url = htmlspecialchars( $wgRightsUrl );
865 $out .= '<a href="'.$url.'">';
866 }
867 $text = htmlspecialchars( $wgRightsText );
868 $out .= "<img src=\"$icon\" alt='$text' />";
869 if ( $wgRightsUrl ) {
870 $out .= '</a>';
871 }
872 }
873 return $out;
874 }
875
876 function getPoweredBy() {
877 global $wgStylePath;
878 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
879 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
880 return $img;
881 }
882
883 function lastModified() {
884 global $wgLang, $wgArticle, $wgLoadBalancer;
885
886 $timestamp = $wgArticle->getTimestamp();
887 if ( $timestamp ) {
888 $d = $wgLang->timeanddate( $timestamp, true );
889 $s = ' ' . wfMsg( 'lastmodified', $d );
890 } else {
891 $s = '';
892 }
893 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
894 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
895 }
896 return $s;
897 }
898
899 function logoText( $align = '' ) {
900 if ( '' != $align ) { $a = " align='{$align}'"; }
901 else { $a = ''; }
902
903 $mp = wfMsg( 'mainpage' );
904 $titleObj = Title::newFromText( $mp );
905 if ( is_object( $titleObj ) ) {
906 $url = $titleObj->escapeLocalURL();
907 } else {
908 $url = '';
909 }
910
911 $logourl = $this->getLogo();
912 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
913 return $s;
914 }
915
916 /**
917 * show a drop-down box of special pages
918 * @TODO crash bug913. Need to be rewrote completly.
919 */
920 function specialPagesList() {
921 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript, $wgAvailableRights;
922 require_once('SpecialPage.php');
923 $a = array();
924 $pages = SpecialPage::getPages();
925
926 // special pages without access restriction
927 foreach ( $pages[''] as $name => $page ) {
928 $a[$name] = $page->getDescription();
929 }
930
931 // Other special pages that are restricted.
932 // Copied from SpecialSpecialpages.php
933 foreach($wgAvailableRights as $right) {
934 if( $wgUser->isAllowed($right) ) {
935 /** Add all pages for this right */
936 if(isset($pages[$right])) {
937 foreach($pages[$right] as $name => $page) {
938 $a[$name] = $page->getDescription();
939 }
940 }
941 }
942 }
943
944 $go = wfMsg( 'go' );
945 $sp = wfMsg( 'specialpages' );
946 $spp = $wgContLang->specialPage( 'Specialpages' );
947
948 $s = '<form id="specialpages" method="get" class="inline" ' .
949 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
950 $s .= "<select name=\"wpDropdown\">\n";
951 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
952
953
954 foreach ( $a as $name => $desc ) {
955 $p = $wgContLang->specialPage( $name );
956 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
957 }
958 $s .= "</select>\n";
959 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
960 $s .= "</form>\n";
961 return $s;
962 }
963
964 function mainPageLink() {
965 $mp = wfMsgForContent( 'mainpage' );
966 $mptxt = wfMsg( 'mainpage');
967 $s = $this->makeKnownLink( $mp, $mptxt );
968 return $s;
969 }
970
971 function copyrightLink() {
972 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
973 wfMsg( 'copyrightpagename' ) );
974 return $s;
975 }
976
977 function aboutLink() {
978 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
979 wfMsg( 'aboutsite' ) );
980 return $s;
981 }
982
983
984 function disclaimerLink() {
985 $disclaimers = wfMsg( 'disclaimers' );
986 if ($disclaimers == '-') {
987 return '';
988 } else {
989 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
990 $disclaimers );
991 }
992 }
993
994 function editThisPage() {
995 global $wgOut, $wgTitle, $wgRequest;
996
997 $oldid = $wgRequest->getVal( 'oldid' );
998 $diff = $wgRequest->getVal( 'diff' );
999 $redirect = $wgRequest->getVal( 'redirect' );
1000
1001 if ( ! $wgOut->isArticleRelated() ) {
1002 $s = wfMsg( 'protectedpage' );
1003 } else {
1004 if ( $wgTitle->userCanEdit() ) {
1005 $t = wfMsg( 'editthispage' );
1006 } else {
1007 $t = wfMsg( 'viewsource' );
1008 }
1009 $oid = $red = '';
1010
1011 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
1012 if ( $oldid && ! isset( $diff ) ) {
1013 $oid = '&oldid='.$oldid;
1014 }
1015 $s = $this->makeKnownLinkObj( $wgTitle, $t, "action=edit{$oid}{$red}" );
1016 }
1017 return $s;
1018 }
1019
1020 function deleteThisPage() {
1021 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1022
1023 $diff = $wgRequest->getVal( 'diff' );
1024 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1025 $t = wfMsg( 'deletethispage' );
1026
1027 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1028 } else {
1029 $s = '';
1030 }
1031 return $s;
1032 }
1033
1034 function protectThisPage() {
1035 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1036
1037 $diff = $wgRequest->getVal( 'diff' );
1038 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1039 if ( $wgTitle->isProtected() ) {
1040 $t = wfMsg( 'unprotectthispage' );
1041 $q = 'action=unprotect';
1042 } else {
1043 $t = wfMsg( 'protectthispage' );
1044 $q = 'action=protect';
1045 }
1046 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1047 } else {
1048 $s = '';
1049 }
1050 return $s;
1051 }
1052
1053 function watchThisPage() {
1054 global $wgUser, $wgOut, $wgTitle;
1055
1056 if ( $wgOut->isArticleRelated() ) {
1057 if ( $wgTitle->userIsWatching() ) {
1058 $t = wfMsg( 'unwatchthispage' );
1059 $q = 'action=unwatch';
1060 } else {
1061 $t = wfMsg( 'watchthispage' );
1062 $q = 'action=watch';
1063 }
1064 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1065 } else {
1066 $s = wfMsg( 'notanarticle' );
1067 }
1068 return $s;
1069 }
1070
1071 function moveThisPage() {
1072 global $wgTitle;
1073
1074 if ( $wgTitle->userCanMove() ) {
1075 return $this->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Movepage' ),
1076 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1077 } else {
1078 // no message if page is protected - would be redundant
1079 return '';
1080 }
1081 }
1082
1083 function historyLink() {
1084 global $wgTitle;
1085
1086 return $this->makeKnownLinkObj( $wgTitle,
1087 wfMsg( 'history' ), 'action=history' );
1088 }
1089
1090 function whatLinksHere() {
1091 global $wgTitle;
1092
1093 return $this->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Whatlinkshere' ),
1094 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1095 }
1096
1097 function userContribsLink() {
1098 global $wgTitle;
1099
1100 return $this->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Contributions' ),
1101 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1102 }
1103
1104 function showEmailUser( $id ) {
1105 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1106 return $wgEnableEmail &&
1107 $wgEnableUserEmail &&
1108 $wgUser->isLoggedIn() && # show only to signed in users
1109 0 != $id; # we can only email to non-anons ..
1110 # '' != $id->getEmail() && # who must have an email address stored ..
1111 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1112 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1113 }
1114
1115 function emailUserLink() {
1116 global $wgTitle;
1117
1118 return $this->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Emailuser' ),
1119 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1120 }
1121
1122 function watchPageLinksLink() {
1123 global $wgOut, $wgTitle;
1124
1125 if ( ! $wgOut->isArticleRelated() ) {
1126 return '(' . wfMsg( 'notanarticle' ) . ')';
1127 } else {
1128 return $this->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL,
1129 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1130 'target=' . $wgTitle->getPrefixedURL() );
1131 }
1132 }
1133
1134 function trackbackLink() {
1135 global $wgTitle;
1136
1137 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1138 . wfMsg('trackbacklink') . "</a>";
1139 }
1140
1141 function otherLanguages() {
1142 global $wgOut, $wgContLang, $wgTitle, $wgHideInterlanguageLinks;
1143
1144 if ( $wgHideInterlanguageLinks ) {
1145 return '';
1146 }
1147
1148 $a = $wgOut->getLanguageLinks();
1149 if ( 0 == count( $a ) ) {
1150 return '';
1151 }
1152
1153 $s = wfMsg( 'otherlanguages' ) . ': ';
1154 $first = true;
1155 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1156 foreach( $a as $l ) {
1157 if ( ! $first ) { $s .= ' | '; }
1158 $first = false;
1159
1160 $nt = Title::newFromText( $l );
1161 $url = $nt->escapeFullURL();
1162 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1163
1164 if ( '' == $text ) { $text = $l; }
1165 $style = $this->getExternalLinkAttributes( $l, $text );
1166 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1167 }
1168 if($wgContLang->isRTL()) $s .= '</span>';
1169 return $s;
1170 }
1171
1172 function bugReportsLink() {
1173 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1174 wfMsg( 'bugreports' ) );
1175 return $s;
1176 }
1177
1178 function dateLink() {
1179 global $wgLinkCache;
1180 $t1 = Title::newFromText( gmdate( 'F j' ) );
1181 $t2 = Title::newFromText( gmdate( 'Y' ) );
1182
1183 $wgLinkCache->suspend();
1184 $id = $t1->getArticleID();
1185 $wgLinkCache->resume();
1186
1187 if ( 0 == $id ) {
1188 $s = $this->makeBrokenLink( $t1->getText() );
1189 } else {
1190 $s = $this->makeKnownLink( $t1->getText() );
1191 }
1192 $s .= ', ';
1193
1194 $wgLinkCache->suspend();
1195 $id = $t2->getArticleID();
1196 $wgLinkCache->resume();
1197
1198 if ( 0 == $id ) {
1199 $s .= $this->makeBrokenLink( $t2->getText() );
1200 } else {
1201 $s .= $this->makeKnownLink( $t2->getText() );
1202 }
1203 return $s;
1204 }
1205
1206 function talkLink() {
1207 global $wgTitle, $wgLinkCache;
1208
1209 if ( NS_SPECIAL == $wgTitle->getNamespace() ) {
1210 # No discussion links for special pages
1211 return '';
1212 }
1213
1214 if( $wgTitle->isTalkPage() ) {
1215 $link = $wgTitle->getSubjectPage();
1216 switch( $link->getNamespace() ) {
1217 case NS_MAIN:
1218 $text = wfMsg('articlepage');
1219 break;
1220 case NS_USER:
1221 $text = wfMsg('userpage');
1222 break;
1223 case NS_PROJECT:
1224 $text = wfMsg('wikipediapage');
1225 break;
1226 case NS_IMAGE:
1227 $text = wfMsg('imagepage');
1228 break;
1229 default:
1230 $text= wfMsg('articlepage');
1231 }
1232 } else {
1233 $link = $wgTitle->getTalkPage();
1234 $text = wfMsg( 'talkpage' );
1235 }
1236
1237 $wgLinkCache->suspend();
1238 $s = $this->makeLinkObj( $link, $text );
1239 $wgLinkCache->resume();
1240
1241 return $s;
1242 }
1243
1244 function commentLink() {
1245 global $wgContLang, $wgTitle, $wgLinkCache;
1246
1247 if ( $wgTitle->getNamespace() == NS_SPECIAL ) {
1248 return '';
1249 }
1250 return $this->makeKnownLinkObj( $wgTitle->getTalkPage(),
1251 wfMsg( 'postcomment' ), 'action=edit&section=new' );
1252 }
1253
1254 /* these are used extensively in SkinPHPTal, but also some other places */
1255 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1256 $title = Title::makeTitle( NS_SPECIAL, $name );
1257 return $title->getLocalURL( $urlaction );
1258 }
1259
1260 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1261 $title = Title::newFromText( wfMsgForContent($name) );
1262 $this->checkTitle($title, $name);
1263 return $title->getLocalURL( $urlaction );
1264 }
1265
1266 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1267 $title = Title::newFromText( $name );
1268 $this->checkTitle($title, $name);
1269 return $title->getLocalURL( $urlaction );
1270 }
1271
1272 # If url string starts with http, consider as external URL, else
1273 # internal
1274 /*static*/ function makeInternalOrExternalUrl( $name ) {
1275 global $wgUrlProtocols;
1276 if ( preg_match( '/^(?:' . $wgUrlProtocols . ')/', $name ) ) {
1277 return $name;
1278 } else {
1279 return $this->makeUrl( $name );
1280 }
1281 }
1282
1283 # this can be passed the NS number as defined in Language.php
1284 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN ) {
1285 $title = Title::makeTitleSafe( $namespace, $name );
1286 $this->checkTitle($title, $name);
1287 return $title->getLocalURL( $urlaction );
1288 }
1289
1290 /* these return an array with the 'href' and boolean 'exists' */
1291 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1292 $title = Title::newFromText( $name );
1293 $this->checkTitle($title, $name);
1294 return array(
1295 'href' => $title->getLocalURL( $urlaction ),
1296 'exists' => $title->getArticleID() != 0?true:false
1297 );
1298 }
1299
1300 /**
1301 * Make URL details where the article exists (or at least it's convenient to think so)
1302 */
1303 function makeKnownUrlDetails( $name, $urlaction='' ) {
1304 $title = Title::newFromText( $name );
1305 $this->checkTitle($title, $name);
1306 return array(
1307 'href' => $title->getLocalURL( $urlaction ),
1308 'exists' => true
1309 );
1310 }
1311
1312 # make sure we have some title to operate on
1313 /*static*/ function checkTitle ( &$title, &$name ) {
1314 if(!is_object($title)) {
1315 $title = Title::newFromText( $name );
1316 if(!is_object($title)) {
1317 $title = Title::newFromText( '--error: link target missing--' );
1318 }
1319 }
1320 }
1321
1322 /**
1323 * Build an array that represents the sidebar(s), the navigation bar among them
1324 *
1325 * @return array
1326 * @access private
1327 */
1328 function buildSidebar() {
1329 global $wgTitle, $action;
1330
1331 $fname = 'SkinTemplate::buildSidebar';
1332 $pageurl = $wgTitle->getLocalURL();
1333 wfProfileIn( $fname );
1334
1335 $bar = array();
1336 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1337 foreach ($lines as $line) {
1338 if (strpos($line, '*') !== 0)
1339 continue;
1340 if (strpos($line, '**') !== 0) {
1341 $line = trim($line, '* ');
1342 $heading = $line;
1343 } else {
1344 if (strpos($line, '|') !== false) { // sanity check
1345 $line = explode( '|' , trim($line, '* '), 2 );
1346 $link = wfMsgForContent( $line[0] );
1347 if ($link == '-')
1348 continue;
1349 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1350 $text = $line[1];
1351 if (wfEmptyMsg($line[0], $link))
1352 $link = $line[0];
1353 $href = $this->makeInternalOrExternalUrl( $link );
1354 $bar[$heading][] = array(
1355 'text' => $text,
1356 'href' => $href,
1357 'id' => 'n-' . strtr($line[1], ' ', '-'),
1358 'active' => $pageurl == $href
1359 );
1360 } else { continue; }
1361 }
1362 }
1363
1364 wfProfileOut( $fname );
1365 return $bar;
1366 }
1367 }
1368
1369 }
1370 ?>