10 * This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
12 if( defined( "MEDIAWIKI" ) ) {
15 require_once( 'Image.php' );
17 # These are the INTERNAL names, which get mapped directly to class names and
18 # file names in ./skins/. For display purposes, the Language class has
19 # internationalized names
22 $wgValidSkinNames = array(
23 'standard' => 'Standard',
24 'nostalgia' => 'Nostalgia',
25 'cologneblue' => 'CologneBlue'
28 #$wgValidSkinNames[] = 'PHPTal';
29 #$wgValidSkinNames['davinci'] = 'DaVinci';
30 #$wgValidSkinNames['mono'] = 'Mono';
31 #$wgValidSkinNames['monobookminimal'] = 'MonoBookMinimal';
32 $wgValidSkinNames['monobook'] = 'MonoBook';
33 $wgValidSkinNames['myskin'] = 'MySkin';
34 $wgValidSkinNames['chick'] = 'Chick';
38 # Get a list of all skins available in /skins/
39 # Build using the regular expression '^(.*).php$'
40 # Array keys are all lower case, array value keep the case used by filename
43 $skinDir = dir($IP.'/skins');
45 # while code from www.php.net
46 while (false !== ($file = $skinDir->read())) {
47 if(preg_match('/^(.*).php$/',$file, $matches)) {
49 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
55 require_once( 'RecentChange.php' );
57 global $wgLinkHolders;
58 $wgLinkHolders = array(
59 'namespaces' => array(),
65 global $wgInterwikiLinkHolders;
66 $wgInterwikiLinkHolders = array();
72 class RCCacheEntry
extends RecentChange
74 var $secureName, $link;
75 var $curlink , $difflink, $lastlink , $usertalklink , $versionlink ;
76 var $userlink, $timestamp, $watched;
78 function newFromParent( $rc )
80 $rc2 = new RCCacheEntry
;
81 $rc2->mAttribs
= $rc->mAttribs
;
82 $rc2->mExtra
= $rc->mExtra
;
89 * The main skin class that provide methods and properties for all other skins
90 * including PHPTal skins.
91 * This base class is also the "Standard" skin.
98 var $lastdate, $lastline;
99 var $linktrail ; # linktrail regexp
100 var $rc_cache ; # Cache for Enhanced Recent Changes
101 var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle
103 var $postParseLinkColour = false;
107 $this->linktrail
= wfMsg('linktrail');
110 function getSkinNames() {
111 global $wgValidSkinNames;
112 return $wgValidSkinNames;
115 function getStylesheet() {
116 return 'common/wikistandard.css';
119 function getSkinName() {
124 * Get/set accessor for delayed link colouring
126 function postParseLinkColour( $setting = NULL ) {
127 return wfSetVar( $this->postParseLinkColour
, $setting );
130 function qbSetting() {
131 global $wgOut, $wgUser;
133 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
134 $q = $wgUser->getOption( 'quickbar' );
135 if ( '' == $q ) { $q = 0; }
139 function initPage( &$out ) {
140 $fname = 'Skin::initPage';
141 wfProfileIn( $fname );
143 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => '/favicon.ico' ) );
145 $this->addMetadataLinks($out);
147 wfProfileOut( $fname );
150 function addMetadataLinks( &$out ) {
151 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf, $wgRdfMimeType, $action;
152 global $wgRightsPage, $wgRightsUrl;
154 if( $out->isArticleRelated() ) {
155 # note: buggy CC software only reads first "meta" link
156 if( $wgEnableCreativeCommonsRdf ) {
157 $out->addMetadataLink( array(
158 'title' => 'Creative Commons',
159 'type' => 'application/rdf+xml',
160 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
162 if( $wgEnableDublinCoreRdf ) {
163 $out->addMetadataLink( array(
164 'title' => 'Dublin Core',
165 'type' => 'application/rdf+xml',
166 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
170 if( $wgRightsPage ) {
171 $copy = Title
::newFromText( $wgRightsPage );
173 $copyright = $copy->getLocalURL();
176 if( !$copyright && $wgRightsUrl ) {
177 $copyright = $wgRightsUrl;
180 $out->addLink( array(
181 'rel' => 'copyright',
182 'href' => $copyright ) );
186 function outputPage( &$out ) {
187 global $wgDebugComments;
189 wfProfileIn( 'Skin::outputPage' );
190 $this->initPage( $out );
191 $out->out( $out->headElement() );
193 $out->out( "\n<body" );
194 $ops = $this->getBodyOptions();
195 foreach ( $ops as $name => $val ) {
196 $out->out( " $name='$val'" );
199 if ( $wgDebugComments ) {
200 $out->out( "<!-- Wiki debugging output:\n" .
201 $out->mDebugtext
. "-->\n" );
203 $out->out( $this->beforeContent() );
205 $out->out( $out->mBodytext
. "\n" );
207 $out->out( $this->afterContent() );
210 $out->out( $out->reportTime() );
212 $out->out( "\n</body></html>" );
215 function getHeadScripts() {
216 global $wgStylePath, $wgUser, $wgContLang, $wgAllowUserJs;
217 $r = "<script type=\"text/javascript\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
218 if( $wgAllowUserJs && $wgUser->getID() != 0 ) { # logged in
219 $userpage = $wgContLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
220 $userjs = htmlspecialchars($this->makeUrl($userpage.'/'.$this->getSkinName().'.js', 'action=raw&ctype=text/javascript'));
221 $r .= '<script type="text/javascript" src="'.$userjs."\"></script>\n";
226 # get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way)
227 function getUserStylesheet() {
228 global $wgOut, $wgStylePath, $wgContLang, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
229 $sheet = $this->getStylesheet();
230 $action = $wgRequest->getText('action');
231 $s = "@import \"$wgStylePath/$sheet\";\n";
232 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css\";\n";
233 if( $wgAllowUserCss && $wgUser->getID() != 0 ) { # logged in
234 if($wgTitle->isCssSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) {
235 $s .= $wgRequest->getText('wpTextbox1');
237 $userpage = $wgContLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
238 $s.= '@import "'.$this->makeUrl($userpage.'/'.$this->getSkinName().'.css', 'action=raw&ctype=text/css').'";'."\n";
241 $s .= $this->doGetUserStyles();
246 * placeholder, returns generated js in monobook
248 function getUserJs() { return; }
251 * Return html code that include User stylesheets
253 function getUserStyles() {
254 global $wgOut, $wgStylePath, $wgLang;
255 $s = "<style type='text/css'>\n";
256 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
257 $s .= $this->getUserStylesheet();
258 $s .= "/*]]>*/ /* */\n";
264 * Some styles that are set by user through the user settings interface.
266 function doGetUserStyles() {
267 global $wgUser, $wgContLang;
269 $csspage = $wgContLang->getNsText( NS_MEDIAWIKI
) . ':' . $this->getSkinName() . '.css';
270 $s = '@import "'.$this->makeUrl($csspage, 'action=raw&ctype=text/css')."\";\n";
272 if ( 1 == $wgUser->getOption( 'underline' ) ) {
273 # Don't override browser settings
277 $s .= "a { text-decoration: none; }\n";
279 if ( 1 == $wgUser->getOption( 'highlightbroken' ) ) {
280 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
282 if ( 1 == $wgUser->getOption( 'justify' ) ) {
283 $s .= "#article { text-align: justify; }\n";
288 function getBodyOptions() {
289 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
291 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
293 if ( 0 != $wgTitle->getNamespace() ) {
294 $a = array( 'bgcolor' => '#ffffec' );
296 else $a = array( 'bgcolor' => '#FFFFFF' );
297 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
298 (!$wgTitle->isProtected() ||
$wgUser->isAllowed('protect')) ) {
299 $t = wfMsg( 'editthispage' );
301 if ( !empty($redirect) && $redirect == 'no' ) {
302 $red = "&redirect={$redirect}";
304 if ( !empty($oldid) && ! isset( $diff ) ) {
305 $oid = "&oldid=" . IntVal( $oldid );
307 $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
308 $s = 'document.location = "' .$s .'";';
309 $a +
= array ('ondblclick' => $s);
312 $a['onload'] = $wgOut->getOnloadHandler();
316 function getExternalLinkAttributes( $link, $text, $class='' ) {
317 global $wgUser, $wgOut, $wgContLang;
319 $same = ($link == $text);
320 $link = urldecode( $link );
321 $link = $wgContLang->checkTitleEncoding( $link );
322 $link = str_replace( '_', ' ', $link );
323 $link = htmlspecialchars( $link );
325 $r = ($class != '') ?
" class='$class'" : " class='external'";
327 if ( !$same && $wgUser->getOption( 'hover' ) ) {
328 $r .= " title=\"{$link}\"";
333 function getInternalLinkAttributes( $link, $text, $broken = false ) {
334 global $wgUser, $wgOut;
336 $link = urldecode( $link );
337 $link = str_replace( '_', ' ', $link );
338 $link = htmlspecialchars( $link );
340 if ( $broken == 'stub' ) {
341 $r = ' class="stub"';
342 } else if ( $broken == 'yes' ) {
348 if ( 1 == $wgUser->getOption( 'hover' ) ) {
349 $r .= " title=\"{$link}\"";
355 * @param bool $broken
357 function getInternalLinkAttributesObj( &$nt, $text, $broken = false ) {
358 global $wgUser, $wgOut;
360 if ( $broken == 'stub' ) {
361 $r = ' class="stub"';
362 } else if ( $broken == 'yes' ) {
368 if ( 1 == $wgUser->getOption( 'hover' ) ) {
369 $r .= ' title="' . $nt->getEscapedText() . '"';
383 * This will be called immediately after the <body> tag. Split into
384 * two functions to make it easier to subclass.
386 function beforeContent() {
387 global $wgUser, $wgOut;
389 return $this->doBeforeContent();
392 function doBeforeContent() {
393 global $wgUser, $wgOut, $wgTitle, $wgContLang, $wgSiteNotice;
394 $fname = 'Skin::doBeforeContent';
395 wfProfileIn( $fname );
398 $qb = $this->qbSetting();
400 if( $langlinks = $this->otherLanguages() ) {
406 $borderhack = 'class="top"';
409 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
410 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
413 $left = ($qb == 1 ||
$qb == 3);
414 if($wgContLang->isRTL()) $left = !$left;
417 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
418 $this->logoText() . '</td>';
420 $s .= $this->getQuickbarCompensator( $rows );
422 $l = $wgContLang->isRTL() ?
'right' : 'left';
423 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
425 $s .= $this->topLinks() ;
426 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
428 $r = $wgContLang->isRTL() ?
"left" : "right";
429 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
430 $s .= $this->nameAndLogin();
431 $s .= "\n<br />" . $this->searchForm() . "</td>";
434 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
437 if ( $shove && !$left ) { # Right
438 $s .= $this->getQuickbarCompensator( $rows );
440 $s .= "</tr>\n</table>\n</div>\n";
441 $s .= "\n<div id='article'>\n";
443 if( $wgSiteNotice ) {
444 $s .= "\n<div id='siteNotice'>$wgSiteNotice</div>\n";
446 $s .= $this->pageTitle();
447 $s .= $this->pageSubtitle() ;
448 $s .= $this->getCategories();
449 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 $disclaimer = $this->disclaimerLink(); # may be empty
549 $s .= ' | ' . $disclaimer;
552 if ( $wgOut->isArticleRelated() ) {
553 if ( $wgTitle->getNamespace() == Namespace::getImage() ) {
554 $name = $wgTitle->getDBkey();
555 $link = htmlspecialchars( Image
::wfImageUrl( $name ) );
556 $style = $this->getInternalLinkAttributes( $link, $name );
557 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
559 # This will show the "Approve" link if $wgUseApproval=true;
560 if ( isset ( $wgUseApproval ) && $wgUseApproval )
562 $t = $wgTitle->getDBkey();
563 $name = 'Approve this article' ;
564 $link = "http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ;
565 #htmlspecialchars( wfImageUrl( $name ) );
566 $style = $this->getExternalLinkAttributes( $link, $name );
567 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>" ;
570 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
571 $s .= ' | ' . $this->makeKnownLink( $wgTitle->getPrefixedText(),
572 wfMsg( 'currentrev' ) );
575 if ( $wgUser->getNewtalk() ) {
576 # do not show "You have new messages" text when we are viewing our
579 if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 &&
580 $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) {
581 $n =$wgUser->getName();
582 $tl = $this->makeKnownLink( $wgContLang->getNsText(
583 Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
584 wfMsg('newmessageslink') );
585 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
587 $wgOut->setSquidMaxage(0);
588 $wgOut->enableClientCache(false);
592 $undelete = $this->getUndeleteLink();
593 if( !empty( $undelete ) ) {
594 $s .= ' | '.$undelete;
599 function getUndeleteLink() {
600 global $wgUser, $wgTitle, $wgContLang, $action;
601 if( $wgUser->isAllowed('rollback') &&
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($wgTitle, 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 ( $wgTitle->getArticleId() ) {
806 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
807 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
808 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
810 $s .= "<br />\n" . $this->otherLanguages();
815 function pageStats() {
816 global $wgOut, $wgLang, $wgArticle, $wgRequest;
817 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax;
819 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
820 if ( ! $wgOut->isArticle() ) { return ''; }
821 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
822 if ( 0 == $wgArticle->getID() ) { return ''; }
825 if ( !$wgDisableCounters ) {
826 $count = $wgLang->formatNum( $wgArticle->getCount() );
828 $s = wfMsg( 'viewcount', $count );
832 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
833 require_once("Credits.php");
834 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
836 $s .= $this->lastModified();
839 return $s . ' ' . $this->getCopyright();
842 function getCopyright() {
843 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
846 $oldid = $wgRequest->getVal( 'oldid' );
847 $diff = $wgRequest->getVal( 'diff' );
849 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
850 $msg = 'history_copyright';
856 if( $wgRightsPage ) {
857 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
858 } elseif( $wgRightsUrl ) {
859 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
864 $out .= wfMsgForContent( $msg, $link );
868 function getCopyrightIcon() {
869 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon;
871 if( $wgRightsIcon ) {
872 $icon = htmlspecialchars( $wgRightsIcon );
874 $url = htmlspecialchars( $wgRightsUrl );
875 $out .= '<a href="'.$url.'">';
877 $text = htmlspecialchars( $wgRightsText );
878 $out .= "<img src=\"$icon\" alt='$text' />";
886 function getPoweredBy() {
888 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
889 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
893 function lastModified() {
894 global $wgLang, $wgArticle;
896 $timestamp = $wgArticle->getTimestamp();
898 $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true );
899 $s = ' ' . wfMsg( 'lastmodified', $d );
906 function logoText( $align = '' ) {
907 if ( '' != $align ) { $a = " align='{$align}'"; }
910 $mp = wfMsg( 'mainpage' );
911 $titleObj = Title
::newFromText( $mp );
912 if ( is_object( $titleObj ) ) {
913 $url = $titleObj->escapeLocalURL();
918 $logourl = $this->getLogo();
919 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
923 function specialPagesList() {
924 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript;
925 require_once('SpecialPage.php');
927 $pages = SpecialPage
::getPages();
929 foreach ( $pages[''] as $name => $page ) {
930 $a[$name] = $page->getDescription();
932 if ( $wgUser->isSysop() )
934 foreach ( $pages['sysop'] as $name => $page ) {
935 $a[$name] = $page->getDescription();
938 if ( $wgUser->isDeveloper() )
940 foreach ( $pages['developer'] as $name => $page ) {
941 $a[$name] = $page->getDescription() ;
945 $sp = wfMsg( 'specialpages' );
946 $spp = $wgContLang->specialPage( 'Specialpages' );
948 $s = '<form id="specialpages" method="get" class="inline" ' .
949 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
950 $s .= "<select name=\"wpDropdown\">\n";
951 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
953 foreach ( $a as $name => $desc ) {
954 $p = $wgContLang->specialPage( $name );
955 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
958 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
963 function mainPageLink() {
964 $mp = wfMsgForContent( 'mainpage' );
965 $mptxt = wfMsg( 'mainpage');
966 $s = $this->makeKnownLink( $mp, $mptxt );
970 function copyrightLink() {
971 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
972 wfMsg( 'copyrightpagename' ) );
976 function aboutLink() {
977 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
978 wfMsg( 'aboutsite' ) );
983 function disclaimerLink() {
984 $disclaimers = wfMsg( 'disclaimers' );
985 if ($disclaimers == '-') {
988 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
993 function editThisPage() {
994 global $wgOut, $wgTitle, $wgRequest;
996 $oldid = $wgRequest->getVal( 'oldid' );
997 $diff = $wgRequest->getVal( 'diff' );
998 $redirect = $wgRequest->getVal( 'redirect' );
1000 if ( ! $wgOut->isArticleRelated() ) {
1001 $s = wfMsg( 'protectedpage' );
1003 $n = $wgTitle->getPrefixedText();
1004 if ( $wgTitle->userCanEdit() ) {
1005 $t = wfMsg( 'editthispage' );
1007 #$t = wfMsg( "protectedpage" );
1008 $t = wfMsg( 'viewsource' );
1012 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
1013 if ( $oldid && ! isset( $diff ) ) {
1014 $oid = '&oldid='.$oldid;
1016 $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
1021 function deleteThisPage() {
1022 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1024 $diff = $wgRequest->getVal( 'diff' );
1025 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1026 $n = $wgTitle->getPrefixedText();
1027 $t = wfMsg( 'deletethispage' );
1029 $s = $this->makeKnownLink( $n, $t, 'action=delete' );
1036 function protectThisPage() {
1037 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1039 $diff = $wgRequest->getVal( 'diff' );
1040 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1041 $n = $wgTitle->getPrefixedText();
1043 if ( $wgTitle->isProtected() ) {
1044 $t = wfMsg( 'unprotectthispage' );
1045 $q = 'action=unprotect';
1047 $t = wfMsg( 'protectthispage' );
1048 $q = 'action=protect';
1050 $s = $this->makeKnownLink( $n, $t, $q );
1057 function watchThisPage() {
1058 global $wgUser, $wgOut, $wgTitle;
1060 if ( $wgOut->isArticleRelated() ) {
1061 $n = $wgTitle->getPrefixedText();
1063 if ( $wgTitle->userIsWatching() ) {
1064 $t = wfMsg( 'unwatchthispage' );
1065 $q = 'action=unwatch';
1067 $t = wfMsg( 'watchthispage' );
1068 $q = 'action=watch';
1070 $s = $this->makeKnownLink( $n, $t, $q );
1072 $s = wfMsg( 'notanarticle' );
1077 function moveThisPage() {
1078 global $wgTitle, $wgContLang;
1080 if ( $wgTitle->userCanEdit() ) {
1081 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Movepage' ),
1082 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1083 } // no message if page is protected - would be redundant
1087 function historyLink() {
1090 $s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
1091 wfMsg( 'history' ), 'action=history' );
1095 function whatLinksHere() {
1096 global $wgTitle, $wgContLang;
1098 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Whatlinkshere' ),
1099 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1103 function userContribsLink() {
1104 global $wgTitle, $wgContLang;
1106 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
1107 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1111 function emailUserLink() {
1112 global $wgTitle, $wgContLang;
1114 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Emailuser' ),
1115 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1119 function watchPageLinksLink() {
1120 global $wgOut, $wgTitle, $wgContLang;
1122 if ( ! $wgOut->isArticleRelated() ) {
1123 $s = '(' . wfMsg( 'notanarticle' ) . ')';
1125 $s = $this->makeKnownLink( $wgContLang->specialPage(
1126 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1127 'target=' . $wgTitle->getPrefixedURL() );
1132 function otherLanguages() {
1133 global $wgOut, $wgContLang, $wgTitle, $wgUseNewInterlanguage;
1135 $a = $wgOut->getLanguageLinks();
1136 if ( 0 == count( $a ) ) {
1137 if ( !$wgUseNewInterlanguage ) return '';
1138 $ns = $wgContLang->getNsIndex ( $wgTitle->getNamespace () ) ;
1139 if ( $ns != 0 AND $ns != 1 ) return '' ;
1141 $x = 'mode=addlink&xt='.$wgTitle->getDBkey() ;
1142 return $this->makeKnownLink( $wgContLang->specialPage( $pn ),
1143 wfMsg( 'intl' ) , $x );
1146 if ( !$wgUseNewInterlanguage ) {
1147 $s = wfMsg( 'otherlanguages' ) . ': ';
1149 global $wgContLanguageCode ;
1150 $x = 'mode=zoom&xt='.$wgTitle->getDBkey() ;
1151 $x .= '&xl='.$wgContLanguageCode ;
1152 $s = $this->makeKnownLink( $wgContLang->specialPage( 'Intl' ),
1153 wfMsg( 'otherlanguages' ) , $x ) . ': ' ;
1156 $s = wfMsg( 'otherlanguages' ) . ': ';
1158 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1159 foreach( $a as $l ) {
1160 if ( ! $first ) { $s .= ' | '; }
1163 $nt = Title
::newFromText( $l );
1164 $url = $nt->getFullURL();
1165 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1167 if ( '' == $text ) { $text = $l; }
1168 $style = $this->getExternalLinkAttributes( $l, $text );
1169 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1171 if($wgContLang->isRTL()) $s .= '</span>';
1175 function bugReportsLink() {
1176 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1177 wfMsg( 'bugreports' ) );
1181 function dateLink() {
1182 global $wgLinkCache;
1183 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1184 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1186 $wgLinkCache->suspend();
1187 $id = $t1->getArticleID();
1188 $wgLinkCache->resume();
1191 $s = $this->makeBrokenLink( $t1->getText() );
1193 $s = $this->makeKnownLink( $t1->getText() );
1197 $wgLinkCache->suspend();
1198 $id = $t2->getArticleID();
1199 $wgLinkCache->resume();
1202 $s .= $this->makeBrokenLink( $t2->getText() );
1204 $s .= $this->makeKnownLink( $t2->getText() );
1209 function talkLink() {
1210 global $wgContLang, $wgTitle, $wgLinkCache;
1212 $tns = $wgTitle->getNamespace();
1213 if ( -1 == $tns ) { return ''; }
1215 $pn = $wgTitle->getText();
1216 $tp = wfMsg( 'talkpage' );
1217 if ( Namespace::isTalk( $tns ) ) {
1218 $lns = Namespace::getSubject( $tns );
1221 $text = wfMsg('articlepage');
1224 $text = wfMsg('userpage');
1227 $text = wfMsg('wikipediapage');
1230 $text = wfMsg('imagepage');
1233 $text= wfMsg('articlepage');
1237 $lns = Namespace::getTalk( $tns );
1240 $n = $wgContLang->getNsText( $lns );
1241 if ( '' == $n ) { $link = $pn; }
1242 else { $link = $n.':'.$pn; }
1244 $wgLinkCache->suspend();
1245 $s = $this->makeLink( $link, $text );
1246 $wgLinkCache->resume();
1251 function commentLink() {
1252 global $wgContLang, $wgTitle, $wgLinkCache;
1254 $tns = $wgTitle->getNamespace();
1255 if ( -1 == $tns ) { return ''; }
1257 $lns = ( Namespace::isTalk( $tns ) ) ?
$tns : Namespace::getTalk( $tns );
1259 # assert Namespace::isTalk( $lns )
1261 $n = $wgContLang->getNsText( $lns );
1262 $pn = $wgTitle->getText();
1266 $wgLinkCache->suspend();
1267 $s = $this->makeKnownLink($link, wfMsg('postcomment'), 'action=edit§ion=new');
1268 $wgLinkCache->resume();
1274 * After all the page content is transformed into HTML, it makes
1275 * a final pass through here for things like table backgrounds.
1276 * @todo probably deprecated [AV]
1278 function transformContent( $text ) {
1283 * Note: This function MUST call getArticleID() on the link,
1284 * otherwise the cache won't get updated properly. See LINKCACHE.DOC.
1286 function makeLink( $title, $text = '', $query = '', $trail = '' ) {
1287 wfProfileIn( 'Skin::makeLink' );
1288 $nt = Title
::newFromText( $title );
1290 $result = $this->makeLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1292 wfDebug( 'Invalid title passed to Skin::makeLink(): "'.$title."\"\n" );
1293 $result = $text == "" ?
$title : $text;
1296 wfProfileOut( 'Skin::makeLink' );
1300 function makeKnownLink( $title, $text = '', $query = '', $trail = '', $prefix = '',$aprops = '') {
1301 $nt = Title
::newFromText( $title );
1303 return $this->makeKnownLinkObj( Title
::newFromText( $title ), $text, $query, $trail, $prefix , $aprops );
1305 wfDebug( 'Invalid title passed to Skin::makeKnownLink(): "'.$title."\"\n" );
1306 return $text == '' ?
$title : $text;
1310 function makeBrokenLink( $title, $text = '', $query = '', $trail = '' ) {
1311 $nt = Title
::newFromText( $title );
1313 return $this->makeBrokenLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1315 wfDebug( 'Invalid title passed to Skin::makeBrokenLink(): "'.$title."\"\n" );
1316 return $text == '' ?
$title : $text;
1320 function makeStubLink( $title, $text = '', $query = '', $trail = '' ) {
1321 $nt = Title
::newFromText( $title );
1323 return $this->makeStubLinkObj( Title
::newFromText( $title ), $text, $query, $trail );
1325 wfDebug( 'Invalid title passed to Skin::makeStubLink(): "'.$title."\"\n" );
1326 return $text == '' ?
$title : $text;
1331 * Pass a title object, not a title string
1333 function makeLinkObj( &$nt, $text= '', $query = '', $trail = '', $prefix = '' ) {
1334 global $wgOut, $wgUser, $wgLinkHolders;
1335 $fname = 'Skin::makeLinkObj';
1338 if ( ! isset($nt) ) {
1339 # wfDebugDieBacktrace();
1340 return "<!-- ERROR -->{$prefix}{$text}{$trail}";
1343 if ( $nt->isExternal() ) {
1344 $u = $nt->getFullURL();
1345 $link = $nt->getPrefixedURL();
1346 if ( '' == $text ) { $text = $nt->getPrefixedText(); }
1347 $style = $this->getExternalLinkAttributes( $link, $text, 'extiw' );
1350 if ( '' != $trail ) {
1351 if ( preg_match( '/^([a-z]+)(.*)$$/sD', $trail, $m ) ) {
1356 # Assume $this->postParseLinkColour(). This prevents
1357 # interwiki links from being parsed as external links.
1358 global $wgInterwikiLinkHolders;
1359 $t = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>";
1360 $nr = array_push($wgInterwikiLinkHolders, $t);
1361 $retVal = '<!--IWLINK '. ($nr-1) ."-->{$trail}";
1362 } elseif ( 0 == $nt->getNamespace() && "" == $nt->getText() ) {
1363 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1364 } elseif ( ( -1 == $nt->getNamespace() ) ||
1365 ( NS_IMAGE
== $nt->getNamespace() ) ) {
1366 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1368 if ( $this->postParseLinkColour() ) {
1370 if ( '' != $trail ) {
1371 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1377 # Allows wiki to bypass using linkcache, see OutputPage::parseLinkHolders()
1378 $nr = array_push( $wgLinkHolders['namespaces'], $nt->getNamespace() );
1379 $wgLinkHolders['dbkeys'][] = $nt->getDBkey();
1380 $wgLinkHolders['queries'][] = $query;
1381 $wgLinkHolders['texts'][] = $prefix.$text.$inside;
1382 $wgLinkHolders['titles'][] = $nt;
1384 $retVal = '<!--LINK '. ($nr-1) ."-->{$trail}";
1386 # Work out link colour immediately
1387 $aid = $nt->getArticleID() ;
1389 $retVal = $this->makeBrokenLinkObj( $nt, $text, $query, $trail, $prefix );
1391 $threshold = $wgUser->getOption('stubthreshold') ;
1392 if ( $threshold > 0 ) {
1393 $dbr =& wfGetDB( DB_SLAVE
);
1394 $s = $dbr->selectRow( 'cur', array( 'LENGTH(cur_text) AS x', 'cur_namespace',
1395 'cur_is_redirect' ), array( 'cur_id' => $aid ), $fname ) ;
1396 if ( $s !== false ) {
1398 if ( $s->cur_is_redirect
OR $s->cur_namespace
!= 0 ) {
1399 $size = $threshold*2 ; # Really big
1401 $dbr->freeResult( $res );
1403 $size = $threshold*2 ; # Really big
1408 if ( $size < $threshold ) {
1409 $retVal = $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix );
1411 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
1420 * Pass a title object, not a title string
1422 function makeKnownLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '' ) {
1423 global $wgOut, $wgTitle, $wgInputEncoding;
1425 $fname = 'Skin::makeKnownLinkObj';
1426 wfProfileIn( $fname );
1428 if ( !is_object( $nt ) ) {
1431 $link = $nt->getPrefixedURL();
1432 # if ( '' != $section && substr($section,0,1) != "#" ) {
1435 if ( '' == $link ) {
1437 if ( '' == $text ) {
1438 $text = htmlspecialchars( $nt->getFragment() );
1441 $u = $nt->escapeLocalURL( $query );
1443 if ( '' != $nt->getFragment() ) {
1444 $anchor = urlencode( do_html_entity_decode( str_replace(' ', '_', $nt->getFragment()), ENT_COMPAT
, $wgInputEncoding ) );
1445 $replacearray = array(
1449 $u .= '#' . str_replace(array_keys($replacearray),array_values($replacearray),$anchor);
1451 if ( '' == $text ) {
1452 $text = htmlspecialchars( $nt->getPrefixedText() );
1454 $style = $this->getInternalLinkAttributesObj( $nt, $text );
1457 if ( '' != $trail ) {
1458 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1463 $r = "<a href=\"{$u}\"{$style}{$aprops}>{$prefix}{$text}{$inside}</a>{$trail}";
1464 wfProfileOut( $fname );
1469 * Pass a title object, not a title string
1471 function makeBrokenLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
1472 global $wgOut, $wgUser;
1475 if ( ! isset($nt) ) {
1476 # wfDebugDieBacktrace();
1477 return "<!-- ERROR -->{$prefix}{$text}{$trail}";
1480 $fname = 'Skin::makeBrokenLinkObj';
1481 wfProfileIn( $fname );
1483 if ( '' == $query ) {
1486 $q = 'action=edit&'.$query;
1488 $u = $nt->escapeLocalURL( $q );
1490 if ( '' == $text ) {
1491 $text = htmlspecialchars( $nt->getPrefixedText() );
1493 $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" );
1496 if ( '' != $trail ) {
1497 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1502 if ( $wgUser->getOption( 'highlightbroken' ) ) {
1503 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
1505 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
1508 wfProfileOut( $fname );
1513 * Pass a title object, not a title string
1515 function makeStubLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
1516 global $wgOut, $wgUser;
1518 $link = $nt->getPrefixedURL();
1520 $u = $nt->escapeLocalURL( $query );
1522 if ( '' == $text ) {
1523 $text = htmlspecialchars( $nt->getPrefixedText() );
1525 $style = $this->getInternalLinkAttributesObj( $nt, $text, 'stub' );
1528 if ( '' != $trail ) {
1529 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1534 if ( $wgUser->getOption( 'highlightbroken' ) ) {
1535 $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
1537 $s = "{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
1542 function makeSelfLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
1543 $u = $nt->escapeLocalURL( $query );
1544 if ( '' == $text ) {
1545 $text = htmlspecialchars( $nt->getPrefixedText() );
1548 if ( '' != $trail ) {
1549 if ( preg_match( $this->linktrail
, $trail, $m ) ) {
1554 return "<strong>{$prefix}{$text}{$inside}</strong>{$trail}";
1557 /* these are used extensively in SkinPHPTal, but also some other places */
1558 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1559 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1560 $this->checkTitle($title, $name);
1561 return $title->getLocalURL( $urlaction );
1563 /*static*/ function makeTalkUrl ( $name, $urlaction='' ) {
1564 $title = Title
::newFromText( $name );
1565 $title = $title->getTalkPage();
1566 $this->checkTitle($title, $name);
1567 return $title->getLocalURL( $urlaction );
1569 /*static*/ function makeArticleUrl ( $name, $urlaction='' ) {
1570 $title = Title
::newFromText( $name );
1571 $title= $title->getSubjectPage();
1572 $this->checkTitle($title, $name);
1573 return $title->getLocalURL( $urlaction );
1575 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1576 $title = Title
::newFromText( wfMsgForContent($name) );
1577 $this->checkTitle($title, $name);
1578 return $title->getLocalURL( $urlaction );
1580 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1581 $title = Title
::newFromText( $name );
1582 $this->checkTitle($title, $name);
1583 return $title->getLocalURL( $urlaction );
1586 # If url string starts with http, consider as external URL, else
1588 /*static*/ function makeInternalOrExternalUrl( $name ) {
1589 if ( strncmp( $name, 'http', 4 ) == 0 ) {
1592 return $this->makeUrl( $name );
1596 # this can be passed the NS number as defined in Language.php
1597 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=0 ) {
1598 $title = Title
::makeTitleSafe( $namespace, $name );
1599 $this->checkTitle($title, $name);
1600 return $title->getLocalURL( $urlaction );
1603 /* these return an array with the 'href' and boolean 'exists' */
1604 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1605 $title = Title
::newFromText( $name );
1606 $this->checkTitle($title, $name);
1608 'href' => $title->getLocalURL( $urlaction ),
1609 'exists' => $title->getArticleID() != 0?
true:false
1612 /*static*/ function makeTalkUrlDetails ( $name, $urlaction='' ) {
1613 $title = Title
::newFromText( $name );
1614 $title = $title->getTalkPage();
1615 $this->checkTitle($title, $name);
1617 'href' => $title->getLocalURL( $urlaction ),
1618 'exists' => $title->getArticleID() != 0?
true:false
1621 /*static*/ function makeArticleUrlDetails ( $name, $urlaction='' ) {
1622 $title = Title
::newFromText( $name );
1623 $title= $title->getSubjectPage();
1624 $this->checkTitle($title, $name);
1626 'href' => $title->getLocalURL( $urlaction ),
1627 'exists' => $title->getArticleID() != 0?
true:false
1630 /*static*/ function makeI18nUrlDetails ( $name, $urlaction='' ) {
1631 $title = Title
::newFromText( wfMsgForContent($name) );
1632 $this->checkTitle($title, $name);
1634 'href' => $title->getLocalURL( $urlaction ),
1635 'exists' => $title->getArticleID() != 0?
true:false
1639 # make sure we have some title to operate on
1640 /*static*/ function checkTitle ( &$title, &$name ) {
1641 if(!is_object($title)) {
1642 $title = Title
::newFromText( $name );
1643 if(!is_object($title)) {
1644 $title = Title
::newFromText( '--error: link target missing--' );
1649 function fnamePart( $url ) {
1650 $basename = strrchr( $url, '/' );
1651 if ( false === $basename ) {
1654 $basename = substr( $basename, 1 );
1656 return htmlspecialchars( $basename );
1659 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 # Check if the alt text is of the form "options|alt text"
1683 # * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang
1684 # * left no resizing, just left align. label is used for alt= only
1685 # * right same, but right aligned
1686 # * none same, but not aligned
1687 # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox
1688 # * center center the image
1689 # * framed Keep original image size, no magnify-button.
1691 $part = explode( '|', $alt);
1693 $mwThumb =& MagicWord
::get( MAG_IMG_THUMBNAIL
);
1694 $mwLeft =& MagicWord
::get( MAG_IMG_LEFT
);
1695 $mwRight =& MagicWord
::get( MAG_IMG_RIGHT
);
1696 $mwNone =& MagicWord
::get( MAG_IMG_NONE
);
1697 $mwWidth =& MagicWord
::get( MAG_IMG_WIDTH
);
1698 $mwCenter =& MagicWord
::get( MAG_IMG_CENTER
);
1699 $mwFramed =& MagicWord
::get( MAG_IMG_FRAMED
);
1702 $height = $framed = $thumb = false;
1703 $manual_thumb = "" ;
1705 foreach( $part as $key => $val ) {
1706 $val_parts = explode ( "=" , $val , 2 ) ;
1707 $left_part = array_shift ( $val_parts ) ;
1708 if ( $wgUseImageResize && ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) {
1710 } elseif ( $wgUseImageResize && count ( $val_parts ) == 1 && ! is_null( $mwThumb->matchVariableStartToEnd($left_part) ) ) {
1711 # use manually specified thumbnail
1713 $manual_thumb = array_shift ( $val_parts ) ;
1714 } elseif ( ! is_null( $mwRight->matchVariableStartToEnd($val) ) ) {
1715 # remember to set an alignment, don't render immediately
1717 } elseif ( ! is_null( $mwLeft->matchVariableStartToEnd($val) ) ) {
1718 # remember to set an alignment, don't render immediately
1720 } elseif ( ! is_null( $mwCenter->matchVariableStartToEnd($val) ) ) {
1721 # remember to set an alignment, don't render immediately
1723 } elseif ( ! is_null( $mwNone->matchVariableStartToEnd($val) ) ) {
1724 # remember to set an alignment, don't render immediately
1726 } elseif ( $wgUseImageResize && ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
1727 # $match is the image width in pixels
1728 if ( preg_match( '/^([0-9]*)x([0-9]*)$/', $match, $m ) ) {
1729 $width = intval( $m[1] );
1730 $height = intval( $m[2] );
1732 $width = intval($match);
1734 } elseif ( ! is_null( $mwFramed->matchVariableStartToEnd($val) ) ) {
1740 if ( 'center' == $align )
1742 $prefix = '<div class="center">';
1743 $postfix = '</div>';
1747 if ( $thumb ||
$framed ) {
1749 # Create a thumbnail. Alignment depends on language
1750 # writing direction, # right aligned for left-to-right-
1751 # languages ("Western languages"), left-aligned
1752 # for right-to-left-languages ("Semitic languages")
1754 # If thumbnail width has not been provided, it is set
1755 # here to 180 pixels
1756 if ( $align == '' ) {
1757 $align = $wgContLang->isRTL() ?
'left' : 'right';
1759 if ( ! isset($width) ) {
1762 return $prefix.$this->makeThumbLinkObj( $img, $alt, $align, $width, $height, $framed, $manual_thumb ).$postfix;
1764 } elseif ( isset($width) ) {
1766 # Create a resized image, without the additional thumbnail
1769 if ( ( ! $height === false )
1770 && ( $img->getHeight() * $width / $img->getWidth() > $height ) ) {
1771 $width = $img->getWidth() * $height / $img->getHeight();
1773 if ( '' == $manual_thumb ) $url = $img->createThumb( $width );
1776 $alt = preg_replace( '/<[^>]*>/', '', $alt );
1777 $alt = preg_replace('/&(?!:amp;|#[Xx][0-9A-fa-f]+;|#[0-9]+;|[a-zA-Z0-9]+;)/', '&', $alt);
1778 $alt = str_replace( array('<', '>', '"'), array('<', '>', '"'), $alt );
1780 $u = $nt->escapeLocalURL();
1782 $s = wfMsg( 'missingimage', $img->getName() );
1783 $s .= "<br>{$alt}<br>{$url}<br>\n";
1785 $s = '<a href="'.$u.'" class="image" title="'.$alt.'">' .
1786 '<img src="'.$url.'" alt="'.$alt.'" longdesc="'.$u.'" /></a>';
1788 if ( '' != $align ) {
1789 $s = "<div class=\"float{$align}\"><span>{$s}</span></div>";
1791 return str_replace("\n", ' ',$prefix.$s.$postfix);
1795 * Make HTML for a thumbnail including image, border and caption
1796 * $img is an Image object
1798 function makeThumbLinkObj( $img, $label = '', $align = 'right', $boxwidth = 180, $boxheight=false, $framed=false , $manual_thumb = "" ) {
1799 global $wgStylePath, $wgContLang;
1800 # $image = Title::makeTitleSafe( NS_IMAGE, $name );
1801 $url = $img->getViewURL();
1803 #$label = htmlspecialchars( $label );
1804 $alt = preg_replace( '/<[^>]*>/', '', $label);
1805 $alt = preg_replace('/&(?!:amp;|#[Xx][0-9A-fa-f]+;|#[0-9]+;|[a-zA-Z0-9]+;)/', '&', $alt);
1806 $alt = str_replace( array('<', '>', '"'), array('<', '>', '"'), $alt );
1808 $width = $height = 0;
1809 if ( $img->exists() )
1811 $width = $img->getWidth();
1812 $height = $img->getHeight();
1814 if ( 0 == $width ||
0 == $height )
1816 $width = $height = 200;
1818 if ( $boxwidth == 0 )
1824 // Use image dimensions, don't scale
1826 $oboxwidth = $boxwidth +
2;
1827 $boxheight = $height;
1830 $h = intval( $height/($width/$boxwidth) );
1831 $oboxwidth = $boxwidth +
2;
1832 if ( ( ! $boxheight === false ) && ( $h > $boxheight ) )
1834 $boxwidth *= $boxheight/$h;
1838 if ( '' == $manual_thumb ) $thumbUrl = $img->createThumb( $boxwidth );
1841 if ( $manual_thumb != '' ) # Use manually specified thumbnail
1843 $manual_title = Title
::makeTitleSafe( NS_IMAGE
, $manual_thumb ); #new Title ( $manual_thumb ) ;
1844 $manual_img = Image
::newFromTitle( $manual_title );
1845 $thumbUrl = $manual_img->getViewURL();
1846 if ( $manual_img->exists() )
1848 $width = $manual_img->getWidth();
1849 $height = $manual_img->getHeight();
1850 $boxwidth = $width ;
1851 $boxheight = $height ;
1852 $oboxwidth = $boxwidth +
2 ;
1856 $u = $img->getEscapeLocalURL();
1858 $more = htmlspecialchars( wfMsg( 'thumbnail-more' ) );
1859 $magnifyalign = $wgContLang->isRTL() ?
'left' : 'right';
1860 $textalign = $wgContLang->isRTL() ?
' style="text-align:right"' : '';
1862 $s = "<div class=\"thumb t{$align}\"><div style=\"width:{$oboxwidth}px;\">";
1863 if ( $thumbUrl == '' ) {
1864 $s .= wfMsg( 'missingimage', $img->getName() );
1867 $s .= '<a href="'.$u.'" class="internal" title="'.$alt.'">'.
1868 '<img src="'.$thumbUrl.'" alt="'.$alt.'" ' .
1869 'width="'.$boxwidth.'" height="'.$boxheight.'" ' .
1870 'longdesc="'.$u.'" /></a>';
1874 $zoomicon = '<div class="magnify" style="float:'.$magnifyalign.'">'.
1875 '<a href="'.$u.'" class="internal" title="'.$more.'">'.
1876 '<img src="'.$wgStylePath.'/common/images/magnify-clip.png" ' .
1877 'width="15" height="11" alt="'.$more.'" /></a></div>';
1880 $s .= ' <div class="thumbcaption" '.$textalign.'>'.$zoomicon.$label."</div></div></div>";
1881 return str_replace("\n", ' ', $s);
1884 function makeMediaLink( $name, $url, $alt = '' ) {
1885 $nt = Title
::makeTitleSafe( NS_IMAGE
, $name );
1886 return $this->makeMediaLinkObj( $nt, $alt );
1889 function makeMediaLinkObj( $nt, $alt = '', $nourl=false ) {
1890 if ( ! isset( $nt ) )
1892 ### HOTFIX. Instead of breaking, return empty string.
1895 $name = $nt->getDBKey();
1896 $img = Image
::newFromTitle( $nt );
1897 $url = $img->getURL();
1898 # $nourl can be set by the parser
1899 # this is a hack to mask absolute URLs, so the parser doesn't
1900 # linkify them (it is currently not context-aware)
1902 if ($nourl) { $url=str_replace("http://","http-noparse://",$url) ; }
1903 if ( empty( $alt ) ) {
1904 $alt = preg_replace( '/\.(.+?)^/', '', $name );
1906 $u = htmlspecialchars( $url );
1907 $s = "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
1912 function specialLink( $name, $key = '' ) {
1915 if ( '' == $key ) { $key = strtolower( $name ); }
1916 $pn = $wgContLang->ucfirst( $name );
1917 return $this->makeKnownLink( $wgContLang->specialPage( $pn ),
1921 function makeExternalLink( $url, $text, $escape = true ) {
1922 $style = $this->getExternalLinkAttributes( $url, $text );
1923 $url = htmlspecialchars( $url );
1925 $text = htmlspecialchars( $text );
1927 return '<a href="'.$url.'"'.$style.'>'.$text.'</a>';
1930 # Called by history lists and recent changes
1933 # Returns text for the start of the tabular part of RC
1934 function beginRecentChangesList() {
1935 $this->rc_cache
= array() ;
1936 $this->rcMoveIndex
= 0;
1937 $this->rcCacheIndex
= 0 ;
1938 $this->lastdate
= '';
1939 $this->rclistOpen
= false;
1943 function beginImageHistoryList() {
1944 $s = "\n<h2>" . wfMsg( 'imghistory' ) . "</h2>\n" .
1945 "<p>" . wfMsg( 'imghistlegend' ) . "</p>\n".'<ul class="special">';
1950 * Returns text for the end of RC
1951 * If enhanced RC is in use, returns pretty much all the text
1953 function endRecentChangesList() {
1954 $s = $this->recentChangesBlock() ;
1955 if( $this->rclistOpen
) {
1962 * Enhanced RC ungrouped line
1964 function recentChangesBlockLine ( $rcObj ) {
1965 global $wgStylePath, $wgContLang ;
1967 # Get rc_xxxx variables
1968 extract( $rcObj->mAttribs
) ;
1969 $curIdEq = 'curid='.$rc_cur_id;
1974 $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" border="0" />' ;
1977 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
1978 $r .= ' ';
1981 $M = wfMsg( 'minoreditletter' );
1982 $N = wfMsg( 'newpageletter' );
1984 if ( $rc_type == RC_NEW
) {
1994 if ( $rcObj->unpatrolled
) {
2002 $r .= ' '.$rcObj->timestamp
.' ' ;
2006 $link = $rcObj->link
;
2007 if ( $rcObj->watched
) $link = '<strong>'.$link.'</strong>' ;
2012 $r .= $rcObj->difflink
;
2016 $r .= $this->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' );
2019 $r .= ') . . '.$rcObj->userlink
;
2020 $r .= $rcObj->usertalklink
;
2023 if ( $rc_comment != '' && $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
2024 $rc_comment=$this->formatComment($rc_comment, $rcObj->getTitle());
2025 $r .= $wgContLang->emphasize( ' ('.$rc_comment.')' );
2035 function recentChangesBlockGroup ( $block ) {
2036 global $wgStylePath, $wgContLang ;
2039 $M = wfMsg( 'minoreditletter' );
2040 $N = wfMsg( 'newpageletter' );
2042 # Collate list of users
2044 $unpatrolled = false;
2045 $userlinks = array () ;
2046 foreach ( $block AS $rcObj ) {
2047 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
2048 if ( $rcObj->mAttribs
['rc_new'] ) {
2051 $u = $rcObj->userlink
;
2052 if ( !isset ( $userlinks[$u] ) ) {
2053 $userlinks[$u] = 0 ;
2055 if ( $rcObj->unpatrolled
) {
2056 $unpatrolled = true;
2061 # Sort the list and convert to text
2062 krsort ( $userlinks ) ;
2063 asort ( $userlinks ) ;
2065 foreach ( $userlinks as $userlink => $count) {
2067 if ( $count > 1 ) $text .= " ({$count}×)" ;
2068 array_push ( $users , $text ) ;
2070 $users = ' <font size="-1">['.implode('; ',$users).']</font>' ;
2073 $rci = 'RCI'.$this->rcCacheIndex
;
2074 $rcl = 'RCL'.$this->rcCacheIndex
;
2075 $rcm = 'RCM'.$this->rcCacheIndex
;
2076 $toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')" ;
2077 $arrowdir = $wgContLang->isRTL() ?
'l' : 'r';
2078 $tl = '<span id="'.$rcm.'"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_'.$arrowdir.'.png" width="12" height="12" alt="+" /></a></span>' ;
2079 $tl .= '<span id="'.$rcl.'" style="display:none"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_d.png" width="12" height="12" alt="-" /></a></span>' ;
2085 if ( $isnew ) $r .= $N ;
2086 else $r .= ' ' ;
2087 $r .= ' ' ; # Minor
2088 if ( $unpatrolled ) {
2095 $r .= ' '.$block[0]->timestamp
.' ' ;
2099 $link = $block[0]->link
;
2100 if ( $block[0]->watched
) $link = '<strong>'.$link.'</strong>' ;
2103 $curIdEq = 'curid=' . $block[0]->mAttribs
['rc_cur_id'];
2104 if ( $block[0]->mAttribs
['rc_type'] != RC_LOG
) {
2106 $r .= ' ('.count($block).' ' ;
2107 if ( $isnew ) $r .= wfMsg('changes');
2108 else $r .= $this->makeKnownLinkObj( $block[0]->getTitle() , wfMsg('changes') ,
2109 $curIdEq.'&diff=0&oldid='.$oldid ) ;
2113 $r .= $this->makeKnownLinkObj( $block[0]->getTitle(), wfMsg( 'history' ), $curIdEq.'&action=history' );
2121 $r .= '<div id="'.$rci.'" style="display:none">' ;
2122 foreach ( $block AS $rcObj ) {
2123 # Get rc_xxxx variables
2124 extract( $rcObj->mAttribs
);
2126 $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" />';
2127 $r .= '<tt> ' ;
2140 if ( $rcObj->unpatrolled
) {
2146 $r .= ' </tt>' ;
2149 if ( $rc_last_oldid != 0 ) {
2150 $o = 'oldid='.$rc_last_oldid ;
2152 if ( $rc_type == RC_LOG
) {
2153 $link = $rcObj->timestamp
;
2155 $link = $this->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, "{$curIdEq}&$o" ) ;
2157 $link = '<tt>'.$link.'</tt>' ;
2161 $r .= $rcObj->curlink
;
2163 $r .= $rcObj->lastlink
;
2164 $r .= ') . . '.$rcObj->userlink
;
2165 $r .= $rcObj->usertalklink
;
2166 if ( $rc_comment != '' ) {
2167 $rc_comment=$this->formatComment($rc_comment, $rcObj->getTitle());
2168 $r .= $wgContLang->emphasize( ' ('.$rc_comment.')' ) ;
2174 $this->rcCacheIndex++
;
2179 * If enhanced RC is in use, this function takes the previously cached
2180 * RC lines, arranges them, and outputs the HTML
2182 function recentChangesBlock () {
2183 global $wgStylePath ;
2184 if ( count ( $this->rc_cache
) == 0 ) return '' ;
2186 foreach ( $this->rc_cache
AS $secureName => $block ) {
2187 if ( count ( $block ) < 2 ) {
2188 $blockOut .= $this->recentChangesBlockLine ( array_shift ( $block ) ) ;
2190 $blockOut .= $this->recentChangesBlockGroup ( $block ) ;
2194 return '<div>'.$blockOut.'</div>' ;
2198 * Called in a loop over all displayed RC entries
2199 * Either returns the line, or caches it for later use
2201 function recentChangesLine( &$rc, $watched = false ) {
2203 $usenew = $wgUser->getOption( 'usenewrc' );
2205 $line = $this->recentChangesLineNew ( $rc, $watched ) ;
2207 $line = $this->recentChangesLineOld ( $rc, $watched ) ;
2211 function recentChangesLineOld( &$rc, $watched = false ) {
2212 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds, $wgUseRCPatrol, $wgOnlySysopsCanPatrol;
2214 # Extract DB fields into local scope
2215 extract( $rc->mAttribs
);
2216 $curIdEq = 'curid=' . $rc_cur_id;
2218 # Should patrol-related stuff be shown?
2219 $unpatrolled = $wgUseRCPatrol && $wgUser->getID() != 0 &&
2220 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') ) && $rc_patrolled == 0;
2222 # Make date header if necessary
2223 $date = $wgContLang->date( $rc_timestamp, true);
2224 $uidate = $wgLang->date( $rc_timestamp, true);
2226 if ( $date != $this->lastdate
) {
2227 if ( '' != $this->lastdate
) { $s .= "</ul>\n"; }
2228 $s .= "<h4>{$uidate}</h4>\n<ul class=\"special\">";
2229 $this->lastdate
= $date;
2230 $this->rclistOpen
= true;
2235 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2237 $s .= '(' . wfMsg( 'diff' ) . ') (';
2239 $s .= $this->makeKnownLinkObj( $rc->getMovedToTitle(), wfMsg( 'hist' ), 'action=history' ) .
2242 # "[[x]] moved to [[y]]"
2243 $msg = ( $rc_type == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
2244 $s .= wfMsg( $msg, $this->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
2245 $this->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
2246 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
2248 $logtype = $matches[1];
2249 $logname = LogPage
::logName( $logtype );
2250 $s .= '(' . $this->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
2253 if ( $rc_type == RC_NEW ||
$rc_type == RC_LOG
) {
2254 $diffLink = wfMsg( 'diff' );
2257 $rcidparam = "&rcid={$rc_id}";
2260 $diffLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'diff' ),
2261 "{$curIdEq}&diff={$rc_this_oldid}&oldid={$rc_last_oldid}{$rcidparam}",
2262 '', '', ' tabindex="'.$rc->counter
.'"');
2264 $s .= '('.$diffLink.') (';
2267 $s .= $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' );
2270 # M, N and ! (minor, new and unpatrolled)
2271 if ( $rc_minor ) { $s .= ' <span class="minor">'.wfMsg( "minoreditletter" ).'</span>'; }
2272 if ( $rc_type == RC_NEW
) { $s .= '<span class="newpage">'.wfMsg( "newpageletter" ).'</span>'; }
2273 if ( !$rc_patrolled ) { $s .= ' <span class="unpatrolled">!</span>'; }
2276 # If it's a new article, there is no diff link, but if it hasn't been
2277 # patrolled yet, we need to give users a way to do so
2278 if ( $unpatrolled && $rc_type == RC_NEW
)
2279 $articleLink = $this->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
2281 $articleLink = $this->makeKnownLinkObj( $rc->getTitle(), '' );
2284 $articleLink = '<strong>'.$articleLink.'</strong>';
2286 $s .= ' '.$articleLink;
2291 $s .= '; ' . $wgLang->time( $rc_timestamp, true, $wgRCSeconds ) . ' . . ';
2293 # User link (or contributions for unregistered users)
2294 if ( 0 == $rc_user ) {
2295 $userLink = $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
2296 $rc_user_text, 'target=' . $rc_user_text );
2298 $userLink = $this->makeLink( $wgContLang->getNsText( NS_USER
) . ':'.$rc_user_text, $rc_user_text );
2303 $talkname=$wgContLang->getNsText(NS_TALK
); # use the shorter name
2304 global $wgDisableAnonTalk;
2305 if( 0 == $rc_user && $wgDisableAnonTalk ) {
2308 $utns=$wgContLang->getNsText(NS_USER_TALK
);
2309 $userTalkLink= $this->makeLink($utns . ':'.$rc_user_text, $talkname );
2313 if ( ( 0 == $rc_user ) && $wgUser->isAllowed('block') ) {
2314 $blockLink = $this->makeKnownLink( $wgContLang->specialPage(
2315 'Blockip' ), wfMsg( 'blocklink' ), 'ip='.$rc_user_text );
2319 if($userTalkLink) $userTalkLink .= ' | ';
2320 $userTalkLink .= $blockLink;
2322 if($userTalkLink) $s.=' ('.$userTalkLink.')';
2325 if ( '' != $rc_comment && '*' != $rc_comment && $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
2326 $rc_comment=$this->formatComment($rc_comment,$rc->getTitle());
2327 $s .= $wgContLang->emphasize(' (' . $rc_comment . ')');
2334 function recentChangesLineNew( &$baseRC, $watched = false ) {
2335 global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgRCSeconds;
2336 global $wgUseRCPatrol, $wgOnlySysopsCanPatrol;
2338 # Create a specialised object
2339 $rc = RCCacheEntry
::newFromParent( $baseRC ) ;
2341 # Extract fields from DB into the function scope (rc_xxxx variables)
2342 extract( $rc->mAttribs
);
2343 $curIdEq = 'curid=' . $rc_cur_id;
2345 # If it's a new day, add the headline and flush the cache
2346 $date = $wgContLang->date( $rc_timestamp, true);
2347 $uidate = $wgLang->date( $rc_timestamp, true);
2349 if ( $date != $this->lastdate
) {
2350 # Process current cache
2351 $ret = $this->recentChangesBlock () ;
2352 $this->rc_cache
= array() ;
2353 $ret .= "<h4>{$uidate}</h4>\n";
2354 $this->lastdate
= $date;
2357 # Should patrol-related stuff be shown?
2358 if ( $wgUseRCPatrol && $wgUser->getID() != 0 &&
2359 ( !$wgOnlySysopsCanPatrol ||
$wgUser->isAllowed('patrol') )) {
2360 $rc->unpatrolled
= !$rc_patrolled;
2362 $rc->unpatrolled
= false;
2366 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2367 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
2368 $clink = wfMsg( $msg, $this->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
2369 $this->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
2370 } elseif( $rc_namespace == NS_SPECIAL
&& preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
2372 $logtype = $matches[1];
2373 $logname = LogPage
::logName( $logtype );
2374 $clink = '(' . $this->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
2375 } elseif ( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
2376 # Unpatrolled new page, give rc_id in query
2377 $clink = $this->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
2379 $clink = $this->makeKnownLinkObj( $rc->getTitle(), '' ) ;
2382 $time = $wgContLang->time( $rc_timestamp, true, $wgRCSeconds );
2383 $rc->watched
= $watched ;
2384 $rc->link
= $clink ;
2385 $rc->timestamp
= $time;
2387 # Make "cur" and "diff" links
2388 if ( ( $rc_type == RC_NEW
&& $rc_this_oldid == 0 ) ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2389 $curLink = wfMsg( 'cur' );
2390 $diffLink = wfMsg( 'diff' );
2392 $query = $curIdEq.'&diff=0&oldid='.$rc_this_oldid;
2393 $aprops = ' tabindex="'.$baseRC->counter
.'"';
2394 $curLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'cur' ), $query, '' ,'' , $aprops );
2395 $diffLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'diff'), $query, '' ,'' , $aprops );
2399 $titleObj = $rc->getTitle();
2400 if ( $rc->unpatrolled
) {
2401 $rcIdQuery = "&rcid={$rc_id}";
2405 if ( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2406 $lastLink = wfMsg( 'last' );
2408 $lastLink = $this->makeKnownLinkObj( $rc->getTitle(), wfMsg( 'last' ),
2409 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
2412 # Make user link (or user contributions for unregistered users)
2413 if ( $rc_user == 0 ) {
2414 $userLink = $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
2415 $rc_user_text, 'target=' . $rc_user_text );
2417 $userLink = $this->makeLink( $wgContLang->getNsText(
2418 Namespace::getUser() ) . ':'.$rc_user_text, $rc_user_text );
2421 $rc->userlink
= $userLink;
2422 $rc->lastlink
= $lastLink;
2423 $rc->curlink
= $curLink;
2424 $rc->difflink
= $diffLink;
2426 # Make user talk link
2427 $utns=$wgContLang->getNsText(NS_USER_TALK
);
2428 $talkname=$wgContLang->getNsText(NS_TALK
); # use the shorter name
2429 $userTalkLink= $this->makeLink($utns . ':'.$rc_user_text, $talkname );
2431 global $wgDisableAnonTalk;
2432 if ( ( 0 == $rc_user ) && $wgUser->isAllowed('block') ) {
2433 $blockLink = $this->makeKnownLink( $wgContLang->specialPage(
2434 'Blockip' ), wfMsg( 'blocklink' ), 'ip='.$rc_user_text );
2435 if( $wgDisableAnonTalk )
2436 $rc->usertalklink
= ' ('.$blockLink.')';
2438 $rc->usertalklink
= ' ('.$userTalkLink.' | '.$blockLink.')';
2440 if( $wgDisableAnonTalk && ($rc_user == 0) )
2441 $rc->usertalklink
= '';
2443 $rc->usertalklink
= ' ('.$userTalkLink.')';
2446 # Put accumulated information into the cache, for later display
2447 # Page moves go on their own line
2448 $title = $rc->getTitle();
2449 $secureName = $title->getPrefixedDBkey();
2450 if ( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
2451 # Use an @ character to prevent collision with page names
2452 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
2454 if ( !isset ( $this->rc_cache
[$secureName] ) ) $this->rc_cache
[$secureName] = array() ;
2455 array_push ( $this->rc_cache
[$secureName] , $rc ) ;
2460 function endImageHistoryList() {
2466 * This function is called by all recent changes variants, by the page history,
2467 * and by the user contributions list. It is responsible for formatting edit
2468 * comments. It escapes any HTML in the comment, but adds some CSS to format
2469 * auto-generated comments (from section editing) and formats [[wikilinks]].
2471 * The &$title parameter must be a title OBJECT. It is used to generate a
2472 * direct link to the section in the autocomment.
2473 * @author Erik Moeller <moeller@scireview.de>
2475 * Note: there's not always a title to pass to this function.
2476 * Since you can't set a default parameter for a reference, I've turned it
2477 * temporarily to a value pass. Should be adjusted further. --brion
2479 function formatComment($comment, $title = NULL) {
2481 $comment = htmlspecialchars( $comment );
2483 # The pattern for autogen comments is / * foo * /, which makes for
2485 # We look for all comments, match any text before and after the comment,
2486 # add a separator where needed and format the comment itself with CSS
2487 while (preg_match('/(.*)\/\*\s*(.*?)\s*\*\/(.*)/', $comment,$match)) {
2495 # This is hackish but should work in most cases.
2496 $section=str_replace('[[','',$section);
2497 $section=str_replace(']]','',$section);
2498 $title->mFragment
=$section;
2499 $link=$this->makeKnownLinkObj($title,wfMsg('sectionlink'));
2503 if($pre) { $auto = $sep.' '.$auto; }
2504 if($post) { $auto .= ' '.$sep; }
2505 $auto='<span class="autocomment">'.$auto.'</span>';
2506 $comment=$pre.$auto.$post;
2509 # format regular and media links - all other wiki formatting
2511 $medians = $wgContLang->getNsText(Namespace::getMedia()).':';
2512 while(preg_match('/\[\[(.*?)(\|(.*?))*\]\](.*)$/',$comment,$match)) {
2513 # Handle link renaming [[foo|text]] will show link as "text"
2514 if( "" != $match[3] ) {
2519 if( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) {
2520 # Media link; trail not supported.
2521 $linkRegexp = '/\[\[(.*?)\]\]/';
2522 $thelink = $this->makeMediaLink( $submatch[1], "", $text );
2524 # Other kind of link
2525 if( preg_match( wfMsgForContent( "linktrail" ), $match[4], $submatch ) ) {
2526 $trail = $submatch[1];
2530 $linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/';
2531 if ($match[1][0] == ':')
2532 $match[1] = substr($match[1], 1);
2533 $thelink = $this->makeLink( $match[1], $text, "", $trail );
2535 $comment = preg_replace( $linkRegexp, $thelink, $comment, 1 );
2540 function imageHistoryLine( $iscur, $timestamp, $img, $user, $usertext, $size, $description ) {
2541 global $wgUser, $wgLang, $wgContLang, $wgTitle;
2543 $datetime = $wgLang->timeanddate( $timestamp, true );
2544 $del = wfMsg( 'deleteimg' );
2545 $delall = wfMsg( 'deleteimgcompletely' );
2546 $cur = wfMsg( 'cur' );
2549 $url = Image
::wfImageUrl( $img );
2551 if ( $wgUser->isAllowed('delete') ) {
2552 $link = $wgTitle->escapeLocalURL( 'image=' . $wgTitle->getPartialURL() .
2554 $style = $this->getInternalLinkAttributes( $link, $delall );
2556 $dlink = '<a href="'.$link.'"'.$style.'>'.$delall.'</a>';
2561 $url = htmlspecialchars( wfImageArchiveUrl( $img ) );
2562 if( $wgUser->getID() != 0 && $wgTitle->userCanEdit() ) {
2563 $rlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
2564 wfMsg( 'revertimg' ), 'action=revert&oldimage=' .
2565 urlencode( $img ) );
2566 $dlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
2567 $del, 'action=delete&oldimage=' . urlencode( $img ) );
2569 # Having live active links for non-logged in users
2570 # means that bots and spiders crawling our site can
2571 # inadvertently change content. Baaaad idea.
2572 $rlink = wfMsg( 'revertimg' );
2577 $userlink = $usertext;
2579 $userlink = $this->makeLink( $wgContLang->getNsText( Namespace::getUser() ) .
2580 ':'.$usertext, $usertext );
2582 $nbytes = wfMsg( 'nbytes', $size );
2583 $style = $this->getInternalLinkAttributes( $url, $datetime );
2585 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$datetime}</a>"
2586 . " . . {$userlink} ({$nbytes})";
2588 if ( '' != $description && '*' != $description ) {
2589 $sk=$wgUser->getSkin();
2590 $s .= $wgContLang->emphasize(' (' . $sk->formatComment($description,$wgTitle) . ')');
2596 function tocIndent($level) {
2597 return str_repeat( '<div class="tocindent">'."\n", $level>0 ?
$level : 0 );
2600 function tocUnindent($level) {
2601 return str_repeat( "</div>\n", $level>0 ?
$level : 0 );
2605 * parameter level defines if we are on an indentation level
2607 function tocLine( $anchor, $tocline, $level ) {
2608 $link = '<a href="#'.$anchor.'">'.$tocline.'</a><br />';
2612 return '<div class="tocline">'.$link."</div>\n";
2617 function tocTable($toc) {
2618 # note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
2619 # try min-width & co when somebody gets a chance
2620 $hideline = ' <script type="text/javascript">showTocToggle("' . addslashes( wfMsg('showtoc') ) . '","' . addslashes( wfMsg('hidetoc') ) . '")</script>';
2622 '<table border="0" id="toc"><tr id="toctitle"><td align="center">'."\n".
2623 '<b>'.wfMsgForContent('toc').'</b>' .
2625 '</td></tr><tr id="tocinside"><td>'."\n".
2626 $toc."</td></tr></table>\n";
2630 * These two do not check for permissions: check $wgTitle->userCanEdit
2631 * before calling them
2633 function editSectionScriptForOther( $title, $section, $head ) {
2634 $ttl = Title
::newFromText( $title );
2635 $url = $ttl->escapeLocalURL( 'action=edit§ion='.$section );
2636 return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
2639 function editSectionScript( $nt, $section, $head ) {
2641 if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
2644 $url = $nt->escapeLocalURL( 'action=edit§ion='.$section );
2645 return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
2648 function editSectionLinkForOther( $title, $section ) {
2652 $title = Title
::newFromText($title);
2653 $editurl = '§ion='.$section;
2654 $url = $this->makeKnownLink($title->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
2656 if( $wgContLang->isRTL() ) {
2658 $nearside = 'right';
2663 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
2667 function editSectionLink( $nt, $section ) {
2671 if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
2672 # Section edit links would be out of sync on an old page.
2673 # But, if we're diffing to the current page, they'll be
2678 $editurl = '§ion='.$section;
2679 $url = $this->makeKnownLink($nt->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
2681 if( $wgContLang->isRTL() ) {
2683 $nearside = 'right';
2688 return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
2693 * This function is called by EditPage.php and shows a bulletin board style
2694 * toolbar for common editing functions. It can be disabled in the user
2696 * The necessary JavaScript code can be found in style/wikibits.js.
2698 function getEditToolbar() {
2699 global $wgStylePath, $wgLang, $wgMimeType;
2702 * toolarray an array of arrays which each include the filename of
2703 * the button image (without path), the opening tag, the closing tag,
2704 * and optionally a sample text that is inserted between the two when no
2705 * selection is highlighted.
2706 * The tip text is shown when the user moves the mouse over the button.
2708 * Already here are accesskeys (key), which are not used yet until someone
2709 * can figure out a way to make them work in IE. However, we should make
2710 * sure these keys are not defined on the edit page.
2713 array( 'image'=>'button_bold.png',
2715 'close' => "\'\'\'",
2716 'sample'=> wfMsg('bold_sample'),
2717 'tip' => wfMsg('bold_tip'),
2720 array( 'image'=>'button_italic.png',
2723 'sample'=> wfMsg('italic_sample'),
2724 'tip' => wfMsg('italic_tip'),
2727 array( 'image'=>'button_link.png',
2730 'sample'=> wfMsg('link_sample'),
2731 'tip' => wfMsg('link_tip'),
2734 array( 'image'=>'button_extlink.png',
2737 'sample'=> wfMsg('extlink_sample'),
2738 'tip' => wfMsg('extlink_tip'),
2741 array( 'image'=>'button_headline.png',
2743 'close' => " ==\\n",
2744 'sample'=> wfMsg('headline_sample'),
2745 'tip' => wfMsg('headline_tip'),
2748 array( 'image'=>'button_image.png',
2749 'open' => '[['.$wgLang->getNsText(NS_IMAGE
).":",
2751 'sample'=> wfMsg('image_sample'),
2752 'tip' => wfMsg('image_tip'),
2755 array( 'image' => 'button_media.png',
2756 'open' => '[['.$wgLang->getNsText(NS_MEDIA
).':',
2758 'sample'=> wfMsg('media_sample'),
2759 'tip' => wfMsg('media_tip'),
2762 array( 'image' => 'button_math.png',
2763 'open' => "\\<math\\>",
2764 'close' => "\\</math\\>",
2765 'sample'=> wfMsg('math_sample'),
2766 'tip' => wfMsg('math_tip'),
2769 array( 'image' => 'button_nowiki.png',
2770 'open' => "\\<nowiki\\>",
2771 'close' => "\\</nowiki\\>",
2772 'sample'=> wfMsg('nowiki_sample'),
2773 'tip' => wfMsg('nowiki_tip'),
2776 array( 'image' => 'button_sig.png',
2780 'tip' => wfMsg('sig_tip'),
2783 array( 'image' => 'button_hr.png',
2784 'open' => "\\n----\\n",
2787 'tip' => wfMsg('hr_tip'),
2791 $toolbar ="<script type='text/javascript'>\n/*<![CDATA[*/\n";
2793 $toolbar.="document.writeln(\"<div id='toolbar'>\");\n";
2794 foreach($toolarray as $tool) {
2796 $image=$wgStylePath.'/common/images/'.$tool['image'];
2797 $open=$tool['open'];
2798 $close=$tool['close'];
2799 $sample = addslashes( $tool['sample'] );
2801 // Note that we use the tip both for the ALT tag and the TITLE tag of the image.
2802 // Older browsers show a "speedtip" type message only for ALT.
2803 // Ideally these should be different, realistically they
2804 // probably don't need to be.
2805 $tip = addslashes( $tool['tip'] );
2807 #$key = $tool["key"];
2809 $toolbar.="addButton('$image','$tip','$open','$close','$sample');\n";
2812 $toolbar.="addInfobox('" . addslashes( wfMsg( "infobox" ) ) . "','" . addslashes(wfMsg("infobox_alert")) . "');\n";
2813 $toolbar.="document.writeln(\"</div>\");\n";
2815 $toolbar.="/*]]>*/\n</script>";
2822 function suppressUrlExpansion() {