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 $s .= $this->disclaimerLink(); # may be empty
549 if ( $wgOut->isArticleRelated() ) {
550 if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
551 $name = $wgTitle->getDBkey();
552 $link = htmlspecialchars( Image
::wfImageUrl( $name ) );
553 $style = $this->getInternalLinkAttributes( $link, $name );
554 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
556 # This will show the "Approve" link if $wgUseApproval=true;
557 if ( isset ( $wgUseApproval ) && $wgUseApproval )
559 $t = $wgTitle->getDBkey();
560 $name = 'Approve this article' ;
561 $link = "http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ;
562 #htmlspecialchars( wfImageUrl( $name ) );
563 $style = $this->getExternalLinkAttributes( $link, $name );
564 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>" ;
567 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
568 $s .= ' | ' . $this->makeKnownLink( $wgTitle->getPrefixedText(),
569 wfMsg( 'currentrev' ) );
572 if ( $wgUser->getNewtalk() ) {
573 # do not show "You have new messages" text when we are viewing our
576 if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
577 $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
578 $n =$wgUser->getName();
579 $tl = $this->makeKnownLink( $wgContLang->getNsText(
580 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
581 wfMsg('newmessageslink') );
582 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
584 $wgOut->setSquidMaxage(0);
588 $undelete = $this->getUndeleteLink();
589 if( !empty( $undelete ) ) {
590 $s .= ' | '.$undelete;
595 function getUndeleteLink() {
596 global $wgUser, $wgTitle, $wgContLang, $action;
597 if( $wgUser->isSysop() &&
598 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
599 ($n = $wgTitle->isDeleted() ) ) {
600 return wfMsg( 'thisisdeleted',
601 $this->makeKnownLink(
602 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
603 wfMsg( 'restorelink', $n ) ) );
608 function printableLink() {
609 global $wgOut, $wgFeedClasses, $wgRequest;
611 $baseurl = $_SERVER['REQUEST_URI'];
612 if( strpos( '?', $baseurl ) == false ) {
617 $baseurl = htmlspecialchars( $baseurl );
618 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
620 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
621 if( $wgOut->isSyndicated() ) {
622 foreach( $wgFeedClasses as $format => $class ) {
623 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
624 $s .= " | <a href=\"$feedurl\">{$format}</a>";
630 function pageTitle() {
631 global $wgOut, $wgTitle, $wgUser;
633 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
634 if($wgUser->getOption( 'editsectiononrightclick' ) && $wgTitle->userCanEdit()) { $s=$this->editSectionScript(0,$s);}
638 function pageSubtitle() {
641 $sub = $wgOut->getSubtitle();
643 global $wgExtraSubtitle;
644 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
646 $subpages = $this->subPageSubtitle();
647 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
648 $s = "<p class='subtitle'>{$sub}</p>\n";
652 function subPageSubtitle() {
653 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
655 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
656 $ptext=$wgTitle->getPrefixedText();
657 if(preg_match('/\//',$ptext)) {
658 $links = explode('/',$ptext);
661 foreach($links as $link) {
663 if ($c<count($links)) {
664 $growinglink .= $link;
665 $getlink = $this->makeLink( $growinglink, $link );
666 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
670 $subpages .= '< ';
672 $subpages .= $getlink;
681 function nameAndLogin() {
682 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader, $wgIP;
684 $li = $wgContLang->specialPage( 'Userlogin' );
685 $lo = $wgContLang->specialPage( 'Userlogout' );
688 if ( 0 == $wgUser->getID() ) {
689 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
692 $tl = $this->makeKnownLink( $wgContLang->getNsText(
693 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
694 $wgContLang->getNsText( Namespace::getTalk( 0 ) ) );
696 $s .= $n . ' ('.$tl.')';
698 $s .= wfMsg('notloggedin');
701 $rt = $wgTitle->getPrefixedURL();
702 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
704 } else { $q = "returnto={$rt}"; }
706 $s .= "\n<br />" . $this->makeKnownLink( $li,
707 wfMsg( 'login' ), $q );
709 $n = $wgUser->getName();
710 $rt = $wgTitle->getPrefixedURL();
711 $tl = $this->makeKnownLink( $wgContLang->getNsText(
712 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
713 $wgContLang->getNsText( Namespace::getTalk( 0 ) ) );
717 $s .= $this->makeKnownLink( $wgContLang->getNsText(
718 Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}<br />" .
719 $this->makeKnownLink( $lo, wfMsg( 'logout' ),
720 "returnto={$rt}" ) . ' | ' .
721 $this->specialLink( 'preferences' );
723 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
729 function getSearchLink() {
730 $searchPage =& Title
::makeTitle( NS_SPECIAL
, 'Search' );
731 return $searchPage->getLocalURL();
734 function escapeSearchLink() {
735 return htmlspecialchars( $this->getSearchLink() );
738 function searchForm() {
740 $search = $wgRequest->getText( 'search' );
742 $s = '<form name="search" class="inline" method="post" action="'
743 . $this->escapeSearchLink() . "\">\n"
744 . '<input type="text" name="search" size="19" value="'
745 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
746 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
747 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
752 function topLinks() {
756 $s = $this->mainPageLink() . $sep
757 . $this->specialLink( 'recentchanges' );
759 if ( $wgOut->isArticleRelated() ) {
760 $s .= $sep . $this->editThisPage()
761 . $sep . $this->historyLink();
763 # Many people don't like this dropdown box
764 #$s .= $sep . $this->specialPagesList();
769 function bottomLinks() {
770 global $wgOut, $wgUser, $wgTitle;
774 if ( $wgOut->isArticleRelated() ) {
775 $s .= '<strong>' . $this->editThisPage() . '</strong>';
776 if ( 0 != $wgUser->getID() ) {
777 $s .= $sep . $this->watchThisPage();
779 $s .= $sep . $this->talkLink()
780 . $sep . $this->historyLink()
781 . $sep . $this->whatLinksHere()
782 . $sep . $this->watchPageLinksLink();
784 if ( $wgTitle->getNamespace() == Namespace::getUser()
785 ||
$wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) )
788 $id=User
::idFromName($wgTitle->getText());
789 $ip=User
::isIP($wgTitle->getText());
791 if($id ||
$ip) { # both anons and non-anons have contri list
792 $s .= $sep . $this->userContribsLink();
794 if ( 0 != $wgUser->getID() ) { # show only to signed in users
795 if($id) { # can only email non-anons
796 $s .= $sep . $this->emailUserLink();
800 if ( $wgUser->isSysop() && $wgTitle->getArticleId() ) {
801 $s .= "\n<br />" . $this->deleteThisPage() .
802 $sep . $this->protectThisPage() .
803 $sep . $this->moveThisPage();
805 $s .= "<br />\n" . $this->otherLanguages();
810 function pageStats() {
811 global $wgOut, $wgLang, $wgArticle, $wgRequest;
812 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax;
814 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
815 if ( ! $wgOut->isArticle() ) { return ''; }
816 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
817 if ( 0 == $wgArticle->getID() ) { return ''; }
820 if ( !$wgDisableCounters ) {
821 $count = $wgLang->formatNum( $wgArticle->getCount() );
823 $s = wfMsg( 'viewcount', $count );
827 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
828 require_once("Credits.php");
829 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
831 $s .= $this->lastModified();
834 return $s . ' ' . $this->getCopyright();
837 function getCopyright() {
838 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
841 $oldid = $wgRequest->getVal( 'oldid' );
842 $diff = $wgRequest->getVal( 'diff' );
844 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
845 $msg = 'history_copyright';
851 if( $wgRightsPage ) {
852 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
853 } elseif( $wgRightsUrl ) {
854 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
859 $out .= wfMsgForContent( $msg, $link );
863 function getCopyrightIcon() {
864 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon;
866 if( $wgRightsIcon ) {
867 $icon = htmlspecialchars( $wgRightsIcon );
869 $url = htmlspecialchars( $wgRightsUrl );
870 $out .= '<a href="'.$url.'">';
872 $text = htmlspecialchars( $wgRightsText );
873 $out .= "<img src=\"$icon\" alt='$text' />";
881 function getPoweredBy() {
883 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
884 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
888 function lastModified() {
889 global $wgLang, $wgArticle;
891 $timestamp = $wgArticle->getTimestamp();
893 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
894 $s = ' ' . wfMsg( 'lastmodified', $d );
901 function logoText( $align = '' ) {
902 if ( '' != $align ) { $a = " align='{$align}'"; }
905 $mp = wfMsg( 'mainpage' );
906 $titleObj = Title
::newFromText( $mp );
907 if ( is_object( $titleObj ) ) {
908 $url = $titleObj->escapeLocalURL();
913 $logourl = $this->getLogo();
914 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
918 function specialPagesList() {
919 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript;
920 require_once('SpecialPage.php');
922 $pages = SpecialPage
::getPages();
924 foreach ( $pages[''] as $name => $page ) {
925 $a[$name] = $page->getDescription();
927 if ( $wgUser->isSysop() )
929 foreach ( $pages['sysop'] as $name => $page ) {
930 $a[$name] = $page->getDescription();
933 if ( $wgUser->isDeveloper() )
935 foreach ( $pages['developer'] as $name => $page ) {
936 $a[$name] = $page->getDescription() ;
940 $sp = wfMsg( 'specialpages' );
941 $spp = $wgContLang->specialPage( 'Specialpages' );
943 $s = '<form id="specialpages" method="get" class="inline" ' .
944 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
945 $s .= "<select name=\"wpDropdown\">\n";
946 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
948 foreach ( $a as $name => $desc ) {
949 $p = $wgContLang->specialPage( $name );
950 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
953 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
958 function mainPageLink() {
959 $mp = wfMsgForContent( 'mainpage' );
960 $mptxt = wfMsg( 'mainpage');
961 $s = $this->makeKnownLink( $mp, $mptxt );
965 function copyrightLink() {
966 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
967 wfMsg( 'copyrightpagename' ) );
971 function aboutLink() {
972 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
973 wfMsg( 'aboutsite' ) );
978 function disclaimerLink() {
979 $disclaimers = wfMsg( 'disclaimers' );
980 if ($disclaimers == '-') {
983 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
988 function editThisPage() {
989 global $wgOut, $wgTitle, $wgRequest;
991 $oldid = $wgRequest->getVal( 'oldid' );
992 $diff = $wgRequest->getVal( 'diff' );
993 $redirect = $wgRequest->getVal( 'redirect' );
995 if ( ! $wgOut->isArticleRelated() ) {
996 $s = wfMsg( 'protectedpage' );
998 $n = $wgTitle->getPrefixedText();
999 if ( $wgTitle->userCanEdit() ) {
1000 $t = wfMsg( 'editthispage' );
1002 #$t = wfMsg( "protectedpage" );
1003 $t = wfMsg( 'viewsource' );
1007 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
1008 if ( $oldid && ! isset( $diff ) ) {
1009 $oid = '&oldid='.$oldid;
1011 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
1016 function deleteThisPage() {
1017 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1019 $diff = $wgRequest->getVal( 'diff' );
1020 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
1021 $n = $wgTitle->getPrefixedText();
1022 $t = wfMsg( 'deletethispage' );
1024 $s = $this->makeKnownLink( $n, $t, 'action=delete' );
1031 function protectThisPage() {
1032 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1034 $diff = $wgRequest->getVal( 'diff' );
1035 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
1036 $n = $wgTitle->getPrefixedText();
1038 if ( $wgTitle->isProtected() ) {
1039 $t = wfMsg( 'unprotectthispage' );
1040 $q = 'action=unprotect';
1042 $t = wfMsg( 'protectthispage' );
1043 $q = 'action=protect';
1045 $s = $this->makeKnownLink( $n, $t, $q );
1052 function watchThisPage() {
1053 global $wgUser, $wgOut, $wgTitle;
1055 if ( $wgOut->isArticleRelated() ) {
1056 $n = $wgTitle->getPrefixedText();
1058 if ( $wgTitle->userIsWatching() ) {
1059 $t = wfMsg( 'unwatchthispage' );
1060 $q = 'action=unwatch';
1062 $t = wfMsg( 'watchthispage' );
1063 $q = 'action=watch';
1065 $s = $this->makeKnownLink( $n, $t, $q );
1067 $s = wfMsg( 'notanarticle' );
1072 function moveThisPage() {
1073 global $wgTitle, $wgContLang;
1075 if ( $wgTitle->userCanEdit() ) {
1076 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Movepage' ),
1077 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1078 } // no message if page is protected - would be redundant
1082 function historyLink() {
1085 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1086 wfMsg( 'history' ), 'action=history' );
1090 function whatLinksHere() {
1091 global $wgTitle, $wgContLang;
1093 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Whatlinkshere' ),
1094 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1098 function userContribsLink() {
1099 global $wgTitle, $wgContLang;
1101 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
1102 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1106 function emailUserLink() {
1107 global $wgTitle, $wgContLang;
1109 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Emailuser' ),
1110 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1114 function watchPageLinksLink() {
1115 global $wgOut, $wgTitle, $wgContLang;
1117 if ( ! $wgOut->isArticleRelated() ) {
1118 $s = '(' . wfMsg( 'notanarticle' ) . ')';
1120 $s = $this->makeKnownLink( $wgContLang->specialPage(
1121 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1122 'target=' . $wgTitle->getPrefixedURL() );
1127 function otherLanguages() {
1128 global $wgOut, $wgContLang, $wgTitle, $wgUseNewInterlanguage;
1130 $a = $wgOut->getLanguageLinks();
1131 if ( 0 == count( $a ) ) {
1132 if ( !$wgUseNewInterlanguage ) return '';
1133 $ns = $wgContLang->getNsIndex ( $wgTitle->getNamespace () ) ;
1134 if ( $ns != 0 AND $ns != 1 ) return '' ;
1136 $x = 'mode=addlink&xt='.$wgTitle->getDBkey() ;
1137 return $this->makeKnownLink( $wgContLang->specialPage( $pn ),
1138 wfMsg( 'intl' ) , $x );
1141 if ( !$wgUseNewInterlanguage ) {
1142 $s = wfMsg( 'otherlanguages' ) . ': ';
1144 global $wgContLanguageCode ;
1145 $x = 'mode=zoom&xt='.$wgTitle->getDBkey() ;
1146 $x .= '&xl='.$wgContLanguageCode ;
1147 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Intl' ),
1148 wfMsg( 'otherlanguages' ) , $x ) . ': ' ;
1151 $s = wfMsg( 'otherlanguages' ) . ': ';
1153 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1154 foreach( $a as $l ) {
1155 if ( ! $first ) { $s .= ' | '; }
1158 $nt = Title
::newFromText( $l );
1159 $url = $nt->getFullURL();
1160 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1162 if ( '' == $text ) { $text = $l; }
1163 $style = $this->getExternalLinkAttributes( $l, $text );
1164 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1166 if($wgContLang->isRTL()) $s .= '</span>';
1170 function bugReportsLink() {
1171 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1172 wfMsg( 'bugreports' ) );
1176 function dateLink() {
1177 global $wgLinkCache;
1178 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1179 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1181 $wgLinkCache->suspend();
1182 $id = $t1->getArticleID();
1183 $wgLinkCache->resume();
1186 $s = $this->makeBrokenLink( $t1->getText() );
1188 $s = $this->makeKnownLink( $t1->getText() );
1192 $wgLinkCache->suspend();
1193 $id = $t2->getArticleID();
1194 $wgLinkCache->resume();
1197 $s .= $this->makeBrokenLink( $t2->getText() );
1199 $s .= $this->makeKnownLink( $t2->getText() );
1204 function talkLink() {
1205 global $wgContLang, $wgTitle, $wgLinkCache;
1207 $tns = $wgTitle->getNamespace();
1208 if ( -1 == $tns ) { return ''; }
1210 $pn = $wgTitle->getText();
1211 $tp = wfMsg( 'talkpage' );
1212 if ( Namespace::isTalk( $tns ) ) {
1213 $lns = Namespace::getSubject( $tns );
1216 $text = wfMsg('articlepage');
1219 $text = wfMsg('userpage');
1222 $text = wfMsg('wikipediapage');
1225 $text = wfMsg('imagepage');
1228 $text= wfMsg('articlepage');
1232 $lns = Namespace::getTalk( $tns );
1235 $n = $wgContLang->getNsText( $lns );
1236 if ( '' == $n ) { $link = $pn; }
1237 else { $link = $n.':'.$pn; }
1239 $wgLinkCache->suspend();
1240 $s = $this->makeLink( $link, $text );
1241 $wgLinkCache->resume();
1246 function commentLink() {
1247 global $wgContLang, $wgTitle, $wgLinkCache;
1249 $tns = $wgTitle->getNamespace();
1250 if ( -1 == $tns ) { return ''; }
1252 $lns = ( Namespace::isTalk( $tns ) ) ?
$tns : Namespace::getTalk( $tns );
1254 # assert Namespace::isTalk( $lns )
1256 $n = $wgContLang->getNsText( $lns );
1257 $pn = $wgTitle->getText();
1261 $wgLinkCache->suspend();
1262 $s = $this->makeKnownLink($link, wfMsg('postcomment'), 'action=edit§ion=new');
1263 $wgLinkCache->resume();
1269 * After all the page content is transformed into HTML, it makes
1270 * a final pass through here for things like table backgrounds.
1271 * @todo probably deprecated [AV]
1273 function transformContent( $text ) {
1278 * Note: This function MUST call getArticleID() on the link,
1279 * otherwise the cache won't get updated properly. See LINKCACHE.DOC.
1281 function makeLink( $title, $text = '', $query = '', $trail = '' ) {
1282 wfProfileIn( 'Skin::makeLink' );
1283 $nt = Title
::newFromText( $title );
1285 $result = $this->makeLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1287 wfDebug( 'Invalid title passed to Skin::makeLink(): "'.$title."\"\n" );
1288 $result = $text == "" ?
$title : $text;
1291 wfProfileOut( 'Skin::makeLink' );
1295 function makeKnownLink( $title, $text = '', $query = '', $trail = '', $prefix = '',$aprops = '') {
1296 $nt = Title
::newFromText( $title );
1298 return $this->makeKnownLinkObj( Title
::newFromText( $title ), $text, $query, $trail, $prefix , $aprops );
1300 wfDebug( 'Invalid title passed to Skin::makeKnownLink(): "'.$title."\"\n" );
1301 return $text == '' ?
$title : $text;
1305 function makeBrokenLink( $title, $text = '', $query = '', $trail = '' ) {
1306 $nt = Title
::newFromText( $title );
1308 return $this->makeBrokenLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1310 wfDebug( 'Invalid title passed to Skin::makeBrokenLink(): "'.$title."\"\n" );
1311 return $text == '' ?
$title : $text;
1315 function makeStubLink( $title, $text = '', $query = '', $trail = '' ) {
1316 $nt = Title
::newFromText( $title );
1318 return $this->makeStubLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1320 wfDebug( 'Invalid title passed to Skin::makeStubLink(): "'.$title."\"\n" );
1321 return $text == '' ?
$title : $text;
1326 * Pass a title object, not a title string
1328 function makeLinkObj( &$nt, $text= '', $query = '', $trail = '', $prefix = '' ) {
1329 global $wgOut, $wgUser, $wgLinkHolders;
1330 $fname = 'Skin::makeLinkObj';
1333 if ( ! isset($nt) ) {
1334 # wfDebugDieBacktrace();
1335 return "<!-- ERROR -->{$prefix}{$text}{$trail}";
1338 if ( $nt->isExternal() ) {
1339 $u = $nt->getFullURL();
1340 $link = $nt->getPrefixedURL();
1341 if ( '' == $text ) { $text = $nt->getPrefixedText(); }
1342 $style = $this->getExternalLinkAttributes( $link, $text, 'extiw' );
1345 if ( '' != $trail ) {
1346 if ( preg_match( '/^([a-z]+)(.*)$$/sD', $trail, $m ) ) {
1351 # Assume $this->postParseLinkColour(). This prevents
1352 # interwiki links from being parsed as external links.
1353 global $wgInterwikiLinkHolders;
1354 $t = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>";
1355 $nr = array_push($wgInterwikiLinkHolders, $t);
1356 $retVal = '<!--IWLINK '. ($nr-1) ."-->{$trail}";
1357 } elseif ( 0 == $nt->getNamespace() && "" == $nt->getText() ) {
1358 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1359 } elseif ( ( -1 == $nt->getNamespace() ) ||
1360 ( NS_IMAGE
== $nt->getNamespace() ) ) {
1361 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1363 if ( $this->postParseLinkColour() ) {
1365 if ( '' != $trail ) {
1366 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1372 # Allows wiki to bypass using linkcache, see OutputPage::parseLinkHolders()
1373 $nr = array_push( $wgLinkHolders['namespaces'], $nt->getNamespace() );
1374 $wgLinkHolders['dbkeys'][] = $nt->getDBkey();
1375 $wgLinkHolders['queries'][] = $query;
1376 $wgLinkHolders['texts'][] = $prefix.$text.$inside;
1377 $wgLinkHolders['titles'][] = $nt;
1379 $retVal = '<!--LINK '. ($nr-1) ."-->{$trail}";
1381 # Work out link colour immediately
1382 $aid = $nt->getArticleID() ;
1384 $retVal = $this->makeBrokenLinkObj( $nt, $text, $query, $trail, $prefix );
1386 $threshold = $wgUser->getOption('stubthreshold') ;
1387 if ( $threshold > 0 ) {
1388 $dbr =& wfGetDB( DB_SLAVE
);
1389 $s = $dbr->selectRow( 'cur', array( 'LENGTH(cur_text) AS x', 'cur_namespace',
1390 'cur_is_redirect' ), array( 'cur_id' => $aid ), $fname ) ;
1391 if ( $s !== false ) {
1393 if ( $s->cur_is_redirect
OR $s->cur_namespace
!= 0 ) {
1394 $size = $threshold*2 ; # Really big
1396 $dbr->freeResult( $res );
1398 $size = $threshold*2 ; # Really big
1403 if ( $size < $threshold ) {
1404 $retVal = $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix );
1406 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1415 * Pass a title object, not a title string
1417 function makeKnownLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '' ) {
1418 global $wgOut, $wgTitle, $wgInputEncoding;
1420 $fname = 'Skin::makeKnownLinkObj';
1421 wfProfileIn( $fname );
1423 if ( !is_object( $nt ) ) {
1426 $link = $nt->getPrefixedURL();
1427 # if ( '' != $section && substr($section,0,1) != "#" ) {
1430 if ( '' == $link ) {
1432 if ( '' == $text ) {
1433 $text = htmlspecialchars( $nt->getFragment() );
1436 $u = $nt->escapeLocalURL( $query );
1438 if ( '' != $nt->getFragment() ) {
1439 $anchor = urlencode( do_html_entity_decode( str_replace(' ', '_', $nt->getFragment()), ENT_COMPAT
, $wgInputEncoding ) );
1440 $replacearray = array(
1444 $u .= '#' . str_replace(array_keys($replacearray),array_values($replacearray),$anchor);
1446 if ( '' == $text ) {
1447 $text = htmlspecialchars( $nt->getPrefixedText() );
1449 $style = $this->getInternalLinkAttributesObj( $nt, $text );
1452 if ( '' != $trail ) {
1453 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1458 $r = "<a href=\"{$u}\"{$style}{$aprops}>{$prefix}{$text}{$inside}</a>{$trail}";
1459 wfProfileOut( $fname );
1464 * Pass a title object, not a title string
1466 function makeBrokenLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
1467 global $wgOut, $wgUser;
1470 if ( ! isset($nt) ) {
1471 # wfDebugDieBacktrace();
1472 return "<!-- ERROR -->{$prefix}{$text}{$trail}";
1475 $fname = 'Skin::makeBrokenLinkObj';
1476 wfProfileIn( $fname );
1478 if ( '' == $query ) {
1481 $q = 'action=edit&'.$query;
1483 $u = $nt->escapeLocalURL( $q );
1485 if ( '' == $text ) {
1486 $text = htmlspecialchars( $nt->getPrefixedText() );
1488 $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" );
1491 if ( '' != $trail ) {
1492 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1497 if ( $wgUser->getOption( 'highlightbroken' ) ) {
1498 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
1500 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
1503 wfProfileOut( $fname );
1508 * Pass a title object, not a title string
1510 function makeStubLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
1511 global $wgOut, $wgUser;
1513 $link = $nt->getPrefixedURL();
1515 $u = $nt->escapeLocalURL( $query );
1517 if ( '' == $text ) {
1518 $text = htmlspecialchars( $nt->getPrefixedText() );
1520 $style = $this->getInternalLinkAttributesObj( $nt, $text, 'stub' );
1523 if ( '' != $trail ) {
1524 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1529 if ( $wgUser->getOption( 'highlightbroken' ) ) {
1530 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
1532 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
1537 function makeSelfLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
1538 $u = $nt->escapeLocalURL( $query );
1539 if ( '' == $text ) {
1540 $text = htmlspecialchars( $nt->getPrefixedText() );
1543 if ( '' != $trail ) {
1544 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1549 return "<strong>{$prefix}{$text}{$inside}</strong>{$trail}";
1552 /* these are used extensively in SkinPHPTal, but also some other places */
1553 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1554 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1555 $this->checkTitle($title, $name);
1556 return $title->getLocalURL( $urlaction );
1558 /*static*/ function makeTalkUrl ( $name, $urlaction='' ) {
1559 $title = Title
::newFromText( $name );
1560 $title = $title->getTalkPage();
1561 $this->checkTitle($title, $name);
1562 return $title->getLocalURL( $urlaction );
1564 /*static*/ function makeArticleUrl ( $name, $urlaction='' ) {
1565 $title = Title
::newFromText( $name );
1566 $title= $title->getSubjectPage();
1567 $this->checkTitle($title, $name);
1568 return $title->getLocalURL( $urlaction );
1570 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1571 $title = Title
::newFromText( wfMsgForContent($name) );
1572 $this->checkTitle($title, $name);
1573 return $title->getLocalURL( $urlaction );
1575 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1576 $title = Title
::newFromText( $name );
1577 $this->checkTitle($title, $name);
1578 return $title->getLocalURL( $urlaction );
1581 # If url string starts with http, consider as external URL, else
1583 /*static*/ function makeInternalOrExternalUrl( $name ) {
1584 if ( strncmp( $name, 'http', 4 ) == 0 ) {
1587 return $this->makeUrl( $name );
1591 # this can be passed the NS number as defined in Language.php
1592 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=0 ) {
1593 $title = Title
::makeTitleSafe( $namespace, $name );
1594 $this->checkTitle($title, $name);
1595 return $title->getLocalURL( $urlaction );
1598 /* these return an array with the 'href' and boolean 'exists' */
1599 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1600 $title = Title
::newFromText( $name );
1601 $this->checkTitle($title, $name);
1603 'href' => $title->getLocalURL( $urlaction ),
1604 'exists' => $title->getArticleID() != 0?
true:false
1607 /*static*/ function makeTalkUrlDetails ( $name, $urlaction='' ) {
1608 $title = Title
::newFromText( $name );
1609 $title = $title->getTalkPage();
1610 $this->checkTitle($title, $name);
1612 'href' => $title->getLocalURL( $urlaction ),
1613 'exists' => $title->getArticleID() != 0?
true:false
1616 /*static*/ function makeArticleUrlDetails ( $name, $urlaction='' ) {
1617 $title = Title
::newFromText( $name );
1618 $title= $title->getSubjectPage();
1619 $this->checkTitle($title, $name);
1621 'href' => $title->getLocalURL( $urlaction ),
1622 'exists' => $title->getArticleID() != 0?
true:false
1625 /*static*/ function makeI18nUrlDetails ( $name, $urlaction='' ) {
1626 $title = Title
::newFromText( wfMsgForContent($name) );
1627 $this->checkTitle($title, $name);
1629 'href' => $title->getLocalURL( $urlaction ),
1630 'exists' => $title->getArticleID() != 0?
true:false
1634 # make sure we have some title to operate on
1635 /*static*/ function checkTitle ( &$title, &$name ) {
1636 if(!is_object($title)) {
1637 $title = Title
::newFromText( $name );
1638 if(!is_object($title)) {
1639 $title = Title
::newFromText( '--error: link target missing--' );
1644 function fnamePart( $url ) {
1645 $basename = strrchr( $url, '/' );
1646 if ( false === $basename ) {
1649 $basename = substr( $basename, 1 );
1651 return htmlspecialchars( $basename );
1654 function makeImage( $url, $alt = '' ) {
1658 $alt = $this->fnamePart( $url );
1660 $s = '<img src="'.$url.'" alt="'.$alt.'" />';
1664 function makeImageLink( $name, $url, $alt = '' ) {
1665 $nt = Title
::makeTitleSafe( NS_IMAGE
, $name );
1666 return $this->makeImageLinkObj( $nt, $alt );
1669 function makeImageLinkObj( $nt, $alt = '' ) {
1670 global $wgContLang, $wgUseImageResize;
1671 $img = Image
::newFromTitle( $nt );
1672 $url = $img->getViewURL();
1675 $prefix = $postfix = '';
1677 if ( $wgUseImageResize ) {
1678 # Check if the alt text is of the form "options|alt text"
1680 # * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang
1681 # * left no resizing, just left align. label is used for alt= only
1682 # * right same, but right aligned
1683 # * none same, but not aligned
1684 # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox
1685 # * center center the image
1686 # * framed Keep original image size, no magnify-button.
1688 $part = explode( '|', $alt);
1690 $mwThumb =& MagicWord
::get( MAG_IMG_THUMBNAIL
);
1691 $mwLeft =& MagicWord
::get( MAG_IMG_LEFT
);
1692 $mwRight =& MagicWord
::get( MAG_IMG_RIGHT
);
1693 $mwNone =& MagicWord
::get( MAG_IMG_NONE
);
1694 $mwWidth =& MagicWord
::get( MAG_IMG_WIDTH
);
1695 $mwCenter =& MagicWord
::get( MAG_IMG_CENTER
);
1696 $mwFramed =& MagicWord
::get( MAG_IMG_FRAMED
);
1697 $alt = $part[count($part)-1];
1699 $height = $framed = $thumb = false;
1700 $manual_thumb = "" ;
1702 foreach( $part as $key => $val ) {
1703 $val_parts = explode ( "=" , $val , 2 ) ;
1704 $left_part = array_shift ( $val_parts ) ;
1705 if ( ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) {
1707 } elseif ( count ( $val_parts ) == 1 && ! is_null( $mwThumb->matchVariableStartToEnd($left_part) ) ) {
1708 # use manually specified thumbnail
1710 $manual_thumb = array_shift ( $val_parts ) ;
1711 } elseif ( ! is_null( $mwRight->matchVariableStartToEnd($val) ) ) {
1712 # remember to set an alignment, don't render immediately
1714 } elseif ( ! is_null( $mwLeft->matchVariableStartToEnd($val) ) ) {
1715 # remember to set an alignment, don't render immediately
1717 } elseif ( ! is_null( $mwCenter->matchVariableStartToEnd($val) ) ) {
1718 # remember to set an alignment, don't render immediately
1720 } elseif ( ! is_null( $mwNone->matchVariableStartToEnd($val) ) ) {
1721 # remember to set an alignment, don't render immediately
1723 } elseif ( ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
1724 # $match is the image width in pixels
1725 if ( preg_match( '/^([0-9]*)x([0-9]*)$/', $match, $m ) ) {
1726 $width = intval( $m[1] );
1727 $height = intval( $m[2] );
1729 $width = intval($match);
1731 } elseif ( ! is_null( $mwFramed->matchVariableStartToEnd($val) ) ) {
1735 if ( 'center' == $align )
1737 $prefix = '<span style="text-align: center">';
1738 $postfix = '</span>';
1742 if ( $thumb ||
$framed ) {
1744 # Create a thumbnail. Alignment depends on language
1745 # writing direction, # right aligned for left-to-right-
1746 # languages ("Western languages"), left-aligned
1747 # for right-to-left-languages ("Semitic languages")
1749 # If thumbnail width has not been provided, it is set
1750 # here to 180 pixels
1751 if ( $align == '' ) {
1752 $align = $wgContLang->isRTL() ?
'left' : 'right';
1754 if ( ! isset($width) ) {
1757 return $prefix.$this->makeThumbLinkObj( $img, $alt, $align, $width, $height, $framed, $manual_thumb ).$postfix;
1759 } elseif ( isset($width) ) {
1761 # Create a resized image, without the additional thumbnail
1764 if ( ( ! $height === false )
1765 && ( $img->getHeight() * $width / $img->getWidth() > $height ) ) {
1766 print "height=$height<br>\nimg->getHeight() = ".$img->getHeight()."<br>\n";
1767 print 'rescaling by factor '. $height / $img->getHeight() . "<br>\n";
1768 $width = $img->getWidth() * $height / $img->getHeight();
1770 if ( '' == $manual_thumb ) $url = $img->createThumb( $width );
1772 } # endif $wgUseImageResize
1774 if ( empty( $alt ) ) {
1775 $alt = preg_replace( '/\.(.+?)^/', '', $img->getName() );
1777 $alt = preg_replace( '/<[^>]*>/', '', $alt );
1778 $alt = preg_replace('/&(?!:amp;|#[Xx][0-9A-fa-f]+;|#[0-9]+;|[a-zA-Z0-9]+;)/', '&', $alt);
1779 $alt = str_replace( array('<', '>', '"'), array('<', '>', '"'), $alt );
1781 $u = $nt->escapeLocalURL();
1784 $s = wfMsg( 'missingimage', $img->getName() );
1785 $s .= "<br>{$alt}<br>{$url}<br>\n";
1787 $s = '<a href="'.$u.'" class="image" title="'.$alt.'">' .
1788 '<img src="'.$url.'" alt="'.$alt.'" /></a>';
1790 if ( '' != $align ) {
1791 $s = "<div class=\"float{$align}\"><span>{$s}</span></div>";
1793 return str_replace("\n", ' ',$prefix.$s.$postfix);
1797 * Make HTML for a thumbnail including image, border and caption
1798 * $img is an Image object
1800 function makeThumbLinkObj( $img, $label = '', $align = 'right', $boxwidth = 180, $boxheight=false, $framed=false , $manual_thumb = "" ) {
1801 global $wgStylePath, $wgContLang;
1802 # $image = Title::makeTitleSafe( NS_IMAGE, $name );
1803 $url = $img->getViewURL();
1805 #$label = htmlspecialchars( $label );
1806 $alt = preg_replace( '/<[^>]*>/', '', $label);
1807 $alt = preg_replace('/&(?!:amp;|#[Xx][0-9A-fa-f]+;|#[0-9]+;|[a-zA-Z0-9]+;)/', '&', $alt);
1808 $alt = str_replace( array('<', '>', '"'), array('<', '>', '"'), $alt );
1810 $width = $height = 0;
1811 if ( $img->exists() )
1813 $width = $img->getWidth();
1814 $height = $img->getHeight();
1816 if ( 0 == $width ||
0 == $height )
1818 $width = $height = 200;
1820 if ( $boxwidth == 0 )
1826 // Use image dimensions, don't scale
1828 $oboxwidth = $boxwidth +
2;
1829 $boxheight = $height;
1832 $h = intval( $height/($width/$boxwidth) );
1833 $oboxwidth = $boxwidth +
2;
1834 if ( ( ! $boxheight === false ) && ( $h > $boxheight ) )
1836 $boxwidth *= $boxheight/$h;
1840 if ( '' == $manual_thumb ) $thumbUrl = $img->createThumb( $boxwidth );
1843 if ( $manual_thumb != '' ) # Use manually specified thumbnail
1845 $manual_title = Title
::makeTitleSafe( NS_IMAGE
, $manual_thumb ); #new Title ( $manual_thumb ) ;
1846 $manual_img = Image
::newFromTitle( $manual_title );
1847 $thumbUrl = $manual_img->getViewURL();
1848 if ( $manual_img->exists() )
1850 $width = $manual_img->getWidth();
1851 $height = $manual_img->getHeight();
1852 $boxwidth = $width ;
1853 $boxheight = $height ;
1854 $oboxwidth = $boxwidth +
2 ;
1858 $u = $img->getEscapeLocalURL();
1860 $more = htmlspecialchars( wfMsg( 'thumbnail-more' ) );
1861 $magnifyalign = $wgContLang->isRTL() ?
'left' : 'right';
1862 $textalign = $wgContLang->isRTL() ?
' style="text-align:right"' : '';
1864 $s = "<div class=\"thumb t{$align}\"><div style=\"width:{$oboxwidth}px;\">";
1865 if ( $thumbUrl == '' ) {
1866 $s .= wfMsg( 'missingimage', $img->getName() );
1869 $s .= '<a href="'.$u.'" class="internal" title="'.$alt.'">'.
1870 '<img src="'.$thumbUrl.'" alt="'.$alt.'" ' .
1871 'width="'.$boxwidth.'" height="'.$boxheight.'" /></a>';
1875 $zoomicon = '<div class="magnify" style="float:'.$magnifyalign.'">'.
1876 '<a href="'.$u.'" class="internal" title="'.$more.'">'.
1877 '<img src="'.$wgStylePath.'/common/images/magnify-clip.png" ' .
1878 'width="15" height="11" alt="'.$more.'" /></a></div>';
1881 $s .= ' <div class="thumbcaption" '.$textalign.'>'.$zoomicon.$label."</div></div></div>";
1882 return str_replace("\n", ' ', $s);
1885 function makeMediaLink( $name, $url, $alt = '' ) {
1886 $nt = Title
::makeTitleSafe( Namespace::getMedia(), $name );
1887 return $this->makeMediaLinkObj( $nt, $alt );
1890 function makeMediaLinkObj( $nt, $alt = '' ) {
1891 if ( ! isset( $nt ) )
1893 ### HOTFIX. Instead of breaking, return empty string.
1896 $name = $nt->getDBKey();
1897 $url = Image
::wfImageUrl( $name );
1898 if ( empty( $alt ) ) {
1899 $alt = preg_replace( '/\.(.+?)^/', '', $name );
1902 $u = htmlspecialchars( $url );
1903 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
1908 function specialLink( $name, $key = '' ) {
1911 if ( '' == $key ) { $key = strtolower( $name ); }
1912 $pn = $wgContLang->ucfirst( $name );
1913 return $this->makeKnownLink( $wgContLang->specialPage( $pn ),
1917 function makeExternalLink( $url, $text, $escape = true ) {
1918 $style = $this->getExternalLinkAttributes( $url, $text );
1919 $url = htmlspecialchars( $url );
1921 $text = htmlspecialchars( $text );
1923 return '<a href="'.$url.'"'.$style.'>'.$text.'</a>';
1926 # Called by history lists and recent changes
1929 # Returns text for the start of the tabular part of RC
1930 function beginRecentChangesList() {
1931 $this->rc_cache
= array() ;
1932 $this->rcMoveIndex
= 0;
1933 $this->rcCacheIndex
= 0 ;
1934 $this->lastdate
= '';
1935 $this->rclistOpen
= false;
1939 function beginImageHistoryList() {
1940 $s = "\n<h2>" . wfMsg( 'imghistory' ) . "</h2>\n" .
1941 "<p>" . wfMsg( 'imghistlegend' ) . "</p>\n".'<ul class="special">';
1946 * Returns text for the end of RC
1947 * If enhanced RC is in use, returns pretty much all the text
1949 function endRecentChangesList() {
1950 $s = $this->recentChangesBlock() ;
1951 if( $this->rclistOpen
) {
1958 * Enhanced RC ungrouped line
1960 function recentChangesBlockLine ( $rcObj ) {
1961 global $wgStylePath, $wgContLang ;
1963 # Get rc_xxxx variables
1964 extract( $rcObj->mAttribs
) ;
1965 $curIdEq = 'curid='.$rc_cur_id;
1970 $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" border="0" />' ;
1973 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
1974 $r .= ' ';
1976 # M & N (minor & new)
1977 $M = wfMsg( 'minoreditletter' );
1978 $N = wfMsg( 'newpageletter' );
1980 if ( $rc_type == RC_NEW
) {
1993 $r .= ' '.$rcObj->timestamp
.' ' ;
1997 $link = $rcObj->link
;
1998 if ( $rcObj->watched
) $link = '<strong>'.$link.'</strong>' ;
2003 $r .= $rcObj->difflink
;
2007 $r .= $this->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' );
2010 $r .= ') . . '.$rcObj->userlink
;
2011 $r .= $rcObj->usertalklink
;
2014 if ( $rc_comment != '' && $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
2015 $rc_comment=$this->formatComment($rc_comment, $rcObj->getTitle());
2016 $r .= $wgContLang->emphasize( ' ('.$rc_comment.')' );
2026 function recentChangesBlockGroup ( $block ) {
2027 global $wgStylePath, $wgContLang ;
2030 $M = wfMsg( 'minoreditletter' );
2031 $N = wfMsg( 'newpageletter' );
2033 # Collate list of users
2035 $userlinks = array () ;
2036 foreach ( $block AS $rcObj ) {
2037 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
2038 if ( $rcObj->mAttribs
['rc_new'] ) $isnew = true ;
2039 $u = $rcObj->userlink
;
2040 if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
2044 # Sort the list and convert to text
2045 krsort ( $userlinks ) ;
2046 asort ( $userlinks ) ;
2048 foreach ( $userlinks as $userlink => $count) {
2050 if ( $count > 1 ) $text .= " ({$count}×)" ;
2051 array_push ( $users , $text ) ;
2053 $users = ' <font size="-1">['.implode('; ',$users).']</font>' ;
2056 $rci = 'RCI'.$this->rcCacheIndex
;
2057 $rcl = 'RCL'.$this->rcCacheIndex
;
2058 $rcm = 'RCM'.$this->rcCacheIndex
;
2059 $toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')" ;
2060 $arrowdir = $wgContLang->isRTL() ?
'l' : 'r';
2061 $tl = '<span id="'.$rcm.'"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_'.$arrowdir.'.png" width="12" height="12" /></a></span>' ;
2062 $tl .= '<span id="'.$rcl.'" style="display:none"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_d.png" width="12" height="12" /></a></span>' ;
2068 if ( $isnew ) $r .= $N ;
2069 else $r .= ' ' ;
2070 $r .= ' ' ; # Minor
2073 $r .= ' '.$block[0]->timestamp
.' ' ;
2077 $link = $block[0]->link
;
2078 if ( $block[0]->watched
) $link = '<strong>'.$link.'</strong>' ;
2081 $curIdEq = 'curid=' . $block[0]->mAttribs
['rc_cur_id'];
2082 if ( $block[0]->mAttribs
['rc_type'] != RC_LOG
) {
2084 $r .= ' ('.count($block).' ' ;
2085 if ( $isnew ) $r .= wfMsg('changes');
2086 else $r .= $this->makeKnownLinkObj( $block[0]->getTitle() , wfMsg('changes') ,
2087 $curIdEq.'&diff=0&oldid='.$oldid ) ;
2091 $r .= $this->makeKnownLinkObj( $block[0]->getTitle(), wfMsg( 'history' ), $curIdEq.'&action=history' );
2099 $r .= '<div id="'.$rci.'" style="display:none">' ;
2100 foreach ( $block AS $rcObj ) {
2101 # Get rc_xxxx variables
2102 extract( $rcObj->mAttribs
);
2104 $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" />';
2105 $r .= '<tt> ' ;
2106 if ( $rc_new ) $r .= $N ;
2107 else $r .= ' ' ;
2108 if ( $rc_minor ) $r .= $M ;
2109 else $r .= ' ' ;
2113 if ( $rc_last_oldid != 0 ) {
2114 $o = 'oldid='.$rc_last_oldid ;
2116 if ( $rc_type == RC_LOG
) {
2117 $link = $rcObj->timestamp
;
2119 $link = $this->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, "{$curIdEq}&$o" ) ;
2121 $link = '<tt>'.$link.'</tt>' ;
2125 $r .= $rcObj->curlink
;
2127 $r .= $rcObj->lastlink
;
2128 $r .= ') . . '.$rcObj->userlink
;
2129 $r .= $rcObj->usertalklink
;
2130 if ( $rc_comment != '' ) {
2131 $rc_comment=$this->formatComment($rc_comment, $rcObj->getTitle());
2132 $r .= $wgContLang->emphasize( ' ('.$rc_comment.')' ) ;
2138 $this->rcCacheIndex++
;
2143 * If enhanced RC is in use, this function takes the previously cached
2144 * RC lines, arranges them, and outputs the HTML
2146 function recentChangesBlock () {
2147 global $wgStylePath ;
2148 if ( count ( $this->rc_cache
) == 0 ) return '' ;
2150 foreach ( $this->rc_cache
AS $secureName => $block ) {
2151 if ( count ( $block ) < 2 ) {
2152 $blockOut .= $this->recentChangesBlockLine ( array_shift ( $block ) ) ;
2154 $blockOut .= $this->recentChangesBlockGroup ( $block ) ;
2158 return '<div>'.$blockOut.'</div>' ;
2162 * Called in a loop over all displayed RC entries
2163 * Either returns the line, or caches it for later use
2165 function recentChangesLine( &$rc, $watched = false ) {
2167 $usenew = $wgUser->getOption( 'usenewrc' );
2169 $line = $this->recentChangesLineNew ( $rc, $watched ) ;
2171 $line = $this->recentChangesLineOld ( $rc, $watched ) ;
2175 function recentChangesLineOld( &$rc, $watched = false ) {
2176 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds, $wgUseRCPatrol, $wgOnlySysopsCanPatrol;
2178 # Extract DB fields into local scope
2179 extract( $rc->mAttribs
);
2180 $curIdEq = 'curid=' . $rc_cur_id;
2182 # Make date header if necessary
2183 $date = $wgContLang->date( $rc_timestamp, true);
2184 $uidate = $wgLang->date( $rc_timestamp, true);
2186 if ( $date != $this->lastdate
) {
2187 if ( '' != $this->lastdate
) { $s .= "</ul>\n"; }
2188 $s .= "<h4>{$uidate}</h4>\n<ul class='special'>";
2189 $this->lastdate
= $date;
2190 $this->rclistOpen
= true;
2193 # If this edit has not yet been patrolled, make it stick out
2194 $s .= ( ! $wgUseRCPatrol ||
$rc_patrolled ) ?
'<li> ' : '<li class="not_patrolled"> ';
2196 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2198 $s .= '(' . wfMsg( 'diff' ) . ') (';
2200 $s .= $this->makeKnownLinkObj( $rc->getMovedToTitle(), wfMsg( 'hist' ), 'action=history' ) .
2203 # "[[x]] moved to [[y]]"
2204 $msg = ( $rc_type == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
2205 $s .= wfMsg( $msg, $this->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
2206 $this->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
2207 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
2209 $logtype = $matches[1];
2210 $logname = LogPage
::logName( $logtype );
2211 $s .= '(' . $this->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
2214 if ( $rc_type == RC_NEW ||
$rc_type == RC_LOG
) {
2215 $diffLink = wfMsg( 'diff' );
2217 if ( $wgUseRCPatrol && $rc_patrolled == 0 && $wgUser->getID() != 0 &&
2218 ( $wgUser->isSysop() ||
!$wgOnlySysopsCanPatrol ) )
2219 $rcidparam = "&rcid={$rc_id}";
2222 $diffLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'diff' ),
2223 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}{$rcidparam}",
2224 '', '', ' tabindex="'.$rc->counter
.'"');
2226 $s .= '('.$diffLink.') (';
2229 $s .= $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' );
2232 # M and N (minor and new)
2233 if ( $rc_minor ) { $s .= ' <span class="minor">'.wfMsg( "minoreditletter" ).'</span>'; }
2234 if ( $rc_type == RC_NEW
) { $s .= '<span class="newpage">'.wfMsg( "newpageletter" ).'</span>'; }
2237 # If it's a new article, there is no diff link, but if it hasn't been
2238 # patrolled yet, we need to give users a way to do so
2239 if ( $wgUseRCPatrol && $rc_type == RC_NEW
&& $rc_patrolled == 0 &&
2240 $wgUser->getID() != 0 && ( $wgUser->isSysop() ||
!$wgOnlySysopsCanPatrol ) )
2241 $articleLink = $this->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
2243 $articleLink = $this->makeKnownLinkObj( $rc->getTitle(), '' );
2246 $articleLink = '<strong>'.$articleLink.'</strong>';
2248 $s .= ' '.$articleLink;
2253 $s .= '; ' . $wgLang->time( $rc_timestamp, true, $wgRCSeconds ) . ' . . ';
2255 # User link (or contributions for unregistered users)
2256 if ( 0 == $rc_user ) {
2257 $userLink = $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
2258 $rc_user_text, 'target=' . $rc_user_text );
2260 $userLink = $this->makeLink( $wgContLang->getNsText( NS_USER
) . ':'.$rc_user_text, $rc_user_text );
2265 $talkname=$wgContLang->getNsText(NS_TALK
); # use the shorter name
2266 global $wgDisableAnonTalk;
2267 if( 0 == $rc_user && $wgDisableAnonTalk ) {
2270 $utns=$wgContLang->getNsText(NS_USER_TALK
);
2271 $userTalkLink= $this->makeLink($utns . ':'.$rc_user_text, $talkname );
2275 if ( ( 0 == $rc_user ) && $wgUser->isSysop() ) {
2276 $blockLink = $this->makeKnownLink( $wgContLang->specialPage(
2277 'Blockip' ), wfMsg( 'blocklink' ), 'ip='.$rc_user_text );
2281 if($userTalkLink) $userTalkLink .= ' | ';
2282 $userTalkLink .= $blockLink;
2284 if($userTalkLink) $s.=' ('.$userTalkLink.')';
2287 if ( '' != $rc_comment && '*' != $rc_comment && $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
2288 $rc_comment=$this->formatComment($rc_comment,$rc->getTitle());
2289 $s .= $wgContLang->emphasize(' (' . $rc_comment . ')');
2296 function recentChangesLineNew( &$baseRC, $watched = false ) {
2297 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds;
2299 # Create a specialised object
2300 $rc = RCCacheEntry
::newFromParent( $baseRC ) ;
2302 # Extract fields from DB into the function scope (rc_xxxx variables)
2303 extract( $rc->mAttribs
);
2304 $curIdEq = 'curid=' . $rc_cur_id;
2306 # If it's a new day, add the headline and flush the cache
2307 $date = $wgContLang->date( $rc_timestamp, true);
2308 $uidate = $wgLang->date( $rc_timestamp, true);
2310 if ( $date != $this->lastdate
) {
2311 # Process current cache
2312 $ret = $this->recentChangesBlock () ;
2313 $this->rc_cache
= array() ;
2314 $ret .= "<h4>{$uidate}</h4>\n";
2315 $this->lastdate
= $date;
2319 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2320 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
2321 $clink = wfMsg( $msg, $this->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
2322 $this->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
2323 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
2325 $logtype = $matches[1];
2326 $logname = LogPage
::logName( $logtype );
2327 $clink = '(' . $this->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
2329 $clink = $this->makeKnownLinkObj( $rc->getTitle(), '' ) ;
2332 $time = $wgContLang->time( $rc_timestamp, true, $wgRCSeconds );
2333 $rc->watched
= $watched ;
2334 $rc->link
= $clink ;
2335 $rc->timestamp
= $time;
2337 # Make "cur" and "diff" links
2338 if ( ( $rc_type == RC_NEW
&& $rc_this_oldid == 0 ) ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2339 $curLink = wfMsg( 'cur' );
2340 $diffLink = wfMsg( 'diff' );
2342 $query = $curIdEq.'&diff=0&oldid='.$rc_this_oldid;
2343 $aprops = ' tabindex="'.$baseRC->counter
.'"';
2344 $curLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'cur' ), $query, '' ,'' , $aprops );
2345 $diffLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'diff'), $query, '' ,'' , $aprops );
2349 $titleObj = $rc->getTitle();
2350 if ( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2351 $lastLink = wfMsg( 'last' );
2353 $lastLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'last' ),
2354 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid );
2357 # Make user link (or user contributions for unregistered users)
2358 if ( $rc_user == 0 ) {
2359 $userLink = $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
2360 $rc_user_text, 'target=' . $rc_user_text );
2362 $userLink = $this->makeLink( $wgContLang->getNsText(
2363 Namespace::getUser() ) . ':'.$rc_user_text, $rc_user_text );
2366 $rc->userlink
= $userLink;
2367 $rc->lastlink
= $lastLink;
2368 $rc->curlink
= $curLink;
2369 $rc->difflink
= $diffLink;
2371 # Make user talk link
2372 $utns=$wgContLang->getNsText(NS_USER_TALK
);
2373 $talkname=$wgContLang->getNsText(NS_TALK
); # use the shorter name
2374 $userTalkLink= $this->makeLink($utns . ':'.$rc_user_text, $talkname );
2376 global $wgDisableAnonTalk;
2377 if ( ( 0 == $rc_user ) && $wgUser->isSysop() ) {
2378 $blockLink = $this->makeKnownLink( $wgContLang->specialPage(
2379 'Blockip' ), wfMsg( 'blocklink' ), 'ip='.$rc_user_text );
2380 if( $wgDisableAnonTalk )
2381 $rc->usertalklink
= ' ('.$blockLink.')';
2383 $rc->usertalklink
= ' ('.$userTalkLink.' | '.$blockLink.')';
2385 if( $wgDisableAnonTalk && ($rc_user == 0) )
2386 $rc->usertalklink
= '';
2388 $rc->usertalklink
= ' ('.$userTalkLink.')';
2391 # Put accumulated information into the cache, for later display
2392 # Page moves go on their own line
2393 $title = $rc->getTitle();
2394 $secureName = $title->getPrefixedDBkey();
2395 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2396 # Use an @ character to prevent collision with page names
2397 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
2399 if ( !isset ( $this->rc_cache
[$secureName] ) ) $this->rc_cache
[$secureName] = array() ;
2400 array_push ( $this->rc_cache
[$secureName] , $rc ) ;
2405 function endImageHistoryList() {
2411 * This function is called by all recent changes variants, by the page history,
2412 * and by the user contributions list. It is responsible for formatting edit
2413 * comments. It escapes any HTML in the comment, but adds some CSS to format
2414 * auto-generated comments (from section editing) and formats [[wikilinks]].
2416 * The &$title parameter must be a title OBJECT. It is used to generate a
2417 * direct link to the section in the autocomment.
2418 * @author Erik Moeller <moeller@scireview.de>
2420 * Note: there's not always a title to pass to this function.
2421 * Since you can't set a default parameter for a reference, I've turned it
2422 * temporarily to a value pass. Should be adjusted further. --brion
2424 function formatComment($comment, $title = NULL) {
2426 $comment = htmlspecialchars( $comment );
2428 # The pattern for autogen comments is / * foo * /, which makes for
2430 # We look for all comments, match any text before and after the comment,
2431 # add a separator where needed and format the comment itself with CSS
2432 while (preg_match('/(.*)\/\*\s*(.*?)\s*\*\/(.*)/', $comment,$match)) {
2440 # This is hackish but should work in most cases.
2441 $section=str_replace('[[','',$section);
2442 $section=str_replace(']]','',$section);
2443 $title->mFragment
=$section;
2444 $link=$this->makeKnownLinkObj($title,wfMsg('sectionlink'));
2448 if($pre) { $auto = $sep.' '.$auto; }
2449 if($post) { $auto .= ' '.$sep; }
2450 $auto='<span class="autocomment">'.$auto.'</span>';
2451 $comment=$pre.$auto.$post;
2454 # format regular and media links - all other wiki formatting
2456 $medians = $wgContLang->getNsText(Namespace::getMedia()).':';
2457 while(preg_match('/\[\[(.*?)(\|(.*?))*\]\](.*)$/',$comment,$match)) {
2458 # Handle link renaming [[foo|text]] will show link as "text"
2459 if( "" != $match[3] ) {
2464 if( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) {
2465 # Media link; trail not supported.
2466 $linkRegexp = '/\[\[(.*?)\]\]/';
2467 $thelink = $this->makeMediaLink( $submatch[1], "", $text );
2469 # Other kind of link
2470 if( preg_match( wfMsgForContent( "linktrail" ), $match[4], $submatch ) ) {
2471 $trail = $submatch[1];
2475 $linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/';
2476 if ($match[1][0] == ':')
2477 $match[1] = substr($match[1], 1);
2478 $thelink = $this->makeLink( $match[1], $text, "", $trail );
2480 $comment = preg_replace( $linkRegexp, $thelink, $comment, 1 );
2485 function imageHistoryLine( $iscur, $timestamp, $img, $user, $usertext, $size, $description ) {
2486 global $wgUser, $wgLang, $wgContLang, $wgTitle;
2488 $datetime = $wgLang->timeanddate( $timestamp, true );
2489 $del = wfMsg( 'deleteimg' );
2490 $delall = wfMsg( 'deleteimgcompletely' );
2491 $cur = wfMsg( 'cur' );
2494 $url = Image
::wfImageUrl( $img );
2496 if ( $wgUser->isSysop() ) {
2497 $link = $wgTitle->escapeLocalURL( 'image=' . $wgTitle->getPartialURL() .
2499 $style = $this->getInternalLinkAttributes( $link, $delall );
2501 $dlink = '<a href="'.$link.'"'.$style.'>'.$delall.'</a>';
2506 $url = htmlspecialchars( wfImageArchiveUrl( $img ) );
2507 if( $wgUser->getID() != 0 && $wgTitle->userCanEdit() ) {
2508 $rlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
2509 wfMsg( 'revertimg' ), 'action=revert&oldimage=' .
2510 urlencode( $img ) );
2511 $dlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
2512 $del, 'action=delete&oldimage=' . urlencode( $img ) );
2514 # Having live active links for non-logged in users
2515 # means that bots and spiders crawling our site can
2516 # inadvertently change content. Baaaad idea.
2517 $rlink = wfMsg( 'revertimg' );
2522 $userlink = $usertext;
2524 $userlink = $this->makeLink( $wgContLang->getNsText( Namespace::getUser() ) .
2525 ':'.$usertext, $usertext );
2527 $nbytes = wfMsg( 'nbytes', $size );
2528 $style = $this->getInternalLinkAttributes( $url, $datetime );
2530 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$datetime}</a>"
2531 . " . . {$userlink} ({$nbytes})";
2533 if ( '' != $description && '*' != $description ) {
2534 $sk=$wgUser->getSkin();
2535 $s .= $wgContLang->emphasize(' (' . $sk->formatComment($description,$wgTitle) . ')');
2541 function tocIndent($level) {
2542 return str_repeat( '<div class="tocindent">'."\n", $level>0 ?
$level : 0 );
2545 function tocUnindent($level) {
2546 return str_repeat( "</div>\n", $level>0 ?
$level : 0 );
2550 * parameter level defines if we are on an indentation level
2552 function tocLine( $anchor, $tocline, $level ) {
2553 $link = '<a href="#'.$anchor.'">'.$tocline.'</a><br />';
2557 return '<div class="tocline">'.$link."</div>\n";
2562 function tocTable($toc) {
2563 # note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
2564 # try min-width & co when somebody gets a chance
2565 $hideline = ' <script type="text/javascript">showTocToggle("' . addslashes( wfMsg('showtoc') ) . '","' . addslashes( wfMsg('hidetoc') ) . '")</script>';
2567 '<table border="0" id="toc"><tr id="toctitle"><td align="center">'."\n".
2568 '<b>'.wfMsg('toc').'</b>' .
2570 '</td></tr><tr id="tocinside"><td>'."\n".
2571 $toc."</td></tr></table>\n";
2575 * These two do not check for permissions: check $wgTitle->userCanEdit
2576 * before calling them
2578 function editSectionScriptForOther( $title, $section, $head ) {
2579 $ttl = Title
::newFromText( $title );
2580 $url = $ttl->escapeLocalURL( 'action=edit§ion='.$section );
2581 return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
2584 function editSectionScript( $section, $head ) {
2585 global $wgTitle, $wgRequest;
2586 if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
2589 $url = $wgTitle->escapeLocalURL( 'action=edit§ion='.$section );
2590 return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
2593 function editSectionLinkForOther( $title, $section ) {
2595 global $wgUser, $wgContLang;
2597 $title = Title
::newFromText($title);
2598 $editurl = '§ion='.$section;
2599 $url = $this->makeKnownLink($title->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
2601 if( $wgContLang->isRTL() ) {
2603 $nearside = 'right';
2608 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
2612 function editSectionLink( $section ) {
2614 global $wgTitle, $wgUser, $wgContLang;
2616 if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
2617 # Section edit links would be out of sync on an old page.
2618 # But, if we're diffing to the current page, they'll be
2623 $editurl = '§ion='.$section;
2624 $url = $this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
2626 if( $wgContLang->isRTL() ) {
2628 $nearside = 'right';
2633 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
2638 * This function is called by EditPage.php and shows a bulletin board style
2639 * toolbar for common editing functions. It can be disabled in the user
2641 * The necessary JavaScript code can be found in style/wikibits.js.
2643 function getEditToolbar() {
2644 global $wgStylePath, $wgLang, $wgMimeType;
2647 * toolarray an array of arrays which each include the filename of
2648 * the button image (without path), the opening tag, the closing tag,
2649 * and optionally a sample text that is inserted between the two when no
2650 * selection is highlighted.
2651 * The tip text is shown when the user moves the mouse over the button.
2653 * Already here are accesskeys (key), which are not used yet until someone
2654 * can figure out a way to make them work in IE. However, we should make
2655 * sure these keys are not defined on the edit page.
2658 array( 'image'=>'button_bold.png',
2660 'close' => "\'\'\'",
2661 'sample'=> wfMsg('bold_sample'),
2662 'tip' => wfMsg('bold_tip'),
2665 array( 'image'=>'button_italic.png',
2668 'sample'=> wfMsg('italic_sample'),
2669 'tip' => wfMsg('italic_tip'),
2672 array( 'image'=>'button_link.png',
2675 'sample'=> wfMsg('link_sample'),
2676 'tip' => wfMsg('link_tip'),
2679 array( 'image'=>'button_extlink.png',
2682 'sample'=> wfMsg('extlink_sample'),
2683 'tip' => wfMsg('extlink_tip'),
2686 array( 'image'=>'button_headline.png',
2688 'close' => " ==\\n",
2689 'sample'=> wfMsg('headline_sample'),
2690 'tip' => wfMsg('headline_tip'),
2693 array( 'image'=>'button_image.png',
2694 'open' => '[['.$wgLang->getNsText(NS_IMAGE
).":",
2696 'sample'=> wfMsg('image_sample'),
2697 'tip' => wfMsg('image_tip'),
2700 array( 'image' => 'button_media.png',
2701 'open' => '[['.$wgLang->getNsText(NS_MEDIA
).':',
2703 'sample'=> wfMsg('media_sample'),
2704 'tip' => wfMsg('media_tip'),
2707 array( 'image' => 'button_math.png',
2708 'open' => "\\<math\\>",
2709 'close' => "\\</math\\>",
2710 'sample'=> wfMsg('math_sample'),
2711 'tip' => wfMsg('math_tip'),
2714 array( 'image' => 'button_nowiki.png',
2715 'open' => "\\<nowiki\\>",
2716 'close' => "\\</nowiki\\>",
2717 'sample'=> wfMsg('nowiki_sample'),
2718 'tip' => wfMsg('nowiki_tip'),
2721 array( 'image' => 'button_sig.png',
2725 'tip' => wfMsg('sig_tip'),
2728 array( 'image' => 'button_hr.png',
2729 'open' => "\\n----\\n",
2732 'tip' => wfMsg('hr_tip'),
2736 $toolbar ="<script type='text/javascript'>\n/*<![CDATA[*/\n";
2738 $toolbar.="document.writeln(\"<div id='toolbar'>\");\n";
2739 foreach($toolarray as $tool) {
2741 $image=$wgStylePath.'/common/images/'.$tool['image'];
2742 $open=$tool['open'];
2743 $close=$tool['close'];
2744 $sample = addslashes( $tool['sample'] );
2746 // Note that we use the tip both for the ALT tag and the TITLE tag of the image.
2747 // Older browsers show a "speedtip" type message only for ALT.
2748 // Ideally these should be different, realistically they
2749 // probably don't need to be.
2750 $tip = addslashes( $tool['tip'] );
2752 #$key = $tool["key"];
2754 $toolbar.="addButton('$image','$tip','$open','$close','$sample');\n";
2757 $toolbar.="addInfobox('" . addslashes( wfMsg( "infobox" ) ) . "','" . addslashes(wfMsg("infobox_alert")) . "');\n";
2758 $toolbar.="document.writeln(\"</div>\");\n";
2760 $toolbar.="/*]]>*/\n</script>";
2767 function suppressUrlExpansion() {