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 ( NS_IMAGE
== $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->getViewURL();
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 = preg_replace( '/<[^>]*>/', '', $alt );
1777 $alt = preg_replace('/&(?!:amp;|#[Xx][0-9A-fa-f]+;|#[0-9]+;|[a-zA-Z0-9]+;)/', '&', $alt);
1778 $alt = str_replace( array('<', '>', '"'), array('<', '>', '"'), $alt );
1780 $u = $nt->escapeLocalURL();
1783 $s = wfMsg( 'missingimage', $img->getName() );
1784 $s .= "<br>{$alt}<br>{$url}<br>\n";
1786 $s = '<a href="'.$u.'" class="image" title="'.$alt.'">' .
1787 '<img src="'.$url.'" alt="'.$alt.'" /></a>';
1789 if ( '' != $align ) {
1790 $s = "<div class=\"float{$align}\"><span>{$s}</span></div>";
1792 return str_replace("\n", ' ',$prefix.$s.$postfix);
1796 * Make HTML for a thumbnail including image, border and caption
1797 * $img is an Image object
1799 function makeThumbLinkObj( $img, $label = '', $align = 'right', $boxwidth = 180, $boxheight=false, $framed=false , $manual_thumb = "" ) {
1800 global $wgStylePath, $wgContLang;
1801 # $image = Title::makeTitleSafe( NS_IMAGE, $name );
1802 $url = $img->getViewURL();
1804 #$label = htmlspecialchars( $label );
1805 $alt = preg_replace( '/<[^>]*>/', '', $label);
1806 $alt = preg_replace('/&(?!:amp;|#[Xx][0-9A-fa-f]+;|#[0-9]+;|[a-zA-Z0-9]+;)/', '&', $alt);
1807 $alt = str_replace( array('<', '>', '"'), array('<', '>', '"'), $alt );
1809 $width = $height = 0;
1810 if ( $img->exists() )
1812 $width = $img->getWidth();
1813 $height = $img->getHeight();
1815 if ( 0 == $width ||
0 == $height )
1817 $width = $height = 200;
1819 if ( $boxwidth == 0 )
1825 // Use image dimensions, don't scale
1827 $oboxwidth = $boxwidth +
2;
1828 $boxheight = $height;
1831 $h = intval( $height/($width/$boxwidth) );
1832 $oboxwidth = $boxwidth +
2;
1833 if ( ( ! $boxheight === false ) && ( $h > $boxheight ) )
1835 $boxwidth *= $boxheight/$h;
1839 if ( '' == $manual_thumb ) $thumbUrl = $img->createThumb( $boxwidth );
1842 if ( $manual_thumb != '' ) # Use manually specified thumbnail
1844 $manual_title = Title
::makeTitleSafe( NS_IMAGE
, $manual_thumb ); #new Title ( $manual_thumb ) ;
1845 $manual_img = Image
::newFromTitle( $manual_title );
1846 $thumbUrl = $manual_img->getViewURL();
1847 if ( $manual_img->exists() )
1849 $width = $manual_img->getWidth();
1850 $height = $manual_img->getHeight();
1851 $boxwidth = $width ;
1852 $boxheight = $height ;
1853 $oboxwidth = $boxwidth +
2 ;
1857 $u = $img->getEscapeLocalURL();
1859 $more = htmlspecialchars( wfMsg( 'thumbnail-more' ) );
1860 $magnifyalign = $wgContLang->isRTL() ?
'left' : 'right';
1861 $textalign = $wgContLang->isRTL() ?
' style="text-align:right"' : '';
1863 $s = "<div class=\"thumb t{$align}\"><div style=\"width:{$oboxwidth}px;\">";
1864 if ( $thumbUrl == '' ) {
1865 $s .= wfMsg( 'missingimage', $img->getName() );
1868 $s .= '<a href="'.$u.'" class="internal" title="'.$alt.'">'.
1869 '<img src="'.$thumbUrl.'" alt="'.$alt.'" ' .
1870 'width="'.$boxwidth.'" height="'.$boxheight.'" /></a>';
1874 $zoomicon = '<div class="magnify" style="float:'.$magnifyalign.'">'.
1875 '<a href="'.$u.'" class="internal" title="'.$more.'">'.
1876 '<img src="'.$wgStylePath.'/common/images/magnify-clip.png" ' .
1877 'width="15" height="11" alt="'.$more.'" /></a></div>';
1880 $s .= ' <div class="thumbcaption" '.$textalign.'>'.$zoomicon.$label."</div></div></div>";
1881 return str_replace("\n", ' ', $s);
1884 function makeMediaLink( $name, $url, $alt = '' ) {
1885 $nt = Title
::makeTitleSafe( Namespace::getMedia(), $name );
1886 return $this->makeMediaLinkObj( $nt, $alt );
1889 function makeMediaLinkObj( $nt, $alt = '' ) {
1890 if ( ! isset( $nt ) )
1892 ### HOTFIX. Instead of breaking, return empty string.
1895 $name = $nt->getDBKey();
1896 $url = Image
::wfImageUrl( $name );
1897 if ( empty( $alt ) ) {
1898 $alt = preg_replace( '/\.(.+?)^/', '', $name );
1901 $u = htmlspecialchars( $url );
1902 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
1907 function specialLink( $name, $key = '' ) {
1910 if ( '' == $key ) { $key = strtolower( $name ); }
1911 $pn = $wgContLang->ucfirst( $name );
1912 return $this->makeKnownLink( $wgContLang->specialPage( $pn ),
1916 function makeExternalLink( $url, $text, $escape = true ) {
1917 $style = $this->getExternalLinkAttributes( $url, $text );
1918 $url = htmlspecialchars( $url );
1920 $text = htmlspecialchars( $text );
1922 return '<a href="'.$url.'"'.$style.'>'.$text.'</a>';
1925 # Called by history lists and recent changes
1928 # Returns text for the start of the tabular part of RC
1929 function beginRecentChangesList() {
1930 $this->rc_cache
= array() ;
1931 $this->rcMoveIndex
= 0;
1932 $this->rcCacheIndex
= 0 ;
1933 $this->lastdate
= '';
1934 $this->rclistOpen
= false;
1938 function beginImageHistoryList() {
1939 $s = "\n<h2>" . wfMsg( 'imghistory' ) . "</h2>\n" .
1940 "<p>" . wfMsg( 'imghistlegend' ) . "</p>\n".'<ul class="special">';
1945 * Returns text for the end of RC
1946 * If enhanced RC is in use, returns pretty much all the text
1948 function endRecentChangesList() {
1949 $s = $this->recentChangesBlock() ;
1950 if( $this->rclistOpen
) {
1957 * Enhanced RC ungrouped line
1959 function recentChangesBlockLine ( $rcObj ) {
1960 global $wgStylePath, $wgContLang ;
1962 # Get rc_xxxx variables
1963 extract( $rcObj->mAttribs
) ;
1964 $curIdEq = 'curid='.$rc_cur_id;
1969 $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" border="0" />' ;
1972 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
1973 $r .= ' ';
1975 # M & N (minor & new)
1976 $M = wfMsg( 'minoreditletter' );
1977 $N = wfMsg( 'newpageletter' );
1979 if ( $rc_type == RC_NEW
) {
1992 $r .= ' '.$rcObj->timestamp
.' ' ;
1996 $link = $rcObj->link
;
1997 if ( $rcObj->watched
) $link = '<strong>'.$link.'</strong>' ;
2002 $r .= $rcObj->difflink
;
2006 $r .= $this->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' );
2009 $r .= ') . . '.$rcObj->userlink
;
2010 $r .= $rcObj->usertalklink
;
2013 if ( $rc_comment != '' && $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
2014 $rc_comment=$this->formatComment($rc_comment, $rcObj->getTitle());
2015 $r .= $wgContLang->emphasize( ' ('.$rc_comment.')' );
2025 function recentChangesBlockGroup ( $block ) {
2026 global $wgStylePath, $wgContLang ;
2029 $M = wfMsg( 'minoreditletter' );
2030 $N = wfMsg( 'newpageletter' );
2032 # Collate list of users
2034 $userlinks = array () ;
2035 foreach ( $block AS $rcObj ) {
2036 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
2037 if ( $rcObj->mAttribs
['rc_new'] ) $isnew = true ;
2038 $u = $rcObj->userlink
;
2039 if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
2043 # Sort the list and convert to text
2044 krsort ( $userlinks ) ;
2045 asort ( $userlinks ) ;
2047 foreach ( $userlinks as $userlink => $count) {
2049 if ( $count > 1 ) $text .= " ({$count}×)" ;
2050 array_push ( $users , $text ) ;
2052 $users = ' <font size="-1">['.implode('; ',$users).']</font>' ;
2055 $rci = 'RCI'.$this->rcCacheIndex
;
2056 $rcl = 'RCL'.$this->rcCacheIndex
;
2057 $rcm = 'RCM'.$this->rcCacheIndex
;
2058 $toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')" ;
2059 $arrowdir = $wgContLang->isRTL() ?
'l' : 'r';
2060 $tl = '<span id="'.$rcm.'"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_'.$arrowdir.'.png" width="12" height="12" /></a></span>' ;
2061 $tl .= '<span id="'.$rcl.'" style="display:none"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_d.png" width="12" height="12" /></a></span>' ;
2067 if ( $isnew ) $r .= $N ;
2068 else $r .= ' ' ;
2069 $r .= ' ' ; # Minor
2072 $r .= ' '.$block[0]->timestamp
.' ' ;
2076 $link = $block[0]->link
;
2077 if ( $block[0]->watched
) $link = '<strong>'.$link.'</strong>' ;
2080 $curIdEq = 'curid=' . $block[0]->mAttribs
['rc_cur_id'];
2081 if ( $block[0]->mAttribs
['rc_type'] != RC_LOG
) {
2083 $r .= ' ('.count($block).' ' ;
2084 if ( $isnew ) $r .= wfMsg('changes');
2085 else $r .= $this->makeKnownLinkObj( $block[0]->getTitle() , wfMsg('changes') ,
2086 $curIdEq.'&diff=0&oldid='.$oldid ) ;
2090 $r .= $this->makeKnownLinkObj( $block[0]->getTitle(), wfMsg( 'history' ), $curIdEq.'&action=history' );
2098 $r .= '<div id="'.$rci.'" style="display:none">' ;
2099 foreach ( $block AS $rcObj ) {
2100 # Get rc_xxxx variables
2101 extract( $rcObj->mAttribs
);
2103 $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" />';
2104 $r .= '<tt> ' ;
2105 if ( $rc_new ) $r .= $N ;
2106 else $r .= ' ' ;
2107 if ( $rc_minor ) $r .= $M ;
2108 else $r .= ' ' ;
2112 if ( $rc_last_oldid != 0 ) {
2113 $o = 'oldid='.$rc_last_oldid ;
2115 if ( $rc_type == RC_LOG
) {
2116 $link = $rcObj->timestamp
;
2118 $link = $this->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, "{$curIdEq}&$o" ) ;
2120 $link = '<tt>'.$link.'</tt>' ;
2124 $r .= $rcObj->curlink
;
2126 $r .= $rcObj->lastlink
;
2127 $r .= ') . . '.$rcObj->userlink
;
2128 $r .= $rcObj->usertalklink
;
2129 if ( $rc_comment != '' ) {
2130 $rc_comment=$this->formatComment($rc_comment, $rcObj->getTitle());
2131 $r .= $wgContLang->emphasize( ' ('.$rc_comment.')' ) ;
2137 $this->rcCacheIndex++
;
2142 * If enhanced RC is in use, this function takes the previously cached
2143 * RC lines, arranges them, and outputs the HTML
2145 function recentChangesBlock () {
2146 global $wgStylePath ;
2147 if ( count ( $this->rc_cache
) == 0 ) return '' ;
2149 foreach ( $this->rc_cache
AS $secureName => $block ) {
2150 if ( count ( $block ) < 2 ) {
2151 $blockOut .= $this->recentChangesBlockLine ( array_shift ( $block ) ) ;
2153 $blockOut .= $this->recentChangesBlockGroup ( $block ) ;
2157 return '<div>'.$blockOut.'</div>' ;
2161 * Called in a loop over all displayed RC entries
2162 * Either returns the line, or caches it for later use
2164 function recentChangesLine( &$rc, $watched = false ) {
2166 $usenew = $wgUser->getOption( 'usenewrc' );
2168 $line = $this->recentChangesLineNew ( $rc, $watched ) ;
2170 $line = $this->recentChangesLineOld ( $rc, $watched ) ;
2174 function recentChangesLineOld( &$rc, $watched = false ) {
2175 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds, $wgUseRCPatrol, $wgOnlySysopsCanPatrol;
2177 # Extract DB fields into local scope
2178 extract( $rc->mAttribs
);
2179 $curIdEq = 'curid=' . $rc_cur_id;
2181 # Make date header if necessary
2182 $date = $wgContLang->date( $rc_timestamp, true);
2183 $uidate = $wgLang->date( $rc_timestamp, true);
2185 if ( $date != $this->lastdate
) {
2186 if ( '' != $this->lastdate
) { $s .= "</ul>\n"; }
2187 $s .= "<h4>{$uidate}</h4>\n<ul class='special'>";
2188 $this->lastdate
= $date;
2189 $this->rclistOpen
= true;
2192 # If this edit has not yet been patrolled, make it stick out
2193 $s .= ( ! $wgUseRCPatrol ||
$rc_patrolled ) ?
'<li> ' : '<li class="not_patrolled"> ';
2195 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2197 $s .= '(' . wfMsg( 'diff' ) . ') (';
2199 $s .= $this->makeKnownLinkObj( $rc->getMovedToTitle(), wfMsg( 'hist' ), 'action=history' ) .
2202 # "[[x]] moved to [[y]]"
2203 $msg = ( $rc_type == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
2204 $s .= wfMsg( $msg, $this->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
2205 $this->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
2206 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
2208 $logtype = $matches[1];
2209 $logname = LogPage
::logName( $logtype );
2210 $s .= '(' . $this->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
2213 if ( $rc_type == RC_NEW ||
$rc_type == RC_LOG
) {
2214 $diffLink = wfMsg( 'diff' );
2216 if ( $wgUseRCPatrol && $rc_patrolled == 0 && $wgUser->getID() != 0 &&
2217 ( $wgUser->isSysop() ||
!$wgOnlySysopsCanPatrol ) )
2218 $rcidparam = "&rcid={$rc_id}";
2221 $diffLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'diff' ),
2222 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}{$rcidparam}",
2223 '', '', ' tabindex="'.$rc->counter
.'"');
2225 $s .= '('.$diffLink.') (';
2228 $s .= $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' );
2231 # M and N (minor and new)
2232 if ( $rc_minor ) { $s .= ' <span class="minor">'.wfMsg( "minoreditletter" ).'</span>'; }
2233 if ( $rc_type == RC_NEW
) { $s .= '<span class="newpage">'.wfMsg( "newpageletter" ).'</span>'; }
2236 # If it's a new article, there is no diff link, but if it hasn't been
2237 # patrolled yet, we need to give users a way to do so
2238 if ( $wgUseRCPatrol && $rc_type == RC_NEW
&& $rc_patrolled == 0 &&
2239 $wgUser->getID() != 0 && ( $wgUser->isSysop() ||
!$wgOnlySysopsCanPatrol ) )
2240 $articleLink = $this->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
2242 $articleLink = $this->makeKnownLinkObj( $rc->getTitle(), '' );
2245 $articleLink = '<strong>'.$articleLink.'</strong>';
2247 $s .= ' '.$articleLink;
2252 $s .= '; ' . $wgLang->time( $rc_timestamp, true, $wgRCSeconds ) . ' . . ';
2254 # User link (or contributions for unregistered users)
2255 if ( 0 == $rc_user ) {
2256 $userLink = $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
2257 $rc_user_text, 'target=' . $rc_user_text );
2259 $userLink = $this->makeLink( $wgContLang->getNsText( NS_USER
) . ':'.$rc_user_text, $rc_user_text );
2264 $talkname=$wgContLang->getNsText(NS_TALK
); # use the shorter name
2265 global $wgDisableAnonTalk;
2266 if( 0 == $rc_user && $wgDisableAnonTalk ) {
2269 $utns=$wgContLang->getNsText(NS_USER_TALK
);
2270 $userTalkLink= $this->makeLink($utns . ':'.$rc_user_text, $talkname );
2274 if ( ( 0 == $rc_user ) && $wgUser->isSysop() ) {
2275 $blockLink = $this->makeKnownLink( $wgContLang->specialPage(
2276 'Blockip' ), wfMsg( 'blocklink' ), 'ip='.$rc_user_text );
2280 if($userTalkLink) $userTalkLink .= ' | ';
2281 $userTalkLink .= $blockLink;
2283 if($userTalkLink) $s.=' ('.$userTalkLink.')';
2286 if ( '' != $rc_comment && '*' != $rc_comment && $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
2287 $rc_comment=$this->formatComment($rc_comment,$rc->getTitle());
2288 $s .= $wgContLang->emphasize(' (' . $rc_comment . ')');
2295 function recentChangesLineNew( &$baseRC, $watched = false ) {
2296 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds;
2298 # Create a specialised object
2299 $rc = RCCacheEntry
::newFromParent( $baseRC ) ;
2301 # Extract fields from DB into the function scope (rc_xxxx variables)
2302 extract( $rc->mAttribs
);
2303 $curIdEq = 'curid=' . $rc_cur_id;
2305 # If it's a new day, add the headline and flush the cache
2306 $date = $wgContLang->date( $rc_timestamp, true);
2307 $uidate = $wgLang->date( $rc_timestamp, true);
2309 if ( $date != $this->lastdate
) {
2310 # Process current cache
2311 $ret = $this->recentChangesBlock () ;
2312 $this->rc_cache
= array() ;
2313 $ret .= "<h4>{$uidate}</h4>\n";
2314 $this->lastdate
= $date;
2318 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2319 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
2320 $clink = wfMsg( $msg, $this->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
2321 $this->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
2322 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
2324 $logtype = $matches[1];
2325 $logname = LogPage
::logName( $logtype );
2326 $clink = '(' . $this->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
2328 $clink = $this->makeKnownLinkObj( $rc->getTitle(), '' ) ;
2331 $time = $wgContLang->time( $rc_timestamp, true, $wgRCSeconds );
2332 $rc->watched
= $watched ;
2333 $rc->link
= $clink ;
2334 $rc->timestamp
= $time;
2336 # Make "cur" and "diff" links
2337 if ( ( $rc_type == RC_NEW
&& $rc_this_oldid == 0 ) ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2338 $curLink = wfMsg( 'cur' );
2339 $diffLink = wfMsg( 'diff' );
2341 $query = $curIdEq.'&diff=0&oldid='.$rc_this_oldid;
2342 $aprops = ' tabindex="'.$baseRC->counter
.'"';
2343 $curLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'cur' ), $query, '' ,'' , $aprops );
2344 $diffLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'diff'), $query, '' ,'' , $aprops );
2348 $titleObj = $rc->getTitle();
2349 if ( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2350 $lastLink = wfMsg( 'last' );
2352 $lastLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'last' ),
2353 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid );
2356 # Make user link (or user contributions for unregistered users)
2357 if ( $rc_user == 0 ) {
2358 $userLink = $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
2359 $rc_user_text, 'target=' . $rc_user_text );
2361 $userLink = $this->makeLink( $wgContLang->getNsText(
2362 Namespace::getUser() ) . ':'.$rc_user_text, $rc_user_text );
2365 $rc->userlink
= $userLink;
2366 $rc->lastlink
= $lastLink;
2367 $rc->curlink
= $curLink;
2368 $rc->difflink
= $diffLink;
2370 # Make user talk link
2371 $utns=$wgContLang->getNsText(NS_USER_TALK
);
2372 $talkname=$wgContLang->getNsText(NS_TALK
); # use the shorter name
2373 $userTalkLink= $this->makeLink($utns . ':'.$rc_user_text, $talkname );
2375 global $wgDisableAnonTalk;
2376 if ( ( 0 == $rc_user ) && $wgUser->isSysop() ) {
2377 $blockLink = $this->makeKnownLink( $wgContLang->specialPage(
2378 'Blockip' ), wfMsg( 'blocklink' ), 'ip='.$rc_user_text );
2379 if( $wgDisableAnonTalk )
2380 $rc->usertalklink
= ' ('.$blockLink.')';
2382 $rc->usertalklink
= ' ('.$userTalkLink.' | '.$blockLink.')';
2384 if( $wgDisableAnonTalk && ($rc_user == 0) )
2385 $rc->usertalklink
= '';
2387 $rc->usertalklink
= ' ('.$userTalkLink.')';
2390 # Put accumulated information into the cache, for later display
2391 # Page moves go on their own line
2392 $title = $rc->getTitle();
2393 $secureName = $title->getPrefixedDBkey();
2394 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2395 # Use an @ character to prevent collision with page names
2396 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
2398 if ( !isset ( $this->rc_cache
[$secureName] ) ) $this->rc_cache
[$secureName] = array() ;
2399 array_push ( $this->rc_cache
[$secureName] , $rc ) ;
2404 function endImageHistoryList() {
2410 * This function is called by all recent changes variants, by the page history,
2411 * and by the user contributions list. It is responsible for formatting edit
2412 * comments. It escapes any HTML in the comment, but adds some CSS to format
2413 * auto-generated comments (from section editing) and formats [[wikilinks]].
2415 * The &$title parameter must be a title OBJECT. It is used to generate a
2416 * direct link to the section in the autocomment.
2417 * @author Erik Moeller <moeller@scireview.de>
2419 * Note: there's not always a title to pass to this function.
2420 * Since you can't set a default parameter for a reference, I've turned it
2421 * temporarily to a value pass. Should be adjusted further. --brion
2423 function formatComment($comment, $title = NULL) {
2425 $comment = htmlspecialchars( $comment );
2427 # The pattern for autogen comments is / * foo * /, which makes for
2429 # We look for all comments, match any text before and after the comment,
2430 # add a separator where needed and format the comment itself with CSS
2431 while (preg_match('/(.*)\/\*\s*(.*?)\s*\*\/(.*)/', $comment,$match)) {
2439 # This is hackish but should work in most cases.
2440 $section=str_replace('[[','',$section);
2441 $section=str_replace(']]','',$section);
2442 $title->mFragment
=$section;
2443 $link=$this->makeKnownLinkObj($title,wfMsg('sectionlink'));
2447 if($pre) { $auto = $sep.' '.$auto; }
2448 if($post) { $auto .= ' '.$sep; }
2449 $auto='<span class="autocomment">'.$auto.'</span>';
2450 $comment=$pre.$auto.$post;
2453 # format regular and media links - all other wiki formatting
2455 $medians = $wgContLang->getNsText(Namespace::getMedia()).':';
2456 while(preg_match('/\[\[(.*?)(\|(.*?))*\]\](.*)$/',$comment,$match)) {
2457 # Handle link renaming [[foo|text]] will show link as "text"
2458 if( "" != $match[3] ) {
2463 if( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) {
2464 # Media link; trail not supported.
2465 $linkRegexp = '/\[\[(.*?)\]\]/';
2466 $thelink = $this->makeMediaLink( $submatch[1], "", $text );
2468 # Other kind of link
2469 if( preg_match( wfMsgForContent( "linktrail" ), $match[4], $submatch ) ) {
2470 $trail = $submatch[1];
2474 $linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/';
2475 if ($match[1][0] == ':')
2476 $match[1] = substr($match[1], 1);
2477 $thelink = $this->makeLink( $match[1], $text, "", $trail );
2479 $comment = preg_replace( $linkRegexp, $thelink, $comment, 1 );
2484 function imageHistoryLine( $iscur, $timestamp, $img, $user, $usertext, $size, $description ) {
2485 global $wgUser, $wgLang, $wgContLang, $wgTitle;
2487 $datetime = $wgLang->timeanddate( $timestamp, true );
2488 $del = wfMsg( 'deleteimg' );
2489 $delall = wfMsg( 'deleteimgcompletely' );
2490 $cur = wfMsg( 'cur' );
2493 $url = Image
::wfImageUrl( $img );
2495 if ( $wgUser->isSysop() ) {
2496 $link = $wgTitle->escapeLocalURL( 'image=' . $wgTitle->getPartialURL() .
2498 $style = $this->getInternalLinkAttributes( $link, $delall );
2500 $dlink = '<a href="'.$link.'"'.$style.'>'.$delall.'</a>';
2505 $url = htmlspecialchars( wfImageArchiveUrl( $img ) );
2506 if( $wgUser->getID() != 0 && $wgTitle->userCanEdit() ) {
2507 $rlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
2508 wfMsg( 'revertimg' ), 'action=revert&oldimage=' .
2509 urlencode( $img ) );
2510 $dlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
2511 $del, 'action=delete&oldimage=' . urlencode( $img ) );
2513 # Having live active links for non-logged in users
2514 # means that bots and spiders crawling our site can
2515 # inadvertently change content. Baaaad idea.
2516 $rlink = wfMsg( 'revertimg' );
2521 $userlink = $usertext;
2523 $userlink = $this->makeLink( $wgContLang->getNsText( Namespace::getUser() ) .
2524 ':'.$usertext, $usertext );
2526 $nbytes = wfMsg( 'nbytes', $size );
2527 $style = $this->getInternalLinkAttributes( $url, $datetime );
2529 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$datetime}</a>"
2530 . " . . {$userlink} ({$nbytes})";
2532 if ( '' != $description && '*' != $description ) {
2533 $sk=$wgUser->getSkin();
2534 $s .= $wgContLang->emphasize(' (' . $sk->formatComment($description,$wgTitle) . ')');
2540 function tocIndent($level) {
2541 return str_repeat( '<div class="tocindent">'."\n", $level>0 ?
$level : 0 );
2544 function tocUnindent($level) {
2545 return str_repeat( "</div>\n", $level>0 ?
$level : 0 );
2549 * parameter level defines if we are on an indentation level
2551 function tocLine( $anchor, $tocline, $level ) {
2552 $link = '<a href="#'.$anchor.'">'.$tocline.'</a><br />';
2556 return '<div class="tocline">'.$link."</div>\n";
2561 function tocTable($toc) {
2562 # note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
2563 # try min-width & co when somebody gets a chance
2564 $hideline = ' <script type="text/javascript">showTocToggle("' . addslashes( wfMsg('showtoc') ) . '","' . addslashes( wfMsg('hidetoc') ) . '")</script>';
2566 '<table border="0" id="toc"><tr id="toctitle"><td align="center">'."\n".
2567 '<b>'.wfMsg('toc').'</b>' .
2569 '</td></tr><tr id="tocinside"><td>'."\n".
2570 $toc."</td></tr></table>\n";
2574 * These two do not check for permissions: check $wgTitle->userCanEdit
2575 * before calling them
2577 function editSectionScriptForOther( $title, $section, $head ) {
2578 $ttl = Title
::newFromText( $title );
2579 $url = $ttl->escapeLocalURL( 'action=edit§ion='.$section );
2580 return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
2583 function editSectionScript( $section, $head ) {
2584 global $wgTitle, $wgRequest;
2585 if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
2588 $url = $wgTitle->escapeLocalURL( 'action=edit§ion='.$section );
2589 return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
2592 function editSectionLinkForOther( $title, $section ) {
2594 global $wgUser, $wgContLang;
2596 $title = Title
::newFromText($title);
2597 $editurl = '§ion='.$section;
2598 $url = $this->makeKnownLink($title->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
2600 if( $wgContLang->isRTL() ) {
2602 $nearside = 'right';
2607 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
2611 function editSectionLink( $section ) {
2613 global $wgTitle, $wgUser, $wgContLang;
2615 if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
2616 # Section edit links would be out of sync on an old page.
2617 # But, if we're diffing to the current page, they'll be
2622 $editurl = '§ion='.$section;
2623 $url = $this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
2625 if( $wgContLang->isRTL() ) {
2627 $nearside = 'right';
2632 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
2637 * This function is called by EditPage.php and shows a bulletin board style
2638 * toolbar for common editing functions. It can be disabled in the user
2640 * The necessary JavaScript code can be found in style/wikibits.js.
2642 function getEditToolbar() {
2643 global $wgStylePath, $wgLang, $wgMimeType;
2646 * toolarray an array of arrays which each include the filename of
2647 * the button image (without path), the opening tag, the closing tag,
2648 * and optionally a sample text that is inserted between the two when no
2649 * selection is highlighted.
2650 * The tip text is shown when the user moves the mouse over the button.
2652 * Already here are accesskeys (key), which are not used yet until someone
2653 * can figure out a way to make them work in IE. However, we should make
2654 * sure these keys are not defined on the edit page.
2657 array( 'image'=>'button_bold.png',
2659 'close' => "\'\'\'",
2660 'sample'=> wfMsg('bold_sample'),
2661 'tip' => wfMsg('bold_tip'),
2664 array( 'image'=>'button_italic.png',
2667 'sample'=> wfMsg('italic_sample'),
2668 'tip' => wfMsg('italic_tip'),
2671 array( 'image'=>'button_link.png',
2674 'sample'=> wfMsg('link_sample'),
2675 'tip' => wfMsg('link_tip'),
2678 array( 'image'=>'button_extlink.png',
2681 'sample'=> wfMsg('extlink_sample'),
2682 'tip' => wfMsg('extlink_tip'),
2685 array( 'image'=>'button_headline.png',
2687 'close' => " ==\\n",
2688 'sample'=> wfMsg('headline_sample'),
2689 'tip' => wfMsg('headline_tip'),
2692 array( 'image'=>'button_image.png',
2693 'open' => '[['.$wgLang->getNsText(NS_IMAGE
).":",
2695 'sample'=> wfMsg('image_sample'),
2696 'tip' => wfMsg('image_tip'),
2699 array( 'image' => 'button_media.png',
2700 'open' => '[['.$wgLang->getNsText(NS_MEDIA
).':',
2702 'sample'=> wfMsg('media_sample'),
2703 'tip' => wfMsg('media_tip'),
2706 array( 'image' => 'button_math.png',
2707 'open' => "\\<math\\>",
2708 'close' => "\\</math\\>",
2709 'sample'=> wfMsg('math_sample'),
2710 'tip' => wfMsg('math_tip'),
2713 array( 'image' => 'button_nowiki.png',
2714 'open' => "\\<nowiki\\>",
2715 'close' => "\\</nowiki\\>",
2716 'sample'=> wfMsg('nowiki_sample'),
2717 'tip' => wfMsg('nowiki_tip'),
2720 array( 'image' => 'button_sig.png',
2724 'tip' => wfMsg('sig_tip'),
2727 array( 'image' => 'button_hr.png',
2728 'open' => "\\n----\\n",
2731 'tip' => wfMsg('hr_tip'),
2735 $toolbar ="<script type='text/javascript'>\n/*<![CDATA[*/\n";
2737 $toolbar.="document.writeln(\"<div id='toolbar'>\");\n";
2738 foreach($toolarray as $tool) {
2740 $image=$wgStylePath.'/common/images/'.$tool['image'];
2741 $open=$tool['open'];
2742 $close=$tool['close'];
2743 $sample = addslashes( $tool['sample'] );
2745 // Note that we use the tip both for the ALT tag and the TITLE tag of the image.
2746 // Older browsers show a "speedtip" type message only for ALT.
2747 // Ideally these should be different, realistically they
2748 // probably don't need to be.
2749 $tip = addslashes( $tool['tip'] );
2751 #$key = $tool["key"];
2753 $toolbar.="addButton('$image','$tip','$open','$close','$sample');\n";
2756 $toolbar.="addInfobox('" . addslashes( wfMsg( "infobox" ) ) . "','" . addslashes(wfMsg("infobox_alert")) . "');\n";
2757 $toolbar.="document.writeln(\"</div>\");\n";
2759 $toolbar.="/*]]>*/\n</script>";
2766 function suppressUrlExpansion() {