b07965914416d54d886bfe6942ffefba78e498cf
9 * This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
11 if( defined( "MEDIAWIKI" ) ) {
14 require_once( 'Image.php' );
16 # These are the INTERNAL names, which get mapped directly to class names and
17 # file names in ./skins/. For display purposes, the Language class has
18 # internationalized names
21 $wgValidSkinNames = array(
22 'standard' => 'Standard',
23 'nostalgia' => 'Nostalgia',
24 'cologneblue' => 'CologneBlue'
27 #$wgValidSkinNames[] = 'PHPTal';
28 #$wgValidSkinNames['davinci'] = 'DaVinci';
29 #$wgValidSkinNames['mono'] = 'Mono';
30 #$wgValidSkinNames['monobookminimal'] = 'MonoBookMinimal';
31 $wgValidSkinNames['monobook'] = 'MonoBook';
32 $wgValidSkinNames['myskin'] = 'MySkin';
33 $wgValidSkinNames['chick'] = 'Chick';
37 # Get a list of all skins available in /skins/
38 # Build using the regular expression '^(.*).php$'
39 # Array keys are all lower case, array value keep the case used by filename
42 $skinDir = dir($IP.'/skins');
44 # while code from www.php.net
45 while (false !== ($file = $skinDir->read())) {
46 if(preg_match('/^(.*).php$/',$file, $matches)) {
48 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
54 require_once( 'RecentChange.php' );
56 global $wgLinkHolders;
57 $wgLinkHolders = array(
58 'namespaces' => array(),
64 global $wgInterwikiLinkHolders;
65 $wgInterwikiLinkHolders = array();
71 class RCCacheEntry
extends RecentChange
73 var $secureName, $link;
74 var $curlink , $difflink, $lastlink , $usertalklink , $versionlink ;
75 var $userlink, $timestamp, $watched;
77 function newFromParent( $rc )
79 $rc2 = new RCCacheEntry
;
80 $rc2->mAttribs
= $rc->mAttribs
;
81 $rc2->mExtra
= $rc->mExtra
;
88 * The main skin class that provide methods and properties for all other skins
89 * including PHPTal skins.
90 * This base class is also the "Standard" skin.
97 var $lastdate, $lastline;
98 var $linktrail ; # linktrail regexp
99 var $rc_cache ; # Cache for Enhanced Recent Changes
100 var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle
102 var $postParseLinkColour = true;
106 global $wgUseOldExistenceCheck;
107 $postParseLinkColour = !$wgUseOldExistenceCheck;
108 $this->linktrail
= wfMsg('linktrail');
111 function getSkinNames() {
112 global $wgValidSkinNames;
113 return $wgValidSkinNames;
116 function getStylesheet() {
117 return 'common/wikistandard.css';
120 function getSkinName() {
125 * Get/set accessor for delayed link colouring
127 function postParseLinkColour( $setting = NULL ) {
128 return wfSetVar( $this->postParseLinkColour
, $setting );
131 function qbSetting() {
132 global $wgOut, $wgUser;
134 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
135 $q = $wgUser->getOption( 'quickbar' );
136 if ( '' == $q ) { $q = 0; }
140 function initPage( &$out ) {
141 $fname = 'Skin::initPage';
142 wfProfileIn( $fname );
144 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => '/favicon.ico' ) );
146 $this->addMetadataLinks($out);
148 wfProfileOut( $fname );
151 function addMetadataLinks( &$out ) {
152 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf, $wgRdfMimeType, $action;
153 global $wgRightsPage, $wgRightsUrl;
155 if( $out->isArticleRelated() ) {
156 # note: buggy CC software only reads first "meta" link
157 if( $wgEnableCreativeCommonsRdf ) {
158 $out->addMetadataLink( array(
159 'title' => 'Creative Commons',
160 'type' => 'application/rdf+xml',
161 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
163 if( $wgEnableDublinCoreRdf ) {
164 $out->addMetadataLink( array(
165 'title' => 'Dublin Core',
166 'type' => 'application/rdf+xml',
167 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
171 if( $wgRightsPage ) {
172 $copy = Title
::newFromText( $wgRightsPage );
174 $copyright = $copy->getLocalURL();
177 if( !$copyright && $wgRightsUrl ) {
178 $copyright = $wgRightsUrl;
181 $out->addLink( array(
182 'rel' => 'copyright',
183 'href' => $copyright ) );
187 function outputPage( &$out ) {
188 global $wgDebugComments;
190 wfProfileIn( 'Skin::outputPage' );
191 $this->initPage( $out );
192 $out->out( $out->headElement() );
194 $out->out( "\n<body" );
195 $ops = $this->getBodyOptions();
196 foreach ( $ops as $name => $val ) {
197 $out->out( " $name='$val'" );
200 if ( $wgDebugComments ) {
201 $out->out( "<!-- Wiki debugging output:\n" .
202 $out->mDebugtext
. "-->\n" );
204 $out->out( $this->beforeContent() );
206 $out->out( $out->mBodytext
. "\n" );
208 $out->out( $this->afterContent() );
211 $out->out( $out->reportTime() );
213 $out->out( "\n</body></html>" );
216 function getHeadScripts() {
217 global $wgStylePath, $wgUser, $wgContLang, $wgAllowUserJs;
218 $r = "<script type=\"text/javascript\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
219 if( $wgAllowUserJs && $wgUser->getID() != 0 ) { # logged in
220 $userpage = $wgContLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
221 $userjs = htmlspecialchars($this->makeUrl($userpage.'/'.$this->getSkinName().'.js', 'action=raw&ctype=text/javascript'));
222 $r .= '<script type="text/javascript" src="'.$userjs."\"></script>\n";
227 # get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way)
228 function getUserStylesheet() {
229 global $wgOut, $wgStylePath, $wgContLang, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
230 $sheet = $this->getStylesheet();
231 $action = $wgRequest->getText('action');
232 $s = "@import \"$wgStylePath/$sheet\";\n";
233 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css\";\n";
234 if( $wgAllowUserCss && $wgUser->getID() != 0 ) { # logged in
235 if($wgTitle->isCssSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) {
236 $s .= $wgRequest->getText('wpTextbox1');
238 $userpage = $wgContLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
239 $s.= '@import "'.$this->makeUrl($userpage.'/'.$this->getSkinName().'.css', 'action=raw&ctype=text/css').'";'."\n";
242 $s .= $this->doGetUserStyles();
247 * placeholder, returns generated js in monobook
249 function getUserJs() { return; }
252 * Return html code that include User stylesheets
254 function getUserStyles() {
255 global $wgOut, $wgStylePath, $wgLang;
256 $s = "<style type='text/css'>\n";
257 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
258 $s .= $this->getUserStylesheet();
259 $s .= "/*]]>*/ /* */\n";
265 * Some styles that are set by user through the user settings interface.
267 function doGetUserStyles() {
268 global $wgUser, $wgContLang;
270 $csspage = $wgContLang->getNsText( NS_MEDIAWIKI
) . ':' . $this->getSkinName() . '.css';
271 $s = '@import "'.$this->makeUrl($csspage, 'action=raw&ctype=text/css')."\";\n";
273 if ( 1 == $wgUser->getOption( 'underline' ) ) {
274 # Don't override browser settings
278 $s .= "a { text-decoration: none; }\n";
280 if ( 1 == $wgUser->getOption( 'highlightbroken' ) ) {
281 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
283 if ( 1 == $wgUser->getOption( 'justify' ) ) {
284 $s .= "#article { text-align: justify; }\n";
289 function getBodyOptions() {
290 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
292 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
294 if ( 0 != $wgTitle->getNamespace() ) {
295 $a = array( 'bgcolor' => '#ffffec' );
297 else $a = array( 'bgcolor' => '#FFFFFF' );
298 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
299 (!$wgTitle->isProtected() ||
$wgUser->isSysop()) ) {
300 $t = wfMsg( 'editthispage' );
302 if ( !empty($redirect) ) {
303 $red = "&redirect={$redirect}";
305 if ( !empty($oldid) && ! isset( $diff ) ) {
306 $oid = "&oldid={$oldid}";
308 $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
309 $s = 'document.location = "' .$s .'";';
310 $a +
= array ('ondblclick' => $s);
313 $a['onload'] = $wgOut->getOnloadHandler();
317 function getExternalLinkAttributes( $link, $text, $class='' ) {
318 global $wgUser, $wgOut, $wgContLang;
320 $same = ($link == $text);
321 $link = urldecode( $link );
322 $link = $wgContLang->checkTitleEncoding( $link );
323 $link = str_replace( '_', ' ', $link );
324 $link = htmlspecialchars( $link );
326 $r = ($class != '') ?
" class='$class'" : " class='external'";
328 if ( !$same && $wgUser->getOption( 'hover' ) ) {
329 $r .= " title=\"{$link}\"";
334 function getInternalLinkAttributes( $link, $text, $broken = false ) {
335 global $wgUser, $wgOut;
337 $link = urldecode( $link );
338 $link = str_replace( '_', ' ', $link );
339 $link = htmlspecialchars( $link );
341 if ( $broken == 'stub' ) {
342 $r = ' class="stub"';
343 } else if ( $broken == 'yes' ) {
349 if ( 1 == $wgUser->getOption( 'hover' ) ) {
350 $r .= " title=\"{$link}\"";
356 * @param bool $broken
358 function getInternalLinkAttributesObj( &$nt, $text, $broken = false ) {
359 global $wgUser, $wgOut;
361 if ( $broken == 'stub' ) {
362 $r = ' class="stub"';
363 } else if ( $broken == 'yes' ) {
369 if ( 1 == $wgUser->getOption( 'hover' ) ) {
370 $r .= ' title="' . $nt->getEscapedText() . '"';
384 * This will be called immediately after the <body> tag. Split into
385 * two functions to make it easier to subclass.
387 function beforeContent() {
388 global $wgUser, $wgOut;
390 return $this->doBeforeContent();
393 function doBeforeContent() {
394 global $wgUser, $wgOut, $wgTitle, $wgContLang, $wgSiteNotice;
395 $fname = 'Skin::doBeforeContent';
396 wfProfileIn( $fname );
399 $qb = $this->qbSetting();
401 if( $langlinks = $this->otherLanguages() ) {
407 $borderhack = 'class="top"';
410 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
411 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
414 $left = ($qb == 1 ||
$qb == 3);
415 if($wgContLang->isRTL()) $left = !$left;
418 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
419 $this->logoText() . '</td>';
421 $s .= $this->getQuickbarCompensator( $rows );
423 $l = $wgContLang->isRTL() ?
'right' : 'left';
424 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
426 $s .= $this->topLinks() ;
427 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
429 $r = $wgContLang->isRTL() ?
"left" : "right";
430 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
431 $s .= $this->nameAndLogin();
432 $s .= "\n<br />" . $this->searchForm() . "</td>";
435 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
438 if ( $shove && !$left ) { # Right
439 $s .= $this->getQuickbarCompensator( $rows );
441 $s .= "</tr>\n</table>\n</div>\n";
442 $s .= "\n<div id='article'>\n";
444 if( $wgSiteNotice ) {
445 $s .= "\n<div id='siteNotice'>$wgSiteNotice</div>\n";
447 $s .= $this->pageTitle();
448 $s .= $this->pageSubtitle() ;
449 $s .= $this->getCategories();
450 wfProfileOut( $fname );
454 function getCategoryLinks () {
455 global $wgOut, $wgTitle, $wgUser, $wgParser;
456 global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang;
458 if( !$wgUseCategoryMagic ) return '' ;
459 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
461 # Taken out so that they will be displayed in previews -- TS
462 #if( !$wgOut->isArticle() ) return '';
464 $t = implode ( ' | ' , $wgOut->mCategoryLinks
) ;
465 $s = $this->makeKnownLink( 'Special:Categories',
466 wfMsg( 'categories' ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
469 # optional 'dmoz-like' category browser. Will be shown under the list
470 # of categories an article belong to
471 if($wgUseCategoryBrowser) {
474 # get a big array of the parents tree
475 $parenttree = $wgTitle->getCategorieBrowser();
477 # Render the array as a serie of links
478 function walkThrough ($tree) {
480 $sk = $wgUser->getSkin();
482 foreach($tree as $element => $parent) {
484 # element start a new list
487 # grab the others elements
488 $return .= walkThrough($parent);
490 # add our current element to the list
491 $eltitle = Title
::NewFromText($element);
492 # FIXME : should be makeLink() [AV]
493 $return .= $sk->makeKnownLink($element, $eltitle->getText()).' > ';
498 $s .= walkThrough($parenttree);
504 function getCategories() {
505 $catlinks=$this->getCategoryLinks();
506 if(!empty($catlinks)) {
507 return "<p class='catlinks'>{$catlinks}</p>";
511 function getQuickbarCompensator( $rows = 1 ) {
512 return "<td width='152' rowspan='{$rows}'> </td>";
515 # This gets called immediately before the </body> tag.
517 function afterContent() {
518 global $wgUser, $wgOut, $wgServer;
519 global $wgTitle, $wgLang;
521 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
522 return $printfooter . $this->doAfterContent();
525 function printSource() {
527 $url = htmlspecialchars( $wgTitle->getFullURL() );
528 return wfMsg( "retrievedfrom", "<a href=\"$url\">$url</a>" );
531 function printFooter() {
532 return "<p>" . $this->printSource() .
533 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
536 function doAfterContent() {
537 # overloaded by derived classes
540 function pageTitleLinks() {
541 global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgUseApproval, $wgRequest;
543 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
544 $action = $wgRequest->getText( 'action' );
546 $s = $this->printableLink();
547 if ( wfMsgForContent ( 'disclaimers' ) != '-' )
548 $s .= ' | ' . $this->makeKnownLink(
549 wfMsgForContent( 'disclaimerpage' ),
550 wfMsgForContent( 'disclaimers' ) ) ;
552 if ( $wgOut->isArticleRelated() ) {
553 if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
554 $name = $wgTitle->getDBkey();
555 $link = htmlspecialchars( Image
::wfImageUrl( $name ) );
556 $style = $this->getInternalLinkAttributes( $link, $name );
557 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
559 # This will show the "Approve" link if $wgUseApproval=true;
560 if ( isset ( $wgUseApproval ) && $wgUseApproval )
562 $t = $wgTitle->getDBkey();
563 $name = 'Approve this article' ;
564 $link = "http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ;
565 #htmlspecialchars( wfImageUrl( $name ) );
566 $style = $this->getExternalLinkAttributes( $link, $name );
567 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>" ;
570 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
571 $s .= ' | ' . $this->makeKnownLink( $wgTitle->getPrefixedText(),
572 wfMsg( 'currentrev' ) );
575 if ( $wgUser->getNewtalk() ) {
576 # do not show "You have new messages" text when we are viewing our
579 if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
580 $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
581 $n =$wgUser->getName();
582 $tl = $this->makeKnownLink( $wgContLang->getNsText(
583 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
584 wfMsg('newmessageslink') );
585 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
587 $wgOut->setSquidMaxage(0);
591 $undelete = $this->getUndeleteLink();
592 if( !empty( $undelete ) ) {
593 $s .= ' | '.$undelete;
598 function getUndeleteLink() {
599 global $wgUser, $wgTitle, $wgContLang, $action;
600 if( $wgUser->isSysop() &&
601 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
602 ($n = $wgTitle->isDeleted() ) ) {
603 return wfMsg( 'thisisdeleted',
604 $this->makeKnownLink(
605 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
606 wfMsg( 'restorelink', $n ) ) );
611 function printableLink() {
612 global $wgOut, $wgFeedClasses, $wgRequest;
614 $baseurl = $_SERVER['REQUEST_URI'];
615 if( strpos( '?', $baseurl ) == false ) {
620 $baseurl = htmlspecialchars( $baseurl );
621 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
623 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
624 if( $wgOut->isSyndicated() ) {
625 foreach( $wgFeedClasses as $format => $class ) {
626 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
627 $s .= " | <a href=\"$feedurl\">{$format}</a>";
633 function pageTitle() {
634 global $wgOut, $wgTitle, $wgUser;
636 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
637 if($wgUser->getOption( 'editsectiononrightclick' ) && $wgTitle->userCanEdit()) { $s=$this->editSectionScript(0,$s);}
641 function pageSubtitle() {
644 $sub = $wgOut->getSubtitle();
646 global $wgExtraSubtitle;
647 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
649 $subpages = $this->subPageSubtitle();
650 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
651 $s = "<p class='subtitle'>{$sub}</p>\n";
655 function subPageSubtitle() {
656 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
658 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
659 $ptext=$wgTitle->getPrefixedText();
660 if(preg_match('/\//',$ptext)) {
661 $links = explode('/',$ptext);
664 foreach($links as $link) {
666 if ($c<count($links)) {
667 $growinglink .= $link;
668 $getlink = $this->makeLink( $growinglink, $link );
669 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
673 $subpages .= '< ';
675 $subpages .= $getlink;
684 function nameAndLogin() {
685 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader, $wgIP;
687 $li = $wgContLang->specialPage( 'Userlogin' );
688 $lo = $wgContLang->specialPage( 'Userlogout' );
691 if ( 0 == $wgUser->getID() ) {
692 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
695 $tl = $this->makeKnownLink( $wgContLang->getNsText(
696 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
697 $wgContLang->getNsText( Namespace::getTalk( 0 ) ) );
699 $s .= $n . ' ('.$tl.')';
701 $s .= wfMsg('notloggedin');
704 $rt = $wgTitle->getPrefixedURL();
705 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
707 } else { $q = "returnto={$rt}"; }
709 $s .= "\n<br />" . $this->makeKnownLink( $li,
710 wfMsg( 'login' ), $q );
712 $n = $wgUser->getName();
713 $rt = $wgTitle->getPrefixedURL();
714 $tl = $this->makeKnownLink( $wgContLang->getNsText(
715 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
716 $wgContLang->getNsText( Namespace::getTalk( 0 ) ) );
720 $s .= $this->makeKnownLink( $wgContLang->getNsText(
721 Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}<br />" .
722 $this->makeKnownLink( $lo, wfMsg( 'logout' ),
723 "returnto={$rt}" ) . ' | ' .
724 $this->specialLink( 'preferences' );
726 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
732 function getSearchLink() {
733 $searchPage =& Title
::makeTitle( NS_SPECIAL
, 'Search' );
734 return $searchPage->getLocalURL();
737 function escapeSearchLink() {
738 return htmlspecialchars( $this->getSearchLink() );
741 function searchForm() {
743 $search = $wgRequest->getText( 'search' );
745 $s = '<form name="search" class="inline" method="post" action="'
746 . $this->escapeSearchLink() . "\">\n"
747 . '<input type="text" name="search" size="19" value="'
748 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
749 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
750 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
755 function topLinks() {
759 $s = $this->mainPageLink() . $sep
760 . $this->specialLink( 'recentchanges' );
762 if ( $wgOut->isArticleRelated() ) {
763 $s .= $sep . $this->editThisPage()
764 . $sep . $this->historyLink();
766 # Many people don't like this dropdown box
767 #$s .= $sep . $this->specialPagesList();
772 function bottomLinks() {
773 global $wgOut, $wgUser, $wgTitle;
777 if ( $wgOut->isArticleRelated() ) {
778 $s .= '<strong>' . $this->editThisPage() . '</strong>';
779 if ( 0 != $wgUser->getID() ) {
780 $s .= $sep . $this->watchThisPage();
782 $s .= $sep . $this->talkLink()
783 . $sep . $this->historyLink()
784 . $sep . $this->whatLinksHere()
785 . $sep . $this->watchPageLinksLink();
787 if ( $wgTitle->getNamespace() == Namespace::getUser()
788 ||
$wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) )
791 $id=User
::idFromName($wgTitle->getText());
792 $ip=User
::isIP($wgTitle->getText());
794 if($id ||
$ip) { # both anons and non-anons have contri list
795 $s .= $sep . $this->userContribsLink();
797 if ( 0 != $wgUser->getID() ) { # show only to signed in users
798 if($id) { # can only email non-anons
799 $s .= $sep . $this->emailUserLink();
803 if ( $wgUser->isSysop() && $wgTitle->getArticleId() ) {
804 $s .= "\n<br />" . $this->deleteThisPage() .
805 $sep . $this->protectThisPage() .
806 $sep . $this->moveThisPage();
808 $s .= "<br />\n" . $this->otherLanguages();
813 function pageStats() {
814 global $wgOut, $wgLang, $wgArticle, $wgRequest;
815 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax;
817 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
818 if ( ! $wgOut->isArticle() ) { return ''; }
819 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
820 if ( 0 == $wgArticle->getID() ) { return ''; }
823 if ( !$wgDisableCounters ) {
824 $count = $wgLang->formatNum( $wgArticle->getCount() );
826 $s = wfMsg( 'viewcount', $count );
830 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
831 require_once("Credits.php");
832 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
834 $s .= $this->lastModified();
837 return $s . ' ' . $this->getCopyright();
840 function getCopyright() {
841 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
844 $oldid = $wgRequest->getVal( 'oldid' );
845 $diff = $wgRequest->getVal( 'diff' );
847 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
848 $msg = 'history_copyright';
854 if( $wgRightsPage ) {
855 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
856 } elseif( $wgRightsUrl ) {
857 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
862 $out .= wfMsgForContent( $msg, $link );
866 function getCopyrightIcon() {
867 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon;
869 if( $wgRightsIcon ) {
870 $icon = htmlspecialchars( $wgRightsIcon );
872 $url = htmlspecialchars( $wgRightsUrl );
873 $out .= '<a href="'.$url.'">';
875 $text = htmlspecialchars( $wgRightsText );
876 $out .= "<img src=\"$icon\" alt='$text' />";
884 function getPoweredBy() {
886 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
887 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
891 function lastModified() {
892 global $wgLang, $wgArticle;
894 $timestamp = $wgArticle->getTimestamp();
896 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
897 $s = ' ' . wfMsg( 'lastmodified', $d );
904 function logoText( $align = '' ) {
905 if ( '' != $align ) { $a = " align='{$align}'"; }
908 $mp = wfMsg( 'mainpage' );
909 $titleObj = Title
::newFromText( $mp );
910 if ( is_object( $titleObj ) ) {
911 $url = $titleObj->escapeLocalURL();
916 $logourl = $this->getLogo();
917 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
921 function specialPagesList() {
922 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript;
923 require_once('SpecialPage.php');
925 $pages = SpecialPage
::getPages();
927 foreach ( $pages[''] as $name => $page ) {
928 $a[$name] = $page->getDescription();
930 if ( $wgUser->isSysop() )
932 foreach ( $pages['sysop'] as $name => $page ) {
933 $a[$name] = $page->getDescription();
936 if ( $wgUser->isDeveloper() )
938 foreach ( $pages['developer'] as $name => $page ) {
939 $a[$name] = $page->getDescription() ;
943 $sp = wfMsg( 'specialpages' );
944 $spp = $wgContLang->specialPage( 'Specialpages' );
946 $s = '<form id="specialpages" method="get" class="inline" ' .
947 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
948 $s .= "<select name=\"wpDropdown\">\n";
949 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
951 foreach ( $a as $name => $desc ) {
952 $p = $wgContLang->specialPage( $name );
953 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
956 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
961 function mainPageLink() {
962 $mp = wfMsgForContent( 'mainpage' );
963 $mptxt = wfMsg( 'mainpage');
964 $s = $this->makeKnownLink( $mp, $mptxt );
968 function copyrightLink() {
969 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
970 wfMsg( 'copyrightpagename' ) );
974 function aboutLink() {
975 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
976 wfMsg( 'aboutsite' ) );
981 function disclaimerLink() {
982 $s = $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
983 wfMsg( 'disclaimers' ) );
987 function editThisPage() {
988 global $wgOut, $wgTitle, $wgRequest;
990 $oldid = $wgRequest->getVal( 'oldid' );
991 $diff = $wgRequest->getVal( 'diff' );
992 $redirect = $wgRequest->getVal( 'redirect' );
994 if ( ! $wgOut->isArticleRelated() ) {
995 $s = wfMsg( 'protectedpage' );
997 $n = $wgTitle->getPrefixedText();
998 if ( $wgTitle->userCanEdit() ) {
999 $t = wfMsg( 'editthispage' );
1001 #$t = wfMsg( "protectedpage" );
1002 $t = wfMsg( 'viewsource' );
1006 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
1007 if ( $oldid && ! isset( $diff ) ) {
1008 $oid = '&oldid='.$oldid;
1010 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
1015 function deleteThisPage() {
1016 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1018 $diff = $wgRequest->getVal( 'diff' );
1019 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
1020 $n = $wgTitle->getPrefixedText();
1021 $t = wfMsg( 'deletethispage' );
1023 $s = $this->makeKnownLink( $n, $t, 'action=delete' );
1030 function protectThisPage() {
1031 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1033 $diff = $wgRequest->getVal( 'diff' );
1034 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
1035 $n = $wgTitle->getPrefixedText();
1037 if ( $wgTitle->isProtected() ) {
1038 $t = wfMsg( 'unprotectthispage' );
1039 $q = 'action=unprotect';
1041 $t = wfMsg( 'protectthispage' );
1042 $q = 'action=protect';
1044 $s = $this->makeKnownLink( $n, $t, $q );
1051 function watchThisPage() {
1052 global $wgUser, $wgOut, $wgTitle;
1054 if ( $wgOut->isArticleRelated() ) {
1055 $n = $wgTitle->getPrefixedText();
1057 if ( $wgTitle->userIsWatching() ) {
1058 $t = wfMsg( 'unwatchthispage' );
1059 $q = 'action=unwatch';
1061 $t = wfMsg( 'watchthispage' );
1062 $q = 'action=watch';
1064 $s = $this->makeKnownLink( $n, $t, $q );
1066 $s = wfMsg( 'notanarticle' );
1071 function moveThisPage() {
1072 global $wgTitle, $wgContLang;
1074 if ( $wgTitle->userCanEdit() ) {
1075 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Movepage' ),
1076 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1077 } // no message if page is protected - would be redundant
1081 function historyLink() {
1084 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1085 wfMsg( 'history' ), 'action=history' );
1089 function whatLinksHere() {
1090 global $wgTitle, $wgContLang;
1092 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Whatlinkshere' ),
1093 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1097 function userContribsLink() {
1098 global $wgTitle, $wgContLang;
1100 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
1101 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1105 function emailUserLink() {
1106 global $wgTitle, $wgContLang;
1108 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Emailuser' ),
1109 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1113 function watchPageLinksLink() {
1114 global $wgOut, $wgTitle, $wgContLang;
1116 if ( ! $wgOut->isArticleRelated() ) {
1117 $s = '(' . wfMsg( 'notanarticle' ) . ')';
1119 $s = $this->makeKnownLink( $wgContLang->specialPage(
1120 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1121 'target=' . $wgTitle->getPrefixedURL() );
1126 function otherLanguages() {
1127 global $wgOut, $wgContLang, $wgTitle, $wgUseNewInterlanguage;
1129 $a = $wgOut->getLanguageLinks();
1130 if ( 0 == count( $a ) ) {
1131 if ( !$wgUseNewInterlanguage ) return '';
1132 $ns = $wgContLang->getNsIndex ( $wgTitle->getNamespace () ) ;
1133 if ( $ns != 0 AND $ns != 1 ) return '' ;
1135 $x = 'mode=addlink&xt='.$wgTitle->getDBkey() ;
1136 return $this->makeKnownLink( $wgContLang->specialPage( $pn ),
1137 wfMsg( 'intl' ) , $x );
1140 if ( !$wgUseNewInterlanguage ) {
1141 $s = wfMsg( 'otherlanguages' ) . ': ';
1143 global $wgContLanguageCode ;
1144 $x = 'mode=zoom&xt='.$wgTitle->getDBkey() ;
1145 $x .= '&xl='.$wgContLanguageCode ;
1146 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Intl' ),
1147 wfMsg( 'otherlanguages' ) , $x ) . ': ' ;
1150 $s = wfMsg( 'otherlanguages' ) . ': ';
1152 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1153 foreach( $a as $l ) {
1154 if ( ! $first ) { $s .= ' | '; }
1157 $nt = Title
::newFromText( $l );
1158 $url = $nt->getFullURL();
1159 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1161 if ( '' == $text ) { $text = $l; }
1162 $style = $this->getExternalLinkAttributes( $l, $text );
1163 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1165 if($wgContLang->isRTL()) $s .= '</span>';
1169 function bugReportsLink() {
1170 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1171 wfMsg( 'bugreports' ) );
1175 function dateLink() {
1176 global $wgLinkCache;
1177 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1178 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1180 $wgLinkCache->suspend();
1181 $id = $t1->getArticleID();
1182 $wgLinkCache->resume();
1185 $s = $this->makeBrokenLink( $t1->getText() );
1187 $s = $this->makeKnownLink( $t1->getText() );
1191 $wgLinkCache->suspend();
1192 $id = $t2->getArticleID();
1193 $wgLinkCache->resume();
1196 $s .= $this->makeBrokenLink( $t2->getText() );
1198 $s .= $this->makeKnownLink( $t2->getText() );
1203 function talkLink() {
1204 global $wgContLang, $wgTitle, $wgLinkCache;
1206 $tns = $wgTitle->getNamespace();
1207 if ( -1 == $tns ) { return ''; }
1209 $pn = $wgTitle->getText();
1210 $tp = wfMsg( 'talkpage' );
1211 if ( Namespace::isTalk( $tns ) ) {
1212 $lns = Namespace::getSubject( $tns );
1215 $text = wfMsg('articlepage');
1218 $text = wfMsg('userpage');
1221 $text = wfMsg('wikipediapage');
1224 $text = wfMsg('imagepage');
1227 $text= wfMsg('articlepage');
1231 $lns = Namespace::getTalk( $tns );
1234 $n = $wgContLang->getNsText( $lns );
1235 if ( '' == $n ) { $link = $pn; }
1236 else { $link = $n.':'.$pn; }
1238 $wgLinkCache->suspend();
1239 $s = $this->makeLink( $link, $text );
1240 $wgLinkCache->resume();
1245 function commentLink() {
1246 global $wgContLang, $wgTitle, $wgLinkCache;
1248 $tns = $wgTitle->getNamespace();
1249 if ( -1 == $tns ) { return ''; }
1251 $lns = ( Namespace::isTalk( $tns ) ) ?
$tns : Namespace::getTalk( $tns );
1253 # assert Namespace::isTalk( $lns )
1255 $n = $wgContLang->getNsText( $lns );
1256 $pn = $wgTitle->getText();
1260 $wgLinkCache->suspend();
1261 $s = $this->makeKnownLink($link, wfMsg('postcomment'), 'action=edit§ion=new');
1262 $wgLinkCache->resume();
1268 * After all the page content is transformed into HTML, it makes
1269 * a final pass through here for things like table backgrounds.
1270 * @todo probably deprecated [AV]
1272 function transformContent( $text ) {
1277 * Note: This function MUST call getArticleID() on the link,
1278 * otherwise the cache won't get updated properly. See LINKCACHE.DOC.
1280 function makeLink( $title, $text = '', $query = '', $trail = '' ) {
1281 wfProfileIn( 'Skin::makeLink' );
1282 $nt = Title
::newFromText( $title );
1284 $result = $this->makeLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1286 wfDebug( 'Invalid title passed to Skin::makeLink(): "'.$title."\"\n" );
1287 $result = $text == "" ?
$title : $text;
1290 wfProfileOut( 'Skin::makeLink' );
1294 function makeKnownLink( $title, $text = '', $query = '', $trail = '', $prefix = '',$aprops = '') {
1295 $nt = Title
::newFromText( $title );
1297 return $this->makeKnownLinkObj( Title
::newFromText( $title ), $text, $query, $trail, $prefix , $aprops );
1299 wfDebug( 'Invalid title passed to Skin::makeKnownLink(): "'.$title."\"\n" );
1300 return $text == '' ?
$title : $text;
1304 function makeBrokenLink( $title, $text = '', $query = '', $trail = '' ) {
1305 $nt = Title
::newFromText( $title );
1307 return $this->makeBrokenLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1309 wfDebug( 'Invalid title passed to Skin::makeBrokenLink(): "'.$title."\"\n" );
1310 return $text == '' ?
$title : $text;
1314 function makeStubLink( $title, $text = '', $query = '', $trail = '' ) {
1315 $nt = Title
::newFromText( $title );
1317 return $this->makeStubLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1319 wfDebug( 'Invalid title passed to Skin::makeStubLink(): "'.$title."\"\n" );
1320 return $text == '' ?
$title : $text;
1325 * Pass a title object, not a title string
1327 function makeLinkObj( &$nt, $text= '', $query = '', $trail = '', $prefix = '' ) {
1328 global $wgOut, $wgUser, $wgLinkHolders;
1329 $fname = 'Skin::makeLinkObj';
1332 if ( ! isset($nt) ) {
1333 # wfDebugDieBacktrace();
1334 return "<!-- ERROR -->{$prefix}{$text}{$trail}";
1337 if ( $nt->isExternal() ) {
1338 $u = $nt->getFullURL();
1339 $link = $nt->getPrefixedURL();
1340 if ( '' == $text ) { $text = $nt->getPrefixedText(); }
1341 $style = $this->getExternalLinkAttributes( $link, $text, 'extiw' );
1344 if ( '' != $trail ) {
1345 if ( preg_match( '/^([a-z]+)(.*)$$/sD', $trail, $m ) ) {
1350 # Assume $this->postParseLinkColour(). This prevents
1351 # interwiki links from being parsed as external links.
1352 global $wgInterwikiLinkHolders;
1353 $t = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>";
1354 $nr = array_push($wgInterwikiLinkHolders, $t);
1355 $retVal = '<!--IWLINK '. ($nr-1) ."-->{$trail}";
1356 } elseif ( 0 == $nt->getNamespace() && "" == $nt->getText() ) {
1357 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1358 } elseif ( ( -1 == $nt->getNamespace() ) ||
1359 ( Namespace::getImage() == $nt->getNamespace() ) ) {
1360 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1362 if ( $this->postParseLinkColour() ) {
1364 if ( '' != $trail ) {
1365 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1371 # Allows wiki to bypass using linkcache, see OutputPage::parseLinkHolders()
1372 $nr = array_push( $wgLinkHolders['namespaces'], $nt->getNamespace() );
1373 $wgLinkHolders['dbkeys'][] = $nt->getDBkey();
1374 $wgLinkHolders['queries'][] = $query;
1375 $wgLinkHolders['texts'][] = $prefix.$text.$inside;
1376 $wgLinkHolders['titles'][] = $nt;
1378 $retVal = '<!--LINK '. ($nr-1) ."-->{$trail}";
1380 # Work out link colour immediately
1381 $aid = $nt->getArticleID() ;
1383 $retVal = $this->makeBrokenLinkObj( $nt, $text, $query, $trail, $prefix );
1385 $threshold = $wgUser->getOption('stubthreshold') ;
1386 if ( $threshold > 0 ) {
1387 $dbr =& wfGetDB( DB_SLAVE
);
1388 $s = $dbr->selectRow( 'cur', array( 'LENGTH(cur_text) AS x', 'cur_namespace',
1389 'cur_is_redirect' ), array( 'cur_id' => $aid ), $fname ) ;
1390 if ( $s !== false ) {
1392 if ( $s->cur_is_redirect
OR $s->cur_namespace
!= 0 ) {
1393 $size = $threshold*2 ; # Really big
1395 $dbr->freeResult( $res );
1397 $size = $threshold*2 ; # Really big
1402 if ( $size < $threshold ) {
1403 $retVal = $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix );
1405 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1414 * Pass a title object, not a title string
1416 function makeKnownLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '' ) {
1417 global $wgOut, $wgTitle, $wgInputEncoding;
1419 $fname = 'Skin::makeKnownLinkObj';
1420 wfProfileIn( $fname );
1422 if ( !is_object( $nt ) ) {
1425 $link = $nt->getPrefixedURL();
1426 # if ( '' != $section && substr($section,0,1) != "#" ) {
1429 if ( '' == $link ) {
1431 if ( '' == $text ) {
1432 $text = htmlspecialchars( $nt->getFragment() );
1435 $u = $nt->escapeLocalURL( $query );
1437 if ( '' != $nt->getFragment() ) {
1438 $anchor = urlencode( do_html_entity_decode( str_replace(' ', '_', $nt->getFragment()), ENT_COMPAT
, $wgInputEncoding ) );
1439 $replacearray = array(
1443 $u .= '#' . str_replace(array_keys($replacearray),array_values($replacearray),$anchor);
1445 if ( '' == $text ) {
1446 $text = htmlspecialchars( $nt->getPrefixedText() );
1448 $style = $this->getInternalLinkAttributesObj( $nt, $text );
1451 if ( '' != $trail ) {
1452 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1457 $r = "<a href=\"{$u}\"{$style}{$aprops}>{$prefix}{$text}{$inside}</a>{$trail}";
1458 wfProfileOut( $fname );
1463 * Pass a title object, not a title string
1465 function makeBrokenLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
1466 global $wgOut, $wgUser;
1469 if ( ! isset($nt) ) {
1470 # wfDebugDieBacktrace();
1471 return "<!-- ERROR -->{$prefix}{$text}{$trail}";
1474 $fname = 'Skin::makeBrokenLinkObj';
1475 wfProfileIn( $fname );
1477 if ( '' == $query ) {
1480 $q = 'action=edit&'.$query;
1482 $u = $nt->escapeLocalURL( $q );
1484 if ( '' == $text ) {
1485 $text = htmlspecialchars( $nt->getPrefixedText() );
1487 $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" );
1490 if ( '' != $trail ) {
1491 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1496 if ( $wgUser->getOption( 'highlightbroken' ) ) {
1497 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
1499 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
1502 wfProfileOut( $fname );
1507 * Pass a title object, not a title string
1509 function makeStubLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
1510 global $wgOut, $wgUser;
1512 $link = $nt->getPrefixedURL();
1514 $u = $nt->escapeLocalURL( $query );
1516 if ( '' == $text ) {
1517 $text = htmlspecialchars( $nt->getPrefixedText() );
1519 $style = $this->getInternalLinkAttributesObj( $nt, $text, 'stub' );
1522 if ( '' != $trail ) {
1523 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1528 if ( $wgUser->getOption( 'highlightbroken' ) ) {
1529 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
1531 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
1536 function makeSelfLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
1537 $u = $nt->escapeLocalURL( $query );
1538 if ( '' == $text ) {
1539 $text = htmlspecialchars( $nt->getPrefixedText() );
1542 if ( '' != $trail ) {
1543 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1548 return "<strong>{$prefix}{$text}{$inside}</strong>{$trail}";
1551 /* these are used extensively in SkinPHPTal, but also some other places */
1552 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1553 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1554 $this->checkTitle($title, $name);
1555 return $title->getLocalURL( $urlaction );
1557 /*static*/ function makeTalkUrl ( $name, $urlaction='' ) {
1558 $title = Title
::newFromText( $name );
1559 $title = $title->getTalkPage();
1560 $this->checkTitle($title, $name);
1561 return $title->getLocalURL( $urlaction );
1563 /*static*/ function makeArticleUrl ( $name, $urlaction='' ) {
1564 $title = Title
::newFromText( $name );
1565 $title= $title->getSubjectPage();
1566 $this->checkTitle($title, $name);
1567 return $title->getLocalURL( $urlaction );
1569 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1570 $title = Title
::newFromText( wfMsgForContent($name) );
1571 $this->checkTitle($title, $name);
1572 return $title->getLocalURL( $urlaction );
1574 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1575 $title = Title
::newFromText( $name );
1576 $this->checkTitle($title, $name);
1577 return $title->getLocalURL( $urlaction );
1580 # If url string starts with http, consider as external URL, else
1582 /*static*/ function makeInternalOrExternalUrl( $name ) {
1583 if ( strncmp( $name, 'http', 4 ) == 0 ) {
1586 return $this->makeUrl( $name );
1590 # this can be passed the NS number as defined in Language.php
1591 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=0 ) {
1592 $title = Title
::makeTitleSafe( $namespace, $name );
1593 $this->checkTitle($title, $name);
1594 return $title->getLocalURL( $urlaction );
1597 /* these return an array with the 'href' and boolean 'exists' */
1598 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1599 $title = Title
::newFromText( $name );
1600 $this->checkTitle($title, $name);
1602 'href' => $title->getLocalURL( $urlaction ),
1603 'exists' => $title->getArticleID() != 0?
true:false
1606 /*static*/ function makeTalkUrlDetails ( $name, $urlaction='' ) {
1607 $title = Title
::newFromText( $name );
1608 $title = $title->getTalkPage();
1609 $this->checkTitle($title, $name);
1611 'href' => $title->getLocalURL( $urlaction ),
1612 'exists' => $title->getArticleID() != 0?
true:false
1615 /*static*/ function makeArticleUrlDetails ( $name, $urlaction='' ) {
1616 $title = Title
::newFromText( $name );
1617 $title= $title->getSubjectPage();
1618 $this->checkTitle($title, $name);
1620 'href' => $title->getLocalURL( $urlaction ),
1621 'exists' => $title->getArticleID() != 0?
true:false
1624 /*static*/ function makeI18nUrlDetails ( $name, $urlaction='' ) {
1625 $title = Title
::newFromText( wfMsgForContent($name) );
1626 $this->checkTitle($title, $name);
1628 'href' => $title->getLocalURL( $urlaction ),
1629 'exists' => $title->getArticleID() != 0?
true:false
1633 # make sure we have some title to operate on
1634 /*static*/ function checkTitle ( &$title, &$name ) {
1635 if(!is_object($title)) {
1636 $title = Title
::newFromText( $name );
1637 if(!is_object($title)) {
1638 $title = Title
::newFromText( '--error: link target missing--' );
1643 function fnamePart( $url ) {
1644 $basename = strrchr( $url, '/' );
1645 if ( false === $basename ) {
1648 $basename = substr( $basename, 1 );
1650 return htmlspecialchars( $basename );
1653 function makeImage( $url, $alt = '' ) {
1657 $alt = $this->fnamePart( $url );
1659 $s = '<img src="'.$url.'" alt="'.$alt.'" />';
1663 function makeImageLink( $name, $url, $alt = '' ) {
1664 $nt = Title
::makeTitleSafe( NS_IMAGE
, $name );
1665 return $this->makeImageLinkObj( $nt, $alt );
1668 function makeImageLinkObj( $nt, $alt = '' ) {
1669 global $wgContLang, $wgUseImageResize;
1670 $img = Image
::newFromTitle( $nt );
1671 $url = $img->getURL();
1674 $prefix = $postfix = '';
1676 if ( $wgUseImageResize ) {
1677 # Check if the alt text is of the form "options|alt text"
1679 # * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang
1680 # * left no resizing, just left align. label is used for alt= only
1681 # * right same, but right aligned
1682 # * none same, but not aligned
1683 # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox
1684 # * center center the image
1685 # * framed Keep original image size, no magnify-button.
1687 $part = explode( '|', $alt);
1689 $mwThumb =& MagicWord
::get( MAG_IMG_THUMBNAIL
);
1690 $mwLeft =& MagicWord
::get( MAG_IMG_LEFT
);
1691 $mwRight =& MagicWord
::get( MAG_IMG_RIGHT
);
1692 $mwNone =& MagicWord
::get( MAG_IMG_NONE
);
1693 $mwWidth =& MagicWord
::get( MAG_IMG_WIDTH
);
1694 $mwCenter =& MagicWord
::get( MAG_IMG_CENTER
);
1695 $mwFramed =& MagicWord
::get( MAG_IMG_FRAMED
);
1696 $alt = $part[count($part)-1];
1698 $height = $framed = $thumb = false;
1699 $manual_thumb = "" ;
1701 foreach( $part as $key => $val ) {
1702 $val_parts = explode ( "=" , $val , 2 ) ;
1703 $left_part = array_shift ( $val_parts ) ;
1704 if ( ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) {
1706 } elseif ( count ( $val_parts ) == 1 && ! is_null( $mwThumb->matchVariableStartToEnd($left_part) ) ) {
1707 # use manually specified thumbnail
1709 $manual_thumb = array_shift ( $val_parts ) ;
1710 } elseif ( ! is_null( $mwRight->matchVariableStartToEnd($val) ) ) {
1711 # remember to set an alignment, don't render immediately
1713 } elseif ( ! is_null( $mwLeft->matchVariableStartToEnd($val) ) ) {
1714 # remember to set an alignment, don't render immediately
1716 } elseif ( ! is_null( $mwCenter->matchVariableStartToEnd($val) ) ) {
1717 # remember to set an alignment, don't render immediately
1719 } elseif ( ! is_null( $mwNone->matchVariableStartToEnd($val) ) ) {
1720 # remember to set an alignment, don't render immediately
1722 } elseif ( ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
1723 # $match is the image width in pixels
1724 if ( preg_match( '/^([0-9]*)x([0-9]*)$/', $match, $m ) ) {
1725 $width = intval( $m[1] );
1726 $height = intval( $m[2] );
1728 $width = intval($match);
1730 } elseif ( ! is_null( $mwFramed->matchVariableStartToEnd($val) ) ) {
1734 if ( 'center' == $align )
1736 $prefix = '<span style="text-align: center">';
1737 $postfix = '</span>';
1741 if ( $thumb ||
$framed ) {
1743 # Create a thumbnail. Alignment depends on language
1744 # writing direction, # right aligned for left-to-right-
1745 # languages ("Western languages"), left-aligned
1746 # for right-to-left-languages ("Semitic languages")
1748 # If thumbnail width has not been provided, it is set
1749 # here to 180 pixels
1750 if ( $align == '' ) {
1751 $align = $wgContLang->isRTL() ?
'left' : 'right';
1753 if ( ! isset($width) ) {
1756 return $prefix.$this->makeThumbLinkObj( $img, $alt, $align, $width, $height, $framed, $manual_thumb ).$postfix;
1758 } elseif ( isset($width) ) {
1760 # Create a resized image, without the additional thumbnail
1763 if ( ( ! $height === false )
1764 && ( $img->getHeight() * $width / $img->getWidth() > $height ) ) {
1765 print "height=$height<br>\nimg->getHeight() = ".$img->getHeight()."<br>\n";
1766 print 'rescaling by factor '. $height / $img->getHeight() . "<br>\n";
1767 $width = $img->getWidth() * $height / $img->getHeight();
1769 if ( '' == $manual_thumb ) $url = $img->createThumb( $width );
1771 } # endif $wgUseImageResize
1773 if ( empty( $alt ) ) {
1774 $alt = preg_replace( '/\.(.+?)^/', '', $img->getName() );
1776 $alt = htmlspecialchars( $alt );
1778 $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.'" /></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->getURL();
1802 #$label = htmlspecialchars( $label );
1803 $alt = preg_replace( '/<[^>]*>/', '', $label);
1804 $alt = htmlspecialchars( $alt );
1806 $width = $height = 0;
1807 if ( $img->exists() )
1809 $width = $img->getWidth();
1810 $height = $img->getHeight();
1812 if ( 0 == $width ||
0 == $height )
1814 $width = $height = 200;
1816 if ( $boxwidth == 0 )
1822 // Use image dimensions, don't scale
1824 $oboxwidth = $boxwidth +
2;
1825 $boxheight = $height;
1828 $h = intval( $height/($width/$boxwidth) );
1829 $oboxwidth = $boxwidth +
2;
1830 if ( ( ! $boxheight === false ) && ( $h > $boxheight ) )
1832 $boxwidth *= $boxheight/$h;
1836 if ( '' == $manual_thumb ) $thumbUrl = $img->createThumb( $boxwidth );
1839 if ( $manual_thumb != '' ) # Use manually specified thumbnail
1841 $manual_title = Title
::makeTitleSafe( NS_IMAGE
, $manual_thumb ); #new Title ( $manual_thumb ) ;
1842 $manual_img = Image
::newFromTitle( $manual_title );
1843 $thumbUrl = $manual_img->getURL();
1844 if ( $manual_img->exists() )
1846 $width = $manual_img->getWidth();
1847 $height = $manual_img->getHeight();
1848 $boxwidth = $width ;
1849 $boxheight = $height ;
1850 $oboxwidth = $boxwidth +
2 ;
1854 $u = $img->getEscapeLocalURL();
1856 $more = htmlspecialchars( wfMsg( 'thumbnail-more' ) );
1857 $magnifyalign = $wgContLang->isRTL() ?
'left' : 'right';
1858 $textalign = $wgContLang->isRTL() ?
' style="text-align:right"' : '';
1860 $s = "<div class=\"thumb t{$align}\"><div style=\"width:{$oboxwidth}px;\">";
1861 if ( $thumbUrl == '' ) {
1862 $s .= wfMsg( 'missingimage', $img->getName() );
1865 $s .= '<a href="'.$u.'" class="internal" title="'.$alt.'">'.
1866 '<img src="'.$thumbUrl.'" alt="'.$alt.'" ' .
1867 'width="'.$boxwidth.'" height="'.$boxheight.'" /></a>';
1871 $zoomicon = '<div class="magnify" style="float:'.$magnifyalign.'">'.
1872 '<a href="'.$u.'" class="internal" title="'.$more.'">'.
1873 '<img src="'.$wgStylePath.'/common/images/magnify-clip.png" ' .
1874 'width="15" height="11" alt="'.$more.'" /></a></div>';
1877 $s .= ' <div class="thumbcaption" '.$textalign.'>'.$zoomicon.$label."</div></div></div>";
1878 return str_replace("\n", ' ', $s);
1881 function makeMediaLink( $name, $url, $alt = '' ) {
1882 $nt = Title
::makeTitleSafe( Namespace::getMedia(), $name );
1883 return $this->makeMediaLinkObj( $nt, $alt );
1886 function makeMediaLinkObj( $nt, $alt = '' ) {
1887 if ( ! isset( $nt ) )
1889 ### HOTFIX. Instead of breaking, return empty string.
1892 $name = $nt->getDBKey();
1893 $url = Image
::wfImageUrl( $name );
1894 if ( empty( $alt ) ) {
1895 $alt = preg_replace( '/\.(.+?)^/', '', $name );
1898 $u = htmlspecialchars( $url );
1899 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
1904 function specialLink( $name, $key = '' ) {
1907 if ( '' == $key ) { $key = strtolower( $name ); }
1908 $pn = $wgContLang->ucfirst( $name );
1909 return $this->makeKnownLink( $wgContLang->specialPage( $pn ),
1913 function makeExternalLink( $url, $text, $escape = true ) {
1914 $style = $this->getExternalLinkAttributes( $url, $text );
1915 $url = htmlspecialchars( $url );
1917 $text = htmlspecialchars( $text );
1919 return '<a href="'.$url.'"'.$style.'>'.$text.'</a>';
1922 # Called by history lists and recent changes
1925 # Returns text for the start of the tabular part of RC
1926 function beginRecentChangesList() {
1927 $this->rc_cache
= array() ;
1928 $this->rcMoveIndex
= 0;
1929 $this->rcCacheIndex
= 0 ;
1930 $this->lastdate
= '';
1931 $this->rclistOpen
= false;
1935 function beginImageHistoryList() {
1936 $s = "\n<h2>" . wfMsg( 'imghistory' ) . "</h2>\n" .
1937 "<p>" . wfMsg( 'imghistlegend' ) . "</p>\n".'<ul class="special">';
1942 * Returns text for the end of RC
1943 * If enhanced RC is in use, returns pretty much all the text
1945 function endRecentChangesList() {
1946 $s = $this->recentChangesBlock() ;
1947 if( $this->rclistOpen
) {
1954 * Enhanced RC ungrouped line
1956 function recentChangesBlockLine ( $rcObj ) {
1957 global $wgStylePath, $wgContLang ;
1959 # Get rc_xxxx variables
1960 extract( $rcObj->mAttribs
) ;
1961 $curIdEq = 'curid='.$rc_cur_id;
1966 $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" border="0" />' ;
1969 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
1970 $r .= ' ';
1972 # M & N (minor & new)
1973 $M = wfMsg( 'minoreditletter' );
1974 $N = wfMsg( 'newpageletter' );
1976 if ( $rc_type == RC_NEW
) {
1989 $r .= ' '.$rcObj->timestamp
.' ' ;
1993 $link = $rcObj->link
;
1994 if ( $rcObj->watched
) $link = '<strong>'.$link.'</strong>' ;
1999 $r .= $rcObj->difflink
;
2003 $r .= $this->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' );
2006 $r .= ') . . '.$rcObj->userlink
;
2007 $r .= $rcObj->usertalklink
;
2010 if ( $rc_comment != '' && $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
2011 $rc_comment=$this->formatComment($rc_comment, $rcObj->getTitle());
2012 $r .= $wgContLang->emphasize( ' ('.$rc_comment.')' );
2022 function recentChangesBlockGroup ( $block ) {
2023 global $wgStylePath, $wgContLang ;
2026 $M = wfMsg( 'minoreditletter' );
2027 $N = wfMsg( 'newpageletter' );
2029 # Collate list of users
2031 $userlinks = array () ;
2032 foreach ( $block AS $rcObj ) {
2033 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
2034 if ( $rcObj->mAttribs
['rc_new'] ) $isnew = true ;
2035 $u = $rcObj->userlink
;
2036 if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
2040 # Sort the list and convert to text
2041 krsort ( $userlinks ) ;
2042 asort ( $userlinks ) ;
2044 foreach ( $userlinks as $userlink => $count) {
2046 if ( $count > 1 ) $text .= " ({$count}×)" ;
2047 array_push ( $users , $text ) ;
2049 $users = ' <font size="-1">['.implode('; ',$users).']</font>' ;
2052 $rci = 'RCI'.$this->rcCacheIndex
;
2053 $rcl = 'RCL'.$this->rcCacheIndex
;
2054 $rcm = 'RCM'.$this->rcCacheIndex
;
2055 $toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')" ;
2056 $arrowdir = $wgContLang->isRTL() ?
'l' : 'r';
2057 $tl = '<span id="'.$rcm.'"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_'.$arrowdir.'.png" width="12" height="12" /></a></span>' ;
2058 $tl .= '<span id="'.$rcl.'" style="display:none"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_d.png" width="12" height="12" /></a></span>' ;
2064 if ( $isnew ) $r .= $N ;
2065 else $r .= ' ' ;
2066 $r .= ' ' ; # Minor
2069 $r .= ' '.$block[0]->timestamp
.' ' ;
2073 $link = $block[0]->link
;
2074 if ( $block[0]->watched
) $link = '<strong>'.$link.'</strong>' ;
2077 $curIdEq = 'curid=' . $block[0]->mAttribs
['rc_cur_id'];
2078 if ( $block[0]->mAttribs
['rc_type'] != RC_LOG
) {
2080 $r .= ' ('.count($block).' ' ;
2081 if ( $isnew ) $r .= wfMsg('changes');
2082 else $r .= $this->makeKnownLinkObj( $block[0]->getTitle() , wfMsg('changes') ,
2083 $curIdEq.'&diff=0&oldid='.$oldid ) ;
2087 $r .= $this->makeKnownLinkObj( $block[0]->getTitle(), wfMsg( 'history' ), $curIdEq.'&action=history' );
2095 $r .= '<div id="'.$rci.'" style="display:none">' ;
2096 foreach ( $block AS $rcObj ) {
2097 # Get rc_xxxx variables
2098 extract( $rcObj->mAttribs
);
2100 $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" />';
2101 $r .= '<tt> ' ;
2102 if ( $rc_new ) $r .= $N ;
2103 else $r .= ' ' ;
2104 if ( $rc_minor ) $r .= $M ;
2105 else $r .= ' ' ;
2109 if ( $rc_last_oldid != 0 ) {
2110 $o = 'oldid='.$rc_last_oldid ;
2112 if ( $rc_type == RC_LOG
) {
2113 $link = $rcObj->timestamp
;
2115 $link = $this->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, "{$curIdEq}&$o" ) ;
2117 $link = '<tt>'.$link.'</tt>' ;
2121 $r .= $rcObj->curlink
;
2123 $r .= $rcObj->lastlink
;
2124 $r .= ') . . '.$rcObj->userlink
;
2125 $r .= $rcObj->usertalklink
;
2126 if ( $rc_comment != '' ) {
2127 $rc_comment=$this->formatComment($rc_comment, $rcObj->getTitle());
2128 $r .= $wgContLang->emphasize( ' ('.$rc_comment.')' ) ;
2134 $this->rcCacheIndex++
;
2139 * If enhanced RC is in use, this function takes the previously cached
2140 * RC lines, arranges them, and outputs the HTML
2142 function recentChangesBlock () {
2143 global $wgStylePath ;
2144 if ( count ( $this->rc_cache
) == 0 ) return '' ;
2146 foreach ( $this->rc_cache
AS $secureName => $block ) {
2147 if ( count ( $block ) < 2 ) {
2148 $blockOut .= $this->recentChangesBlockLine ( array_shift ( $block ) ) ;
2150 $blockOut .= $this->recentChangesBlockGroup ( $block ) ;
2154 return '<div>'.$blockOut.'</div>' ;
2158 * Called in a loop over all displayed RC entries
2159 * Either returns the line, or caches it for later use
2161 function recentChangesLine( &$rc, $watched = false ) {
2163 $usenew = $wgUser->getOption( 'usenewrc' );
2165 $line = $this->recentChangesLineNew ( $rc, $watched ) ;
2167 $line = $this->recentChangesLineOld ( $rc, $watched ) ;
2171 function recentChangesLineOld( &$rc, $watched = false ) {
2172 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds, $wgUseRCPatrol, $wgOnlySysopsCanPatrol;
2174 # Extract DB fields into local scope
2175 extract( $rc->mAttribs
);
2176 $curIdEq = 'curid=' . $rc_cur_id;
2178 # Make date header if necessary
2179 $date = $wgContLang->date( $rc_timestamp, true);
2180 $uidate = $wgLang->date( $rc_timestamp, true);
2182 if ( $date != $this->lastdate
) {
2183 if ( '' != $this->lastdate
) { $s .= "</ul>\n"; }
2184 $s .= "<h4>{$uidate}</h4>\n<ul class='special'>";
2185 $this->lastdate
= $date;
2186 $this->rclistOpen
= true;
2189 # If this edit has not yet been patrolled, make it stick out
2190 $s .= ( ! $wgUseRCPatrol ||
$rc_patrolled ) ?
'<li> ' : '<li class="not_patrolled"> ';
2192 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2194 $s .= '(' . wfMsg( 'diff' ) . ') (';
2196 $s .= $this->makeKnownLinkObj( $rc->getMovedToTitle(), wfMsg( 'hist' ), 'action=history' ) .
2199 # "[[x]] moved to [[y]]"
2200 $msg = ( $rc_type == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
2201 $s .= wfMsg( $msg, $this->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
2202 $this->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
2203 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
2205 $logtype = $matches[1];
2206 $logname = LogPage
::logName( $logtype );
2207 $s .= '(' . $this->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
2210 if ( $rc_type == RC_NEW ||
$rc_type == RC_LOG
) {
2211 $diffLink = wfMsg( 'diff' );
2213 if ( $wgUseRCPatrol && $rc_patrolled == 0 && $wgUser->getID() != 0 &&
2214 ( $wgUser->isSysop() ||
!$wgOnlySysopsCanPatrol ) )
2215 $rcidparam = "&rcid={$rc_id}";
2218 $diffLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'diff' ),
2219 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}{$rcidparam}",
2220 '', '', ' tabindex="'.$rc->counter
.'"');
2222 $s .= '('.$diffLink.') (';
2225 $s .= $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' );
2228 # M and N (minor and new)
2229 if ( $rc_minor ) { $s .= ' <span class="minor">'.wfMsg( "minoreditletter" ).'</span>'; }
2230 if ( $rc_type == RC_NEW
) { $s .= '<span class="newpage">'.wfMsg( "newpageletter" ).'</span>'; }
2233 # If it's a new article, there is no diff link, but if it hasn't been
2234 # patrolled yet, we need to give users a way to do so
2235 if ( $wgUseRCPatrol && $rc_type == RC_NEW
&& $rc_patrolled == 0 &&
2236 $wgUser->getID() != 0 && ( $wgUser->isSysop() ||
!$wgOnlySysopsCanPatrol ) )
2237 $articleLink = $this->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
2239 $articleLink = $this->makeKnownLinkObj( $rc->getTitle(), '' );
2242 $articleLink = '<strong>'.$articleLink.'</strong>';
2244 $s .= ' '.$articleLink;
2249 $s .= '; ' . $wgLang->time( $rc_timestamp, true, $wgRCSeconds ) . ' . . ';
2251 # User link (or contributions for unregistered users)
2252 if ( 0 == $rc_user ) {
2253 $userLink = $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
2254 $rc_user_text, 'target=' . $rc_user_text );
2256 $userLink = $this->makeLink( $wgContLang->getNsText( NS_USER
) . ':'.$rc_user_text, $rc_user_text );
2261 $talkname=$wgContLang->getNsText(NS_TALK
); # use the shorter name
2262 global $wgDisableAnonTalk;
2263 if( 0 == $rc_user && $wgDisableAnonTalk ) {
2266 $utns=$wgContLang->getNsText(NS_USER_TALK
);
2267 $userTalkLink= $this->makeLink($utns . ':'.$rc_user_text, $talkname );
2271 if ( ( 0 == $rc_user ) && $wgUser->isSysop() ) {
2272 $blockLink = $this->makeKnownLink( $wgContLang->specialPage(
2273 'Blockip' ), wfMsg( 'blocklink' ), 'ip='.$rc_user_text );
2277 if($userTalkLink) $userTalkLink .= ' | ';
2278 $userTalkLink .= $blockLink;
2280 if($userTalkLink) $s.=' ('.$userTalkLink.')';
2283 if ( '' != $rc_comment && '*' != $rc_comment && $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
2284 $rc_comment=$this->formatComment($rc_comment,$rc->getTitle());
2285 $s .= $wgContLang->emphasize(' (' . $rc_comment . ')');
2292 function recentChangesLineNew( &$baseRC, $watched = false ) {
2293 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds;
2295 # Create a specialised object
2296 $rc = RCCacheEntry
::newFromParent( $baseRC ) ;
2298 # Extract fields from DB into the function scope (rc_xxxx variables)
2299 extract( $rc->mAttribs
);
2300 $curIdEq = 'curid=' . $rc_cur_id;
2302 # If it's a new day, add the headline and flush the cache
2303 $date = $wgContLang->date( $rc_timestamp, true);
2304 $uidate = $wgLang->date( $rc_timestamp, true);
2306 if ( $date != $this->lastdate
) {
2307 # Process current cache
2308 $ret = $this->recentChangesBlock () ;
2309 $this->rc_cache
= array() ;
2310 $ret .= "<h4>{$uidate}</h4>\n";
2311 $this->lastdate
= $date;
2315 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2316 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
2317 $clink = wfMsg( $msg, $this->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
2318 $this->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
2319 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
2321 $logtype = $matches[1];
2322 $logname = LogPage
::logName( $logtype );
2323 $clink = '(' . $this->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
2325 $clink = $this->makeKnownLinkObj( $rc->getTitle(), '' ) ;
2328 $time = $wgContLang->time( $rc_timestamp, true, $wgRCSeconds );
2329 $rc->watched
= $watched ;
2330 $rc->link
= $clink ;
2331 $rc->timestamp
= $time;
2333 # Make "cur" and "diff" links
2334 if ( ( $rc_type == RC_NEW
&& $rc_this_oldid == 0 ) ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2335 $curLink = wfMsg( 'cur' );
2336 $diffLink = wfMsg( 'diff' );
2338 $query = $curIdEq.'&diff=0&oldid='.$rc_this_oldid;
2339 $aprops = ' tabindex="'.$baseRC->counter
.'"';
2340 $curLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'cur' ), $query, '' ,'' , $aprops );
2341 $diffLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'diff'), $query, '' ,'' , $aprops );
2345 $titleObj = $rc->getTitle();
2346 if ( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2347 $lastLink = wfMsg( 'last' );
2349 $lastLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'last' ),
2350 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid );
2353 # Make user link (or user contributions for unregistered users)
2354 if ( $rc_user == 0 ) {
2355 $userLink = $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
2356 $rc_user_text, 'target=' . $rc_user_text );
2358 $userLink = $this->makeLink( $wgContLang->getNsText(
2359 Namespace::getUser() ) . ':'.$rc_user_text, $rc_user_text );
2362 $rc->userlink
= $userLink;
2363 $rc->lastlink
= $lastLink;
2364 $rc->curlink
= $curLink;
2365 $rc->difflink
= $diffLink;
2367 # Make user talk link
2368 $utns=$wgContLang->getNsText(NS_USER_TALK
);
2369 $talkname=$wgContLang->getNsText(NS_TALK
); # use the shorter name
2370 $userTalkLink= $this->makeLink($utns . ':'.$rc_user_text, $talkname );
2372 global $wgDisableAnonTalk;
2373 if ( ( 0 == $rc_user ) && $wgUser->isSysop() ) {
2374 $blockLink = $this->makeKnownLink( $wgContLang->specialPage(
2375 'Blockip' ), wfMsg( 'blocklink' ), 'ip='.$rc_user_text );
2376 if( $wgDisableAnonTalk )
2377 $rc->usertalklink
= ' ('.$blockLink.')';
2379 $rc->usertalklink
= ' ('.$userTalkLink.' | '.$blockLink.')';
2381 if( $wgDisableAnonTalk && ($rc_user == 0) )
2382 $rc->usertalklink
= '';
2384 $rc->usertalklink
= ' ('.$userTalkLink.')';
2387 # Put accumulated information into the cache, for later display
2388 # Page moves go on their own line
2389 $title = $rc->getTitle();
2390 $secureName = $title->getPrefixedDBkey();
2391 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2392 # Use an @ character to prevent collision with page names
2393 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
2395 if ( !isset ( $this->rc_cache
[$secureName] ) ) $this->rc_cache
[$secureName] = array() ;
2396 array_push ( $this->rc_cache
[$secureName] , $rc ) ;
2401 function endImageHistoryList() {
2407 * This function is called by all recent changes variants, by the page history,
2408 * and by the user contributions list. It is responsible for formatting edit
2409 * comments. It escapes any HTML in the comment, but adds some CSS to format
2410 * auto-generated comments (from section editing) and formats [[wikilinks]].
2412 * The &$title parameter must be a title OBJECT. It is used to generate a
2413 * direct link to the section in the autocomment.
2414 * @author Erik Moeller <moeller@scireview.de>
2416 * Note: there's not always a title to pass to this function.
2417 * Since you can't set a default parameter for a reference, I've turned it
2418 * temporarily to a value pass. Should be adjusted further. --brion
2420 function formatComment($comment, $title = NULL) {
2422 $comment = htmlspecialchars( $comment );
2424 # The pattern for autogen comments is / * foo * /, which makes for
2426 # We look for all comments, match any text before and after the comment,
2427 # add a separator where needed and format the comment itself with CSS
2428 while (preg_match('/(.*)\/\*\s*(.*?)\s*\*\/(.*)/', $comment,$match)) {
2436 # This is hackish but should work in most cases.
2437 $section=str_replace('[[','',$section);
2438 $section=str_replace(']]','',$section);
2439 $title->mFragment
=$section;
2440 $link=$this->makeKnownLinkObj($title,wfMsg('sectionlink'));
2444 if($pre) { $auto = $sep.' '.$auto; }
2445 if($post) { $auto .= ' '.$sep; }
2446 $auto='<span class="autocomment">'.$auto.'</span>';
2447 $comment=$pre.$auto.$post;
2450 # format regular and media links - all other wiki formatting
2452 $medians = $wgContLang->getNsText(Namespace::getMedia()).':';
2453 while(preg_match('/\[\[(.*?)(\|(.*?))*\]\](.*)$/',$comment,$match)) {
2454 # Handle link renaming [[foo|text]] will show link as "text"
2455 if( "" != $match[3] ) {
2460 if( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) {
2461 # Media link; trail not supported.
2462 $linkRegexp = '/\[\[(.*?)\]\]/';
2463 $thelink = $this->makeMediaLink( $submatch[1], "", $text );
2465 # Other kind of link
2466 if( preg_match( wfMsgForContent( "linktrail" ), $match[4], $submatch ) ) {
2467 $trail = $submatch[1];
2471 $linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/';
2472 if ($match[1][0] == ':')
2473 $match[1] = substr($match[1], 1);
2474 $thelink = $this->makeLink( $match[1], $text, "", $trail );
2476 $comment = preg_replace( $linkRegexp, $thelink, $comment, 1 );
2481 function imageHistoryLine( $iscur, $timestamp, $img, $user, $usertext, $size, $description ) {
2482 global $wgUser, $wgLang, $wgContLang, $wgTitle;
2484 $datetime = $wgLang->timeanddate( $timestamp, true );
2485 $del = wfMsg( 'deleteimg' );
2486 $delall = wfMsg( 'deleteimgcompletely' );
2487 $cur = wfMsg( 'cur' );
2490 $url = Image
::wfImageUrl( $img );
2492 if ( $wgUser->isSysop() ) {
2493 $link = $wgTitle->escapeLocalURL( 'image=' . $wgTitle->getPartialURL() .
2495 $style = $this->getInternalLinkAttributes( $link, $delall );
2497 $dlink = '<a href="'.$link.'"'.$style.'>'.$delall.'</a>';
2502 $url = htmlspecialchars( wfImageArchiveUrl( $img ) );
2503 if( $wgUser->getID() != 0 && $wgTitle->userCanEdit() ) {
2504 $rlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
2505 wfMsg( 'revertimg' ), 'action=revert&oldimage=' .
2506 urlencode( $img ) );
2507 $dlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
2508 $del, 'action=delete&oldimage=' . urlencode( $img ) );
2510 # Having live active links for non-logged in users
2511 # means that bots and spiders crawling our site can
2512 # inadvertently change content. Baaaad idea.
2513 $rlink = wfMsg( 'revertimg' );
2518 $userlink = $usertext;
2520 $userlink = $this->makeLink( $wgContLang->getNsText( Namespace::getUser() ) .
2521 ':'.$usertext, $usertext );
2523 $nbytes = wfMsg( 'nbytes', $size );
2524 $style = $this->getInternalLinkAttributes( $url, $datetime );
2526 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$datetime}</a>"
2527 . " . . {$userlink} ({$nbytes})";
2529 if ( '' != $description && '*' != $description ) {
2530 $sk=$wgUser->getSkin();
2531 $s .= $wgContLang->emphasize(' (' . $sk->formatComment($description,$wgTitle) . ')');
2537 function tocIndent($level) {
2538 return str_repeat( '<div class="tocindent">'."\n", $level>0 ?
$level : 0 );
2541 function tocUnindent($level) {
2542 return str_repeat( "</div>\n", $level>0 ?
$level : 0 );
2546 * parameter level defines if we are on an indentation level
2548 function tocLine( $anchor, $tocline, $level ) {
2549 $link = '<a href="#'.$anchor.'">'.$tocline.'</a><br />';
2553 return '<div class="tocline">'.$link."</div>\n";
2558 function tocTable($toc) {
2559 # note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
2560 # try min-width & co when somebody gets a chance
2561 $hideline = ' <script type="text/javascript">showTocToggle("' . addslashes( wfMsg('showtoc') ) . '","' . addslashes( wfMsg('hidetoc') ) . '")</script>';
2563 '<table border="0" id="toc"><tr id="toctitle"><td align="center">'."\n".
2564 '<b>'.wfMsg('toc').'</b>' .
2566 '</td></tr><tr id="tocinside"><td>'."\n".
2567 $toc."</td></tr></table>\n";
2571 * These two do not check for permissions: check $wgTitle->userCanEdit
2572 * before calling them
2574 function editSectionScriptForOther( $title, $section, $head ) {
2575 $ttl = Title
::newFromText( $title );
2576 $url = $ttl->escapeLocalURL( 'action=edit§ion='.$section );
2577 return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
2580 function editSectionScript( $section, $head ) {
2581 global $wgTitle, $wgRequest;
2582 if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
2585 $url = $wgTitle->escapeLocalURL( 'action=edit§ion='.$section );
2586 return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
2589 function editSectionLinkForOther( $title, $section ) {
2591 global $wgUser, $wgContLang;
2593 $title = Title
::newFromText($title);
2594 $editurl = '§ion='.$section;
2595 $url = $this->makeKnownLink($title->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
2597 if( $wgContLang->isRTL() ) {
2599 $nearside = 'right';
2604 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
2608 function editSectionLink( $section ) {
2610 global $wgTitle, $wgUser, $wgContLang;
2612 if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
2613 # Section edit links would be out of sync on an old page.
2614 # But, if we're diffing to the current page, they'll be
2619 $editurl = '§ion='.$section;
2620 $url = $this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
2622 if( $wgContLang->isRTL() ) {
2624 $nearside = 'right';
2629 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
2634 * This function is called by EditPage.php and shows a bulletin board style
2635 * toolbar for common editing functions. It can be disabled in the user
2637 * The necessary JavaScript code can be found in style/wikibits.js.
2639 function getEditToolbar() {
2640 global $wgStylePath, $wgLang, $wgMimeType;
2643 * toolarray an array of arrays which each include the filename of
2644 * the button image (without path), the opening tag, the closing tag,
2645 * and optionally a sample text that is inserted between the two when no
2646 * selection is highlighted.
2647 * The tip text is shown when the user moves the mouse over the button.
2649 * Already here are accesskeys (key), which are not used yet until someone
2650 * can figure out a way to make them work in IE. However, we should make
2651 * sure these keys are not defined on the edit page.
2654 array( 'image'=>'button_bold.png',
2656 'close' => "\'\'\'",
2657 'sample'=> wfMsg('bold_sample'),
2658 'tip' => wfMsg('bold_tip'),
2661 array( 'image'=>'button_italic.png',
2664 'sample'=> wfMsg('italic_sample'),
2665 'tip' => wfMsg('italic_tip'),
2668 array( 'image'=>'button_link.png',
2671 'sample'=> wfMsg('link_sample'),
2672 'tip' => wfMsg('link_tip'),
2675 array( 'image'=>'button_extlink.png',
2678 'sample'=> wfMsg('extlink_sample'),
2679 'tip' => wfMsg('extlink_tip'),
2682 array( 'image'=>'button_headline.png',
2684 'close' => " ==\\n",
2685 'sample'=> wfMsg('headline_sample'),
2686 'tip' => wfMsg('headline_tip'),
2689 array( 'image'=>'button_image.png',
2690 'open' => '[['.$wgLang->getNsText(NS_IMAGE
).":",
2692 'sample'=> wfMsg('image_sample'),
2693 'tip' => wfMsg('image_tip'),
2696 array( 'image' => 'button_media.png',
2697 'open' => '[['.$wgLang->getNsText(NS_MEDIA
).':',
2699 'sample'=> wfMsg('media_sample'),
2700 'tip' => wfMsg('media_tip'),
2703 array( 'image' => 'button_math.png',
2704 'open' => "\\<math\\>",
2705 'close' => "\\</math\\>",
2706 'sample'=> wfMsg('math_sample'),
2707 'tip' => wfMsg('math_tip'),
2710 array( 'image' => 'button_nowiki.png',
2711 'open' => "\\<nowiki\\>",
2712 'close' => "\\</nowiki\\>",
2713 'sample'=> wfMsg('nowiki_sample'),
2714 'tip' => wfMsg('nowiki_tip'),
2717 array( 'image' => 'button_sig.png',
2721 'tip' => wfMsg('sig_tip'),
2724 array( 'image' => 'button_hr.png',
2725 'open' => "\\n----\\n",
2728 'tip' => wfMsg('hr_tip'),
2732 $toolbar ="<script type='text/javascript'>\n/*<![CDATA[*/\n";
2734 $toolbar.="document.writeln(\"<div id='toolbar'>\");\n";
2735 foreach($toolarray as $tool) {
2737 $image=$wgStylePath.'/common/images/'.$tool['image'];
2738 $open=$tool['open'];
2739 $close=$tool['close'];
2740 $sample = addslashes( $tool['sample'] );
2742 // Note that we use the tip both for the ALT tag and the TITLE tag of the image.
2743 // Older browsers show a "speedtip" type message only for ALT.
2744 // Ideally these should be different, realistically they
2745 // probably don't need to be.
2746 $tip = addslashes( $tool['tip'] );
2748 #$key = $tool["key"];
2750 $toolbar.="addButton('$image','$tip','$open','$close','$sample');\n";
2753 $toolbar.="addInfobox('" . addslashes( wfMsg( "infobox" ) ) . "','" . addslashes(wfMsg("infobox_alert")) . "');\n";
2754 $toolbar.="document.writeln(\"</div>\");\n";
2756 $toolbar.="/*]]>*/\n</script>";
2763 function suppressUrlExpansion() {