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