10 * This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
12 if( defined( "MEDIAWIKI" ) ) {
15 require_once( 'Image.php' );
17 # Get a list of all skins available in /skins/
18 # Build using the regular expression '^(.*).php$'
19 # Array keys are all lower case, array value keep the case used by filename
22 $skinDir = dir($IP.'/skins');
24 # while code from www.php.net
25 while (false !== ($file = $skinDir->read())) {
26 if(preg_match('/^([^.].*)\.php$/',$file, $matches)) {
28 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
34 require_once( 'RecentChange.php' );
36 global $wgLinkHolders;
37 $wgLinkHolders = array(
38 'namespaces' => array(),
44 global $wgInterwikiLinkHolders;
45 $wgInterwikiLinkHolders = array();
51 class RCCacheEntry
extends RecentChange
53 var $secureName, $link;
54 var $curlink , $difflink, $lastlink , $usertalklink , $versionlink ;
55 var $userlink, $timestamp, $watched;
57 function newFromParent( $rc )
59 $rc2 = new RCCacheEntry
;
60 $rc2->mAttribs
= $rc->mAttribs
;
61 $rc2->mExtra
= $rc->mExtra
;
68 * The main skin class that provide methods and properties for all other skins
69 * including PHPTal skins.
70 * This base class is also the "Standard" skin.
77 var $lastdate, $lastline;
78 var $linktrail ; # linktrail regexp
79 var $rc_cache ; # Cache for Enhanced Recent Changes
80 var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle
82 var $postParseLinkColour = false;
86 $this->linktrail
= wfMsgForContent('linktrail');
89 function getSkinNames() {
90 global $wgValidSkinNames;
91 return $wgValidSkinNames;
94 function getStylesheet() {
95 return 'common/wikistandard.css';
98 function getSkinName() {
103 * Get/set accessor for delayed link colouring
105 function postParseLinkColour( $setting = NULL ) {
106 return wfSetVar( $this->postParseLinkColour
, $setting );
109 function qbSetting() {
110 global $wgOut, $wgUser;
112 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
113 $q = $wgUser->getOption( 'quickbar' );
114 if ( '' == $q ) { $q = 0; }
118 function initPage( &$out ) {
119 $fname = 'Skin::initPage';
120 wfProfileIn( $fname );
122 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => '/favicon.ico' ) );
124 $this->addMetadataLinks($out);
126 wfProfileOut( $fname );
129 function addMetadataLinks( &$out ) {
130 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf, $wgRdfMimeType, $action;
131 global $wgRightsPage, $wgRightsUrl;
133 if( $out->isArticleRelated() ) {
134 # note: buggy CC software only reads first "meta" link
135 if( $wgEnableCreativeCommonsRdf ) {
136 $out->addMetadataLink( array(
137 'title' => 'Creative Commons',
138 'type' => 'application/rdf+xml',
139 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
141 if( $wgEnableDublinCoreRdf ) {
142 $out->addMetadataLink( array(
143 'title' => 'Dublin Core',
144 'type' => 'application/rdf+xml',
145 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
149 if( $wgRightsPage ) {
150 $copy = Title
::newFromText( $wgRightsPage );
152 $copyright = $copy->getLocalURL();
155 if( !$copyright && $wgRightsUrl ) {
156 $copyright = $wgRightsUrl;
159 $out->addLink( array(
160 'rel' => 'copyright',
161 'href' => $copyright ) );
165 function outputPage( &$out ) {
166 global $wgDebugComments;
168 wfProfileIn( 'Skin::outputPage' );
169 $this->initPage( $out );
170 $out->out( $out->headElement() );
172 $out->out( "\n<body" );
173 $ops = $this->getBodyOptions();
174 foreach ( $ops as $name => $val ) {
175 $out->out( " $name='$val'" );
178 if ( $wgDebugComments ) {
179 $out->out( "<!-- Wiki debugging output:\n" .
180 $out->mDebugtext
. "-->\n" );
182 $out->out( $this->beforeContent() );
184 $out->out( $out->mBodytext
. "\n" );
186 $out->out( $this->afterContent() );
189 $out->out( $out->reportTime() );
191 $out->out( "\n</body></html>" );
194 function getHeadScripts() {
195 global $wgStylePath, $wgUser, $wgContLang, $wgAllowUserJs;
196 $r = "<script type=\"text/javascript\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
197 if( $wgAllowUserJs && $wgUser->getID() != 0 ) { # logged in
198 $userpage = $wgContLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
199 $userjs = htmlspecialchars($this->makeUrl($userpage.'/'.$this->getSkinName().'.js', 'action=raw&ctype=text/javascript'));
200 $r .= '<script type="text/javascript" src="'.$userjs."\"></script>\n";
205 # get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way)
206 function getUserStylesheet() {
207 global $wgOut, $wgStylePath, $wgContLang, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
208 $sheet = $this->getStylesheet();
209 $action = $wgRequest->getText('action');
210 $s = "@import \"$wgStylePath/$sheet\";\n";
211 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css\";\n";
212 if( $wgAllowUserCss && $wgUser->getID() != 0 ) { # logged in
213 if($wgTitle->isCssSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) {
214 $s .= $wgRequest->getText('wpTextbox1');
216 $userpage = $wgContLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
217 $s.= '@import "'.$this->makeUrl($userpage.'/'.$this->getSkinName().'.css', 'action=raw&ctype=text/css').'";'."\n";
220 $s .= $this->doGetUserStyles();
225 * placeholder, returns generated js in monobook
227 function getUserJs() { return; }
230 * Return html code that include User stylesheets
232 function getUserStyles() {
233 global $wgOut, $wgStylePath, $wgLang;
234 $s = "<style type='text/css'>\n";
235 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
236 $s .= $this->getUserStylesheet();
237 $s .= "/*]]>*/ /* */\n";
243 * Some styles that are set by user through the user settings interface.
245 function doGetUserStyles() {
246 global $wgUser, $wgContLang;
248 $csspage = $wgContLang->getNsText( NS_MEDIAWIKI
) . ':' . $this->getSkinName() . '.css';
249 $s = '@import "'.$this->makeUrl($csspage, 'action=raw&ctype=text/css')."\";\n";
251 if ( 1 == $wgUser->getOption( 'underline' ) ) {
252 # Don't override browser settings
256 $s .= "a { text-decoration: none; }\n";
258 if ( 1 == $wgUser->getOption( 'highlightbroken' ) ) {
259 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
261 if ( 1 == $wgUser->getOption( 'justify' ) ) {
262 $s .= "#article { text-align: justify; }\n";
267 function getBodyOptions() {
268 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
270 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
272 if ( 0 != $wgTitle->getNamespace() ) {
273 $a = array( 'bgcolor' => '#ffffec' );
275 else $a = array( 'bgcolor' => '#FFFFFF' );
276 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
277 (!$wgTitle->isProtected() ||
$wgUser->isAllowed('protect')) ) {
278 $t = wfMsg( 'editthispage' );
280 if ( !empty($redirect) && $redirect == 'no' ) {
281 $red = "&redirect={$redirect}";
283 if ( !empty($oldid) && ! isset( $diff ) ) {
284 $oid = "&oldid=" . IntVal( $oldid );
286 $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
287 $s = 'document.location = "' .$s .'";';
288 $a +
= array ('ondblclick' => $s);
291 $a['onload'] = $wgOut->getOnloadHandler();
295 function getExternalLinkAttributes( $link, $text, $class='' ) {
296 global $wgUser, $wgOut, $wgContLang;
298 $same = ($link == $text);
299 $link = urldecode( $link );
300 $link = $wgContLang->checkTitleEncoding( $link );
301 $link = str_replace( '_', ' ', $link );
302 $link = htmlspecialchars( $link );
304 $r = ($class != '') ?
" class='$class'" : " class='external'";
306 if ( !$same && $wgUser->getOption( 'hover' ) ) {
307 $r .= " title=\"{$link}\"";
312 function getInternalLinkAttributes( $link, $text, $broken = false ) {
313 global $wgUser, $wgOut;
315 $link = urldecode( $link );
316 $link = str_replace( '_', ' ', $link );
317 $link = htmlspecialchars( $link );
319 if ( $broken == 'stub' ) {
320 $r = ' class="stub"';
321 } else if ( $broken == 'yes' ) {
327 if ( 1 == $wgUser->getOption( 'hover' ) ) {
328 $r .= " title=\"{$link}\"";
334 * @param bool $broken
336 function getInternalLinkAttributesObj( &$nt, $text, $broken = false ) {
337 global $wgUser, $wgOut;
339 if ( $broken == 'stub' ) {
340 $r = ' class="stub"';
341 } else if ( $broken == 'yes' ) {
347 if ( 1 == $wgUser->getOption( 'hover' ) ) {
348 $r .= ' title="' . $nt->getEscapedText() . '"';
362 * This will be called immediately after the <body> tag. Split into
363 * two functions to make it easier to subclass.
365 function beforeContent() {
366 global $wgUser, $wgOut;
368 return $this->doBeforeContent();
371 function doBeforeContent() {
372 global $wgUser, $wgOut, $wgTitle, $wgContLang, $wgSiteNotice;
373 $fname = 'Skin::doBeforeContent';
374 wfProfileIn( $fname );
377 $qb = $this->qbSetting();
379 if( $langlinks = $this->otherLanguages() ) {
385 $borderhack = 'class="top"';
388 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
389 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
392 $left = ($qb == 1 ||
$qb == 3);
393 if($wgContLang->isRTL()) $left = !$left;
396 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
397 $this->logoText() . '</td>';
399 $s .= $this->getQuickbarCompensator( $rows );
401 $l = $wgContLang->isRTL() ?
'right' : 'left';
402 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
404 $s .= $this->topLinks() ;
405 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
407 $r = $wgContLang->isRTL() ?
"left" : "right";
408 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
409 $s .= $this->nameAndLogin();
410 $s .= "\n<br />" . $this->searchForm() . "</td>";
413 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
416 if ( $shove && !$left ) { # Right
417 $s .= $this->getQuickbarCompensator( $rows );
419 $s .= "</tr>\n</table>\n</div>\n";
420 $s .= "\n<div id='article'>\n";
422 if( $wgSiteNotice ) {
423 $s .= "\n<div id='siteNotice'>$wgSiteNotice</div>\n";
425 $s .= $this->pageTitle();
426 $s .= $this->pageSubtitle() ;
427 $s .= $this->getCategories();
428 wfProfileOut( $fname );
433 function getCategoryLinks () {
434 global $wgOut, $wgTitle, $wgUser, $wgParser;
435 global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang;
437 if( !$wgUseCategoryMagic ) return '' ;
438 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
440 # Taken out so that they will be displayed in previews -- TS
441 #if( !$wgOut->isArticle() ) return '';
443 $t = implode ( ' | ' , $wgOut->mCategoryLinks
) ;
444 $s = $this->makeKnownLink( 'Special:Categories',
445 wfMsg( 'categories' ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
448 # optional 'dmoz-like' category browser. Will be shown under the list
449 # of categories an article belong to
450 if($wgUseCategoryBrowser) {
453 # get a big array of the parents tree
454 $parenttree = $wgTitle->getParentCategoryTree();
456 # Render the array as a serie of links
457 function walkThrough ($tree) {
459 $sk = $wgUser->getSkin();
461 foreach($tree as $element => $parent) {
463 # element start a new list
466 # grab the others elements
467 $return .= walkThrough($parent);
469 # add our current element to the list
470 $eltitle = Title
::NewFromText($element);
471 # FIXME : should be makeLink() [AV]
472 $return .= $sk->makeLink($element, $eltitle->getText()).' > ';
477 $s .= walkThrough($parenttree);
483 function getCategories() {
484 $catlinks=$this->getCategoryLinks();
485 if(!empty($catlinks)) {
486 return "<p class='catlinks'>{$catlinks}</p>";
490 function getQuickbarCompensator( $rows = 1 ) {
491 return "<td width='152' rowspan='{$rows}'> </td>";
494 # This gets called immediately before the </body> tag.
496 function afterContent() {
497 global $wgUser, $wgOut, $wgServer;
498 global $wgTitle, $wgLang;
500 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
501 return $printfooter . $this->doAfterContent();
504 function printSource() {
506 $url = htmlspecialchars( $wgTitle->getFullURL() );
507 return wfMsg( "retrievedfrom", "<a href=\"$url\">$url</a>" );
510 function printFooter() {
511 return "<p>" . $this->printSource() .
512 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
515 function doAfterContent() {
516 # overloaded by derived classes
519 function pageTitleLinks() {
520 global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgUseApproval, $wgRequest;
522 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
523 $action = $wgRequest->getText( 'action' );
525 $s = $this->printableLink();
526 $disclaimer = $this->disclaimerLink(); # may be empty
528 $s .= ' | ' . $disclaimer;
531 if ( $wgOut->isArticleRelated() ) {
532 if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
533 $name = $wgTitle->getDBkey();
534 $link = htmlspecialchars( Image
::wfImageUrl( $name ) );
535 $style = $this->getInternalLinkAttributes( $link, $name );
536 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
538 # This will show the "Approve" link if $wgUseApproval=true;
539 if ( isset ( $wgUseApproval ) && $wgUseApproval )
541 $t = $wgTitle->getDBkey();
542 $name = 'Approve this article' ;
543 $link = "http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ;
544 #htmlspecialchars( wfImageUrl( $name ) );
545 $style = $this->getExternalLinkAttributes( $link, $name );
546 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>" ;
549 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
550 $s .= ' | ' . $this->makeKnownLink( $wgTitle->getPrefixedText(),
551 wfMsg( 'currentrev' ) );
554 if ( $wgUser->getNewtalk() ) {
555 # do not show "You have new messages" text when we are viewing our
558 if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
559 $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
560 $n =$wgUser->getName();
561 $tl = $this->makeKnownLink( $wgContLang->getNsText(
562 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
563 wfMsg('newmessageslink') );
564 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
566 $wgOut->setSquidMaxage(0);
567 $wgOut->enableClientCache(false);
571 $undelete = $this->getUndeleteLink();
572 if( !empty( $undelete ) ) {
573 $s .= ' | '.$undelete;
578 function getUndeleteLink() {
579 global $wgUser, $wgTitle, $wgContLang, $action;
580 if( $wgUser->isAllowed('rollback') &&
581 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
582 ($n = $wgTitle->isDeleted() ) ) {
583 return wfMsg( 'thisisdeleted',
584 $this->makeKnownLink(
585 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
586 wfMsg( 'restorelink', $n ) ) );
591 function printableLink() {
592 global $wgOut, $wgFeedClasses, $wgRequest;
594 $baseurl = $_SERVER['REQUEST_URI'];
595 if( strpos( '?', $baseurl ) == false ) {
600 $baseurl = htmlspecialchars( $baseurl );
601 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
603 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
604 if( $wgOut->isSyndicated() ) {
605 foreach( $wgFeedClasses as $format => $class ) {
606 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
607 $s .= " | <a href=\"$feedurl\">{$format}</a>";
613 function pageTitle() {
614 global $wgOut, $wgTitle, $wgUser;
616 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
617 if($wgUser->getOption( 'editsectiononrightclick' ) && $wgTitle->userCanEdit()) { $s=$this->editSectionScript($wgTitle, 0,$s);}
621 function pageSubtitle() {
624 $sub = $wgOut->getSubtitle();
626 global $wgExtraSubtitle;
627 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
629 $subpages = $this->subPageSubtitle();
630 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
631 $s = "<p class='subtitle'>{$sub}</p>\n";
635 function subPageSubtitle() {
636 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
638 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
639 $ptext=$wgTitle->getPrefixedText();
640 if(preg_match('/\//',$ptext)) {
641 $links = explode('/',$ptext);
644 foreach($links as $link) {
646 if ($c<count($links)) {
647 $growinglink .= $link;
648 $getlink = $this->makeLink( $growinglink, $link );
649 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
653 $subpages .= '< ';
655 $subpages .= $getlink;
664 function nameAndLogin() {
665 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader, $wgIP;
667 $li = $wgContLang->specialPage( 'Userlogin' );
668 $lo = $wgContLang->specialPage( 'Userlogout' );
671 if ( 0 == $wgUser->getID() ) {
672 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
675 $tl = $this->makeKnownLink( $wgContLang->getNsText(
676 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
677 $wgContLang->getNsText( Namespace::getTalk( 0 ) ) );
679 $s .= $n . ' ('.$tl.')';
681 $s .= wfMsg('notloggedin');
684 $rt = $wgTitle->getPrefixedURL();
685 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
687 } else { $q = "returnto={$rt}"; }
689 $s .= "\n<br />" . $this->makeKnownLink( $li,
690 wfMsg( 'login' ), $q );
692 $n = $wgUser->getName();
693 $rt = $wgTitle->getPrefixedURL();
694 $tl = $this->makeKnownLink( $wgContLang->getNsText(
695 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
696 $wgContLang->getNsText( Namespace::getTalk( 0 ) ) );
700 $s .= $this->makeKnownLink( $wgContLang->getNsText(
701 Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}<br />" .
702 $this->makeKnownLink( $lo, wfMsg( 'logout' ),
703 "returnto={$rt}" ) . ' | ' .
704 $this->specialLink( 'preferences' );
706 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
712 function getSearchLink() {
713 $searchPage =& Title
::makeTitle( NS_SPECIAL
, 'Search' );
714 return $searchPage->getLocalURL();
717 function escapeSearchLink() {
718 return htmlspecialchars( $this->getSearchLink() );
721 function searchForm() {
723 $search = $wgRequest->getText( 'search' );
725 $s = '<form name="search" class="inline" method="post" action="'
726 . $this->escapeSearchLink() . "\">\n"
727 . '<input type="text" name="search" size="19" value="'
728 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
729 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
730 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
735 function topLinks() {
739 $s = $this->mainPageLink() . $sep
740 . $this->specialLink( 'recentchanges' );
742 if ( $wgOut->isArticleRelated() ) {
743 $s .= $sep . $this->editThisPage()
744 . $sep . $this->historyLink();
746 # Many people don't like this dropdown box
747 #$s .= $sep . $this->specialPagesList();
752 function bottomLinks() {
753 global $wgOut, $wgUser, $wgTitle;
757 if ( $wgOut->isArticleRelated() ) {
758 $s .= '<strong>' . $this->editThisPage() . '</strong>';
759 if ( 0 != $wgUser->getID() ) {
760 $s .= $sep . $this->watchThisPage();
762 $s .= $sep . $this->talkLink()
763 . $sep . $this->historyLink()
764 . $sep . $this->whatLinksHere()
765 . $sep . $this->watchPageLinksLink();
767 if ( $wgTitle->getNamespace() == Namespace::getUser()
768 ||
$wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) )
771 $id=User
::idFromName($wgTitle->getText());
772 $ip=User
::isIP($wgTitle->getText());
774 if($id ||
$ip) { # both anons and non-anons have contri list
775 $s .= $sep . $this->userContribsLink();
777 if( $this->showEmailUser( $id ) ) {
778 $s .= $sep . $this->emailUserLink();
781 if ( $wgTitle->getArticleId() ) {
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(); }
787 $s .= "<br />\n" . $this->otherLanguages();
792 function pageStats() {
793 global $wgOut, $wgLang, $wgArticle, $wgRequest;
794 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax;
796 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
797 if ( ! $wgOut->isArticle() ) { return ''; }
798 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
799 if ( 0 == $wgArticle->getID() ) { return ''; }
802 if ( !$wgDisableCounters ) {
803 $count = $wgLang->formatNum( $wgArticle->getCount() );
805 $s = wfMsg( 'viewcount', $count );
809 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
810 require_once("Credits.php");
811 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
813 $s .= $this->lastModified();
816 return $s . ' ' . $this->getCopyright();
819 function getCopyright() {
820 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
823 $oldid = $wgRequest->getVal( 'oldid' );
824 $diff = $wgRequest->getVal( 'diff' );
826 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
827 $msg = 'history_copyright';
833 if( $wgRightsPage ) {
834 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
835 } elseif( $wgRightsUrl ) {
836 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
841 $out .= wfMsgForContent( $msg, $link );
845 function getCopyrightIcon() {
846 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon;
848 if( $wgRightsIcon ) {
849 $icon = htmlspecialchars( $wgRightsIcon );
851 $url = htmlspecialchars( $wgRightsUrl );
852 $out .= '<a href="'.$url.'">';
854 $text = htmlspecialchars( $wgRightsText );
855 $out .= "<img src=\"$icon\" alt='$text' />";
863 function getPoweredBy() {
865 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
866 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
870 function lastModified() {
871 global $wgLang, $wgArticle;
873 $timestamp = $wgArticle->getTimestamp();
875 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
876 $s = ' ' . wfMsg( 'lastmodified', $d );
883 function logoText( $align = '' ) {
884 if ( '' != $align ) { $a = " align='{$align}'"; }
887 $mp = wfMsg( 'mainpage' );
888 $titleObj = Title
::newFromText( $mp );
889 if ( is_object( $titleObj ) ) {
890 $url = $titleObj->escapeLocalURL();
895 $logourl = $this->getLogo();
896 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
901 * show a drop-down box of special pages
902 * @TODO crash bug913. Need to be rewrote completly.
904 function specialPagesList() {
905 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript;
906 require_once('SpecialPage.php');
908 $pages = SpecialPage
::getPages();
910 foreach ( $pages[''] as $name => $page ) {
911 $a[$name] = $page->getDescription();
913 if ( $wgUser->isSysop() )
915 foreach ( $pages['sysop'] as $name => $page ) {
916 $a[$name] = $page->getDescription();
919 if ( $wgUser->isDeveloper() )
921 foreach ( $pages['developer'] as $name => $page ) {
922 $a[$name] = $page->getDescription() ;
926 $sp = wfMsg( 'specialpages' );
927 $spp = $wgContLang->specialPage( 'Specialpages' );
929 $s = '<form id="specialpages" method="get" class="inline" ' .
930 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
931 $s .= "<select name=\"wpDropdown\">\n";
932 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
934 foreach ( $a as $name => $desc ) {
935 $p = $wgContLang->specialPage( $name );
936 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
939 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
944 function mainPageLink() {
945 $mp = wfMsgForContent( 'mainpage' );
946 $mptxt = wfMsg( 'mainpage');
947 $s = $this->makeKnownLink( $mp, $mptxt );
951 function copyrightLink() {
952 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
953 wfMsg( 'copyrightpagename' ) );
957 function aboutLink() {
958 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
959 wfMsg( 'aboutsite' ) );
964 function disclaimerLink() {
965 $disclaimers = wfMsg( 'disclaimers' );
966 if ($disclaimers == '-') {
969 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
974 function editThisPage() {
975 global $wgOut, $wgTitle, $wgRequest;
977 $oldid = $wgRequest->getVal( 'oldid' );
978 $diff = $wgRequest->getVal( 'diff' );
979 $redirect = $wgRequest->getVal( 'redirect' );
981 if ( ! $wgOut->isArticleRelated() ) {
982 $s = wfMsg( 'protectedpage' );
984 $n = $wgTitle->getPrefixedText();
985 if ( $wgTitle->userCanEdit() ) {
986 $t = wfMsg( 'editthispage' );
988 #$t = wfMsg( "protectedpage" );
989 $t = wfMsg( 'viewsource' );
993 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
994 if ( $oldid && ! isset( $diff ) ) {
995 $oid = '&oldid='.$oldid;
997 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
1002 function deleteThisPage() {
1003 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1005 $diff = $wgRequest->getVal( 'diff' );
1006 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1007 $n = $wgTitle->getPrefixedText();
1008 $t = wfMsg( 'deletethispage' );
1010 $s = $this->makeKnownLink( $n, $t, 'action=delete' );
1017 function protectThisPage() {
1018 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1020 $diff = $wgRequest->getVal( 'diff' );
1021 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1022 $n = $wgTitle->getPrefixedText();
1024 if ( $wgTitle->isProtected() ) {
1025 $t = wfMsg( 'unprotectthispage' );
1026 $q = 'action=unprotect';
1028 $t = wfMsg( 'protectthispage' );
1029 $q = 'action=protect';
1031 $s = $this->makeKnownLink( $n, $t, $q );
1038 function watchThisPage() {
1039 global $wgUser, $wgOut, $wgTitle;
1041 if ( $wgOut->isArticleRelated() ) {
1042 $n = $wgTitle->getPrefixedText();
1044 if ( $wgTitle->userIsWatching() ) {
1045 $t = wfMsg( 'unwatchthispage' );
1046 $q = 'action=unwatch';
1048 $t = wfMsg( 'watchthispage' );
1049 $q = 'action=watch';
1051 $s = $this->makeKnownLink( $n, $t, $q );
1053 $s = wfMsg( 'notanarticle' );
1058 function moveThisPage() {
1059 global $wgTitle, $wgContLang;
1061 if ( $wgTitle->userCanMove() ) {
1062 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Movepage' ),
1063 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1064 } // no message if page is protected - would be redundant
1068 function historyLink() {
1071 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1072 wfMsg( 'history' ), 'action=history' );
1076 function whatLinksHere() {
1077 global $wgTitle, $wgContLang;
1079 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Whatlinkshere' ),
1080 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1084 function userContribsLink() {
1085 global $wgTitle, $wgContLang;
1087 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
1088 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1092 function showEmailUser( $id ) {
1093 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1094 return $wgEnableEmail &&
1095 $wgEnableUserEmail &&
1096 0 != $wgUser->getID() && # show only to signed in users
1097 0 != $id; # can only email non-anons
1100 function emailUserLink() {
1101 global $wgTitle, $wgContLang;
1103 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Emailuser' ),
1104 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1108 function watchPageLinksLink() {
1109 global $wgOut, $wgTitle, $wgContLang;
1111 if ( ! $wgOut->isArticleRelated() ) {
1112 $s = '(' . wfMsg( 'notanarticle' ) . ')';
1114 $s = $this->makeKnownLink( $wgContLang->specialPage(
1115 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1116 'target=' . $wgTitle->getPrefixedURL() );
1121 function otherLanguages() {
1122 global $wgOut, $wgContLang, $wgTitle, $wgUseNewInterlanguage;
1124 $a = $wgOut->getLanguageLinks();
1125 if ( 0 == count( $a ) ) {
1126 if ( !$wgUseNewInterlanguage ) return '';
1127 $ns = $wgContLang->getNsIndex ( $wgTitle->getNamespace () ) ;
1128 if ( $ns != 0 AND $ns != 1 ) return '' ;
1130 $x = 'mode=addlink&xt='.$wgTitle->getDBkey() ;
1131 return $this->makeKnownLink( $wgContLang->specialPage( $pn ),
1132 wfMsg( 'intl' ) , $x );
1135 if ( !$wgUseNewInterlanguage ) {
1136 $s = wfMsg( 'otherlanguages' ) . ': ';
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 ) . ': ' ;
1145 $s = wfMsg( 'otherlanguages' ) . ': ';
1147 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1148 foreach( $a as $l ) {
1149 if ( ! $first ) { $s .= ' | '; }
1152 $nt = Title
::newFromText( $l );
1153 $url = $nt->getFullURL();
1154 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1156 if ( '' == $text ) { $text = $l; }
1157 $style = $this->getExternalLinkAttributes( $l, $text );
1158 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1160 if($wgContLang->isRTL()) $s .= '</span>';
1164 function bugReportsLink() {
1165 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1166 wfMsg( 'bugreports' ) );
1170 function dateLink() {
1171 global $wgLinkCache;
1172 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1173 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1175 $wgLinkCache->suspend();
1176 $id = $t1->getArticleID();
1177 $wgLinkCache->resume();
1180 $s = $this->makeBrokenLink( $t1->getText() );
1182 $s = $this->makeKnownLink( $t1->getText() );
1186 $wgLinkCache->suspend();
1187 $id = $t2->getArticleID();
1188 $wgLinkCache->resume();
1191 $s .= $this->makeBrokenLink( $t2->getText() );
1193 $s .= $this->makeKnownLink( $t2->getText() );
1198 function talkLink() {
1199 global $wgContLang, $wgTitle, $wgLinkCache;
1201 $tns = $wgTitle->getNamespace();
1202 if ( -1 == $tns ) { return ''; }
1204 $pn = $wgTitle->getText();
1205 $tp = wfMsg( 'talkpage' );
1206 if ( Namespace::isTalk( $tns ) ) {
1207 $lns = Namespace::getSubject( $tns );
1210 $text = wfMsg('articlepage');
1213 $text = wfMsg('userpage');
1216 $text = wfMsg('wikipediapage');
1219 $text = wfMsg('imagepage');
1222 $text= wfMsg('articlepage');
1226 $lns = Namespace::getTalk( $tns );
1229 $n = $wgContLang->getNsText( $lns );
1230 if ( '' == $n ) { $link = $pn; }
1231 else { $link = $n.':'.$pn; }
1233 $wgLinkCache->suspend();
1234 $s = $this->makeLink( $link, $text );
1235 $wgLinkCache->resume();
1240 function commentLink() {
1241 global $wgContLang, $wgTitle, $wgLinkCache;
1243 $tns = $wgTitle->getNamespace();
1244 if ( -1 == $tns ) { return ''; }
1246 $lns = ( Namespace::isTalk( $tns ) ) ?
$tns : Namespace::getTalk( $tns );
1248 # assert Namespace::isTalk( $lns )
1250 $n = $wgContLang->getNsText( $lns );
1251 $pn = $wgTitle->getText();
1255 $wgLinkCache->suspend();
1256 $s = $this->makeKnownLink($link, wfMsg('postcomment'), 'action=edit§ion=new');
1257 $wgLinkCache->resume();
1263 * After all the page content is transformed into HTML, it makes
1264 * a final pass through here for things like table backgrounds.
1265 * @todo probably deprecated [AV]
1267 function transformContent( $text ) {
1272 * Note: This function MUST call getArticleID() on the link,
1273 * otherwise the cache won't get updated properly. See LINKCACHE.DOC.
1275 function makeLink( $title, $text = '', $query = '', $trail = '' ) {
1276 wfProfileIn( 'Skin::makeLink' );
1277 $nt = Title
::newFromText( $title );
1279 $result = $this->makeLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1281 wfDebug( 'Invalid title passed to Skin::makeLink(): "'.$title."\"\n" );
1282 $result = $text == "" ?
$title : $text;
1285 wfProfileOut( 'Skin::makeLink' );
1289 function makeKnownLink( $title, $text = '', $query = '', $trail = '', $prefix = '',$aprops = '') {
1290 $nt = Title
::newFromText( $title );
1292 return $this->makeKnownLinkObj( Title
::newFromText( $title ), $text, $query, $trail, $prefix , $aprops );
1294 wfDebug( 'Invalid title passed to Skin::makeKnownLink(): "'.$title."\"\n" );
1295 return $text == '' ?
$title : $text;
1299 function makeBrokenLink( $title, $text = '', $query = '', $trail = '' ) {
1300 $nt = Title
::newFromText( $title );
1302 return $this->makeBrokenLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1304 wfDebug( 'Invalid title passed to Skin::makeBrokenLink(): "'.$title."\"\n" );
1305 return $text == '' ?
$title : $text;
1309 function makeStubLink( $title, $text = '', $query = '', $trail = '' ) {
1310 $nt = Title
::newFromText( $title );
1312 return $this->makeStubLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1314 wfDebug( 'Invalid title passed to Skin::makeStubLink(): "'.$title."\"\n" );
1315 return $text == '' ?
$title : $text;
1320 * Pass a title object, not a title string
1322 function makeLinkObj( &$nt, $text= '', $query = '', $trail = '', $prefix = '' ) {
1323 global $wgOut, $wgUser, $wgLinkHolders;
1324 $fname = 'Skin::makeLinkObj';
1325 wfProfileIn( $fname );
1328 if ( ! isset($nt) ) {
1329 # wfDebugDieBacktrace();
1330 wfProfileOut( $fname );
1331 return "<!-- ERROR -->{$prefix}{$text}{$trail}";
1334 $ns = $nt->getNamespace();
1335 $dbkey = $nt->getDBkey();
1336 if ( $nt->isExternal() ) {
1337 $u = $nt->getFullURL();
1338 $link = $nt->getPrefixedURL();
1339 if ( '' == $text ) { $text = $nt->getPrefixedText(); }
1340 $style = $this->getExternalLinkAttributes( $link, $text, 'extiw' );
1343 if ( '' != $trail ) {
1344 if ( preg_match( '/^([a-z]+)(.*)$$/sD', $trail, $m ) ) {
1349 # Assume $this->postParseLinkColour(). This prevents
1350 # interwiki links from being parsed as external links.
1351 global $wgInterwikiLinkHolders;
1352 $t = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>";
1353 $nr = array_push($wgInterwikiLinkHolders, $t);
1354 $retVal = '<!--IWLINK '. ($nr-1) ."-->{$trail}";
1355 } elseif ( 0 == $ns && "" == $dbkey ) {
1356 # A self-link with a fragment; skip existence check.
1357 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1358 } elseif ( ( NS_SPECIAL
== $ns ) ||
( NS_IMAGE
== $ns ) ) {
1359 # These are always shown as existing, currently.
1360 # Special pages don't exist in the database; images may
1361 # occasionally be present when there is no description
1362 # page per se, so we always shown them.
1363 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1364 } elseif ( $this->postParseLinkColour
) {
1365 wfProfileIn( $fname.'-postparse' );
1366 # Insert a placeholder, and we'll work out the existence checks
1367 # in a big lump later.
1369 if ( '' != $trail ) {
1370 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1376 # These get picked up by Parser::replaceLinkHolders()
1377 $nr = array_push( $wgLinkHolders['namespaces'], $nt->getNamespace() );
1378 $wgLinkHolders['dbkeys'][] = $dbkey;
1379 $wgLinkHolders['queries'][] = $query;
1380 $wgLinkHolders['texts'][] = $prefix.$text.$inside;
1381 $wgLinkHolders['titles'][] =& $nt;
1383 $retVal = '<!--LINK '. ($nr-1) ."-->{$trail}";
1384 wfProfileOut( $fname.'-postparse' );
1386 wfProfileIn( $fname.'-immediate' );
1387 # Work out link colour immediately
1388 $aid = $nt->getArticleID() ;
1390 $retVal = $this->makeBrokenLinkObj( $nt, $text, $query, $trail, $prefix );
1392 $threshold = $wgUser->getOption('stubthreshold') ;
1393 if ( $threshold > 0 ) {
1394 $dbr =& wfGetDB( DB_SLAVE
);
1395 $s = $dbr->selectRow( 'cur', array( 'LENGTH(cur_text) AS x', 'cur_namespace',
1396 'cur_is_redirect' ), array( 'cur_id' => $aid ), $fname ) ;
1397 if ( $s !== false ) {
1399 if ( $s->cur_is_redirect
OR $s->cur_namespace
!= 0 ) {
1400 $size = $threshold*2 ; # Really big
1402 $dbr->freeResult( $res );
1404 $size = $threshold*2 ; # Really big
1409 if ( $size < $threshold ) {
1410 $retVal = $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix );
1412 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1415 wfProfileOut( $fname.'-immediate' );
1417 wfProfileOut( $fname );
1422 * Pass a title object, not a title string
1424 function makeKnownLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '' ) {
1425 global $wgOut, $wgTitle, $wgInputEncoding;
1427 $fname = 'Skin::makeKnownLinkObj';
1428 wfProfileIn( $fname );
1430 if ( !is_object( $nt ) ) {
1431 wfProfileIn( $fname );
1435 $u = $nt->escapeLocalURL( $query );
1436 if ( '' != $nt->getFragment() ) {
1437 if( $nt->getPrefixedDbkey() == '' ) {
1439 if ( '' == $text ) {
1440 $text = htmlspecialchars( $nt->getFragment() );
1443 $anchor = urlencode( do_html_entity_decode( str_replace(' ', '_', $nt->getFragment()), ENT_COMPAT
, $wgInputEncoding ) );
1444 $replacearray = array(
1448 $u .= '#' . str_replace(array_keys($replacearray),array_values($replacearray),$anchor);
1450 if ( '' == $text ) {
1451 $text = htmlspecialchars( $nt->getPrefixedText() );
1453 $style = $this->getInternalLinkAttributesObj( $nt, $text );
1456 if ( '' != $trail ) {
1457 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1462 $r = "<a href=\"{$u}\"{$style}{$aprops}>{$prefix}{$text}{$inside}</a>{$trail}";
1463 wfProfileOut( $fname );
1468 * Pass a title object, not a title string
1470 function makeBrokenLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
1471 global $wgOut, $wgUser;
1474 if ( ! isset($nt) ) {
1475 # wfDebugDieBacktrace();
1476 return "<!-- ERROR -->{$prefix}{$text}{$trail}";
1479 $fname = 'Skin::makeBrokenLinkObj';
1480 wfProfileIn( $fname );
1482 if ( '' == $query ) {
1485 $q = 'action=edit&'.$query;
1487 $u = $nt->escapeLocalURL( $q );
1489 if ( '' == $text ) {
1490 $text = htmlspecialchars( $nt->getPrefixedText() );
1492 $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" );
1495 if ( '' != $trail ) {
1496 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1501 if ( $wgUser->getOption( 'highlightbroken' ) ) {
1502 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
1504 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
1507 wfProfileOut( $fname );
1512 * Pass a title object, not a title string
1514 function makeStubLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
1515 global $wgOut, $wgUser;
1517 $link = $nt->getPrefixedURL();
1519 $u = $nt->escapeLocalURL( $query );
1521 if ( '' == $text ) {
1522 $text = htmlspecialchars( $nt->getPrefixedText() );
1524 $style = $this->getInternalLinkAttributesObj( $nt, $text, 'stub' );
1527 if ( '' != $trail ) {
1528 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1533 if ( $wgUser->getOption( 'highlightbroken' ) ) {
1534 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
1536 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
1541 function makeSelfLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
1542 $u = $nt->escapeLocalURL( $query );
1543 if ( '' == $text ) {
1544 $text = htmlspecialchars( $nt->getPrefixedText() );
1547 if ( '' != $trail ) {
1548 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1553 return "<strong>{$prefix}{$text}{$inside}</strong>{$trail}";
1556 /* these are used extensively in SkinPHPTal, but also some other places */
1557 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1558 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1559 $this->checkTitle($title, $name);
1560 return $title->getLocalURL( $urlaction );
1562 /*static*/ function makeTalkUrl ( $name, $urlaction='' ) {
1563 $title = Title
::newFromText( $name );
1564 $title = $title->getTalkPage();
1565 $this->checkTitle($title, $name);
1566 return $title->getLocalURL( $urlaction );
1568 /*static*/ function makeArticleUrl ( $name, $urlaction='' ) {
1569 $title = Title
::newFromText( $name );
1570 $title= $title->getSubjectPage();
1571 $this->checkTitle($title, $name);
1572 return $title->getLocalURL( $urlaction );
1574 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1575 $title = Title
::newFromText( wfMsgForContent($name) );
1576 $this->checkTitle($title, $name);
1577 return $title->getLocalURL( $urlaction );
1579 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1580 $title = Title
::newFromText( $name );
1581 $this->checkTitle($title, $name);
1582 return $title->getLocalURL( $urlaction );
1585 # If url string starts with http, consider as external URL, else
1587 /*static*/ function makeInternalOrExternalUrl( $name ) {
1588 if ( strncmp( $name, 'http', 4 ) == 0 ) {
1591 return $this->makeUrl( $name );
1595 # this can be passed the NS number as defined in Language.php
1596 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=0 ) {
1597 $title = Title
::makeTitleSafe( $namespace, $name );
1598 $this->checkTitle($title, $name);
1599 return $title->getLocalURL( $urlaction );
1602 /* these return an array with the 'href' and boolean 'exists' */
1603 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1604 $title = Title
::newFromText( $name );
1605 $this->checkTitle($title, $name);
1607 'href' => $title->getLocalURL( $urlaction ),
1608 'exists' => $title->getArticleID() != 0?
true:false
1611 /*static*/ function makeTalkUrlDetails ( $name, $urlaction='' ) {
1612 $title = Title
::newFromText( $name );
1613 $title = $title->getTalkPage();
1614 $this->checkTitle($title, $name);
1616 'href' => $title->getLocalURL( $urlaction ),
1617 'exists' => $title->getArticleID() != 0?
true:false
1620 /*static*/ function makeArticleUrlDetails ( $name, $urlaction='' ) {
1621 $title = Title
::newFromText( $name );
1622 $title= $title->getSubjectPage();
1623 $this->checkTitle($title, $name);
1625 'href' => $title->getLocalURL( $urlaction ),
1626 'exists' => $title->getArticleID() != 0?
true:false
1629 /*static*/ function makeI18nUrlDetails ( $name, $urlaction='' ) {
1630 $title = Title
::newFromText( wfMsgForContent($name) );
1631 $this->checkTitle($title, $name);
1633 'href' => $title->getLocalURL( $urlaction ),
1634 'exists' => $title->getArticleID() != 0?
true:false
1638 # make sure we have some title to operate on
1639 /*static*/ function checkTitle ( &$title, &$name ) {
1640 if(!is_object($title)) {
1641 $title = Title
::newFromText( $name );
1642 if(!is_object($title)) {
1643 $title = Title
::newFromText( '--error: link target missing--' );
1648 function fnamePart( $url ) {
1649 $basename = strrchr( $url, '/' );
1650 if ( false === $basename ) {
1653 $basename = substr( $basename, 1 );
1655 return htmlspecialchars( $basename );
1658 function makeImage( $url, $alt = '' ) {
1661 $alt = $this->fnamePart( $url );
1663 $s = '<img src="'.$url.'" alt="'.$alt.'" />';
1667 function makeImageLink( $name, $url, $alt = '' ) {
1668 $nt = Title
::makeTitleSafe( NS_IMAGE
, $name );
1669 return $this->makeImageLinkObj( $nt, $alt );
1672 function makeImageLinkObj( $nt, $alt = '' ) {
1673 global $wgContLang, $wgUseImageResize;
1674 $img = Image
::newFromTitle( $nt );
1675 $url = $img->getViewURL();
1678 $prefix = $postfix = '';
1680 # Check if the alt text is of the form "options|alt text"
1682 # * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang
1683 # * left no resizing, just left align. label is used for alt= only
1684 # * right same, but right aligned
1685 # * none same, but not aligned
1686 # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox
1687 # * center center the image
1688 # * framed Keep original image size, no magnify-button.
1690 $part = explode( '|', $alt);
1692 $mwThumb =& MagicWord
::get( MAG_IMG_THUMBNAIL
);
1693 $mwLeft =& MagicWord
::get( MAG_IMG_LEFT
);
1694 $mwRight =& MagicWord
::get( MAG_IMG_RIGHT
);
1695 $mwNone =& MagicWord
::get( MAG_IMG_NONE
);
1696 $mwWidth =& MagicWord
::get( MAG_IMG_WIDTH
);
1697 $mwCenter =& MagicWord
::get( MAG_IMG_CENTER
);
1698 $mwFramed =& MagicWord
::get( MAG_IMG_FRAMED
);
1701 $height = $framed = $thumb = false;
1702 $manual_thumb = "" ;
1704 foreach( $part as $key => $val ) {
1705 $val_parts = explode ( "=" , $val , 2 ) ;
1706 $left_part = array_shift ( $val_parts ) ;
1707 if ( $wgUseImageResize && ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) {
1709 } elseif ( $wgUseImageResize && count ( $val_parts ) == 1 && ! is_null( $mwThumb->matchVariableStartToEnd($left_part) ) ) {
1710 # use manually specified thumbnail
1712 $manual_thumb = array_shift ( $val_parts ) ;
1713 } elseif ( ! is_null( $mwRight->matchVariableStartToEnd($val) ) ) {
1714 # remember to set an alignment, don't render immediately
1716 } elseif ( ! is_null( $mwLeft->matchVariableStartToEnd($val) ) ) {
1717 # remember to set an alignment, don't render immediately
1719 } elseif ( ! is_null( $mwCenter->matchVariableStartToEnd($val) ) ) {
1720 # remember to set an alignment, don't render immediately
1722 } elseif ( ! is_null( $mwNone->matchVariableStartToEnd($val) ) ) {
1723 # remember to set an alignment, don't render immediately
1725 } elseif ( $wgUseImageResize && ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
1726 # $match is the image width in pixels
1727 if ( preg_match( '/^([0-9]*)x([0-9]*)$/', $match, $m ) ) {
1728 $width = intval( $m[1] );
1729 $height = intval( $m[2] );
1731 $width = intval($match);
1733 } elseif ( ! is_null( $mwFramed->matchVariableStartToEnd($val) ) ) {
1739 if ( 'center' == $align )
1741 $prefix = '<div class="center">';
1742 $postfix = '</div>';
1746 if ( $thumb ||
$framed ) {
1748 # Create a thumbnail. Alignment depends on language
1749 # writing direction, # right aligned for left-to-right-
1750 # languages ("Western languages"), left-aligned
1751 # for right-to-left-languages ("Semitic languages")
1753 # If thumbnail width has not been provided, it is set
1754 # here to 180 pixels
1755 if ( $align == '' ) {
1756 $align = $wgContLang->isRTL() ?
'left' : 'right';
1758 if ( ! isset($width) ) {
1761 return $prefix.$this->makeThumbLinkObj( $img, $alt, $align, $width, $height, $framed, $manual_thumb ).$postfix;
1763 } elseif ( isset($width) ) {
1765 # Create a resized image, without the additional thumbnail
1768 if ( ( ! $height === false )
1769 && ( $img->getHeight() * $width / $img->getWidth() > $height ) ) {
1770 $width = $img->getWidth() * $height / $img->getHeight();
1772 if ( '' == $manual_thumb ) $url = $img->createThumb( $width );
1775 $alt = preg_replace( '/<[^>]*>/', '', $alt );
1776 $alt = preg_replace('/&(?!:amp;|#[Xx][0-9A-fa-f]+;|#[0-9]+;|[a-zA-Z0-9]+;)/', '&', $alt);
1777 $alt = str_replace( array('<', '>', '"'), array('<', '>', '"'), $alt );
1779 $u = $nt->escapeLocalURL();
1781 $s = wfMsg( 'missingimage', $img->getName() );
1782 $s .= "<br>{$alt}<br>{$url}<br>\n";
1784 $s = '<a href="'.$u.'" class="image" title="'.$alt.'">' .
1785 '<img src="'.$url.'" alt="'.$alt.'" longdesc="'.$u.'" /></a>';
1787 if ( '' != $align ) {
1788 $s = "<div class=\"float{$align}\"><span>{$s}</span></div>";
1790 return str_replace("\n", ' ',$prefix.$s.$postfix);
1794 * Make HTML for a thumbnail including image, border and caption
1795 * $img is an Image object
1797 function makeThumbLinkObj( $img, $label = '', $align = 'right', $boxwidth = 180, $boxheight=false, $framed=false , $manual_thumb = "" ) {
1798 global $wgStylePath, $wgContLang;
1799 # $image = Title::makeTitleSafe( NS_IMAGE, $name );
1800 $url = $img->getViewURL();
1802 #$label = htmlspecialchars( $label );
1803 $alt = preg_replace( '/<[^>]*>/', '', $label);
1804 $alt = preg_replace('/&(?!:amp;|#[Xx][0-9A-fa-f]+;|#[0-9]+;|[a-zA-Z0-9]+;)/', '&', $alt);
1805 $alt = str_replace( array('<', '>', '"'), array('<', '>', '"'), $alt );
1807 $width = $height = 0;
1808 if ( $img->exists() )
1810 $width = $img->getWidth();
1811 $height = $img->getHeight();
1813 if ( 0 == $width ||
0 == $height )
1815 $width = $height = 200;
1817 if ( $boxwidth == 0 )
1823 // Use image dimensions, don't scale
1825 $oboxwidth = $boxwidth +
2;
1826 $boxheight = $height;
1829 $h = intval( $height/($width/$boxwidth) );
1830 $oboxwidth = $boxwidth +
2;
1831 if ( ( ! $boxheight === false ) && ( $h > $boxheight ) )
1833 $boxwidth *= $boxheight/$h;
1837 if ( '' == $manual_thumb ) $thumbUrl = $img->createThumb( $boxwidth );
1840 if ( $manual_thumb != '' ) # Use manually specified thumbnail
1842 $manual_title = Title
::makeTitleSafe( NS_IMAGE
, $manual_thumb ); #new Title ( $manual_thumb ) ;
1843 $manual_img = Image
::newFromTitle( $manual_title );
1844 $thumbUrl = $manual_img->getViewURL();
1845 if ( $manual_img->exists() )
1847 $width = $manual_img->getWidth();
1848 $height = $manual_img->getHeight();
1849 $boxwidth = $width ;
1850 $boxheight = $height ;
1851 $oboxwidth = $boxwidth +
2 ;
1855 $u = $img->getEscapeLocalURL();
1857 $more = htmlspecialchars( wfMsg( 'thumbnail-more' ) );
1858 $magnifyalign = $wgContLang->isRTL() ?
'left' : 'right';
1859 $textalign = $wgContLang->isRTL() ?
' style="text-align:right"' : '';
1861 $s = "<div class=\"thumb t{$align}\"><div style=\"width:{$oboxwidth}px;\">";
1862 if ( $thumbUrl == '' ) {
1863 $s .= wfMsg( 'missingimage', $img->getName() );
1866 $s .= '<a href="'.$u.'" class="internal" title="'.$alt.'">'.
1867 '<img src="'.$thumbUrl.'" alt="'.$alt.'" ' .
1868 'width="'.$boxwidth.'" height="'.$boxheight.'" ' .
1869 'longdesc="'.$u.'" /></a>';
1873 $zoomicon = '<div class="magnify" style="float:'.$magnifyalign.'">'.
1874 '<a href="'.$u.'" class="internal" title="'.$more.'">'.
1875 '<img src="'.$wgStylePath.'/common/images/magnify-clip.png" ' .
1876 'width="15" height="11" alt="'.$more.'" /></a></div>';
1879 $s .= ' <div class="thumbcaption" '.$textalign.'>'.$zoomicon.$label."</div></div></div>";
1880 return str_replace("\n", ' ', $s);
1883 function makeMediaLink( $name, $url, $alt = '' ) {
1884 $nt = Title
::makeTitleSafe( NS_IMAGE
, $name );
1885 return $this->makeMediaLinkObj( $nt, $alt );
1888 function makeMediaLinkObj( $nt, $alt = '', $nourl=false ) {
1889 if ( ! isset( $nt ) )
1891 ### HOTFIX. Instead of breaking, return empty string.
1894 $name = $nt->getDBKey();
1895 $img = Image
::newFromTitle( $nt );
1896 $url = $img->getURL();
1897 # $nourl can be set by the parser
1898 # this is a hack to mask absolute URLs, so the parser doesn't
1899 # linkify them (it is currently not context-aware)
1901 if ($nourl) { $url=str_replace("http://","http-noparse://",$url) ; }
1902 if ( empty( $alt ) ) {
1903 $alt = preg_replace( '/\.(.+?)^/', '', $name );
1905 $u = htmlspecialchars( $url );
1906 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
1911 function specialLink( $name, $key = '' ) {
1914 if ( '' == $key ) { $key = strtolower( $name ); }
1915 $pn = $wgContLang->ucfirst( $name );
1916 return $this->makeKnownLink( $wgContLang->specialPage( $pn ),
1920 function makeExternalLink( $url, $text, $escape = true ) {
1921 $style = $this->getExternalLinkAttributes( $url, $text );
1922 $url = htmlspecialchars( $url );
1924 $text = htmlspecialchars( $text );
1926 return '<a href="'.$url.'"'.$style.'>'.$text.'</a>';
1931 * This function is called by all recent changes variants, by the page history,
1932 * and by the user contributions list. It is responsible for formatting edit
1933 * comments. It escapes any HTML in the comment, but adds some CSS to format
1934 * auto-generated comments (from section editing) and formats [[wikilinks]].
1936 * The &$title parameter must be a title OBJECT. It is used to generate a
1937 * direct link to the section in the autocomment.
1938 * @author Erik Moeller <moeller@scireview.de>
1940 * Note: there's not always a title to pass to this function.
1941 * Since you can't set a default parameter for a reference, I've turned it
1942 * temporarily to a value pass. Should be adjusted further. --brion
1944 function formatComment($comment, $title = NULL) {
1945 $fname = 'Skin::formatComment';
1946 wfProfileIn( $fname );
1949 $comment = htmlspecialchars( $comment );
1951 # The pattern for autogen comments is / * foo * /, which makes for
1953 # We look for all comments, match any text before and after the comment,
1954 # add a separator where needed and format the comment itself with CSS
1955 while (preg_match('/(.*)\/\*\s*(.*?)\s*\*\/(.*)/', $comment,$match)) {
1963 # This is hackish but should work in most cases.
1964 $section=str_replace('[[','',$section);
1965 $section=str_replace(']]','',$section);
1966 $title->mFragment
=$section;
1967 $link=$this->makeKnownLinkObj($title,wfMsg('sectionlink'));
1971 if($pre) { $auto = $sep.' '.$auto; }
1972 if($post) { $auto .= ' '.$sep; }
1973 $auto='<span class="autocomment">'.$auto.'</span>';
1974 $comment=$pre.$auto.$post;
1977 # format regular and media links - all other wiki formatting
1979 $medians = $wgContLang->getNsText(Namespace::getMedia()).':';
1980 while(preg_match('/\[\[(.*?)(\|(.*?))*\]\](.*)$/',$comment,$match)) {
1981 # Handle link renaming [[foo|text]] will show link as "text"
1982 if( "" != $match[3] ) {
1987 if( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) {
1988 # Media link; trail not supported.
1989 $linkRegexp = '/\[\[(.*?)\]\]/';
1990 $thelink = $this->makeMediaLink( $submatch[1], "", $text );
1992 # Other kind of link
1993 if( preg_match( wfMsgForContent( "linktrail" ), $match[4], $submatch ) ) {
1994 $trail = $submatch[1];
1998 $linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/';
1999 if ($match[1][0] == ':')
2000 $match[1] = substr($match[1], 1);
2001 $thelink = $this->makeLink( $match[1], $text, "", $trail );
2003 $comment = preg_replace( $linkRegexp, $thelink, $comment, 1 );
2005 wfProfileOut( $fname );
2009 function tocIndent($level) {
2010 return str_repeat( '<div class="tocindent">'."\n", $level>0 ?
$level : 0 );
2013 function tocUnindent($level) {
2014 return str_repeat( "</div>\n", $level>0 ?
$level : 0 );
2018 * parameter level defines if we are on an indentation level
2020 function tocLine( $anchor, $tocline, $level ) {
2021 $link = '<a href="#'.$anchor.'">'.$tocline.'</a><br />';
2025 return '<div class="tocline">'.$link."</div>\n";
2030 function tocTable($toc) {
2031 # note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
2032 # try min-width & co when somebody gets a chance
2033 $hideline = ' <script type="text/javascript">showTocToggle("' . addslashes( wfMsg('showtoc') ) . '","' . addslashes( wfMsg('hidetoc') ) . '")</script>';
2035 '<table border="0" id="toc"><tr id="toctitle"><td align="center">'."\n".
2036 '<b>'.wfMsgForContent('toc').'</b>' .
2038 '</td></tr><tr id="tocinside"><td>'."\n".
2039 $toc."</td></tr></table>\n";
2043 * These two do not check for permissions: check $wgTitle->userCanEdit
2044 * before calling them
2046 function editSectionScriptForOther( $title, $section, $head ) {
2047 $ttl = Title
::newFromText( $title );
2048 $url = $ttl->escapeLocalURL( 'action=edit§ion='.$section );
2049 return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
2052 function editSectionScript( $nt, $section, $head ) {
2054 if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
2057 $url = $nt->escapeLocalURL( 'action=edit§ion='.$section );
2058 return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
2061 function editSectionLinkForOther( $title, $section ) {
2065 $title = Title
::newFromText($title);
2066 $editurl = '§ion='.$section;
2067 $url = $this->makeKnownLink($title->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
2069 if( $wgContLang->isRTL() ) {
2071 $nearside = 'right';
2076 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
2080 function editSectionLink( $nt, $section ) {
2084 if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
2085 # Section edit links would be out of sync on an old page.
2086 # But, if we're diffing to the current page, they'll be
2091 $editurl = '§ion='.$section;
2092 $url = $this->makeKnownLink($nt->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
2094 if( $wgContLang->isRTL() ) {
2096 $nearside = 'right';
2101 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
2108 function suppressUrlExpansion() {