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