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 );
455 function getCategoryLinks () {
456 global $wgOut, $wgTitle, $wgUser, $wgParser;
457 global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang;
459 if( !$wgUseCategoryMagic ) return '' ;
460 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
462 # Taken out so that they will be displayed in previews -- TS
463 #if( !$wgOut->isArticle() ) return '';
465 $t = implode ( ' | ' , $wgOut->mCategoryLinks
) ;
466 $s = $this->makeKnownLink( 'Special:Categories',
467 wfMsg( 'categories' ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
470 # optional 'dmoz-like' category browser. Will be shown under the list
471 # of categories an article belong to
472 if($wgUseCategoryBrowser) {
475 # get a big array of the parents tree
476 $parenttree = $wgTitle->getCategorieBrowser();
478 # Render the array as a serie of links
479 function walkThrough ($tree) {
481 $sk = $wgUser->getSkin();
483 foreach($tree as $element => $parent) {
485 # element start a new list
488 # grab the others elements
489 $return .= walkThrough($parent);
491 # add our current element to the list
492 $eltitle = Title
::NewFromText($element);
493 # FIXME : should be makeLink() [AV]
494 $return .= $sk->makeKnownLink($element, $eltitle->getText()).' > ';
499 $s .= walkThrough($parenttree);
505 function getCategories() {
506 $catlinks=$this->getCategoryLinks();
507 if(!empty($catlinks)) {
508 return "<p class='catlinks'>{$catlinks}</p>";
512 function getQuickbarCompensator( $rows = 1 ) {
513 return "<td width='152' rowspan='{$rows}'> </td>";
516 # This gets called immediately before the </body> tag.
518 function afterContent() {
519 global $wgUser, $wgOut, $wgServer;
520 global $wgTitle, $wgLang;
522 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
523 return $printfooter . $this->doAfterContent();
526 function printSource() {
528 $url = htmlspecialchars( $wgTitle->getFullURL() );
529 return wfMsg( "retrievedfrom", "<a href=\"$url\">$url</a>" );
532 function printFooter() {
533 return "<p>" . $this->printSource() .
534 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
537 function doAfterContent() {
538 # overloaded by derived classes
541 function pageTitleLinks() {
542 global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgUseApproval, $wgRequest;
544 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
545 $action = $wgRequest->getText( 'action' );
547 $s = $this->printableLink();
548 $disclaimer = $this->disclaimerLink(); # may be empty
550 $s .= ' | ' . $disclaimer;
553 if ( $wgOut->isArticleRelated() ) {
554 if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
555 $name = $wgTitle->getDBkey();
556 $link = htmlspecialchars( Image
::wfImageUrl( $name ) );
557 $style = $this->getInternalLinkAttributes( $link, $name );
558 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
560 # This will show the "Approve" link if $wgUseApproval=true;
561 if ( isset ( $wgUseApproval ) && $wgUseApproval )
563 $t = $wgTitle->getDBkey();
564 $name = 'Approve this article' ;
565 $link = "http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ;
566 #htmlspecialchars( wfImageUrl( $name ) );
567 $style = $this->getExternalLinkAttributes( $link, $name );
568 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>" ;
571 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
572 $s .= ' | ' . $this->makeKnownLink( $wgTitle->getPrefixedText(),
573 wfMsg( 'currentrev' ) );
576 if ( $wgUser->getNewtalk() ) {
577 # do not show "You have new messages" text when we are viewing our
580 if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
581 $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
582 $n =$wgUser->getName();
583 $tl = $this->makeKnownLink( $wgContLang->getNsText(
584 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
585 wfMsg('newmessageslink') );
586 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
588 $wgOut->setSquidMaxage(0);
592 $undelete = $this->getUndeleteLink();
593 if( !empty( $undelete ) ) {
594 $s .= ' | '.$undelete;
599 function getUndeleteLink() {
600 global $wgUser, $wgTitle, $wgContLang, $action;
601 if( $wgUser->isSysop() &&
602 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
603 ($n = $wgTitle->isDeleted() ) ) {
604 return wfMsg( 'thisisdeleted',
605 $this->makeKnownLink(
606 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
607 wfMsg( 'restorelink', $n ) ) );
612 function printableLink() {
613 global $wgOut, $wgFeedClasses, $wgRequest;
615 $baseurl = $_SERVER['REQUEST_URI'];
616 if( strpos( '?', $baseurl ) == false ) {
621 $baseurl = htmlspecialchars( $baseurl );
622 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
624 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
625 if( $wgOut->isSyndicated() ) {
626 foreach( $wgFeedClasses as $format => $class ) {
627 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
628 $s .= " | <a href=\"$feedurl\">{$format}</a>";
634 function pageTitle() {
635 global $wgOut, $wgTitle, $wgUser;
637 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
638 if($wgUser->getOption( 'editsectiononrightclick' ) && $wgTitle->userCanEdit()) { $s=$this->editSectionScript(0,$s);}
642 function pageSubtitle() {
645 $sub = $wgOut->getSubtitle();
647 global $wgExtraSubtitle;
648 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
650 $subpages = $this->subPageSubtitle();
651 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
652 $s = "<p class='subtitle'>{$sub}</p>\n";
656 function subPageSubtitle() {
657 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
659 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
660 $ptext=$wgTitle->getPrefixedText();
661 if(preg_match('/\//',$ptext)) {
662 $links = explode('/',$ptext);
665 foreach($links as $link) {
667 if ($c<count($links)) {
668 $growinglink .= $link;
669 $getlink = $this->makeLink( $growinglink, $link );
670 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
674 $subpages .= '< ';
676 $subpages .= $getlink;
685 function nameAndLogin() {
686 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader, $wgIP;
688 $li = $wgContLang->specialPage( 'Userlogin' );
689 $lo = $wgContLang->specialPage( 'Userlogout' );
692 if ( 0 == $wgUser->getID() ) {
693 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
696 $tl = $this->makeKnownLink( $wgContLang->getNsText(
697 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
698 $wgContLang->getNsText( Namespace::getTalk( 0 ) ) );
700 $s .= $n . ' ('.$tl.')';
702 $s .= wfMsg('notloggedin');
705 $rt = $wgTitle->getPrefixedURL();
706 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
708 } else { $q = "returnto={$rt}"; }
710 $s .= "\n<br />" . $this->makeKnownLink( $li,
711 wfMsg( 'login' ), $q );
713 $n = $wgUser->getName();
714 $rt = $wgTitle->getPrefixedURL();
715 $tl = $this->makeKnownLink( $wgContLang->getNsText(
716 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
717 $wgContLang->getNsText( Namespace::getTalk( 0 ) ) );
721 $s .= $this->makeKnownLink( $wgContLang->getNsText(
722 Namespace::getUser() ) . ":{$n}", $n ) . "{$tl}<br />" .
723 $this->makeKnownLink( $lo, wfMsg( 'logout' ),
724 "returnto={$rt}" ) . ' | ' .
725 $this->specialLink( 'preferences' );
727 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
733 function getSearchLink() {
734 $searchPage =& Title
::makeTitle( NS_SPECIAL
, 'Search' );
735 return $searchPage->getLocalURL();
738 function escapeSearchLink() {
739 return htmlspecialchars( $this->getSearchLink() );
742 function searchForm() {
744 $search = $wgRequest->getText( 'search' );
746 $s = '<form name="search" class="inline" method="post" action="'
747 . $this->escapeSearchLink() . "\">\n"
748 . '<input type="text" name="search" size="19" value="'
749 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
750 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
751 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
756 function topLinks() {
760 $s = $this->mainPageLink() . $sep
761 . $this->specialLink( 'recentchanges' );
763 if ( $wgOut->isArticleRelated() ) {
764 $s .= $sep . $this->editThisPage()
765 . $sep . $this->historyLink();
767 # Many people don't like this dropdown box
768 #$s .= $sep . $this->specialPagesList();
773 function bottomLinks() {
774 global $wgOut, $wgUser, $wgTitle;
778 if ( $wgOut->isArticleRelated() ) {
779 $s .= '<strong>' . $this->editThisPage() . '</strong>';
780 if ( 0 != $wgUser->getID() ) {
781 $s .= $sep . $this->watchThisPage();
783 $s .= $sep . $this->talkLink()
784 . $sep . $this->historyLink()
785 . $sep . $this->whatLinksHere()
786 . $sep . $this->watchPageLinksLink();
788 if ( $wgTitle->getNamespace() == Namespace::getUser()
789 ||
$wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) )
792 $id=User
::idFromName($wgTitle->getText());
793 $ip=User
::isIP($wgTitle->getText());
795 if($id ||
$ip) { # both anons and non-anons have contri list
796 $s .= $sep . $this->userContribsLink();
798 if ( 0 != $wgUser->getID() ) { # show only to signed in users
799 if($id) { # can only email non-anons
800 $s .= $sep . $this->emailUserLink();
804 if ( $wgUser->isSysop() && $wgTitle->getArticleId() ) {
805 $s .= "\n<br />" . $this->deleteThisPage() .
806 $sep . $this->protectThisPage() .
807 $sep . $this->moveThisPage();
809 $s .= "<br />\n" . $this->otherLanguages();
814 function pageStats() {
815 global $wgOut, $wgLang, $wgArticle, $wgRequest;
816 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax;
818 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
819 if ( ! $wgOut->isArticle() ) { return ''; }
820 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
821 if ( 0 == $wgArticle->getID() ) { return ''; }
824 if ( !$wgDisableCounters ) {
825 $count = $wgLang->formatNum( $wgArticle->getCount() );
827 $s = wfMsg( 'viewcount', $count );
831 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
832 require_once("Credits.php");
833 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
835 $s .= $this->lastModified();
838 return $s . ' ' . $this->getCopyright();
841 function getCopyright() {
842 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
845 $oldid = $wgRequest->getVal( 'oldid' );
846 $diff = $wgRequest->getVal( 'diff' );
848 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
849 $msg = 'history_copyright';
855 if( $wgRightsPage ) {
856 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
857 } elseif( $wgRightsUrl ) {
858 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
863 $out .= wfMsgForContent( $msg, $link );
867 function getCopyrightIcon() {
868 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon;
870 if( $wgRightsIcon ) {
871 $icon = htmlspecialchars( $wgRightsIcon );
873 $url = htmlspecialchars( $wgRightsUrl );
874 $out .= '<a href="'.$url.'">';
876 $text = htmlspecialchars( $wgRightsText );
877 $out .= "<img src=\"$icon\" alt='$text' />";
885 function getPoweredBy() {
887 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
888 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
892 function lastModified() {
893 global $wgLang, $wgArticle;
895 $timestamp = $wgArticle->getTimestamp();
897 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
898 $s = ' ' . wfMsg( 'lastmodified', $d );
905 function logoText( $align = '' ) {
906 if ( '' != $align ) { $a = " align='{$align}'"; }
909 $mp = wfMsg( 'mainpage' );
910 $titleObj = Title
::newFromText( $mp );
911 if ( is_object( $titleObj ) ) {
912 $url = $titleObj->escapeLocalURL();
917 $logourl = $this->getLogo();
918 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
922 function specialPagesList() {
923 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript;
924 require_once('SpecialPage.php');
926 $pages = SpecialPage
::getPages();
928 foreach ( $pages[''] as $name => $page ) {
929 $a[$name] = $page->getDescription();
931 if ( $wgUser->isSysop() )
933 foreach ( $pages['sysop'] as $name => $page ) {
934 $a[$name] = $page->getDescription();
937 if ( $wgUser->isDeveloper() )
939 foreach ( $pages['developer'] as $name => $page ) {
940 $a[$name] = $page->getDescription() ;
944 $sp = wfMsg( 'specialpages' );
945 $spp = $wgContLang->specialPage( 'Specialpages' );
947 $s = '<form id="specialpages" method="get" class="inline" ' .
948 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
949 $s .= "<select name=\"wpDropdown\">\n";
950 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
952 foreach ( $a as $name => $desc ) {
953 $p = $wgContLang->specialPage( $name );
954 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
957 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
962 function mainPageLink() {
963 $mp = wfMsgForContent( 'mainpage' );
964 $mptxt = wfMsg( 'mainpage');
965 $s = $this->makeKnownLink( $mp, $mptxt );
969 function copyrightLink() {
970 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
971 wfMsg( 'copyrightpagename' ) );
975 function aboutLink() {
976 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
977 wfMsg( 'aboutsite' ) );
982 function disclaimerLink() {
983 $disclaimers = wfMsg( 'disclaimers' );
984 if ($disclaimers == '-') {
987 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
992 function editThisPage() {
993 global $wgOut, $wgTitle, $wgRequest;
995 $oldid = $wgRequest->getVal( 'oldid' );
996 $diff = $wgRequest->getVal( 'diff' );
997 $redirect = $wgRequest->getVal( 'redirect' );
999 if ( ! $wgOut->isArticleRelated() ) {
1000 $s = wfMsg( 'protectedpage' );
1002 $n = $wgTitle->getPrefixedText();
1003 if ( $wgTitle->userCanEdit() ) {
1004 $t = wfMsg( 'editthispage' );
1006 #$t = wfMsg( "protectedpage" );
1007 $t = wfMsg( 'viewsource' );
1011 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
1012 if ( $oldid && ! isset( $diff ) ) {
1013 $oid = '&oldid='.$oldid;
1015 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
1020 function deleteThisPage() {
1021 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1023 $diff = $wgRequest->getVal( 'diff' );
1024 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
1025 $n = $wgTitle->getPrefixedText();
1026 $t = wfMsg( 'deletethispage' );
1028 $s = $this->makeKnownLink( $n, $t, 'action=delete' );
1035 function protectThisPage() {
1036 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1038 $diff = $wgRequest->getVal( 'diff' );
1039 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isSysop() ) {
1040 $n = $wgTitle->getPrefixedText();
1042 if ( $wgTitle->isProtected() ) {
1043 $t = wfMsg( 'unprotectthispage' );
1044 $q = 'action=unprotect';
1046 $t = wfMsg( 'protectthispage' );
1047 $q = 'action=protect';
1049 $s = $this->makeKnownLink( $n, $t, $q );
1056 function watchThisPage() {
1057 global $wgUser, $wgOut, $wgTitle;
1059 if ( $wgOut->isArticleRelated() ) {
1060 $n = $wgTitle->getPrefixedText();
1062 if ( $wgTitle->userIsWatching() ) {
1063 $t = wfMsg( 'unwatchthispage' );
1064 $q = 'action=unwatch';
1066 $t = wfMsg( 'watchthispage' );
1067 $q = 'action=watch';
1069 $s = $this->makeKnownLink( $n, $t, $q );
1071 $s = wfMsg( 'notanarticle' );
1076 function moveThisPage() {
1077 global $wgTitle, $wgContLang;
1079 if ( $wgTitle->userCanEdit() ) {
1080 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Movepage' ),
1081 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1082 } // no message if page is protected - would be redundant
1086 function historyLink() {
1089 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1090 wfMsg( 'history' ), 'action=history' );
1094 function whatLinksHere() {
1095 global $wgTitle, $wgContLang;
1097 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Whatlinkshere' ),
1098 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1102 function userContribsLink() {
1103 global $wgTitle, $wgContLang;
1105 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
1106 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1110 function emailUserLink() {
1111 global $wgTitle, $wgContLang;
1113 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Emailuser' ),
1114 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1118 function watchPageLinksLink() {
1119 global $wgOut, $wgTitle, $wgContLang;
1121 if ( ! $wgOut->isArticleRelated() ) {
1122 $s = '(' . wfMsg( 'notanarticle' ) . ')';
1124 $s = $this->makeKnownLink( $wgContLang->specialPage(
1125 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1126 'target=' . $wgTitle->getPrefixedURL() );
1131 function otherLanguages() {
1132 global $wgOut, $wgContLang, $wgTitle, $wgUseNewInterlanguage;
1134 $a = $wgOut->getLanguageLinks();
1135 if ( 0 == count( $a ) ) {
1136 if ( !$wgUseNewInterlanguage ) return '';
1137 $ns = $wgContLang->getNsIndex ( $wgTitle->getNamespace () ) ;
1138 if ( $ns != 0 AND $ns != 1 ) return '' ;
1140 $x = 'mode=addlink&xt='.$wgTitle->getDBkey() ;
1141 return $this->makeKnownLink( $wgContLang->specialPage( $pn ),
1142 wfMsg( 'intl' ) , $x );
1145 if ( !$wgUseNewInterlanguage ) {
1146 $s = wfMsg( 'otherlanguages' ) . ': ';
1148 global $wgContLanguageCode ;
1149 $x = 'mode=zoom&xt='.$wgTitle->getDBkey() ;
1150 $x .= '&xl='.$wgContLanguageCode ;
1151 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Intl' ),
1152 wfMsg( 'otherlanguages' ) , $x ) . ': ' ;
1155 $s = wfMsg( 'otherlanguages' ) . ': ';
1157 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1158 foreach( $a as $l ) {
1159 if ( ! $first ) { $s .= ' | '; }
1162 $nt = Title
::newFromText( $l );
1163 $url = $nt->getFullURL();
1164 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1166 if ( '' == $text ) { $text = $l; }
1167 $style = $this->getExternalLinkAttributes( $l, $text );
1168 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1170 if($wgContLang->isRTL()) $s .= '</span>';
1174 function bugReportsLink() {
1175 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1176 wfMsg( 'bugreports' ) );
1180 function dateLink() {
1181 global $wgLinkCache;
1182 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1183 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1185 $wgLinkCache->suspend();
1186 $id = $t1->getArticleID();
1187 $wgLinkCache->resume();
1190 $s = $this->makeBrokenLink( $t1->getText() );
1192 $s = $this->makeKnownLink( $t1->getText() );
1196 $wgLinkCache->suspend();
1197 $id = $t2->getArticleID();
1198 $wgLinkCache->resume();
1201 $s .= $this->makeBrokenLink( $t2->getText() );
1203 $s .= $this->makeKnownLink( $t2->getText() );
1208 function talkLink() {
1209 global $wgContLang, $wgTitle, $wgLinkCache;
1211 $tns = $wgTitle->getNamespace();
1212 if ( -1 == $tns ) { return ''; }
1214 $pn = $wgTitle->getText();
1215 $tp = wfMsg( 'talkpage' );
1216 if ( Namespace::isTalk( $tns ) ) {
1217 $lns = Namespace::getSubject( $tns );
1220 $text = wfMsg('articlepage');
1223 $text = wfMsg('userpage');
1226 $text = wfMsg('wikipediapage');
1229 $text = wfMsg('imagepage');
1232 $text= wfMsg('articlepage');
1236 $lns = Namespace::getTalk( $tns );
1239 $n = $wgContLang->getNsText( $lns );
1240 if ( '' == $n ) { $link = $pn; }
1241 else { $link = $n.':'.$pn; }
1243 $wgLinkCache->suspend();
1244 $s = $this->makeLink( $link, $text );
1245 $wgLinkCache->resume();
1250 function commentLink() {
1251 global $wgContLang, $wgTitle, $wgLinkCache;
1253 $tns = $wgTitle->getNamespace();
1254 if ( -1 == $tns ) { return ''; }
1256 $lns = ( Namespace::isTalk( $tns ) ) ?
$tns : Namespace::getTalk( $tns );
1258 # assert Namespace::isTalk( $lns )
1260 $n = $wgContLang->getNsText( $lns );
1261 $pn = $wgTitle->getText();
1265 $wgLinkCache->suspend();
1266 $s = $this->makeKnownLink($link, wfMsg('postcomment'), 'action=edit§ion=new');
1267 $wgLinkCache->resume();
1273 * After all the page content is transformed into HTML, it makes
1274 * a final pass through here for things like table backgrounds.
1275 * @todo probably deprecated [AV]
1277 function transformContent( $text ) {
1282 * Note: This function MUST call getArticleID() on the link,
1283 * otherwise the cache won't get updated properly. See LINKCACHE.DOC.
1285 function makeLink( $title, $text = '', $query = '', $trail = '' ) {
1286 wfProfileIn( 'Skin::makeLink' );
1287 $nt = Title
::newFromText( $title );
1289 $result = $this->makeLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1291 wfDebug( 'Invalid title passed to Skin::makeLink(): "'.$title."\"\n" );
1292 $result = $text == "" ?
$title : $text;
1295 wfProfileOut( 'Skin::makeLink' );
1299 function makeKnownLink( $title, $text = '', $query = '', $trail = '', $prefix = '',$aprops = '') {
1300 $nt = Title
::newFromText( $title );
1302 return $this->makeKnownLinkObj( Title
::newFromText( $title ), $text, $query, $trail, $prefix , $aprops );
1304 wfDebug( 'Invalid title passed to Skin::makeKnownLink(): "'.$title."\"\n" );
1305 return $text == '' ?
$title : $text;
1309 function makeBrokenLink( $title, $text = '', $query = '', $trail = '' ) {
1310 $nt = Title
::newFromText( $title );
1312 return $this->makeBrokenLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1314 wfDebug( 'Invalid title passed to Skin::makeBrokenLink(): "'.$title."\"\n" );
1315 return $text == '' ?
$title : $text;
1319 function makeStubLink( $title, $text = '', $query = '', $trail = '' ) {
1320 $nt = Title
::newFromText( $title );
1322 return $this->makeStubLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1324 wfDebug( 'Invalid title passed to Skin::makeStubLink(): "'.$title."\"\n" );
1325 return $text == '' ?
$title : $text;
1330 * Pass a title object, not a title string
1332 function makeLinkObj( &$nt, $text= '', $query = '', $trail = '', $prefix = '' ) {
1333 global $wgOut, $wgUser, $wgLinkHolders;
1334 $fname = 'Skin::makeLinkObj';
1337 if ( ! isset($nt) ) {
1338 # wfDebugDieBacktrace();
1339 return "<!-- ERROR -->{$prefix}{$text}{$trail}";
1342 if ( $nt->isExternal() ) {
1343 $u = $nt->getFullURL();
1344 $link = $nt->getPrefixedURL();
1345 if ( '' == $text ) { $text = $nt->getPrefixedText(); }
1346 $style = $this->getExternalLinkAttributes( $link, $text, 'extiw' );
1349 if ( '' != $trail ) {
1350 if ( preg_match( '/^([a-z]+)(.*)$$/sD', $trail, $m ) ) {
1355 # Assume $this->postParseLinkColour(). This prevents
1356 # interwiki links from being parsed as external links.
1357 global $wgInterwikiLinkHolders;
1358 $t = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>";
1359 $nr = array_push($wgInterwikiLinkHolders, $t);
1360 $retVal = '<!--IWLINK '. ($nr-1) ."-->{$trail}";
1361 } elseif ( 0 == $nt->getNamespace() && "" == $nt->getText() ) {
1362 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1363 } elseif ( ( -1 == $nt->getNamespace() ) ||
1364 ( NS_IMAGE
== $nt->getNamespace() ) ) {
1365 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1367 if ( $this->postParseLinkColour() ) {
1369 if ( '' != $trail ) {
1370 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1376 # Allows wiki to bypass using linkcache, see OutputPage::parseLinkHolders()
1377 $nr = array_push( $wgLinkHolders['namespaces'], $nt->getNamespace() );
1378 $wgLinkHolders['dbkeys'][] = $nt->getDBkey();
1379 $wgLinkHolders['queries'][] = $query;
1380 $wgLinkHolders['texts'][] = $prefix.$text.$inside;
1381 $wgLinkHolders['titles'][] = $nt;
1383 $retVal = '<!--LINK '. ($nr-1) ."-->{$trail}";
1385 # Work out link colour immediately
1386 $aid = $nt->getArticleID() ;
1388 $retVal = $this->makeBrokenLinkObj( $nt, $text, $query, $trail, $prefix );
1390 $threshold = $wgUser->getOption('stubthreshold') ;
1391 if ( $threshold > 0 ) {
1392 $dbr =& wfGetDB( DB_SLAVE
);
1393 $s = $dbr->selectRow( 'cur', array( 'LENGTH(cur_text) AS x', 'cur_namespace',
1394 'cur_is_redirect' ), array( 'cur_id' => $aid ), $fname ) ;
1395 if ( $s !== false ) {
1397 if ( $s->cur_is_redirect
OR $s->cur_namespace
!= 0 ) {
1398 $size = $threshold*2 ; # Really big
1400 $dbr->freeResult( $res );
1402 $size = $threshold*2 ; # Really big
1407 if ( $size < $threshold ) {
1408 $retVal = $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix );
1410 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1419 * Pass a title object, not a title string
1421 function makeKnownLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '' ) {
1422 global $wgOut, $wgTitle, $wgInputEncoding;
1424 $fname = 'Skin::makeKnownLinkObj';
1425 wfProfileIn( $fname );
1427 if ( !is_object( $nt ) ) {
1430 $link = $nt->getPrefixedURL();
1431 # if ( '' != $section && substr($section,0,1) != "#" ) {
1434 if ( '' == $link ) {
1436 if ( '' == $text ) {
1437 $text = htmlspecialchars( $nt->getFragment() );
1440 $u = $nt->escapeLocalURL( $query );
1442 if ( '' != $nt->getFragment() ) {
1443 $anchor = urlencode( do_html_entity_decode( str_replace(' ', '_', $nt->getFragment()), ENT_COMPAT
, $wgInputEncoding ) );
1444 $replacearray = array(
1448 $u .= '#' . str_replace(array_keys($replacearray),array_values($replacearray),$anchor);
1450 if ( '' == $text ) {
1451 $text = htmlspecialchars( $nt->getPrefixedText() );
1453 $style = $this->getInternalLinkAttributesObj( $nt, $text );
1456 if ( '' != $trail ) {
1457 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1462 $r = "<a href=\"{$u}\"{$style}{$aprops}>{$prefix}{$text}{$inside}</a>{$trail}";
1463 wfProfileOut( $fname );
1468 * Pass a title object, not a title string
1470 function makeBrokenLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
1471 global $wgOut, $wgUser;
1474 if ( ! isset($nt) ) {
1475 # wfDebugDieBacktrace();
1476 return "<!-- ERROR -->{$prefix}{$text}{$trail}";
1479 $fname = 'Skin::makeBrokenLinkObj';
1480 wfProfileIn( $fname );
1482 if ( '' == $query ) {
1485 $q = 'action=edit&'.$query;
1487 $u = $nt->escapeLocalURL( $q );
1489 if ( '' == $text ) {
1490 $text = htmlspecialchars( $nt->getPrefixedText() );
1492 $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" );
1495 if ( '' != $trail ) {
1496 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1501 if ( $wgUser->getOption( 'highlightbroken' ) ) {
1502 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
1504 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
1507 wfProfileOut( $fname );
1512 * Pass a title object, not a title string
1514 function makeStubLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
1515 global $wgOut, $wgUser;
1517 $link = $nt->getPrefixedURL();
1519 $u = $nt->escapeLocalURL( $query );
1521 if ( '' == $text ) {
1522 $text = htmlspecialchars( $nt->getPrefixedText() );
1524 $style = $this->getInternalLinkAttributesObj( $nt, $text, 'stub' );
1527 if ( '' != $trail ) {
1528 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1533 if ( $wgUser->getOption( 'highlightbroken' ) ) {
1534 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
1536 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
1541 function makeSelfLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
1542 $u = $nt->escapeLocalURL( $query );
1543 if ( '' == $text ) {
1544 $text = htmlspecialchars( $nt->getPrefixedText() );
1547 if ( '' != $trail ) {
1548 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1553 return "<strong>{$prefix}{$text}{$inside}</strong>{$trail}";
1556 /* these are used extensively in SkinPHPTal, but also some other places */
1557 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1558 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1559 $this->checkTitle($title, $name);
1560 return $title->getLocalURL( $urlaction );
1562 /*static*/ function makeTalkUrl ( $name, $urlaction='' ) {
1563 $title = Title
::newFromText( $name );
1564 $title = $title->getTalkPage();
1565 $this->checkTitle($title, $name);
1566 return $title->getLocalURL( $urlaction );
1568 /*static*/ function makeArticleUrl ( $name, $urlaction='' ) {
1569 $title = Title
::newFromText( $name );
1570 $title= $title->getSubjectPage();
1571 $this->checkTitle($title, $name);
1572 return $title->getLocalURL( $urlaction );
1574 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1575 $title = Title
::newFromText( wfMsgForContent($name) );
1576 $this->checkTitle($title, $name);
1577 return $title->getLocalURL( $urlaction );
1579 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1580 $title = Title
::newFromText( $name );
1581 $this->checkTitle($title, $name);
1582 return $title->getLocalURL( $urlaction );
1585 # If url string starts with http, consider as external URL, else
1587 /*static*/ function makeInternalOrExternalUrl( $name ) {
1588 if ( strncmp( $name, 'http', 4 ) == 0 ) {
1591 return $this->makeUrl( $name );
1595 # this can be passed the NS number as defined in Language.php
1596 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=0 ) {
1597 $title = Title
::makeTitleSafe( $namespace, $name );
1598 $this->checkTitle($title, $name);
1599 return $title->getLocalURL( $urlaction );
1602 /* these return an array with the 'href' and boolean 'exists' */
1603 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1604 $title = Title
::newFromText( $name );
1605 $this->checkTitle($title, $name);
1607 'href' => $title->getLocalURL( $urlaction ),
1608 'exists' => $title->getArticleID() != 0?
true:false
1611 /*static*/ function makeTalkUrlDetails ( $name, $urlaction='' ) {
1612 $title = Title
::newFromText( $name );
1613 $title = $title->getTalkPage();
1614 $this->checkTitle($title, $name);
1616 'href' => $title->getLocalURL( $urlaction ),
1617 'exists' => $title->getArticleID() != 0?
true:false
1620 /*static*/ function makeArticleUrlDetails ( $name, $urlaction='' ) {
1621 $title = Title
::newFromText( $name );
1622 $title= $title->getSubjectPage();
1623 $this->checkTitle($title, $name);
1625 'href' => $title->getLocalURL( $urlaction ),
1626 'exists' => $title->getArticleID() != 0?
true:false
1629 /*static*/ function makeI18nUrlDetails ( $name, $urlaction='' ) {
1630 $title = Title
::newFromText( wfMsgForContent($name) );
1631 $this->checkTitle($title, $name);
1633 'href' => $title->getLocalURL( $urlaction ),
1634 'exists' => $title->getArticleID() != 0?
true:false
1638 # make sure we have some title to operate on
1639 /*static*/ function checkTitle ( &$title, &$name ) {
1640 if(!is_object($title)) {
1641 $title = Title
::newFromText( $name );
1642 if(!is_object($title)) {
1643 $title = Title
::newFromText( '--error: link target missing--' );
1648 function fnamePart( $url ) {
1649 $basename = strrchr( $url, '/' );
1650 if ( false === $basename ) {
1653 $basename = substr( $basename, 1 );
1655 return htmlspecialchars( $basename );
1658 function makeImage( $url, $alt = '' ) {
1662 $alt = $this->fnamePart( $url );
1664 $s = '<img src="'.$url.'" alt="'.$alt.'" />';
1668 function makeImageLink( $name, $url, $alt = '' ) {
1669 $nt = Title
::makeTitleSafe( NS_IMAGE
, $name );
1670 return $this->makeImageLinkObj( $nt, $alt );
1673 function makeImageLinkObj( $nt, $alt = '' ) {
1674 global $wgContLang, $wgUseImageResize;
1675 $img = Image
::newFromTitle( $nt );
1676 $url = $img->getViewURL();
1679 $prefix = $postfix = '';
1681 if ( $wgUseImageResize ) {
1682 # Check if the alt text is of the form "options|alt text"
1684 # * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang
1685 # * left no resizing, just left align. label is used for alt= only
1686 # * right same, but right aligned
1687 # * none same, but not aligned
1688 # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox
1689 # * center center the image
1690 # * framed Keep original image size, no magnify-button.
1692 $part = explode( '|', $alt);
1694 $mwThumb =& MagicWord
::get( MAG_IMG_THUMBNAIL
);
1695 $mwLeft =& MagicWord
::get( MAG_IMG_LEFT
);
1696 $mwRight =& MagicWord
::get( MAG_IMG_RIGHT
);
1697 $mwNone =& MagicWord
::get( MAG_IMG_NONE
);
1698 $mwWidth =& MagicWord
::get( MAG_IMG_WIDTH
);
1699 $mwCenter =& MagicWord
::get( MAG_IMG_CENTER
);
1700 $mwFramed =& MagicWord
::get( MAG_IMG_FRAMED
);
1701 $alt = $part[count($part)-1];
1703 $height = $framed = $thumb = false;
1704 $manual_thumb = "" ;
1706 foreach( $part as $key => $val ) {
1707 $val_parts = explode ( "=" , $val , 2 ) ;
1708 $left_part = array_shift ( $val_parts ) ;
1709 if ( ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) {
1711 } elseif ( count ( $val_parts ) == 1 && ! is_null( $mwThumb->matchVariableStartToEnd($left_part) ) ) {
1712 # use manually specified thumbnail
1714 $manual_thumb = array_shift ( $val_parts ) ;
1715 } elseif ( ! is_null( $mwRight->matchVariableStartToEnd($val) ) ) {
1716 # remember to set an alignment, don't render immediately
1718 } elseif ( ! is_null( $mwLeft->matchVariableStartToEnd($val) ) ) {
1719 # remember to set an alignment, don't render immediately
1721 } elseif ( ! is_null( $mwCenter->matchVariableStartToEnd($val) ) ) {
1722 # remember to set an alignment, don't render immediately
1724 } elseif ( ! is_null( $mwNone->matchVariableStartToEnd($val) ) ) {
1725 # remember to set an alignment, don't render immediately
1727 } elseif ( ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
1728 # $match is the image width in pixels
1729 if ( preg_match( '/^([0-9]*)x([0-9]*)$/', $match, $m ) ) {
1730 $width = intval( $m[1] );
1731 $height = intval( $m[2] );
1733 $width = intval($match);
1735 } elseif ( ! is_null( $mwFramed->matchVariableStartToEnd($val) ) ) {
1739 if ( 'center' == $align )
1741 $prefix = '<div class="center">';
1742 $postfix = '</div>';
1746 if ( $thumb ||
$framed ) {
1748 # Create a thumbnail. Alignment depends on language
1749 # writing direction, # right aligned for left-to-right-
1750 # languages ("Western languages"), left-aligned
1751 # for right-to-left-languages ("Semitic languages")
1753 # If thumbnail width has not been provided, it is set
1754 # here to 180 pixels
1755 if ( $align == '' ) {
1756 $align = $wgContLang->isRTL() ?
'left' : 'right';
1758 if ( ! isset($width) ) {
1761 return $prefix.$this->makeThumbLinkObj( $img, $alt, $align, $width, $height, $framed, $manual_thumb ).$postfix;
1763 } elseif ( isset($width) ) {
1765 # Create a resized image, without the additional thumbnail
1768 if ( ( ! $height === false )
1769 && ( $img->getHeight() * $width / $img->getWidth() > $height ) ) {
1770 $width = $img->getWidth() * $height / $img->getHeight();
1772 if ( '' == $manual_thumb ) $url = $img->createThumb( $width );
1774 } # endif $wgUseImageResize
1776 if ( empty( $alt ) ) {
1777 $alt = preg_replace( '/\.(.+?)^/', '', $img->getName() );
1779 $alt = preg_replace( '/<[^>]*>/', '', $alt );
1780 $alt = preg_replace('/&(?!:amp;|#[Xx][0-9A-fa-f]+;|#[0-9]+;|[a-zA-Z0-9]+;)/', '&', $alt);
1781 $alt = str_replace( array('<', '>', '"'), array('<', '>', '"'), $alt );
1783 $u = $nt->escapeLocalURL();
1784 $uf = $nt->escapeFullURL();
1787 $s = wfMsg( 'missingimage', $img->getName() );
1788 $s .= "<br>{$alt}<br>{$url}<br>\n";
1790 $s = '<a href="'.$u.'" class="image" title="'.$alt.'">' .
1791 '<img src="'.$url.'" alt="'.$alt.'" longdesc="'.$uf.'" /></a>';
1793 if ( '' != $align ) {
1794 $s = "<div class=\"float{$align}\"><span>{$s}</span></div>";
1796 return str_replace("\n", ' ',$prefix.$s.$postfix);
1800 * Make HTML for a thumbnail including image, border and caption
1801 * $img is an Image object
1803 function makeThumbLinkObj( $img, $label = '', $align = 'right', $boxwidth = 180, $boxheight=false, $framed=false , $manual_thumb = "" ) {
1804 global $wgStylePath, $wgContLang;
1805 # $image = Title::makeTitleSafe( NS_IMAGE, $name );
1806 $url = $img->getViewURL();
1808 #$label = htmlspecialchars( $label );
1809 $alt = preg_replace( '/<[^>]*>/', '', $label);
1810 $alt = preg_replace('/&(?!:amp;|#[Xx][0-9A-fa-f]+;|#[0-9]+;|[a-zA-Z0-9]+;)/', '&', $alt);
1811 $alt = str_replace( array('<', '>', '"'), array('<', '>', '"'), $alt );
1813 $width = $height = 0;
1814 if ( $img->exists() )
1816 $width = $img->getWidth();
1817 $height = $img->getHeight();
1819 if ( 0 == $width ||
0 == $height )
1821 $width = $height = 200;
1823 if ( $boxwidth == 0 )
1829 // Use image dimensions, don't scale
1831 $oboxwidth = $boxwidth +
2;
1832 $boxheight = $height;
1835 $h = intval( $height/($width/$boxwidth) );
1836 $oboxwidth = $boxwidth +
2;
1837 if ( ( ! $boxheight === false ) && ( $h > $boxheight ) )
1839 $boxwidth *= $boxheight/$h;
1843 if ( '' == $manual_thumb ) $thumbUrl = $img->createThumb( $boxwidth );
1846 if ( $manual_thumb != '' ) # Use manually specified thumbnail
1848 $manual_title = Title
::makeTitleSafe( NS_IMAGE
, $manual_thumb ); #new Title ( $manual_thumb ) ;
1849 $manual_img = Image
::newFromTitle( $manual_title );
1850 $thumbUrl = $manual_img->getViewURL();
1851 if ( $manual_img->exists() )
1853 $width = $manual_img->getWidth();
1854 $height = $manual_img->getHeight();
1855 $boxwidth = $width ;
1856 $boxheight = $height ;
1857 $oboxwidth = $boxwidth +
2 ;
1861 $u = $img->getEscapeLocalURL();
1862 $uf = $img->getEscapeFullURL();
1864 $more = htmlspecialchars( wfMsg( 'thumbnail-more' ) );
1865 $magnifyalign = $wgContLang->isRTL() ?
'left' : 'right';
1866 $textalign = $wgContLang->isRTL() ?
' style="text-align:right"' : '';
1868 $s = "<div class=\"thumb t{$align}\"><div style=\"width:{$oboxwidth}px;\">";
1869 if ( $thumbUrl == '' ) {
1870 $s .= wfMsg( 'missingimage', $img->getName() );
1873 $s .= '<a href="'.$u.'" class="internal" title="'.$alt.'">'.
1874 '<img src="'.$thumbUrl.'" alt="'.$alt.'" ' .
1875 'width="'.$boxwidth.'" height="'.$boxheight.'" ' .
1876 'longdesc="'.$uf.'" /></a>';
1880 $zoomicon = '<div class="magnify" style="float:'.$magnifyalign.'">'.
1881 '<a href="'.$u.'" class="internal" title="'.$more.'">'.
1882 '<img src="'.$wgStylePath.'/common/images/magnify-clip.png" ' .
1883 'width="15" height="11" alt="'.$more.'" /></a></div>';
1886 $s .= ' <div class="thumbcaption" '.$textalign.'>'.$zoomicon.$label."</div></div></div>";
1887 return str_replace("\n", ' ', $s);
1890 function makeMediaLink( $name, $url, $alt = '' ) {
1891 $nt = Title
::makeTitleSafe( Namespace::getMedia(), $name );
1892 return $this->makeMediaLinkObj( $nt, $alt );
1895 function makeMediaLinkObj( $nt, $alt = '' ) {
1896 if ( ! isset( $nt ) )
1898 ### HOTFIX. Instead of breaking, return empty string.
1901 $name = $nt->getDBKey();
1902 $url = Image
::wfImageUrl( $name );
1903 if ( empty( $alt ) ) {
1904 $alt = preg_replace( '/\.(.+?)^/', '', $name );
1907 $u = htmlspecialchars( $url );
1908 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
1913 function specialLink( $name, $key = '' ) {
1916 if ( '' == $key ) { $key = strtolower( $name ); }
1917 $pn = $wgContLang->ucfirst( $name );
1918 return $this->makeKnownLink( $wgContLang->specialPage( $pn ),
1922 function makeExternalLink( $url, $text, $escape = true ) {
1923 $style = $this->getExternalLinkAttributes( $url, $text );
1924 $url = htmlspecialchars( $url );
1926 $text = htmlspecialchars( $text );
1928 return '<a href="'.$url.'"'.$style.'>'.$text.'</a>';
1931 # Called by history lists and recent changes
1934 # Returns text for the start of the tabular part of RC
1935 function beginRecentChangesList() {
1936 $this->rc_cache
= array() ;
1937 $this->rcMoveIndex
= 0;
1938 $this->rcCacheIndex
= 0 ;
1939 $this->lastdate
= '';
1940 $this->rclistOpen
= false;
1944 function beginImageHistoryList() {
1945 $s = "\n<h2>" . wfMsg( 'imghistory' ) . "</h2>\n" .
1946 "<p>" . wfMsg( 'imghistlegend' ) . "</p>\n".'<ul class="special">';
1951 * Returns text for the end of RC
1952 * If enhanced RC is in use, returns pretty much all the text
1954 function endRecentChangesList() {
1955 $s = $this->recentChangesBlock() ;
1956 if( $this->rclistOpen
) {
1963 * Enhanced RC ungrouped line
1965 function recentChangesBlockLine ( $rcObj ) {
1966 global $wgStylePath, $wgContLang ;
1968 # Get rc_xxxx variables
1969 extract( $rcObj->mAttribs
) ;
1970 $curIdEq = 'curid='.$rc_cur_id;
1975 $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" border="0" />' ;
1978 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
1979 $r .= ' ';
1981 # M & N (minor & new)
1982 $M = wfMsg( 'minoreditletter' );
1983 $N = wfMsg( 'newpageletter' );
1985 if ( $rc_type == RC_NEW
) {
1998 $r .= ' '.$rcObj->timestamp
.' ' ;
2002 $link = $rcObj->link
;
2003 if ( $rcObj->watched
) $link = '<strong>'.$link.'</strong>' ;
2008 $r .= $rcObj->difflink
;
2012 $r .= $this->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' );
2015 $r .= ') . . '.$rcObj->userlink
;
2016 $r .= $rcObj->usertalklink
;
2019 if ( $rc_comment != '' && $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
2020 $rc_comment=$this->formatComment($rc_comment, $rcObj->getTitle());
2021 $r .= $wgContLang->emphasize( ' ('.$rc_comment.')' );
2031 function recentChangesBlockGroup ( $block ) {
2032 global $wgStylePath, $wgContLang ;
2035 $M = wfMsg( 'minoreditletter' );
2036 $N = wfMsg( 'newpageletter' );
2038 # Collate list of users
2040 $userlinks = array () ;
2041 foreach ( $block AS $rcObj ) {
2042 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
2043 if ( $rcObj->mAttribs
['rc_new'] ) $isnew = true ;
2044 $u = $rcObj->userlink
;
2045 if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
2049 # Sort the list and convert to text
2050 krsort ( $userlinks ) ;
2051 asort ( $userlinks ) ;
2053 foreach ( $userlinks as $userlink => $count) {
2055 if ( $count > 1 ) $text .= " ({$count}×)" ;
2056 array_push ( $users , $text ) ;
2058 $users = ' <font size="-1">['.implode('; ',$users).']</font>' ;
2061 $rci = 'RCI'.$this->rcCacheIndex
;
2062 $rcl = 'RCL'.$this->rcCacheIndex
;
2063 $rcm = 'RCM'.$this->rcCacheIndex
;
2064 $toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')" ;
2065 $arrowdir = $wgContLang->isRTL() ?
'l' : 'r';
2066 $tl = '<span id="'.$rcm.'"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_'.$arrowdir.'.png" width="12" height="12" /></a></span>' ;
2067 $tl .= '<span id="'.$rcl.'" style="display:none"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_d.png" width="12" height="12" /></a></span>' ;
2073 if ( $isnew ) $r .= $N ;
2074 else $r .= ' ' ;
2075 $r .= ' ' ; # Minor
2078 $r .= ' '.$block[0]->timestamp
.' ' ;
2082 $link = $block[0]->link
;
2083 if ( $block[0]->watched
) $link = '<strong>'.$link.'</strong>' ;
2086 $curIdEq = 'curid=' . $block[0]->mAttribs
['rc_cur_id'];
2087 if ( $block[0]->mAttribs
['rc_type'] != RC_LOG
) {
2089 $r .= ' ('.count($block).' ' ;
2090 if ( $isnew ) $r .= wfMsg('changes');
2091 else $r .= $this->makeKnownLinkObj( $block[0]->getTitle() , wfMsg('changes') ,
2092 $curIdEq.'&diff=0&oldid='.$oldid ) ;
2096 $r .= $this->makeKnownLinkObj( $block[0]->getTitle(), wfMsg( 'history' ), $curIdEq.'&action=history' );
2104 $r .= '<div id="'.$rci.'" style="display:none">' ;
2105 foreach ( $block AS $rcObj ) {
2106 # Get rc_xxxx variables
2107 extract( $rcObj->mAttribs
);
2109 $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" />';
2110 $r .= '<tt> ' ;
2111 if ( $rc_new ) $r .= $N ;
2112 else $r .= ' ' ;
2113 if ( $rc_minor ) $r .= $M ;
2114 else $r .= ' ' ;
2118 if ( $rc_last_oldid != 0 ) {
2119 $o = 'oldid='.$rc_last_oldid ;
2121 if ( $rc_type == RC_LOG
) {
2122 $link = $rcObj->timestamp
;
2124 $link = $this->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, "{$curIdEq}&$o" ) ;
2126 $link = '<tt>'.$link.'</tt>' ;
2130 $r .= $rcObj->curlink
;
2132 $r .= $rcObj->lastlink
;
2133 $r .= ') . . '.$rcObj->userlink
;
2134 $r .= $rcObj->usertalklink
;
2135 if ( $rc_comment != '' ) {
2136 $rc_comment=$this->formatComment($rc_comment, $rcObj->getTitle());
2137 $r .= $wgContLang->emphasize( ' ('.$rc_comment.')' ) ;
2143 $this->rcCacheIndex++
;
2148 * If enhanced RC is in use, this function takes the previously cached
2149 * RC lines, arranges them, and outputs the HTML
2151 function recentChangesBlock () {
2152 global $wgStylePath ;
2153 if ( count ( $this->rc_cache
) == 0 ) return '' ;
2155 foreach ( $this->rc_cache
AS $secureName => $block ) {
2156 if ( count ( $block ) < 2 ) {
2157 $blockOut .= $this->recentChangesBlockLine ( array_shift ( $block ) ) ;
2159 $blockOut .= $this->recentChangesBlockGroup ( $block ) ;
2163 return '<div>'.$blockOut.'</div>' ;
2167 * Called in a loop over all displayed RC entries
2168 * Either returns the line, or caches it for later use
2170 function recentChangesLine( &$rc, $watched = false ) {
2172 $usenew = $wgUser->getOption( 'usenewrc' );
2174 $line = $this->recentChangesLineNew ( $rc, $watched ) ;
2176 $line = $this->recentChangesLineOld ( $rc, $watched ) ;
2180 function recentChangesLineOld( &$rc, $watched = false ) {
2181 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds, $wgUseRCPatrol, $wgOnlySysopsCanPatrol;
2183 # Extract DB fields into local scope
2184 extract( $rc->mAttribs
);
2185 $curIdEq = 'curid=' . $rc_cur_id;
2187 # Make date header if necessary
2188 $date = $wgContLang->date( $rc_timestamp, true);
2189 $uidate = $wgLang->date( $rc_timestamp, true);
2191 if ( $date != $this->lastdate
) {
2192 if ( '' != $this->lastdate
) { $s .= "</ul>\n"; }
2193 $s .= "<h4>{$uidate}</h4>\n<ul class='special'>";
2194 $this->lastdate
= $date;
2195 $this->rclistOpen
= true;
2198 # If this edit has not yet been patrolled, make it stick out
2199 $s .= ( ! $wgUseRCPatrol ||
$rc_patrolled ) ?
'<li> ' : '<li class="not_patrolled"> ';
2201 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2203 $s .= '(' . wfMsg( 'diff' ) . ') (';
2205 $s .= $this->makeKnownLinkObj( $rc->getMovedToTitle(), wfMsg( 'hist' ), 'action=history' ) .
2208 # "[[x]] moved to [[y]]"
2209 $msg = ( $rc_type == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
2210 $s .= wfMsg( $msg, $this->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
2211 $this->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
2212 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
2214 $logtype = $matches[1];
2215 $logname = LogPage
::logName( $logtype );
2216 $s .= '(' . $this->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
2219 if ( $rc_type == RC_NEW ||
$rc_type == RC_LOG
) {
2220 $diffLink = wfMsg( 'diff' );
2222 if ( $wgUseRCPatrol && $rc_patrolled == 0 && $wgUser->getID() != 0 &&
2223 ( $wgUser->isSysop() ||
!$wgOnlySysopsCanPatrol ) )
2224 $rcidparam = "&rcid={$rc_id}";
2227 $diffLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'diff' ),
2228 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}{$rcidparam}",
2229 '', '', ' tabindex="'.$rc->counter
.'"');
2231 $s .= '('.$diffLink.') (';
2234 $s .= $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' );
2237 # M and N (minor and new)
2238 if ( $rc_minor ) { $s .= ' <span class="minor">'.wfMsg( "minoreditletter" ).'</span>'; }
2239 if ( $rc_type == RC_NEW
) { $s .= '<span class="newpage">'.wfMsg( "newpageletter" ).'</span>'; }
2242 # If it's a new article, there is no diff link, but if it hasn't been
2243 # patrolled yet, we need to give users a way to do so
2244 if ( $wgUseRCPatrol && $rc_type == RC_NEW
&& $rc_patrolled == 0 &&
2245 $wgUser->getID() != 0 && ( $wgUser->isSysop() ||
!$wgOnlySysopsCanPatrol ) )
2246 $articleLink = $this->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
2248 $articleLink = $this->makeKnownLinkObj( $rc->getTitle(), '' );
2251 $articleLink = '<strong>'.$articleLink.'</strong>';
2253 $s .= ' '.$articleLink;
2258 $s .= '; ' . $wgLang->time( $rc_timestamp, true, $wgRCSeconds ) . ' . . ';
2260 # User link (or contributions for unregistered users)
2261 if ( 0 == $rc_user ) {
2262 $userLink = $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
2263 $rc_user_text, 'target=' . $rc_user_text );
2265 $userLink = $this->makeLink( $wgContLang->getNsText( NS_USER
) . ':'.$rc_user_text, $rc_user_text );
2270 $talkname=$wgContLang->getNsText(NS_TALK
); # use the shorter name
2271 global $wgDisableAnonTalk;
2272 if( 0 == $rc_user && $wgDisableAnonTalk ) {
2275 $utns=$wgContLang->getNsText(NS_USER_TALK
);
2276 $userTalkLink= $this->makeLink($utns . ':'.$rc_user_text, $talkname );
2280 if ( ( 0 == $rc_user ) && $wgUser->isSysop() ) {
2281 $blockLink = $this->makeKnownLink( $wgContLang->specialPage(
2282 'Blockip' ), wfMsg( 'blocklink' ), 'ip='.$rc_user_text );
2286 if($userTalkLink) $userTalkLink .= ' | ';
2287 $userTalkLink .= $blockLink;
2289 if($userTalkLink) $s.=' ('.$userTalkLink.')';
2292 if ( '' != $rc_comment && '*' != $rc_comment && $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
2293 $rc_comment=$this->formatComment($rc_comment,$rc->getTitle());
2294 $s .= $wgContLang->emphasize(' (' . $rc_comment . ')');
2301 function recentChangesLineNew( &$baseRC, $watched = false ) {
2302 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds;
2304 # Create a specialised object
2305 $rc = RCCacheEntry
::newFromParent( $baseRC ) ;
2307 # Extract fields from DB into the function scope (rc_xxxx variables)
2308 extract( $rc->mAttribs
);
2309 $curIdEq = 'curid=' . $rc_cur_id;
2311 # If it's a new day, add the headline and flush the cache
2312 $date = $wgContLang->date( $rc_timestamp, true);
2313 $uidate = $wgLang->date( $rc_timestamp, true);
2315 if ( $date != $this->lastdate
) {
2316 # Process current cache
2317 $ret = $this->recentChangesBlock () ;
2318 $this->rc_cache
= array() ;
2319 $ret .= "<h4>{$uidate}</h4>\n";
2320 $this->lastdate
= $date;
2324 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2325 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
2326 $clink = wfMsg( $msg, $this->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
2327 $this->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
2328 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
2330 $logtype = $matches[1];
2331 $logname = LogPage
::logName( $logtype );
2332 $clink = '(' . $this->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
2334 $clink = $this->makeKnownLinkObj( $rc->getTitle(), '' ) ;
2337 $time = $wgContLang->time( $rc_timestamp, true, $wgRCSeconds );
2338 $rc->watched
= $watched ;
2339 $rc->link
= $clink ;
2340 $rc->timestamp
= $time;
2342 # Make "cur" and "diff" links
2343 if ( ( $rc_type == RC_NEW
&& $rc_this_oldid == 0 ) ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2344 $curLink = wfMsg( 'cur' );
2345 $diffLink = wfMsg( 'diff' );
2347 $query = $curIdEq.'&diff=0&oldid='.$rc_this_oldid;
2348 $aprops = ' tabindex="'.$baseRC->counter
.'"';
2349 $curLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'cur' ), $query, '' ,'' , $aprops );
2350 $diffLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'diff'), $query, '' ,'' , $aprops );
2354 $titleObj = $rc->getTitle();
2355 if ( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2356 $lastLink = wfMsg( 'last' );
2358 $lastLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'last' ),
2359 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid );
2362 # Make user link (or user contributions for unregistered users)
2363 if ( $rc_user == 0 ) {
2364 $userLink = $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
2365 $rc_user_text, 'target=' . $rc_user_text );
2367 $userLink = $this->makeLink( $wgContLang->getNsText(
2368 Namespace::getUser() ) . ':'.$rc_user_text, $rc_user_text );
2371 $rc->userlink
= $userLink;
2372 $rc->lastlink
= $lastLink;
2373 $rc->curlink
= $curLink;
2374 $rc->difflink
= $diffLink;
2376 # Make user talk link
2377 $utns=$wgContLang->getNsText(NS_USER_TALK
);
2378 $talkname=$wgContLang->getNsText(NS_TALK
); # use the shorter name
2379 $userTalkLink= $this->makeLink($utns . ':'.$rc_user_text, $talkname );
2381 global $wgDisableAnonTalk;
2382 if ( ( 0 == $rc_user ) && $wgUser->isSysop() ) {
2383 $blockLink = $this->makeKnownLink( $wgContLang->specialPage(
2384 'Blockip' ), wfMsg( 'blocklink' ), 'ip='.$rc_user_text );
2385 if( $wgDisableAnonTalk )
2386 $rc->usertalklink
= ' ('.$blockLink.')';
2388 $rc->usertalklink
= ' ('.$userTalkLink.' | '.$blockLink.')';
2390 if( $wgDisableAnonTalk && ($rc_user == 0) )
2391 $rc->usertalklink
= '';
2393 $rc->usertalklink
= ' ('.$userTalkLink.')';
2396 # Put accumulated information into the cache, for later display
2397 # Page moves go on their own line
2398 $title = $rc->getTitle();
2399 $secureName = $title->getPrefixedDBkey();
2400 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2401 # Use an @ character to prevent collision with page names
2402 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
2404 if ( !isset ( $this->rc_cache
[$secureName] ) ) $this->rc_cache
[$secureName] = array() ;
2405 array_push ( $this->rc_cache
[$secureName] , $rc ) ;
2410 function endImageHistoryList() {
2416 * This function is called by all recent changes variants, by the page history,
2417 * and by the user contributions list. It is responsible for formatting edit
2418 * comments. It escapes any HTML in the comment, but adds some CSS to format
2419 * auto-generated comments (from section editing) and formats [[wikilinks]].
2421 * The &$title parameter must be a title OBJECT. It is used to generate a
2422 * direct link to the section in the autocomment.
2423 * @author Erik Moeller <moeller@scireview.de>
2425 * Note: there's not always a title to pass to this function.
2426 * Since you can't set a default parameter for a reference, I've turned it
2427 * temporarily to a value pass. Should be adjusted further. --brion
2429 function formatComment($comment, $title = NULL) {
2431 $comment = htmlspecialchars( $comment );
2433 # The pattern for autogen comments is / * foo * /, which makes for
2435 # We look for all comments, match any text before and after the comment,
2436 # add a separator where needed and format the comment itself with CSS
2437 while (preg_match('/(.*)\/\*\s*(.*?)\s*\*\/(.*)/', $comment,$match)) {
2445 # This is hackish but should work in most cases.
2446 $section=str_replace('[[','',$section);
2447 $section=str_replace(']]','',$section);
2448 $title->mFragment
=$section;
2449 $link=$this->makeKnownLinkObj($title,wfMsg('sectionlink'));
2453 if($pre) { $auto = $sep.' '.$auto; }
2454 if($post) { $auto .= ' '.$sep; }
2455 $auto='<span class="autocomment">'.$auto.'</span>';
2456 $comment=$pre.$auto.$post;
2459 # format regular and media links - all other wiki formatting
2461 $medians = $wgContLang->getNsText(Namespace::getMedia()).':';
2462 while(preg_match('/\[\[(.*?)(\|(.*?))*\]\](.*)$/',$comment,$match)) {
2463 # Handle link renaming [[foo|text]] will show link as "text"
2464 if( "" != $match[3] ) {
2469 if( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) {
2470 # Media link; trail not supported.
2471 $linkRegexp = '/\[\[(.*?)\]\]/';
2472 $thelink = $this->makeMediaLink( $submatch[1], "", $text );
2474 # Other kind of link
2475 if( preg_match( wfMsgForContent( "linktrail" ), $match[4], $submatch ) ) {
2476 $trail = $submatch[1];
2480 $linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/';
2481 if ($match[1][0] == ':')
2482 $match[1] = substr($match[1], 1);
2483 $thelink = $this->makeLink( $match[1], $text, "", $trail );
2485 $comment = preg_replace( $linkRegexp, $thelink, $comment, 1 );
2490 function imageHistoryLine( $iscur, $timestamp, $img, $user, $usertext, $size, $description ) {
2491 global $wgUser, $wgLang, $wgContLang, $wgTitle;
2493 $datetime = $wgLang->timeanddate( $timestamp, true );
2494 $del = wfMsg( 'deleteimg' );
2495 $delall = wfMsg( 'deleteimgcompletely' );
2496 $cur = wfMsg( 'cur' );
2499 $url = Image
::wfImageUrl( $img );
2501 if ( $wgUser->isSysop() ) {
2502 $link = $wgTitle->escapeLocalURL( 'image=' . $wgTitle->getPartialURL() .
2504 $style = $this->getInternalLinkAttributes( $link, $delall );
2506 $dlink = '<a href="'.$link.'"'.$style.'>'.$delall.'</a>';
2511 $url = htmlspecialchars( wfImageArchiveUrl( $img ) );
2512 if( $wgUser->getID() != 0 && $wgTitle->userCanEdit() ) {
2513 $rlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
2514 wfMsg( 'revertimg' ), 'action=revert&oldimage=' .
2515 urlencode( $img ) );
2516 $dlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
2517 $del, 'action=delete&oldimage=' . urlencode( $img ) );
2519 # Having live active links for non-logged in users
2520 # means that bots and spiders crawling our site can
2521 # inadvertently change content. Baaaad idea.
2522 $rlink = wfMsg( 'revertimg' );
2527 $userlink = $usertext;
2529 $userlink = $this->makeLink( $wgContLang->getNsText( Namespace::getUser() ) .
2530 ':'.$usertext, $usertext );
2532 $nbytes = wfMsg( 'nbytes', $size );
2533 $style = $this->getInternalLinkAttributes( $url, $datetime );
2535 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$datetime}</a>"
2536 . " . . {$userlink} ({$nbytes})";
2538 if ( '' != $description && '*' != $description ) {
2539 $sk=$wgUser->getSkin();
2540 $s .= $wgContLang->emphasize(' (' . $sk->formatComment($description,$wgTitle) . ')');
2546 function tocIndent($level) {
2547 return str_repeat( '<div class="tocindent">'."\n", $level>0 ?
$level : 0 );
2550 function tocUnindent($level) {
2551 return str_repeat( "</div>\n", $level>0 ?
$level : 0 );
2555 * parameter level defines if we are on an indentation level
2557 function tocLine( $anchor, $tocline, $level ) {
2558 $link = '<a href="#'.$anchor.'">'.$tocline.'</a><br />';
2562 return '<div class="tocline">'.$link."</div>\n";
2567 function tocTable($toc) {
2568 # note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
2569 # try min-width & co when somebody gets a chance
2570 $hideline = ' <script type="text/javascript">showTocToggle("' . addslashes( wfMsg('showtoc') ) . '","' . addslashes( wfMsg('hidetoc') ) . '")</script>';
2572 '<table border="0" id="toc"><tr id="toctitle"><td align="center">'."\n".
2573 '<b>'.wfMsg('toc').'</b>' .
2575 '</td></tr><tr id="tocinside"><td>'."\n".
2576 $toc."</td></tr></table>\n";
2580 * These two do not check for permissions: check $wgTitle->userCanEdit
2581 * before calling them
2583 function editSectionScriptForOther( $title, $section, $head ) {
2584 $ttl = Title
::newFromText( $title );
2585 $url = $ttl->escapeLocalURL( 'action=edit§ion='.$section );
2586 return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
2589 function editSectionScript( $section, $head ) {
2590 global $wgTitle, $wgRequest;
2591 if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
2594 $url = $wgTitle->escapeLocalURL( 'action=edit§ion='.$section );
2595 return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
2598 function editSectionLinkForOther( $title, $section ) {
2600 global $wgUser, $wgContLang;
2602 $title = Title
::newFromText($title);
2603 $editurl = '§ion='.$section;
2604 $url = $this->makeKnownLink($title->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
2606 if( $wgContLang->isRTL() ) {
2608 $nearside = 'right';
2613 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
2617 function editSectionLink( $section ) {
2619 global $wgTitle, $wgUser, $wgContLang;
2621 if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
2622 # Section edit links would be out of sync on an old page.
2623 # But, if we're diffing to the current page, they'll be
2628 $editurl = '§ion='.$section;
2629 $url = $this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
2631 if( $wgContLang->isRTL() ) {
2633 $nearside = 'right';
2638 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
2643 * This function is called by EditPage.php and shows a bulletin board style
2644 * toolbar for common editing functions. It can be disabled in the user
2646 * The necessary JavaScript code can be found in style/wikibits.js.
2648 function getEditToolbar() {
2649 global $wgStylePath, $wgLang, $wgMimeType;
2652 * toolarray an array of arrays which each include the filename of
2653 * the button image (without path), the opening tag, the closing tag,
2654 * and optionally a sample text that is inserted between the two when no
2655 * selection is highlighted.
2656 * The tip text is shown when the user moves the mouse over the button.
2658 * Already here are accesskeys (key), which are not used yet until someone
2659 * can figure out a way to make them work in IE. However, we should make
2660 * sure these keys are not defined on the edit page.
2663 array( 'image'=>'button_bold.png',
2665 'close' => "\'\'\'",
2666 'sample'=> wfMsg('bold_sample'),
2667 'tip' => wfMsg('bold_tip'),
2670 array( 'image'=>'button_italic.png',
2673 'sample'=> wfMsg('italic_sample'),
2674 'tip' => wfMsg('italic_tip'),
2677 array( 'image'=>'button_link.png',
2680 'sample'=> wfMsg('link_sample'),
2681 'tip' => wfMsg('link_tip'),
2684 array( 'image'=>'button_extlink.png',
2687 'sample'=> wfMsg('extlink_sample'),
2688 'tip' => wfMsg('extlink_tip'),
2691 array( 'image'=>'button_headline.png',
2693 'close' => " ==\\n",
2694 'sample'=> wfMsg('headline_sample'),
2695 'tip' => wfMsg('headline_tip'),
2698 array( 'image'=>'button_image.png',
2699 'open' => '[['.$wgLang->getNsText(NS_IMAGE
).":",
2701 'sample'=> wfMsg('image_sample'),
2702 'tip' => wfMsg('image_tip'),
2705 array( 'image' => 'button_media.png',
2706 'open' => '[['.$wgLang->getNsText(NS_MEDIA
).':',
2708 'sample'=> wfMsg('media_sample'),
2709 'tip' => wfMsg('media_tip'),
2712 array( 'image' => 'button_math.png',
2713 'open' => "\\<math\\>",
2714 'close' => "\\</math\\>",
2715 'sample'=> wfMsg('math_sample'),
2716 'tip' => wfMsg('math_tip'),
2719 array( 'image' => 'button_nowiki.png',
2720 'open' => "\\<nowiki\\>",
2721 'close' => "\\</nowiki\\>",
2722 'sample'=> wfMsg('nowiki_sample'),
2723 'tip' => wfMsg('nowiki_tip'),
2726 array( 'image' => 'button_sig.png',
2730 'tip' => wfMsg('sig_tip'),
2733 array( 'image' => 'button_hr.png',
2734 'open' => "\\n----\\n",
2737 'tip' => wfMsg('hr_tip'),
2741 $toolbar ="<script type='text/javascript'>\n/*<![CDATA[*/\n";
2743 $toolbar.="document.writeln(\"<div id='toolbar'>\");\n";
2744 foreach($toolarray as $tool) {
2746 $image=$wgStylePath.'/common/images/'.$tool['image'];
2747 $open=$tool['open'];
2748 $close=$tool['close'];
2749 $sample = addslashes( $tool['sample'] );
2751 // Note that we use the tip both for the ALT tag and the TITLE tag of the image.
2752 // Older browsers show a "speedtip" type message only for ALT.
2753 // Ideally these should be different, realistically they
2754 // probably don't need to be.
2755 $tip = addslashes( $tool['tip'] );
2757 #$key = $tool["key"];
2759 $toolbar.="addButton('$image','$tip','$open','$close','$sample');\n";
2762 $toolbar.="addInfobox('" . addslashes( wfMsg( "infobox" ) ) . "','" . addslashes(wfMsg("infobox_alert")) . "');\n";
2763 $toolbar.="document.writeln(\"</div>\");\n";
2765 $toolbar.="/*]]>*/\n</script>";
2772 function suppressUrlExpansion() {