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 ( 0 != $wgUser->getID() ) { # show only to signed in users
778 if($id) { # can only email non-anons
779 $s .= $sep . $this->emailUserLink();
783 if ( $wgTitle->getArticleId() ) {
785 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
786 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
787 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
789 $s .= "<br />\n" . $this->otherLanguages();
794 function pageStats() {
795 global $wgOut, $wgLang, $wgArticle, $wgRequest;
796 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax;
798 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
799 if ( ! $wgOut->isArticle() ) { return ''; }
800 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
801 if ( 0 == $wgArticle->getID() ) { return ''; }
804 if ( !$wgDisableCounters ) {
805 $count = $wgLang->formatNum( $wgArticle->getCount() );
807 $s = wfMsg( 'viewcount', $count );
811 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
812 require_once("Credits.php");
813 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
815 $s .= $this->lastModified();
818 return $s . ' ' . $this->getCopyright();
821 function getCopyright() {
822 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
825 $oldid = $wgRequest->getVal( 'oldid' );
826 $diff = $wgRequest->getVal( 'diff' );
828 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
829 $msg = 'history_copyright';
835 if( $wgRightsPage ) {
836 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
837 } elseif( $wgRightsUrl ) {
838 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
843 $out .= wfMsgForContent( $msg, $link );
847 function getCopyrightIcon() {
848 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon;
850 if( $wgRightsIcon ) {
851 $icon = htmlspecialchars( $wgRightsIcon );
853 $url = htmlspecialchars( $wgRightsUrl );
854 $out .= '<a href="'.$url.'">';
856 $text = htmlspecialchars( $wgRightsText );
857 $out .= "<img src=\"$icon\" alt='$text' />";
865 function getPoweredBy() {
867 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
868 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
872 function lastModified() {
873 global $wgLang, $wgArticle;
875 $timestamp = $wgArticle->getTimestamp();
877 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
878 $s = ' ' . wfMsg( 'lastmodified', $d );
885 function logoText( $align = '' ) {
886 if ( '' != $align ) { $a = " align='{$align}'"; }
889 $mp = wfMsg( 'mainpage' );
890 $titleObj = Title
::newFromText( $mp );
891 if ( is_object( $titleObj ) ) {
892 $url = $titleObj->escapeLocalURL();
897 $logourl = $this->getLogo();
898 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
903 * show a drop-down box of special pages
904 * @TODO crash bug913. Need to be rewrote completly.
906 function specialPagesList() {
907 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript;
908 require_once('SpecialPage.php');
910 $pages = SpecialPage
::getPages();
912 foreach ( $pages[''] as $name => $page ) {
913 $a[$name] = $page->getDescription();
915 if ( $wgUser->isSysop() )
917 foreach ( $pages['sysop'] as $name => $page ) {
918 $a[$name] = $page->getDescription();
921 if ( $wgUser->isDeveloper() )
923 foreach ( $pages['developer'] as $name => $page ) {
924 $a[$name] = $page->getDescription() ;
928 $sp = wfMsg( 'specialpages' );
929 $spp = $wgContLang->specialPage( 'Specialpages' );
931 $s = '<form id="specialpages" method="get" class="inline" ' .
932 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
933 $s .= "<select name=\"wpDropdown\">\n";
934 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
936 foreach ( $a as $name => $desc ) {
937 $p = $wgContLang->specialPage( $name );
938 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
941 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
946 function mainPageLink() {
947 $mp = wfMsgForContent( 'mainpage' );
948 $mptxt = wfMsg( 'mainpage');
949 $s = $this->makeKnownLink( $mp, $mptxt );
953 function copyrightLink() {
954 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
955 wfMsg( 'copyrightpagename' ) );
959 function aboutLink() {
960 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
961 wfMsg( 'aboutsite' ) );
966 function disclaimerLink() {
967 $disclaimers = wfMsg( 'disclaimers' );
968 if ($disclaimers == '-') {
971 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
976 function editThisPage() {
977 global $wgOut, $wgTitle, $wgRequest;
979 $oldid = $wgRequest->getVal( 'oldid' );
980 $diff = $wgRequest->getVal( 'diff' );
981 $redirect = $wgRequest->getVal( 'redirect' );
983 if ( ! $wgOut->isArticleRelated() ) {
984 $s = wfMsg( 'protectedpage' );
986 $n = $wgTitle->getPrefixedText();
987 if ( $wgTitle->userCanEdit() ) {
988 $t = wfMsg( 'editthispage' );
990 #$t = wfMsg( "protectedpage" );
991 $t = wfMsg( 'viewsource' );
995 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
996 if ( $oldid && ! isset( $diff ) ) {
997 $oid = '&oldid='.$oldid;
999 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
1004 function deleteThisPage() {
1005 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1007 $diff = $wgRequest->getVal( 'diff' );
1008 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1009 $n = $wgTitle->getPrefixedText();
1010 $t = wfMsg( 'deletethispage' );
1012 $s = $this->makeKnownLink( $n, $t, 'action=delete' );
1019 function protectThisPage() {
1020 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1022 $diff = $wgRequest->getVal( 'diff' );
1023 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1024 $n = $wgTitle->getPrefixedText();
1026 if ( $wgTitle->isProtected() ) {
1027 $t = wfMsg( 'unprotectthispage' );
1028 $q = 'action=unprotect';
1030 $t = wfMsg( 'protectthispage' );
1031 $q = 'action=protect';
1033 $s = $this->makeKnownLink( $n, $t, $q );
1040 function watchThisPage() {
1041 global $wgUser, $wgOut, $wgTitle;
1043 if ( $wgOut->isArticleRelated() ) {
1044 $n = $wgTitle->getPrefixedText();
1046 if ( $wgTitle->userIsWatching() ) {
1047 $t = wfMsg( 'unwatchthispage' );
1048 $q = 'action=unwatch';
1050 $t = wfMsg( 'watchthispage' );
1051 $q = 'action=watch';
1053 $s = $this->makeKnownLink( $n, $t, $q );
1055 $s = wfMsg( 'notanarticle' );
1060 function moveThisPage() {
1061 global $wgTitle, $wgContLang;
1063 if ( $wgTitle->userCanEdit() ) {
1064 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Movepage' ),
1065 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1066 } // no message if page is protected - would be redundant
1070 function historyLink() {
1073 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1074 wfMsg( 'history' ), 'action=history' );
1078 function whatLinksHere() {
1079 global $wgTitle, $wgContLang;
1081 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Whatlinkshere' ),
1082 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1086 function userContribsLink() {
1087 global $wgTitle, $wgContLang;
1089 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
1090 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1094 function emailUserLink() {
1095 global $wgTitle, $wgContLang;
1097 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Emailuser' ),
1098 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1102 function watchPageLinksLink() {
1103 global $wgOut, $wgTitle, $wgContLang;
1105 if ( ! $wgOut->isArticleRelated() ) {
1106 $s = '(' . wfMsg( 'notanarticle' ) . ')';
1108 $s = $this->makeKnownLink( $wgContLang->specialPage(
1109 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1110 'target=' . $wgTitle->getPrefixedURL() );
1115 function otherLanguages() {
1116 global $wgOut, $wgContLang, $wgTitle, $wgUseNewInterlanguage;
1118 $a = $wgOut->getLanguageLinks();
1119 if ( 0 == count( $a ) ) {
1120 if ( !$wgUseNewInterlanguage ) return '';
1121 $ns = $wgContLang->getNsIndex ( $wgTitle->getNamespace () ) ;
1122 if ( $ns != 0 AND $ns != 1 ) return '' ;
1124 $x = 'mode=addlink&xt='.$wgTitle->getDBkey() ;
1125 return $this->makeKnownLink( $wgContLang->specialPage( $pn ),
1126 wfMsg( 'intl' ) , $x );
1129 if ( !$wgUseNewInterlanguage ) {
1130 $s = wfMsg( 'otherlanguages' ) . ': ';
1132 global $wgContLanguageCode ;
1133 $x = 'mode=zoom&xt='.$wgTitle->getDBkey() ;
1134 $x .= '&xl='.$wgContLanguageCode ;
1135 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Intl' ),
1136 wfMsg( 'otherlanguages' ) , $x ) . ': ' ;
1139 $s = wfMsg( 'otherlanguages' ) . ': ';
1141 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1142 foreach( $a as $l ) {
1143 if ( ! $first ) { $s .= ' | '; }
1146 $nt = Title
::newFromText( $l );
1147 $url = $nt->getFullURL();
1148 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1150 if ( '' == $text ) { $text = $l; }
1151 $style = $this->getExternalLinkAttributes( $l, $text );
1152 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1154 if($wgContLang->isRTL()) $s .= '</span>';
1158 function bugReportsLink() {
1159 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1160 wfMsg( 'bugreports' ) );
1164 function dateLink() {
1165 global $wgLinkCache;
1166 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1167 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1169 $wgLinkCache->suspend();
1170 $id = $t1->getArticleID();
1171 $wgLinkCache->resume();
1174 $s = $this->makeBrokenLink( $t1->getText() );
1176 $s = $this->makeKnownLink( $t1->getText() );
1180 $wgLinkCache->suspend();
1181 $id = $t2->getArticleID();
1182 $wgLinkCache->resume();
1185 $s .= $this->makeBrokenLink( $t2->getText() );
1187 $s .= $this->makeKnownLink( $t2->getText() );
1192 function talkLink() {
1193 global $wgContLang, $wgTitle, $wgLinkCache;
1195 $tns = $wgTitle->getNamespace();
1196 if ( -1 == $tns ) { return ''; }
1198 $pn = $wgTitle->getText();
1199 $tp = wfMsg( 'talkpage' );
1200 if ( Namespace::isTalk( $tns ) ) {
1201 $lns = Namespace::getSubject( $tns );
1204 $text = wfMsg('articlepage');
1207 $text = wfMsg('userpage');
1210 $text = wfMsg('wikipediapage');
1213 $text = wfMsg('imagepage');
1216 $text= wfMsg('articlepage');
1220 $lns = Namespace::getTalk( $tns );
1223 $n = $wgContLang->getNsText( $lns );
1224 if ( '' == $n ) { $link = $pn; }
1225 else { $link = $n.':'.$pn; }
1227 $wgLinkCache->suspend();
1228 $s = $this->makeLink( $link, $text );
1229 $wgLinkCache->resume();
1234 function commentLink() {
1235 global $wgContLang, $wgTitle, $wgLinkCache;
1237 $tns = $wgTitle->getNamespace();
1238 if ( -1 == $tns ) { return ''; }
1240 $lns = ( Namespace::isTalk( $tns ) ) ?
$tns : Namespace::getTalk( $tns );
1242 # assert Namespace::isTalk( $lns )
1244 $n = $wgContLang->getNsText( $lns );
1245 $pn = $wgTitle->getText();
1249 $wgLinkCache->suspend();
1250 $s = $this->makeKnownLink($link, wfMsg('postcomment'), 'action=edit§ion=new');
1251 $wgLinkCache->resume();
1257 * After all the page content is transformed into HTML, it makes
1258 * a final pass through here for things like table backgrounds.
1259 * @todo probably deprecated [AV]
1261 function transformContent( $text ) {
1266 * Note: This function MUST call getArticleID() on the link,
1267 * otherwise the cache won't get updated properly. See LINKCACHE.DOC.
1269 function makeLink( $title, $text = '', $query = '', $trail = '' ) {
1270 wfProfileIn( 'Skin::makeLink' );
1271 $nt = Title
::newFromText( $title );
1273 $result = $this->makeLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1275 wfDebug( 'Invalid title passed to Skin::makeLink(): "'.$title."\"\n" );
1276 $result = $text == "" ?
$title : $text;
1279 wfProfileOut( 'Skin::makeLink' );
1283 function makeKnownLink( $title, $text = '', $query = '', $trail = '', $prefix = '',$aprops = '') {
1284 $nt = Title
::newFromText( $title );
1286 return $this->makeKnownLinkObj( Title
::newFromText( $title ), $text, $query, $trail, $prefix , $aprops );
1288 wfDebug( 'Invalid title passed to Skin::makeKnownLink(): "'.$title."\"\n" );
1289 return $text == '' ?
$title : $text;
1293 function makeBrokenLink( $title, $text = '', $query = '', $trail = '' ) {
1294 $nt = Title
::newFromText( $title );
1296 return $this->makeBrokenLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1298 wfDebug( 'Invalid title passed to Skin::makeBrokenLink(): "'.$title."\"\n" );
1299 return $text == '' ?
$title : $text;
1303 function makeStubLink( $title, $text = '', $query = '', $trail = '' ) {
1304 $nt = Title
::newFromText( $title );
1306 return $this->makeStubLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1308 wfDebug( 'Invalid title passed to Skin::makeStubLink(): "'.$title."\"\n" );
1309 return $text == '' ?
$title : $text;
1314 * Pass a title object, not a title string
1316 function makeLinkObj( &$nt, $text= '', $query = '', $trail = '', $prefix = '' ) {
1317 global $wgOut, $wgUser, $wgLinkHolders;
1318 $fname = 'Skin::makeLinkObj';
1321 if ( ! isset($nt) ) {
1322 # wfDebugDieBacktrace();
1323 return "<!-- ERROR -->{$prefix}{$text}{$trail}";
1326 if ( $nt->isExternal() ) {
1327 $u = $nt->getFullURL();
1328 $link = $nt->getPrefixedURL();
1329 if ( '' == $text ) { $text = $nt->getPrefixedText(); }
1330 $style = $this->getExternalLinkAttributes( $link, $text, 'extiw' );
1333 if ( '' != $trail ) {
1334 if ( preg_match( '/^([a-z]+)(.*)$$/sD', $trail, $m ) ) {
1339 # Assume $this->postParseLinkColour(). This prevents
1340 # interwiki links from being parsed as external links.
1341 global $wgInterwikiLinkHolders;
1342 $t = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>";
1343 $nr = array_push($wgInterwikiLinkHolders, $t);
1344 $retVal = '<!--IWLINK '. ($nr-1) ."-->{$trail}";
1345 } elseif ( 0 == $nt->getNamespace() && "" == $nt->getText() ) {
1346 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1347 } elseif ( ( -1 == $nt->getNamespace() ) ||
1348 ( NS_IMAGE
== $nt->getNamespace() ) ) {
1349 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1351 if ( $this->postParseLinkColour() ) {
1353 if ( '' != $trail ) {
1354 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1360 # Allows wiki to bypass using linkcache, see OutputPage::parseLinkHolders()
1361 $nr = array_push( $wgLinkHolders['namespaces'], $nt->getNamespace() );
1362 $wgLinkHolders['dbkeys'][] = $nt->getDBkey();
1363 $wgLinkHolders['queries'][] = $query;
1364 $wgLinkHolders['texts'][] = $prefix.$text.$inside;
1365 $wgLinkHolders['titles'][] = $nt;
1367 $retVal = '<!--LINK '. ($nr-1) ."-->{$trail}";
1369 # Work out link colour immediately
1370 $aid = $nt->getArticleID() ;
1372 $retVal = $this->makeBrokenLinkObj( $nt, $text, $query, $trail, $prefix );
1374 $threshold = $wgUser->getOption('stubthreshold') ;
1375 if ( $threshold > 0 ) {
1376 $dbr =& wfGetDB( DB_SLAVE
);
1377 $s = $dbr->selectRow( 'cur', array( 'LENGTH(cur_text) AS x', 'cur_namespace',
1378 'cur_is_redirect' ), array( 'cur_id' => $aid ), $fname ) ;
1379 if ( $s !== false ) {
1381 if ( $s->cur_is_redirect
OR $s->cur_namespace
!= 0 ) {
1382 $size = $threshold*2 ; # Really big
1384 $dbr->freeResult( $res );
1386 $size = $threshold*2 ; # Really big
1391 if ( $size < $threshold ) {
1392 $retVal = $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix );
1394 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1403 * Pass a title object, not a title string
1405 function makeKnownLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '' ) {
1406 global $wgOut, $wgTitle, $wgInputEncoding;
1408 $fname = 'Skin::makeKnownLinkObj';
1409 wfProfileIn( $fname );
1411 if ( !is_object( $nt ) ) {
1412 wfProfileIn( $fname );
1416 $u = $nt->escapeLocalURL( $query );
1417 if ( '' != $nt->getFragment() ) {
1418 if( $nt->getPrefixedDbkey() == '' ) {
1420 if ( '' == $text ) {
1421 $text = htmlspecialchars( $nt->getFragment() );
1424 $anchor = urlencode( do_html_entity_decode( str_replace(' ', '_', $nt->getFragment()), ENT_COMPAT
, $wgInputEncoding ) );
1425 $replacearray = array(
1429 $u .= '#' . str_replace(array_keys($replacearray),array_values($replacearray),$anchor);
1431 if ( '' == $text ) {
1432 $text = htmlspecialchars( $nt->getPrefixedText() );
1434 $style = $this->getInternalLinkAttributesObj( $nt, $text );
1437 if ( '' != $trail ) {
1438 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1443 $r = "<a href=\"{$u}\"{$style}{$aprops}>{$prefix}{$text}{$inside}</a>{$trail}";
1444 wfProfileOut( $fname );
1449 * Pass a title object, not a title string
1451 function makeBrokenLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
1452 global $wgOut, $wgUser;
1455 if ( ! isset($nt) ) {
1456 # wfDebugDieBacktrace();
1457 return "<!-- ERROR -->{$prefix}{$text}{$trail}";
1460 $fname = 'Skin::makeBrokenLinkObj';
1461 wfProfileIn( $fname );
1463 if ( '' == $query ) {
1466 $q = 'action=edit&'.$query;
1468 $u = $nt->escapeLocalURL( $q );
1470 if ( '' == $text ) {
1471 $text = htmlspecialchars( $nt->getPrefixedText() );
1473 $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" );
1476 if ( '' != $trail ) {
1477 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1482 if ( $wgUser->getOption( 'highlightbroken' ) ) {
1483 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
1485 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
1488 wfProfileOut( $fname );
1493 * Pass a title object, not a title string
1495 function makeStubLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
1496 global $wgOut, $wgUser;
1498 $link = $nt->getPrefixedURL();
1500 $u = $nt->escapeLocalURL( $query );
1502 if ( '' == $text ) {
1503 $text = htmlspecialchars( $nt->getPrefixedText() );
1505 $style = $this->getInternalLinkAttributesObj( $nt, $text, 'stub' );
1508 if ( '' != $trail ) {
1509 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1514 if ( $wgUser->getOption( 'highlightbroken' ) ) {
1515 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
1517 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
1522 function makeSelfLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
1523 $u = $nt->escapeLocalURL( $query );
1524 if ( '' == $text ) {
1525 $text = htmlspecialchars( $nt->getPrefixedText() );
1528 if ( '' != $trail ) {
1529 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1534 return "<strong>{$prefix}{$text}{$inside}</strong>{$trail}";
1537 /* these are used extensively in SkinPHPTal, but also some other places */
1538 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1539 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1540 $this->checkTitle($title, $name);
1541 return $title->getLocalURL( $urlaction );
1543 /*static*/ function makeTalkUrl ( $name, $urlaction='' ) {
1544 $title = Title
::newFromText( $name );
1545 $title = $title->getTalkPage();
1546 $this->checkTitle($title, $name);
1547 return $title->getLocalURL( $urlaction );
1549 /*static*/ function makeArticleUrl ( $name, $urlaction='' ) {
1550 $title = Title
::newFromText( $name );
1551 $title= $title->getSubjectPage();
1552 $this->checkTitle($title, $name);
1553 return $title->getLocalURL( $urlaction );
1555 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1556 $title = Title
::newFromText( wfMsgForContent($name) );
1557 $this->checkTitle($title, $name);
1558 return $title->getLocalURL( $urlaction );
1560 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1561 $title = Title
::newFromText( $name );
1562 $this->checkTitle($title, $name);
1563 return $title->getLocalURL( $urlaction );
1566 # If url string starts with http, consider as external URL, else
1568 /*static*/ function makeInternalOrExternalUrl( $name ) {
1569 if ( strncmp( $name, 'http', 4 ) == 0 ) {
1572 return $this->makeUrl( $name );
1576 # this can be passed the NS number as defined in Language.php
1577 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=0 ) {
1578 $title = Title
::makeTitleSafe( $namespace, $name );
1579 $this->checkTitle($title, $name);
1580 return $title->getLocalURL( $urlaction );
1583 /* these return an array with the 'href' and boolean 'exists' */
1584 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1585 $title = Title
::newFromText( $name );
1586 $this->checkTitle($title, $name);
1588 'href' => $title->getLocalURL( $urlaction ),
1589 'exists' => $title->getArticleID() != 0?
true:false
1592 /*static*/ function makeTalkUrlDetails ( $name, $urlaction='' ) {
1593 $title = Title
::newFromText( $name );
1594 $title = $title->getTalkPage();
1595 $this->checkTitle($title, $name);
1597 'href' => $title->getLocalURL( $urlaction ),
1598 'exists' => $title->getArticleID() != 0?
true:false
1601 /*static*/ function makeArticleUrlDetails ( $name, $urlaction='' ) {
1602 $title = Title
::newFromText( $name );
1603 $title= $title->getSubjectPage();
1604 $this->checkTitle($title, $name);
1606 'href' => $title->getLocalURL( $urlaction ),
1607 'exists' => $title->getArticleID() != 0?
true:false
1610 /*static*/ function makeI18nUrlDetails ( $name, $urlaction='' ) {
1611 $title = Title
::newFromText( wfMsgForContent($name) );
1612 $this->checkTitle($title, $name);
1614 'href' => $title->getLocalURL( $urlaction ),
1615 'exists' => $title->getArticleID() != 0?
true:false
1619 # make sure we have some title to operate on
1620 /*static*/ function checkTitle ( &$title, &$name ) {
1621 if(!is_object($title)) {
1622 $title = Title
::newFromText( $name );
1623 if(!is_object($title)) {
1624 $title = Title
::newFromText( '--error: link target missing--' );
1629 function fnamePart( $url ) {
1630 $basename = strrchr( $url, '/' );
1631 if ( false === $basename ) {
1634 $basename = substr( $basename, 1 );
1636 return htmlspecialchars( $basename );
1639 function makeImage( $url, $alt = '' ) {
1642 $alt = $this->fnamePart( $url );
1644 $s = '<img src="'.$url.'" alt="'.$alt.'" />';
1648 function makeImageLink( $name, $url, $alt = '' ) {
1649 $nt = Title
::makeTitleSafe( NS_IMAGE
, $name );
1650 return $this->makeImageLinkObj( $nt, $alt );
1653 function makeImageLinkObj( $nt, $alt = '' ) {
1654 global $wgContLang, $wgUseImageResize;
1655 $img = Image
::newFromTitle( $nt );
1656 $url = $img->getViewURL();
1659 $prefix = $postfix = '';
1661 # Check if the alt text is of the form "options|alt text"
1663 # * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang
1664 # * left no resizing, just left align. label is used for alt= only
1665 # * right same, but right aligned
1666 # * none same, but not aligned
1667 # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox
1668 # * center center the image
1669 # * framed Keep original image size, no magnify-button.
1671 $part = explode( '|', $alt);
1673 $mwThumb =& MagicWord
::get( MAG_IMG_THUMBNAIL
);
1674 $mwLeft =& MagicWord
::get( MAG_IMG_LEFT
);
1675 $mwRight =& MagicWord
::get( MAG_IMG_RIGHT
);
1676 $mwNone =& MagicWord
::get( MAG_IMG_NONE
);
1677 $mwWidth =& MagicWord
::get( MAG_IMG_WIDTH
);
1678 $mwCenter =& MagicWord
::get( MAG_IMG_CENTER
);
1679 $mwFramed =& MagicWord
::get( MAG_IMG_FRAMED
);
1682 $height = $framed = $thumb = false;
1683 $manual_thumb = "" ;
1685 foreach( $part as $key => $val ) {
1686 $val_parts = explode ( "=" , $val , 2 ) ;
1687 $left_part = array_shift ( $val_parts ) ;
1688 if ( $wgUseImageResize && ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) {
1690 } elseif ( $wgUseImageResize && count ( $val_parts ) == 1 && ! is_null( $mwThumb->matchVariableStartToEnd($left_part) ) ) {
1691 # use manually specified thumbnail
1693 $manual_thumb = array_shift ( $val_parts ) ;
1694 } elseif ( ! is_null( $mwRight->matchVariableStartToEnd($val) ) ) {
1695 # remember to set an alignment, don't render immediately
1697 } elseif ( ! is_null( $mwLeft->matchVariableStartToEnd($val) ) ) {
1698 # remember to set an alignment, don't render immediately
1700 } elseif ( ! is_null( $mwCenter->matchVariableStartToEnd($val) ) ) {
1701 # remember to set an alignment, don't render immediately
1703 } elseif ( ! is_null( $mwNone->matchVariableStartToEnd($val) ) ) {
1704 # remember to set an alignment, don't render immediately
1706 } elseif ( $wgUseImageResize && ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
1707 # $match is the image width in pixels
1708 if ( preg_match( '/^([0-9]*)x([0-9]*)$/', $match, $m ) ) {
1709 $width = intval( $m[1] );
1710 $height = intval( $m[2] );
1712 $width = intval($match);
1714 } elseif ( ! is_null( $mwFramed->matchVariableStartToEnd($val) ) ) {
1720 if ( 'center' == $align )
1722 $prefix = '<div class="center">';
1723 $postfix = '</div>';
1727 if ( $thumb ||
$framed ) {
1729 # Create a thumbnail. Alignment depends on language
1730 # writing direction, # right aligned for left-to-right-
1731 # languages ("Western languages"), left-aligned
1732 # for right-to-left-languages ("Semitic languages")
1734 # If thumbnail width has not been provided, it is set
1735 # here to 180 pixels
1736 if ( $align == '' ) {
1737 $align = $wgContLang->isRTL() ?
'left' : 'right';
1739 if ( ! isset($width) ) {
1742 return $prefix.$this->makeThumbLinkObj( $img, $alt, $align, $width, $height, $framed, $manual_thumb ).$postfix;
1744 } elseif ( isset($width) ) {
1746 # Create a resized image, without the additional thumbnail
1749 if ( ( ! $height === false )
1750 && ( $img->getHeight() * $width / $img->getWidth() > $height ) ) {
1751 $width = $img->getWidth() * $height / $img->getHeight();
1753 if ( '' == $manual_thumb ) $url = $img->createThumb( $width );
1756 $alt = preg_replace( '/<[^>]*>/', '', $alt );
1757 $alt = preg_replace('/&(?!:amp;|#[Xx][0-9A-fa-f]+;|#[0-9]+;|[a-zA-Z0-9]+;)/', '&', $alt);
1758 $alt = str_replace( array('<', '>', '"'), array('<', '>', '"'), $alt );
1760 $u = $nt->escapeLocalURL();
1762 $s = wfMsg( 'missingimage', $img->getName() );
1763 $s .= "<br>{$alt}<br>{$url}<br>\n";
1765 $s = '<a href="'.$u.'" class="image" title="'.$alt.'">' .
1766 '<img src="'.$url.'" alt="'.$alt.'" longdesc="'.$u.'" /></a>';
1768 if ( '' != $align ) {
1769 $s = "<div class=\"float{$align}\"><span>{$s}</span></div>";
1771 return str_replace("\n", ' ',$prefix.$s.$postfix);
1775 * Make HTML for a thumbnail including image, border and caption
1776 * $img is an Image object
1778 function makeThumbLinkObj( $img, $label = '', $align = 'right', $boxwidth = 180, $boxheight=false, $framed=false , $manual_thumb = "" ) {
1779 global $wgStylePath, $wgContLang;
1780 # $image = Title::makeTitleSafe( NS_IMAGE, $name );
1781 $url = $img->getViewURL();
1783 #$label = htmlspecialchars( $label );
1784 $alt = preg_replace( '/<[^>]*>/', '', $label);
1785 $alt = preg_replace('/&(?!:amp;|#[Xx][0-9A-fa-f]+;|#[0-9]+;|[a-zA-Z0-9]+;)/', '&', $alt);
1786 $alt = str_replace( array('<', '>', '"'), array('<', '>', '"'), $alt );
1788 $width = $height = 0;
1789 if ( $img->exists() )
1791 $width = $img->getWidth();
1792 $height = $img->getHeight();
1794 if ( 0 == $width ||
0 == $height )
1796 $width = $height = 200;
1798 if ( $boxwidth == 0 )
1804 // Use image dimensions, don't scale
1806 $oboxwidth = $boxwidth +
2;
1807 $boxheight = $height;
1810 $h = intval( $height/($width/$boxwidth) );
1811 $oboxwidth = $boxwidth +
2;
1812 if ( ( ! $boxheight === false ) && ( $h > $boxheight ) )
1814 $boxwidth *= $boxheight/$h;
1818 if ( '' == $manual_thumb ) $thumbUrl = $img->createThumb( $boxwidth );
1821 if ( $manual_thumb != '' ) # Use manually specified thumbnail
1823 $manual_title = Title
::makeTitleSafe( NS_IMAGE
, $manual_thumb ); #new Title ( $manual_thumb ) ;
1824 $manual_img = Image
::newFromTitle( $manual_title );
1825 $thumbUrl = $manual_img->getViewURL();
1826 if ( $manual_img->exists() )
1828 $width = $manual_img->getWidth();
1829 $height = $manual_img->getHeight();
1830 $boxwidth = $width ;
1831 $boxheight = $height ;
1832 $oboxwidth = $boxwidth +
2 ;
1836 $u = $img->getEscapeLocalURL();
1838 $more = htmlspecialchars( wfMsg( 'thumbnail-more' ) );
1839 $magnifyalign = $wgContLang->isRTL() ?
'left' : 'right';
1840 $textalign = $wgContLang->isRTL() ?
' style="text-align:right"' : '';
1842 $s = "<div class=\"thumb t{$align}\"><div style=\"width:{$oboxwidth}px;\">";
1843 if ( $thumbUrl == '' ) {
1844 $s .= wfMsg( 'missingimage', $img->getName() );
1847 $s .= '<a href="'.$u.'" class="internal" title="'.$alt.'">'.
1848 '<img src="'.$thumbUrl.'" alt="'.$alt.'" ' .
1849 'width="'.$boxwidth.'" height="'.$boxheight.'" ' .
1850 'longdesc="'.$u.'" /></a>';
1854 $zoomicon = '<div class="magnify" style="float:'.$magnifyalign.'">'.
1855 '<a href="'.$u.'" class="internal" title="'.$more.'">'.
1856 '<img src="'.$wgStylePath.'/common/images/magnify-clip.png" ' .
1857 'width="15" height="11" alt="'.$more.'" /></a></div>';
1860 $s .= ' <div class="thumbcaption" '.$textalign.'>'.$zoomicon.$label."</div></div></div>";
1861 return str_replace("\n", ' ', $s);
1864 function makeMediaLink( $name, $url, $alt = '' ) {
1865 $nt = Title
::makeTitleSafe( NS_IMAGE
, $name );
1866 return $this->makeMediaLinkObj( $nt, $alt );
1869 function makeMediaLinkObj( $nt, $alt = '', $nourl=false ) {
1870 if ( ! isset( $nt ) )
1872 ### HOTFIX. Instead of breaking, return empty string.
1875 $name = $nt->getDBKey();
1876 $img = Image
::newFromTitle( $nt );
1877 $url = $img->getURL();
1878 # $nourl can be set by the parser
1879 # this is a hack to mask absolute URLs, so the parser doesn't
1880 # linkify them (it is currently not context-aware)
1882 if ($nourl) { $url=str_replace("http://","http-noparse://",$url) ; }
1883 if ( empty( $alt ) ) {
1884 $alt = preg_replace( '/\.(.+?)^/', '', $name );
1886 $u = htmlspecialchars( $url );
1887 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
1892 function specialLink( $name, $key = '' ) {
1895 if ( '' == $key ) { $key = strtolower( $name ); }
1896 $pn = $wgContLang->ucfirst( $name );
1897 return $this->makeKnownLink( $wgContLang->specialPage( $pn ),
1901 function makeExternalLink( $url, $text, $escape = true ) {
1902 $style = $this->getExternalLinkAttributes( $url, $text );
1903 $url = htmlspecialchars( $url );
1905 $text = htmlspecialchars( $text );
1907 return '<a href="'.$url.'"'.$style.'>'.$text.'</a>';
1910 # Called by history lists and recent changes
1913 # Returns text for the start of the tabular part of RC
1914 function beginRecentChangesList() {
1915 $this->rc_cache
= array() ;
1916 $this->rcMoveIndex
= 0;
1917 $this->rcCacheIndex
= 0 ;
1918 $this->lastdate
= '';
1919 $this->rclistOpen
= false;
1923 function beginImageHistoryList() {
1924 $s = "\n<h2>" . wfMsg( 'imghistory' ) . "</h2>\n" .
1925 "<p>" . wfMsg( 'imghistlegend' ) . "</p>\n".'<ul class="special">';
1930 * Returns text for the end of RC
1931 * If enhanced RC is in use, returns pretty much all the text
1933 function endRecentChangesList() {
1934 $s = $this->recentChangesBlock() ;
1935 if( $this->rclistOpen
) {
1942 * Enhanced RC ungrouped line
1944 function recentChangesBlockLine ( $rcObj ) {
1945 global $wgStylePath, $wgContLang ;
1947 # Get rc_xxxx variables
1948 extract( $rcObj->mAttribs
) ;
1949 $curIdEq = 'curid='.$rc_cur_id;
1954 $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" border="0" />' ;
1957 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
1958 $r .= ' ';
1961 $M = wfMsg( 'minoreditletter' );
1962 $N = wfMsg( 'newpageletter' );
1964 if ( $rc_type == RC_NEW
) {
1974 if ( $rcObj->unpatrolled
) {
1982 $r .= ' '.$rcObj->timestamp
.' ' ;
1986 $link = $rcObj->link
;
1987 if ( $rcObj->watched
) $link = '<strong>'.$link.'</strong>' ;
1992 $r .= $rcObj->difflink
;
1996 $r .= $this->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' );
1999 $r .= ') . . '.$rcObj->userlink
;
2000 $r .= $rcObj->usertalklink
;
2003 if ( $rc_comment != '' && $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
2004 $rc_comment=$this->formatComment($rc_comment, $rcObj->getTitle());
2005 $r .= $wgContLang->emphasize( ' ('.$rc_comment.')' );
2015 function recentChangesBlockGroup ( $block ) {
2016 global $wgStylePath, $wgContLang ;
2019 $M = wfMsg( 'minoreditletter' );
2020 $N = wfMsg( 'newpageletter' );
2022 # Collate list of users
2024 $unpatrolled = false;
2025 $userlinks = array () ;
2026 foreach ( $block AS $rcObj ) {
2027 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
2028 if ( $rcObj->mAttribs
['rc_new'] ) {
2031 $u = $rcObj->userlink
;
2032 if ( !isset ( $userlinks[$u] ) ) {
2033 $userlinks[$u] = 0 ;
2035 if ( $rcObj->unpatrolled
) {
2036 $unpatrolled = true;
2041 # Sort the list and convert to text
2042 krsort ( $userlinks ) ;
2043 asort ( $userlinks ) ;
2045 foreach ( $userlinks as $userlink => $count) {
2047 if ( $count > 1 ) $text .= " ({$count}×)" ;
2048 array_push ( $users , $text ) ;
2050 $users = ' <font size="-1">['.implode('; ',$users).']</font>' ;
2053 $rci = 'RCI'.$this->rcCacheIndex
;
2054 $rcl = 'RCL'.$this->rcCacheIndex
;
2055 $rcm = 'RCM'.$this->rcCacheIndex
;
2056 $toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')" ;
2057 $arrowdir = $wgContLang->isRTL() ?
'l' : 'r';
2058 $tl = '<span id="'.$rcm.'"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_'.$arrowdir.'.png" width="12" height="12" alt="+" /></a></span>' ;
2059 $tl .= '<span id="'.$rcl.'" style="display:none"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_d.png" width="12" height="12" alt="-" /></a></span>' ;
2065 if ( $isnew ) $r .= $N ;
2066 else $r .= ' ' ;
2067 $r .= ' ' ; # Minor
2068 if ( $unpatrolled ) {
2075 $r .= ' '.$block[0]->timestamp
.' ' ;
2079 $link = $block[0]->link
;
2080 if ( $block[0]->watched
) $link = '<strong>'.$link.'</strong>' ;
2083 $curIdEq = 'curid=' . $block[0]->mAttribs
['rc_cur_id'];
2084 if ( $block[0]->mAttribs
['rc_type'] != RC_LOG
) {
2086 $r .= ' ('.count($block).' ' ;
2087 if ( $isnew ) $r .= wfMsg('changes');
2088 else $r .= $this->makeKnownLinkObj( $block[0]->getTitle() , wfMsg('changes') ,
2089 $curIdEq.'&diff=0&oldid='.$oldid ) ;
2093 $r .= $this->makeKnownLinkObj( $block[0]->getTitle(), wfMsg( 'history' ), $curIdEq.'&action=history' );
2101 $r .= '<div id="'.$rci.'" style="display:none">' ;
2102 foreach ( $block AS $rcObj ) {
2103 # Get rc_xxxx variables
2104 extract( $rcObj->mAttribs
);
2106 $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" />';
2107 $r .= '<tt> ' ;
2120 if ( $rcObj->unpatrolled
) {
2126 $r .= ' </tt>' ;
2129 if ( $rc_last_oldid != 0 ) {
2130 $o = 'oldid='.$rc_last_oldid ;
2132 if ( $rc_type == RC_LOG
) {
2133 $link = $rcObj->timestamp
;
2135 $link = $this->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, "{$curIdEq}&$o" ) ;
2137 $link = '<tt>'.$link.'</tt>' ;
2141 $r .= $rcObj->curlink
;
2143 $r .= $rcObj->lastlink
;
2144 $r .= ') . . '.$rcObj->userlink
;
2145 $r .= $rcObj->usertalklink
;
2146 if ( $rc_comment != '' ) {
2147 $rc_comment=$this->formatComment($rc_comment, $rcObj->getTitle());
2148 $r .= $wgContLang->emphasize( ' ('.$rc_comment.')' ) ;
2154 $this->rcCacheIndex++
;
2159 * If enhanced RC is in use, this function takes the previously cached
2160 * RC lines, arranges them, and outputs the HTML
2162 function recentChangesBlock () {
2163 global $wgStylePath ;
2164 if ( count ( $this->rc_cache
) == 0 ) return '' ;
2166 foreach ( $this->rc_cache
AS $secureName => $block ) {
2167 if ( count ( $block ) < 2 ) {
2168 $blockOut .= $this->recentChangesBlockLine ( array_shift ( $block ) ) ;
2170 $blockOut .= $this->recentChangesBlockGroup ( $block ) ;
2174 return '<div>'.$blockOut.'</div>' ;
2178 * Called in a loop over all displayed RC entries
2179 * Either returns the line, or caches it for later use
2181 function recentChangesLine( &$rc, $watched = false ) {
2183 $usenew = $wgUser->getOption( 'usenewrc' );
2185 $line = $this->recentChangesLineNew ( $rc, $watched ) ;
2187 $line = $this->recentChangesLineOld ( $rc, $watched ) ;
2191 function recentChangesLineOld( &$rc, $watched = false ) {
2192 $fname = 'Skin::recentChangesLineOld';
2193 wfProfileIn( $fname );
2195 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds, $wgUseRCPatrol, $wgOnlySysopsCanPatrol;
2198 if( !isset( $message ) ) {
2199 foreach( explode(' ', 'diff hist minoreditletter newpageletter blocklink' ) as $msg ) {
2200 $message[$msg] = wfMsg( $msg );
2204 # Extract DB fields into local scope
2205 extract( $rc->mAttribs
);
2206 $curIdEq = 'curid=' . $rc_cur_id;
2208 # Should patrol-related stuff be shown?
2209 $unpatrolled = $wgUseRCPatrol && $wgUser->getID() != 0 &&
2210 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') ) && $rc_patrolled == 0;
2212 # Make date header if necessary
2213 $date = $wgLang->date( $rc_timestamp, true);
2215 if ( $date != $this->lastdate
) {
2216 if ( '' != $this->lastdate
) { $s .= "</ul>\n"; }
2217 $s .= "<h4>{$date}</h4>\n<ul class=\"special\">";
2218 $this->lastdate
= $date;
2219 $this->rclistOpen
= true;
2224 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2226 $s .= '(' . $message['diff'] . ') (';
2228 $s .= $this->makeKnownLinkObj( $rc->getMovedToTitle(), $message['hist'], 'action=history' ) .
2231 # "[[x]] moved to [[y]]"
2232 $msg = ( $rc_type == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
2233 $s .= wfMsg( $msg, $this->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
2234 $this->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
2235 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
2237 $logtype = $matches[1];
2238 $logname = LogPage
::logName( $logtype );
2239 $s .= '(' . $this->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
2241 wfProfileIn("$fname-page");
2243 if ( $rc_type == RC_NEW ||
$rc_type == RC_LOG
) {
2244 $diffLink = $message['diff'];
2247 $rcidparam = "&rcid={$rc_id}";
2250 $diffLink = $this->makeKnownLinkObj( $rc->getTitle(), $message['diff'],
2251 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}{$rcidparam}",
2252 '', '', ' tabindex="'.$rc->counter
.'"');
2254 $s .= '('.$diffLink.') (';
2257 $s .= $this->makeKnownLinkObj( $rc->getTitle(), $message['hist'], $curIdEq.'&action=history' );
2260 # M, N and ! (minor, new and unpatrolled)
2261 if ( $rc_minor ) { $s .= ' <span class="minor">'.$message["minoreditletter"].'</span>'; }
2262 if ( $rc_type == RC_NEW
) { $s .= '<span class="newpage">'.$message["newpageletter"].'</span>'; }
2263 if ( !$rc_patrolled ) { $s .= ' <span class="unpatrolled">!</span>'; }
2266 # If it's a new article, there is no diff link, but if it hasn't been
2267 # patrolled yet, we need to give users a way to do so
2268 if ( $unpatrolled && $rc_type == RC_NEW
)
2269 $articleLink = $this->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
2271 $articleLink = $this->makeKnownLinkObj( $rc->getTitle(), '' );
2274 $articleLink = '<strong>'.$articleLink.'</strong>';
2276 $s .= ' '.$articleLink;
2277 wfProfileOut("$fname-page");
2280 wfProfileIn( "$fname-rest" );
2282 $s .= '; ' . $wgLang->time( $rc_timestamp, true, $wgRCSeconds ) . ' . . ';
2284 # User link (or contributions for unregistered users)
2285 if ( 0 == $rc_user ) {
2286 $contribsPage =& Title
::makeTitle( NS_SPECIAL
, 'Contributions' );
2287 $userLink = $this->makeKnownLinkObj( $contribsPage,
2288 $rc_user_text, 'target=' . $rc_user_text );
2290 $userPage =& Title
::makeTitle( NS_USER
, $rc_user_text );
2291 $userLink = $this->makeLinkObj( $userPage, $rc_user_text );
2296 $talkname = $wgContLang->getNsText(NS_TALK
); # use the shorter name
2297 global $wgDisableAnonTalk;
2298 if( 0 == $rc_user && $wgDisableAnonTalk ) {
2301 $userTalkPage =& Title
::makeTitle( NS_USER_TALK
, $rc_user_text );
2302 $userTalkLink= $this->makeLinkObj( $userTalkPage, $talkname );
2306 if ( ( 0 == $rc_user ) && $wgUser->isAllowed('block') ) {
2307 $blockLinkPage = Title
::makeTitle( NS_SPECIAL
, 'Blockip' );
2308 $blockLink = $this->makeKnownLink( $blockLinkPage,
2309 $message['blocklink'], 'ip='.$rc_user_text );
2313 if($userTalkLink) $userTalkLink .= ' | ';
2314 $userTalkLink .= $blockLink;
2316 if($userTalkLink) $s.=' ('.$userTalkLink.')';
2319 if ( '' != $rc_comment && '*' != $rc_comment && $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
2320 $rc_comment = $this->formatComment($rc_comment,$rc->getTitle());
2321 $s .= $wgContLang->emphasize(' (' . $rc_comment . ')');
2325 wfProfileOut( "$fname-rest" );
2326 wfProfileOut( $fname );
2330 function recentChangesLineNew( &$baseRC, $watched = false ) {
2331 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds;
2332 global $wgUseRCPatrol, $wgOnlySysopsCanPatrol;
2335 if( !isset( $message ) ) {
2336 foreach( explode(' ', 'cur diff hist minoreditletter newpageletter last blocklink' ) as $msg ) {
2337 $message[$msg] = wfMsg( $msg );
2341 # Create a specialised object
2342 $rc = RCCacheEntry
::newFromParent( $baseRC ) ;
2344 # Extract fields from DB into the function scope (rc_xxxx variables)
2345 extract( $rc->mAttribs
);
2346 $curIdEq = 'curid=' . $rc_cur_id;
2348 # If it's a new day, add the headline and flush the cache
2349 $date = $wgLang->date( $rc_timestamp, true);
2351 if ( $date != $this->lastdate
) {
2352 # Process current cache
2353 $ret = $this->recentChangesBlock () ;
2354 $this->rc_cache
= array() ;
2355 $ret .= "<h4>{$date}</h4>\n";
2356 $this->lastdate
= $date;
2359 # Should patrol-related stuff be shown?
2360 if ( $wgUseRCPatrol && $wgUser->getID() != 0 &&
2361 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') )) {
2362 $rc->unpatrolled
= !$rc_patrolled;
2364 $rc->unpatrolled
= false;
2368 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2369 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
2370 $clink = wfMsg( $msg, $this->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
2371 $this->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
2372 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
2374 $logtype = $matches[1];
2375 $logname = LogPage
::logName( $logtype );
2376 $clink = '(' . $this->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
2377 } elseif ( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
2378 # Unpatrolled new page, give rc_id in query
2379 $clink = $this->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
2381 $clink = $this->makeKnownLinkObj( $rc->getTitle(), '' ) ;
2384 $time = $wgContLang->time( $rc_timestamp, true, $wgRCSeconds );
2385 $rc->watched
= $watched ;
2386 $rc->link
= $clink ;
2387 $rc->timestamp
= $time;
2389 # Make "cur" and "diff" links
2390 if ( ( $rc_type == RC_NEW
&& $rc_this_oldid == 0 ) ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2391 $curLink = $message['cur'];
2392 $diffLink = $message['diff'];
2394 $query = $curIdEq.'&diff=0&oldid='.$rc_this_oldid;
2395 $aprops = ' tabindex="'.$baseRC->counter
.'"';
2396 $curLink = $this->makeKnownLinkObj( $rc->getTitle(), $message['cur'], $query, '' ,'' , $aprops );
2397 $diffLink = $this->makeKnownLinkObj( $rc->getTitle(), $message['diff'], $query, '' ,'' , $aprops );
2401 $titleObj = $rc->getTitle();
2402 if ( $rc->unpatrolled
) {
2403 $rcIdQuery = "&rcid={$rc_id}";
2407 if ( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2408 $lastLink = $message['last'];
2410 $lastLink = $this->makeKnownLinkObj( $rc->getTitle(), $message['last'],
2411 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
2414 # Make user link (or user contributions for unregistered users)
2415 if ( $rc_user == 0 ) {
2416 $contribsPage =& Title
::makeTitle( NS_SPECIAL
, 'Contributions' );
2417 $userLink = $this->makeKnownLinkObj( $contribsPage,
2418 $rc_user_text, 'target=' . $rc_user_text );
2420 $userPage =& Title
::makeTitle( NS_USER
, $rc_user_text );
2421 $userLink = $this->makeLinkObj( $userPage, $rc_user_text );
2424 $rc->userlink
= $userLink;
2425 $rc->lastlink
= $lastLink;
2426 $rc->curlink
= $curLink;
2427 $rc->difflink
= $diffLink;
2429 # Make user talk link
2430 $talkname = $wgContLang->getNsText( NS_TALK
); # use the shorter name
2431 $userTalkPage =& Title
::makeTitle( NS_USER_TALK
, $rc_user_text );
2432 $userTalkLink = $this->makeLinkObj( $userTalkPage, $talkname );
2434 global $wgDisableAnonTalk;
2435 if ( ( 0 == $rc_user ) && $wgUser->isAllowed('block') ) {
2436 $blockPage =& Title
::makeTitle( NS_SPECIAL
, 'Blockip' );
2437 $blockLink = $this->makeKnownLinkObj( $blockPage,
2438 $message['blocklink'], 'ip='.$rc_user_text );
2439 if( $wgDisableAnonTalk )
2440 $rc->usertalklink
= ' ('.$blockLink.')';
2442 $rc->usertalklink
= ' ('.$userTalkLink.' | '.$blockLink.')';
2444 if( $wgDisableAnonTalk && ($rc_user == 0) )
2445 $rc->usertalklink
= '';
2447 $rc->usertalklink
= ' ('.$userTalkLink.')';
2450 # Put accumulated information into the cache, for later display
2451 # Page moves go on their own line
2452 $title = $rc->getTitle();
2453 $secureName = $title->getPrefixedDBkey();
2454 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2455 # Use an @ character to prevent collision with page names
2456 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
2458 if ( !isset ( $this->rc_cache
[$secureName] ) ) $this->rc_cache
[$secureName] = array() ;
2459 array_push ( $this->rc_cache
[$secureName] , $rc ) ;
2464 function endImageHistoryList() {
2470 * This function is called by all recent changes variants, by the page history,
2471 * and by the user contributions list. It is responsible for formatting edit
2472 * comments. It escapes any HTML in the comment, but adds some CSS to format
2473 * auto-generated comments (from section editing) and formats [[wikilinks]].
2475 * The &$title parameter must be a title OBJECT. It is used to generate a
2476 * direct link to the section in the autocomment.
2477 * @author Erik Moeller <moeller@scireview.de>
2479 * Note: there's not always a title to pass to this function.
2480 * Since you can't set a default parameter for a reference, I've turned it
2481 * temporarily to a value pass. Should be adjusted further. --brion
2483 function formatComment($comment, $title = NULL) {
2484 $fname = 'Skin::formatComment';
2485 wfProfileIn( $fname );
2488 $comment = htmlspecialchars( $comment );
2490 # The pattern for autogen comments is / * foo * /, which makes for
2492 # We look for all comments, match any text before and after the comment,
2493 # add a separator where needed and format the comment itself with CSS
2494 while (preg_match('/(.*)\/\*\s*(.*?)\s*\*\/(.*)/', $comment,$match)) {
2502 # This is hackish but should work in most cases.
2503 $section=str_replace('[[','',$section);
2504 $section=str_replace(']]','',$section);
2505 $title->mFragment
=$section;
2506 $link=$this->makeKnownLinkObj($title,wfMsg('sectionlink'));
2510 if($pre) { $auto = $sep.' '.$auto; }
2511 if($post) { $auto .= ' '.$sep; }
2512 $auto='<span class="autocomment">'.$auto.'</span>';
2513 $comment=$pre.$auto.$post;
2516 # format regular and media links - all other wiki formatting
2518 $medians = $wgContLang->getNsText(Namespace::getMedia()).':';
2519 while(preg_match('/\[\[(.*?)(\|(.*?))*\]\](.*)$/',$comment,$match)) {
2520 # Handle link renaming [[foo|text]] will show link as "text"
2521 if( "" != $match[3] ) {
2526 if( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) {
2527 # Media link; trail not supported.
2528 $linkRegexp = '/\[\[(.*?)\]\]/';
2529 $thelink = $this->makeMediaLink( $submatch[1], "", $text );
2531 # Other kind of link
2532 if( preg_match( wfMsgForContent( "linktrail" ), $match[4], $submatch ) ) {
2533 $trail = $submatch[1];
2537 $linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/';
2538 if ($match[1][0] == ':')
2539 $match[1] = substr($match[1], 1);
2540 $thelink = $this->makeLink( $match[1], $text, "", $trail );
2542 $comment = preg_replace( $linkRegexp, $thelink, $comment, 1 );
2544 wfProfileOut( $fname );
2548 function imageHistoryLine( $iscur, $timestamp, $img, $user, $usertext, $size, $description ) {
2549 global $wgUser, $wgLang, $wgContLang, $wgTitle;
2551 $datetime = $wgLang->timeanddate( $timestamp, true );
2552 $del = wfMsg( 'deleteimg' );
2553 $delall = wfMsg( 'deleteimgcompletely' );
2554 $cur = wfMsg( 'cur' );
2557 $url = Image
::wfImageUrl( $img );
2559 if ( $wgUser->isAllowed('delete') ) {
2560 $link = $wgTitle->escapeLocalURL( 'image=' . $wgTitle->getPartialURL() .
2562 $style = $this->getInternalLinkAttributes( $link, $delall );
2564 $dlink = '<a href="'.$link.'"'.$style.'>'.$delall.'</a>';
2569 $url = htmlspecialchars( wfImageArchiveUrl( $img ) );
2570 if( $wgUser->getID() != 0 && $wgTitle->userCanEdit() ) {
2571 $rlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
2572 wfMsg( 'revertimg' ), 'action=revert&oldimage=' .
2573 urlencode( $img ) );
2574 $dlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
2575 $del, 'action=delete&oldimage=' . urlencode( $img ) );
2577 # Having live active links for non-logged in users
2578 # means that bots and spiders crawling our site can
2579 # inadvertently change content. Baaaad idea.
2580 $rlink = wfMsg( 'revertimg' );
2585 $userlink = $usertext;
2587 $userlink = $this->makeLink( $wgContLang->getNsText( Namespace::getUser() ) .
2588 ':'.$usertext, $usertext );
2590 $nbytes = wfMsg( 'nbytes', $size );
2591 $style = $this->getInternalLinkAttributes( $url, $datetime );
2593 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$datetime}</a>"
2594 . " . . {$userlink} ({$nbytes})";
2596 if ( '' != $description && '*' != $description ) {
2597 $sk=$wgUser->getSkin();
2598 $s .= $wgContLang->emphasize(' (' . $sk->formatComment($description,$wgTitle) . ')');
2604 function tocIndent($level) {
2605 return str_repeat( '<div class="tocindent">'."\n", $level>0 ?
$level : 0 );
2608 function tocUnindent($level) {
2609 return str_repeat( "</div>\n", $level>0 ?
$level : 0 );
2613 * parameter level defines if we are on an indentation level
2615 function tocLine( $anchor, $tocline, $level ) {
2616 $link = '<a href="#'.$anchor.'">'.$tocline.'</a><br />';
2620 return '<div class="tocline">'.$link."</div>\n";
2625 function tocTable($toc) {
2626 # note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
2627 # try min-width & co when somebody gets a chance
2628 $hideline = ' <script type="text/javascript">showTocToggle("' . addslashes( wfMsg('showtoc') ) . '","' . addslashes( wfMsg('hidetoc') ) . '")</script>';
2630 '<table border="0" id="toc"><tr id="toctitle"><td align="center">'."\n".
2631 '<b>'.wfMsgForContent('toc').'</b>' .
2633 '</td></tr><tr id="tocinside"><td>'."\n".
2634 $toc."</td></tr></table>\n";
2638 * These two do not check for permissions: check $wgTitle->userCanEdit
2639 * before calling them
2641 function editSectionScriptForOther( $title, $section, $head ) {
2642 $ttl = Title
::newFromText( $title );
2643 $url = $ttl->escapeLocalURL( 'action=edit§ion='.$section );
2644 return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
2647 function editSectionScript( $nt, $section, $head ) {
2649 if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
2652 $url = $nt->escapeLocalURL( 'action=edit§ion='.$section );
2653 return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
2656 function editSectionLinkForOther( $title, $section ) {
2660 $title = Title
::newFromText($title);
2661 $editurl = '§ion='.$section;
2662 $url = $this->makeKnownLink($title->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
2664 if( $wgContLang->isRTL() ) {
2666 $nearside = 'right';
2671 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
2675 function editSectionLink( $nt, $section ) {
2679 if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
2680 # Section edit links would be out of sync on an old page.
2681 # But, if we're diffing to the current page, they'll be
2686 $editurl = '§ion='.$section;
2687 $url = $this->makeKnownLink($nt->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
2689 if( $wgContLang->isRTL() ) {
2691 $nearside = 'right';
2696 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
2701 * This function is called by EditPage.php and shows a bulletin board style
2702 * toolbar for common editing functions. It can be disabled in the user
2704 * The necessary JavaScript code can be found in style/wikibits.js.
2706 function getEditToolbar() {
2707 global $wgStylePath, $wgLang, $wgMimeType;
2710 * toolarray an array of arrays which each include the filename of
2711 * the button image (without path), the opening tag, the closing tag,
2712 * and optionally a sample text that is inserted between the two when no
2713 * selection is highlighted.
2714 * The tip text is shown when the user moves the mouse over the button.
2716 * Already here are accesskeys (key), which are not used yet until someone
2717 * can figure out a way to make them work in IE. However, we should make
2718 * sure these keys are not defined on the edit page.
2721 array( 'image'=>'button_bold.png',
2723 'close' => "\'\'\'",
2724 'sample'=> wfMsg('bold_sample'),
2725 'tip' => wfMsg('bold_tip'),
2728 array( 'image'=>'button_italic.png',
2731 'sample'=> wfMsg('italic_sample'),
2732 'tip' => wfMsg('italic_tip'),
2735 array( 'image'=>'button_link.png',
2738 'sample'=> wfMsg('link_sample'),
2739 'tip' => wfMsg('link_tip'),
2742 array( 'image'=>'button_extlink.png',
2745 'sample'=> wfMsg('extlink_sample'),
2746 'tip' => wfMsg('extlink_tip'),
2749 array( 'image'=>'button_headline.png',
2751 'close' => " ==\\n",
2752 'sample'=> wfMsg('headline_sample'),
2753 'tip' => wfMsg('headline_tip'),
2756 array( 'image'=>'button_image.png',
2757 'open' => '[['.$wgLang->getNsText(NS_IMAGE
).":",
2759 'sample'=> wfMsg('image_sample'),
2760 'tip' => wfMsg('image_tip'),
2763 array( 'image' => 'button_media.png',
2764 'open' => '[['.$wgLang->getNsText(NS_MEDIA
).':',
2766 'sample'=> wfMsg('media_sample'),
2767 'tip' => wfMsg('media_tip'),
2770 array( 'image' => 'button_math.png',
2771 'open' => "\\<math\\>",
2772 'close' => "\\</math\\>",
2773 'sample'=> wfMsg('math_sample'),
2774 'tip' => wfMsg('math_tip'),
2777 array( 'image' => 'button_nowiki.png',
2778 'open' => "\\<nowiki\\>",
2779 'close' => "\\</nowiki\\>",
2780 'sample'=> wfMsg('nowiki_sample'),
2781 'tip' => wfMsg('nowiki_tip'),
2784 array( 'image' => 'button_sig.png',
2788 'tip' => wfMsg('sig_tip'),
2791 array( 'image' => 'button_hr.png',
2792 'open' => "\\n----\\n",
2795 'tip' => wfMsg('hr_tip'),
2799 $toolbar ="<script type='text/javascript'>\n/*<![CDATA[*/\n";
2801 $toolbar.="document.writeln(\"<div id='toolbar'>\");\n";
2802 foreach($toolarray as $tool) {
2804 $image=$wgStylePath.'/common/images/'.$tool['image'];
2805 $open=$tool['open'];
2806 $close=$tool['close'];
2807 $sample = addslashes( $tool['sample'] );
2809 // Note that we use the tip both for the ALT tag and the TITLE tag of the image.
2810 // Older browsers show a "speedtip" type message only for ALT.
2811 // Ideally these should be different, realistically they
2812 // probably don't need to be.
2813 $tip = addslashes( $tool['tip'] );
2815 #$key = $tool["key"];
2817 $toolbar.="addButton('$image','$tip','$open','$close','$sample');\n";
2820 $toolbar.="addInfobox('" . addslashes( wfMsg( "infobox" ) ) . "','" . addslashes(wfMsg("infobox_alert")) . "');\n";
2821 $toolbar.="document.writeln(\"</div>\");\n";
2823 $toolbar.="/*]]>*/\n</script>";
2830 function suppressUrlExpansion() {