00001 <?php
00002
# See skin.doc
00003
00004 require_once( 'Feed.php' );
00005 require_once( '
Image.php' );
00006
00007
# These are the INTERNAL names, which get mapped
00008
# directly to class names. For display purposes, the
00009
# Language class has internationalized names
00010
#
00011 $wgValidSkinNames = array(
00012 'standard' => 'Standard',
00013 'nostalgia' => 'Nostalgia',
00014 'cologneblue' => 'CologneBlue'
00015 );
00016
if(
$wgUsePHPTal ) {
00017
#$wgValidSkinNames[] = 'PHPTal';
00018
#$wgValidSkinNames['davinci'] = 'DaVinci';
00019
#$wgValidSkinNames['mono'] = 'Mono';
00020
$wgValidSkinNames['monobook'] = 'MonoBook';
00021
$wgValidSkinNames['myskin'] = 'MySkin';
00022
#$wgValidSkinNames['monobookminimal'] = 'MonoBookMinimal';
00023
}
00024
00025 require_once( '
RecentChange.php' );
00026
00027 class RCCacheEntry extends RecentChange
00028 {
00029 var
$secureName,
$link;
00030 var
$curlink ,
$lastlink ,
$usertalklink ,
$versionlink ;
00031 var
$userlink,
$timestamp,
$watched;
00032
00033 function
newFromParent( $rc )
00034 {
00035 $rc2 =
new RCCacheEntry;
00036 $rc2->mAttribs = $rc->mAttribs;
00037 $rc2->mExtra = $rc->mExtra;
00038
return $rc2;
00039 }
00040 } ;
00041
00042
class Skin {
00043
00044 var $lastdate, $lastline;
00045 var $linktrail ; # linktrail regexp
00046 var $rc_cache ; # Cache
for Enhanced Recent Changes
00047 var $rcCacheIndex ; # Recent Changes Cache Counter
for visibility toggle
00048 var $rcMoveIndex;
00049
00050 function Skin()
00051 {
00052 $this->linktrail =
wfMsg('linktrail');
00053 }
00054
00055 function getSkinNames()
00056 {
00057 global
$wgValidSkinNames;
00058
return $wgValidSkinNames;
00059 }
00060
00061 function getStylesheet()
00062 {
00063
return 'wikistandard.css';
00064 }
00065 function getSkinName() {
00066
return "standard";
00067 }
00068
00069 function qbSetting()
00070 {
00071 global
$wgOut,
$wgUser;
00072
00073
if (
$wgOut->isQuickbarSuppressed() ) {
return 0; }
00074 $q =
$wgUser->getOption( 'quickbar' );
00075
if ( '' == $q ) { $q = 0; }
00076
return $q;
00077 }
00078
00079 function initPage( &$out )
00080 {
00081 $fname = 'Skin::initPage';
00082
wfProfileIn( $fname );
00083
00084 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => '/favicon.ico' ) );
00085
00086 $this->addMetadataLinks($out);
00087
00088
wfProfileOut( $fname );
00089 }
00090
00091 function addMetadataLinks( &$out ) {
00092 global
$wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf, $wgRdfMimeType,
$action;
00093 global $wgRightsPage, $wgRightsUrl;
00094
00095
if( $out->isArticleRelated() ) {
00096
# note: buggy CC software only reads first "meta" link
00097
if( $wgEnableCreativeCommonsRdf ) {
00098 $out->addMetadataLink( array(
00099 'title' => 'Creative Commons',
00100 'type' => 'application/rdf+xml',
00101 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
00102 }
00103
if( $wgEnableDublinCoreRdf ) {
00104 $out->addMetadataLink( array(
00105 'title' => 'Dublin Core',
00106 'type' => 'application/rdf+xml',
00107 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
00108 }
00109 }
00110 $copyright = '';
00111
if( $wgRightsPage ) {
00112 $copy = Title::newFromText( $wgRightsPage );
00113
if( $copy ) {
00114 $copyright = $copy->getLocalURL();
00115 }
00116 }
00117
if( !$copyright && $wgRightsUrl ) {
00118 $copyright = $wgRightsUrl;
00119 }
00120
if( $copyright ) {
00121 $out->addLink( array(
00122 'rel' => 'copyright',
00123 'href' => $copyright ) );
00124 }
00125 }
00126
00127 function outputPage( &$out ) {
00128 global
$wgDebugComments;
00129
00130
wfProfileIn( 'Skin::outputPage' );
00131 $this->initPage( $out );
00132 $out->out( $out->headElement() );
00133
00134 $out->out(
"\n<body" );
00135 $ops = $this->getBodyOptions();
00136 foreach ( $ops as $name => $val ) {
00137 $out->out(
" $name='$val'" );
00138 }
00139 $out->out(
">\n" );
00140
if (
$wgDebugComments ) {
00141 $out->out(
"<!-- Wiki debugging output:\n" .
00142 $out->mDebugtext .
"-->\n" );
00143 }
00144 $out->out( $this->beforeContent() );
00145
00146 $out->out( $out->mBodytext .
"\n" );
00147
00148 $out->out( $this->afterContent() );
00149
00150
wfProfileClose();
00151 $out->out( $out->reportTime() );
00152
00153 $out->out(
"\n</body></html>" );
00154 }
00155
00156 function getHeadScripts() {
00157 global
$wgStylePath,
$wgUser,
$wgLang;
00158 $r =
"<script type=\"text/javascript\" src=\"{$wgStylePath}/wikibits.js\"></script>\n";
00159
if(
$wgUser->getID() != 0 ) { # logged in
00160 $userpage =
$wgLang->getNsText( Namespace::getUser() ) .
":" .
$wgUser->getName();
00161 $userjs = htmlspecialchars($this->makeUrl($userpage.
'/'.$this->getSkinName().'.js', 'action=raw&ctype=text/javascript'));
00162 $r .= '<script type=
"text/javascript" src=
"'.$userjs."\
"></script>\n";
00163 }
00164
return $r;
00165 }
00166
00167
# get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way)
00168
function getUserStylesheet() {
00169 global
$wgOut,
$wgStylePath,
$wgLang,
$wgUser,
$wgRequest,
$wgTitle;
00170 $sheet = $this->getStylesheet();
00171
$action =
$wgRequest->getText('action');
00172
$s =
"@import \"$wgStylePath/$sheet\";\n";
00173
if(
$wgLang->isRTL())
$s .=
"@import \"$wgStylePath/common_rtl.css\";\n";
00174
if(
$wgUser->getID() != 0 ) { # logged in
00175
if(
$wgTitle->isCssSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) {
00176
$s .=
$wgRequest->getText('wpTextbox1');
00177 }
else {
00178 $userpage =
$wgLang->getNsText( Namespace::getUser() ) .
":" .
$wgUser->getName();
00179
$s.= '@
import "'.$this->makeUrl($userpage.'/'.$this->getSkinName().'.css', 'action=raw&ctype=text/css').'";'.
"\n";
00180 }
00181 }
00182
$s .= $this->doGetUserStyles();
00183
return $s.
"\n";
00184 }
00185
# placeholder, returns generated js in monobook
00186
function getUserJs() {
00187
return;
00188 }
00189
00190 function getUserStyles()
00191 {
00192 global
$wgOut,
$wgStylePath,
$wgLang;
00193
$s =
"<style type='text/css'>\n";
00194
$s .=
"/*/*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
00195
$s .= $this->getUserStylesheet();
00196
$s .=
"/* */\n";
00197
$s .=
"</style>\n";
00198
return $s;
00199 }
00200
00201 function doGetUserStyles()
00202 {
00203 global
$wgUser;
00204
00205
$s = '';
00206
if ( 1 ==
$wgUser->getOption( 'underline' ) ) {
00207
# Don't override browser settings
00208
}
else {
00209
# CHECK MERGE @@@
00210
# Force no underline
00211
$s .= 'a { ' .
00212
"text-decoration: none; }\n";
00213 }
00214
if ( 1 ==
$wgUser->getOption( 'highlightbroken' ) ) {
00215
$s .=
"a.new, #quickbar a.new { color: #CC2200; }\n";
00216 }
00217
if ( 1 ==
$wgUser->getOption( 'justify' ) ) {
00218
$s .=
"#article { text-align: justify; }\n";
00219 }
00220
return $s;
00221 }
00222
00223 function getBodyOptions()
00224 {
00225 global
$wgUser,
$wgTitle, $wgNamespaceBackgrounds,
$wgOut,
$wgRequest;
00226
00227 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
00228
00229
if ( 0 !=
$wgTitle->getNamespace() ) {
00230 $a = array( 'bgcolor' => '#ffffec' );
00231 }
00232
else $a = array( 'bgcolor' => '#FFFFFF' );
00233
if(
$wgOut->isArticle() &&
$wgUser->getOption('editondblclick') &&
00234 (!
$wgTitle->isProtected() ||
$wgUser->isSysop()) ) {
00235 $t =
wfMsg( 'editthispage' );
00236 $oid = $red = '';
00237
if ( !empty($redirect) ) {
00238 $red =
"&redirect={$redirect}";
00239 }
00240
if ( !empty($oldid) && ! isset( $diff ) ) {
00241 $oid =
"&oldid={$oldid}";
00242 }
00243
$s =
$wgTitle->getFullURL(
"action=edit{$oid}{$red}" );
00244
$s = 'document.location =
"' .$s .'";';
00245 $a += array ('ondblclick' => $s);
00246
00247 }
00248 $a['onload'] =
$wgOut->getOnloadHandler();
00249
return $a;
00250 }
00251
00252 function getExternalLinkAttributes( $link, $text, $
class='' )
00253 {
00254 global
$wgUser,
$wgOut,
$wgLang;
00255
00256 $link = urldecode( $link );
00257 $link =
$wgLang->checkTitleEncoding( $link );
00258 $link = str_replace(
'_',
' ', $link );
00259 $link =
wfEscapeHTML( $link );
00260
00261 $r = ($class != '') ?
" class='$class'" :
" class='external'";
00262
00263
if ( 1 ==
$wgUser->getOption( 'hover' ) ) {
00264 $r .=
" title=\"{$link}\"";
00265 }
00266
return $r;
00267 }
00268
00269 function getInternalLinkAttributes( $link, $text, $broken =
false )
00270 {
00271 global
$wgUser,
$wgOut;
00272
00273 $link = urldecode( $link );
00274 $link = str_replace(
'_',
' ', $link );
00275 $link =
wfEscapeHTML( $link );
00276
00277
if ( $broken == 'stub' ) {
00278 $r = '
class=
"stub"';
00279 }
else if ( $broken == 'yes' ) {
00280 $r = '
class=
"new"';
00281 }
else {
00282 $r = '';
00283 }
00284
00285
if ( 1 ==
$wgUser->getOption( 'hover' ) ) {
00286 $r .=
" title=\"{$link}\"";
00287 }
00288
return $r;
00289 }
00290
00291 function getInternalLinkAttributesObj( &$nt, $text, $broken =
false )
00292 {
00293 global
$wgUser,
$wgOut;
00294
00295
if ( $broken == 'stub' ) {
00296 $r = '
class=
"stub"';
00297 }
else if ( $broken == 'yes' ) {
00298 $r = '
class=
"new"';
00299 }
else {
00300 $r = '';
00301 }
00302
00303
if ( 1 ==
$wgUser->getOption( 'hover' ) ) {
00304 $r .= '
title =
"' . $nt->getEscapedText() . '"';
00305 }
00306
return $r;
00307 }
00308
00309 function getLogo()
00310 {
00311 global
$wgLogo;
00312
return $wgLogo;
00313 }
00314
00315
# This will be called immediately after the <body> tag. Split into
00316
# two functions to make it easier to subclass.
00317
#
00318
function beforeContent()
00319 {
00320 global
$wgUser,
$wgOut,
$wgSiteNotice;
00321
00322
if(
$wgSiteNotice ) {
00323 $note =
"\n<div id='siteNotice'>$wgSiteNotice</div>\n";
00324 }
else {
00325 $note = '';
00326 }
00327
return $this->doBeforeContent() . $note;
00328 }
00329
00330 function doBeforeContent()
00331 {
00332 global
$wgUser,
$wgOut,
$wgTitle,
$wgLang;
00333 $fname = 'Skin::doBeforeContent';
00334
wfProfileIn( $fname );
00335
00336
$s = '';
00337 $qb = $this->qbSetting();
00338
00339
if( $langlinks = $this->otherLanguages() ) {
00340 $rows = 2;
00341 $borderhack = '';
00342 }
else {
00343 $rows = 1;
00344 $langlinks =
false;
00345 $borderhack = '
class=
"top"';
00346 }
00347
00348
$s .=
"\n<div id='content'>\n<div id='topbar'>\n" .
00349
"<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
00350
00351 $shove = ($qb != 0);
00352 $left = ($qb == 1 || $qb == 3);
00353
if(
$wgLang->isRTL()) $left = !$left;
00354
00355
if ( !$shove ) {
00356
$s .=
"<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
00357 $this->logoText() . '</td>';
00358 } elseif( $left ) {
00359
$s .= $this->getQuickbarCompensator( $rows );
00360 }
00361 $l =
$wgLang->isRTL() ? 'right' : 'left';
00362
$s .=
"<td {$borderhack} align='$l' valign='top'>\n";
00363
00364
$s .= $this->topLinks() ;
00365
$s .=
"<p class='subtitle'>" . $this->pageTitleLinks() .
"</p>\n";
00366
00367 $r =
$wgLang->isRTL() ?
"left" :
"right";
00368
$s .=
"</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
00369
$s .= $this->nameAndLogin();
00370
$s .=
"\n<br />" . $this->searchForm() .
"</td>";
00371
00372
if ( $langlinks ) {
00373
$s .=
"</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
00374 }
00375
00376
if ( $shove && !$left ) { # Right
00377
$s .= $this->getQuickbarCompensator( $rows );
00378 }
00379
$s .=
"</tr>\n</table>\n</div>\n";
00380
$s .=
"\n<div id='article'>\n";
00381
00382
$s .= $this->pageTitle();
00383
$s .= $this->pageSubtitle() ;
00384
$s .= $this->getCategories();
00385
wfProfileOut( $fname );
00386
return $s;
00387 }
00388
00389 function getCategoryLinks () {
00390 global
$wgOut,
$wgTitle,
$wgUser,
$wgParser;
00391 global
$wgUseCategoryMagic,
$wgUseCategoryBrowser,
$wgLang;
00392
00393
if( !
$wgUseCategoryMagic )
return '' ;
00394
if( count( $wgOut->mCategoryLinks ) == 0 )
return '';
00395
00396
# Taken out so that they will be displayed in previews -- TS
00397
#if( !$wgOut->isArticle() ) return '';
00398
00399 $t = implode ( ' | ' , $wgOut->mCategoryLinks ) ;
00400
$s = $this->makeKnownLink( 'Special:Categories',
00401
wfMsg( 'categories' ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
00402 . ': ' . $t;
00403
00404
if(
$wgUseCategoryBrowser) {
00405
$s .= '<br/><hr/>';
00406 $catstack = array();
00407
$s.=
$wgTitle->getAllParentCategories($catstack);
00408 }
00409
00410
return $s;
00411 }
00412
00413 function getCategories() {
00414 $catlinks=$this->getCategoryLinks();
00415
if(!empty($catlinks)) {
00416
return "<p class='catlinks'>{$catlinks}</p>";
00417 }
00418 }
00419
00420 function getQuickbarCompensator( $rows = 1 )
00421 {
00422
return "<td width='152' rowspan='{$rows}'> </td>";
00423 }
00424
00425
# This gets called immediately before the </body> tag.
00426
#
00427
function afterContent()
00428 {
00429 global
$wgUser,
$wgOut, $wgServer;
00430 global
$wgTitle,
$wgLang;
00431
00432 $printfooter =
"<div class=\"printfooter\">\n" . $this->printFooter() .
"</div>\n";
00433
return $printfooter . $this->doAfterContent();
00434 }
00435
00436 function printFooter() {
00437 global
$wgTitle;
00438
$url = htmlspecialchars( $wgTitle->getFullURL() );
00439
return "<p>" .
wfMsg(
"retrievedfrom",
"<a href=\"$url\">$url</a>" ) .
00440
"</p>\n\n<p>" . $this->pageStats() .
"</p>\n";
00441 }
00442
00443 function doAfterContent()
00444 {
00445 global
$wgUser,
$wgOut,
$wgLang;
00446 $fname = 'Skin::doAfterContent';
00447
wfProfileIn( $fname );
00448
wfProfileIn( $fname.'-1' );
00449
00450
$s =
"\n</div><br style=\"clear:both\" />\n";
00451
$s .=
"\n<div id='footer'>";
00452
$s .= '<table border=
"0" cellspacing=
"0"><tr>';
00453
00454
wfProfileOut( $fname.'-1' );
00455
wfProfileIn( $fname.'-2' );
00456
00457 $qb = $this->qbSetting();
00458 $shove = ($qb != 0);
00459 $left = ($qb == 1 || $qb == 3);
00460
if(
$wgLang->isRTL()) $left = !$left;
00461
00462
if ( $shove && $left ) { # Left
00463
$s .= $this->getQuickbarCompensator();
00464 }
00465
wfProfileOut( $fname.'-2' );
00466
wfProfileIn( $fname.'-3' );
00467 $l =
$wgLang->isRTL() ? 'right' : 'left';
00468
$s .=
"<td class='bottom' align='$l' valign='top'>";
00469
00470
$s .= $this->bottomLinks();
00471
$s .=
"\n<br />" . $this->mainPageLink()
00472 . ' | ' . $this->aboutLink()
00473 . ' | ' . $this->specialLink( 'recentchanges' )
00474 . ' | ' . $this->searchForm()
00475 . '<br /><span
id=
"pagestats">' . $this->pageStats() . '</span>';
00476
00477
$s .=
"</td>";
00478
if ( $shove && !$left ) { # Right
00479
$s .= $this->getQuickbarCompensator();
00480 }
00481
$s .=
"</tr></table>\n</div>\n</div>\n";
00482
00483
wfProfileOut( $fname.'-3' );
00484
wfProfileIn( $fname.'-4' );
00485
if ( 0 != $qb ) {
$s .= $this->quickBar(); }
00486
wfProfileOut( $fname.'-4' );
00487
wfProfileOut( $fname );
00488
return $s;
00489 }
00490
00491 function pageTitleLinks()
00492 {
00493 global
$wgOut,
$wgTitle,
$wgUser,
$wgLang, $wgUseApproval,
$wgRequest;
00494
00495 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
00496
$action =
$wgRequest->getText( 'action' );
00497
00498
$s = $this->printableLink();
00499
if (
wfMsg ( 'disclaimers' ) !=
'-' )
$s .= ' | ' . $this->makeKnownLink(
wfMsg( 'disclaimerpage' ),
wfMsg( 'disclaimers' ) ) ;
00500
00501
if (
$wgOut->isArticleRelated() ) {
00502
if (
$wgTitle->getNamespace() ==
Namespace::getImage() ) {
00503 $name =
$wgTitle->getDBkey();
00504 $link =
wfEscapeHTML( Image::wfImageUrl( $name ) );
00505 $style = $this->getInternalLinkAttributes( $link, $name );
00506
$s .=
" | <a href=\"{$link}\"{$style}>{$name}</a>";
00507 }
00508
# This will show the "Approve" link if $wgUseApproval=true;
00509
if ( isset ( $wgUseApproval ) && $wgUseApproval )
00510 {
00511 $t =
$wgTitle->getDBkey();
00512 $name = 'Approve
this article' ;
00513 $link =
"http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ;
00514
#wfEscapeHTML( wfImageUrl( $name ) );
00515
$style = $this->getExternalLinkAttributes( $link, $name );
00516
$s .=
" | <a href=\"{$link}\"{$style}>{$name}</a>" ;
00517 }
00518 }
00519
if ( 'history' ==
$action || isset( $diff ) || isset( $oldid ) ) {
00520
$s .= ' | ' . $this->makeKnownLink( $wgTitle->getPrefixedText(),
00521
wfMsg( 'currentrev' ) );
00522 }
00523
00524
if (
$wgUser->getNewtalk() ) {
00525
# do not show "You have new messages" text when we are viewing our
00526
# own talk page
00527
00528
if(!(strcmp($wgTitle->getText(),
$wgUser->getName()) == 0 &&
00529
$wgTitle->getNamespace()==
Namespace::getTalk(Namespace::getUser()))) {
00530
$n =
$wgUser->getName();
00531 $tl = $this->makeKnownLink( $wgLang->getNsText(
00532 Namespace::getTalk( Namespace::getUser() ) ) .
":{$n}",
00533
wfMsg('newmessageslink') );
00534
$s.= ' | <strong>'.
wfMsg( 'newmessages', $tl ) . '</strong>';
00535 }
00536 }
00537
00538 $undelete = $this->getUndeleteLink();
00539
if( !empty( $undelete ) ) {
00540
$s .= ' | '.$undelete;
00541 }
00542
return $s;
00543 }
00544
00545 function getUndeleteLink() {
00546 global
$wgUser,
$wgTitle,
$wgLang,
$action;
00547
if(
$wgUser->isSysop() &&
00548 ((
$wgTitle->getArticleId() == 0) || (
$action ==
"history")) &&
00549 (
$n =
$wgTitle->isDeleted() ) ) {
00550
return wfMsg( 'thisisdeleted',
00551 $this->makeKnownLink(
00552 $wgLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
00553
wfMsg( 'restorelink', $n ) ) );
00554 }
00555
return '';
00556 }
00557
00558 function printableLink()
00559 {
00560 global
$wgOut,
$wgFeedClasses,
$wgRequest;
00561
00562 $baseurl = $_SERVER['REQUEST_URI'];
00563
if( strpos(
'?', $baseurl ) ==
false ) {
00564 $baseurl .=
'?';
00565 }
else {
00566 $baseurl .=
'&';
00567 }
00568 $baseurl = htmlspecialchars( $baseurl );
00569 $printurl =
$wgRequest->escapeAppendQuery( 'printable=yes' );
00570
00571
$s =
"<a href=\"$printurl\">" .
wfMsg( 'printableversion' ) . '</a>';
00572
if(
$wgOut->isSyndicated() ) {
00573 foreach( $wgFeedClasses as $format => $
class ) {
00574 $feedurl =
$wgRequest->escapeAppendQuery(
"feed=$format" );
00575
$s .=
" | <a href=\"$feedurl\">{$format}</a>";
00576 }
00577 }
00578
return $s;
00579 }
00580
00581 function pageTitle()
00582 {
00583 global
$wgOut,
$wgTitle,
$wgUser;
00584
00585
$s = '<h1
class=
"pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
00586
if(
$wgUser->getOption( 'editsectiononrightclick' ) &&
$wgTitle->userCanEdit()) {
$s=$this->editSectionScript(0,$s);}
00587
return $s;
00588 }
00589
00590 function pageSubtitle()
00591 {
00592 global
$wgOut;
00593
00594 $sub =
$wgOut->getSubtitle();
00595
if ( '' == $sub ) {
00596 global
$wgExtraSubtitle;
00597 $sub =
wfMsg( 'fromwikipedia' ) .
$wgExtraSubtitle;
00598 }
00599 $subpages = $this->subPageSubtitle();
00600 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
00601
$s =
"<p class='subtitle'>{$sub}</p>\n";
00602
return $s;
00603 }
00604
00605 function subPageSubtitle()
00606 {
00607 global
$wgOut,
$wgTitle,
$wgNamespacesWithSubpages;
00608 $subpages = '';
00609
if(
$wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
00610 $ptext=
$wgTitle->getPrefixedText();
00611
if(preg_match('/\
00612 $links = explode(
'/',$ptext);
00613 $c = 0;
00614 $growinglink = '';
00615 foreach($links as $link) {
00616 $c++;
00617
if ($c<count($links)) {
00618 $growinglink .= $link;
00619 $getlink = $this->makeLink( $growinglink, $link );
00620
if(preg_match('/
class=
"new"/i',$getlink)) {
break; } #
this is a hack, but it saves time
00621
if ($c>1) {
00622 $subpages .= ' | ';
00623 }
else {
00624 $subpages .= '< ';
00625 }
00626 $subpages .= $getlink;
00627 $growinglink .=
'/';
00628 }
00629 }
00630 }
00631 }
00632
return $subpages;
00633 }
00634
00635 function nameAndLogin()
00636 {
00637 global
$wgUser,
$wgTitle,
$wgLang,
$wgShowIPinHeader,
$wgIP;
00638
00639 $li =
$wgLang->specialPage( 'Userlogin' );
00640 $lo =
$wgLang->specialPage( 'Userlogout' );
00641
00642
$s = '';
00643
if ( 0 ==
$wgUser->getID() ) {
00644
if(
$wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
00645
$n =
$wgIP;
00646
00647 $tl = $this->makeKnownLink( $wgLang->getNsText(
00648 Namespace::getTalk( Namespace::getUser() ) ) .
":{$n}",
00649
$wgLang->getNsText( Namespace::getTalk( 0 ) ) );
00650
00651
$s .=
$n . ' ('.$tl.
')';
00652 }
else {
00653
$s .=
wfMsg('notloggedin');
00654 }
00655
00656 $rt =
$wgTitle->getPrefixedURL();
00657
if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
00658 $q = '';
00659 }
else { $q =
"returnto={$rt}"; }
00660
00661
$s .=
"\n<br />" . $this->makeKnownLink( $li,
00662
wfMsg( 'login' ), $q );
00663 }
else {
00664
$n =
$wgUser->getName();
00665 $rt =
$wgTitle->getPrefixedURL();
00666 $tl = $this->makeKnownLink( $wgLang->getNsText(
00667 Namespace::getTalk( Namespace::getUser() ) ) .
":{$n}",
00668
$wgLang->getNsText( Namespace::getTalk( 0 ) ) );
00669
00670 $tl =
" ({$tl})";
00671
00672
$s .= $this->makeKnownLink( $wgLang->getNsText(
00673 Namespace::getUser() ) .
":{$n}",
$n ) .
"{$tl}<br />" .
00674 $this->makeKnownLink( $lo,
wfMsg( 'logout' ),
00675
"returnto={$rt}" ) . ' | ' .
00676 $this->specialLink( 'preferences' );
00677 }
00678
$s .= ' | ' . $this->makeKnownLink(
wfMsg( 'helppage' ),
00679
wfMsg( 'help' ) );
00680
00681
return $s;
00682 }
00683
00684 function getSearchLink() {
00685 $searchPage =& Title::makeTitle( NS_SPECIAL, 'Search' );
00686
return $searchPage->getLocalURL();
00687 }
00688
00689 function escapeSearchLink() {
00690
return htmlspecialchars( $this->getSearchLink() );
00691 }
00692
00693 function searchForm()
00694 {
00695 global
$wgRequest;
00696 $search =
$wgRequest->getText( 'search' );
00697
00698
$s = '<form
name=
"search" class=
"inline" method=
"post" action=
"'
00699
. $this->escapeSearchLink() . "\
">\n"
00700 . '<input type=
"text" name=
"search" size=
"19" value=
"'
00701
. htmlspecialchars(substr($search,0,256)) . "\
" />\n"
00702 . '<input type=
"submit" name=
"go" value=
"' . wfMsg ('go') . '" /> '
00703 . '<input type=
"submit" name=
"fulltext" value=
"' . wfMsg ('search') . "\
" />\n</form>";
00704
00705
return $s;
00706 }
00707
00708 function topLinks()
00709 {
00710 global
$wgOut;
00711
$sep =
" |\n";
00712
00713
$s = $this->mainPageLink() .
$sep
00714 . $this->specialLink( 'recentchanges' );
00715
00716
if (
$wgOut->isArticleRelated() ) {
00717
$s .=
$sep . $this->editThisPage()
00718 .
$sep . $this->historyLink();
00719 }
00720
# Many people don't like this dropdown box
00721
#$s .= $sep . $this->specialPagesList();
00722
00723
return $s;
00724 }
00725
00726 function bottomLinks()
00727 {
00728 global
$wgOut,
$wgUser,
$wgTitle;
00729
$sep =
" |\n";
00730
00731
$s = '';
00732
if (
$wgOut->isArticleRelated() ) {
00733
$s .= '<strong>' . $this->editThisPage() . '</strong>';
00734
if ( 0 !=
$wgUser->getID() ) {
00735
$s .=
$sep . $this->watchThisPage();
00736 }
00737
$s .=
$sep . $this->talkLink()
00738 .
$sep . $this->historyLink()
00739 .
$sep . $this->whatLinksHere()
00740 .
$sep . $this->watchPageLinksLink();
00741
00742
if (
$wgTitle->getNamespace() ==
Namespace::getUser()
00743 ||
$wgTitle->getNamespace() ==
Namespace::getTalk(Namespace::getUser()) )
00744
00745 {
00746 $id=User::idFromName($wgTitle->getText());
00747 $ip=User::isIP($wgTitle->getText());
00748
00749
if($id || $ip) { # both anons and non-anons have contri list
00750
$s .=
$sep . $this->userContribsLink();
00751 }
00752
if ( 0 !=
$wgUser->getID() ) { # show only to
signed in users
00753
if($id) { # can only email non-anons
00754
$s .=
$sep . $this->emailUserLink();
00755 }
00756 }
00757 }
00758
if (
$wgUser->isSysop() &&
$wgTitle->getArticleId() ) {
00759
$s .=
"\n<br />" . $this->deleteThisPage() .
00760
$sep . $this->protectThisPage() .
00761
$sep . $this->moveThisPage();
00762 }
00763
$s .=
"<br />\n" . $this->otherLanguages();
00764 }
00765
return $s;
00766 }
00767
00768 function pageStats()
00769 {
00770 global
$wgOut,
$wgLang,
$wgArticle,
$wgRequest;
00771 global
$wgDisableCounters;
00772
00773 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
00774
if ( !
$wgOut->isArticle() ) {
return ''; }
00775
if ( isset( $oldid ) || isset( $diff ) ) {
return ''; }
00776
if ( 0 ==
$wgArticle->getID() ) {
return ''; }
00777
00778
$s = '';
00779
if ( !
$wgDisableCounters ) {
00780
$count =
$wgLang->formatNum( $wgArticle->getCount() );
00781
if (
$count ) {
00782
$s =
wfMsg( 'viewcount', $count );
00783 }
00784 }
00785
00786
$s .=
' ' . $this->getCredits();
00787
00788
return $s .
' ' . $this->getCopyright();
00789 }
00790
00791 function getCredits() {
00792 global
$wgMaxCredits;
00793
00794
$s = '';
00795
00796
if (!isset($wgMaxCredits) ||
$wgMaxCredits == 0) {
00797
$s = $this->lastModified();
00798 }
else {
00799
$s = $this->getAuthorCredits();
00800
if (
$wgMaxCredits > 1) {
00801
$s .=
' ' . $this->getContributorCredits();
00802 }
00803 }
00804
00805
return $s;
00806 }
00807
00808 function getAuthorCredits() {
00809 global
$wgLang,
$wgArticle;
00810
00811 $last_author =
$wgArticle->getUser();
00812
00813
if ($last_author == 0) {
00814 $author_credit =
wfMsg('anonymous');
00815 }
else {
00816 $real_name = User::whoIsReal($last_author);
00817
if (!empty($real_name)) {
00818 $author_credit = $real_name;
00819 }
else {
00820 $author_credit =
wfMsg('siteuser', User::whoIs($last_author));
00821 }
00822 }
00823
00824 $timestamp =
$wgArticle->getTimestamp();
00825
if ( $timestamp ) {
00826
$d =
$wgLang->timeanddate( $wgArticle->getTimestamp(),
true );
00827 }
else {
00828
$d = '';
00829 }
00830
return wfMsg('lastmodifiedby', $d, $author_credit);
00831 }
00832
00833 function getContributorCredits() {
00834
00835 global
$wgArticle,
$wgMaxCredits,
$wgLang;
00836
00837
# don't count last editor
00838
00839 $contributors =
$wgArticle->getContributors($wgMaxCredits - 1);
00840
00841 $real_names = array();
00842 $user_names = array();
00843
00844
# Sift for real versus user names
00845
00846 foreach ($contributors as $user_id => $user_parts) {
00847
if ($user_id != 0) {
00848
if (!empty($user_parts[1])) {
00849 $real_names[$user_id] = $user_parts[1];
00850 }
else {
00851 $user_names[$user_id] = $user_parts[0];
00852 }
00853 }
00854 }
00855
00856 $real =
$wgLang->listToText(array_values($real_names));
00857
$user =
$wgLang->listToText(array_values($user_names));
00858
00859
if (!empty($user)) {
00860
$user =
wfMsg('siteusers', $user);
00861 }
00862
00863
if ($contributors[0] && $contributors[0][0] > 0) {
00864 $anon =
wfMsg('anonymous');
00865 }
else {
00866 $anon = '';
00867 }
00868
00869 $creds =
$wgLang->listToText(array($real, $user, $anon));
00870
00871
return wfMsg('othercontribs', $creds);
00872 }
00873
00874 function getCopyright() {
00875 global $wgRightsPage, $wgRightsUrl, $wgRightsText;
00876 $out = '';
00877
if( $wgRightsPage ) {
00878 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
00879 } elseif( $wgRightsUrl ) {
00880 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
00881 }
else {
00882
# Give up now
00883
return $out;
00884 }
00885 $out .=
wfMsg( 'copyright', $link );
00886
return $out;
00887 }
00888
00889 function getCopyrightIcon() {
00890 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon;
00891 $out = '';
00892
if( $wgRightsIcon ) {
00893
$icon = htmlspecialchars( $wgRightsIcon );
00894
if( $wgRightsUrl ) {
00895
$url = htmlspecialchars( $wgRightsUrl );
00896 $out .= '<a href=
"'.$url.'">';
00897 }
00898 $text = htmlspecialchars( $wgRightsText );
00899 $out .=
"<img src=\"$icon\" alt='$text' />";
00900
if( $wgRightsUrl ) {
00901 $out .= '</a>';
00902 }
00903 }
00904
return $out;
00905 }
00906
00907 function getPoweredBy() {
00908 global
$wgStylePath;
00909
$url = htmlspecialchars(
"$wgStylePath/images/poweredby_mediawiki_88x31.png" );
00910 $img = '<a href=
"http://www.mediawiki.org/"><img src=
"'.$url.'" alt=
"MediaWiki" /></a>';
00911
return $img;
00912 }
00913
00914 function lastModified()
00915 {
00916 global
$wgLang,
$wgArticle;
00917
00918 $timestamp =
$wgArticle->getTimestamp();
00919
if ( $timestamp ) {
00920
$d =
$wgLang->timeanddate( $wgArticle->getTimestamp(),
true );
00921
$s =
' ' .
wfMsg( 'lastmodified', $d );
00922 }
else {
00923
$s = '';
00924 }
00925
return $s;
00926 }
00927
00928 function logoText( $align = '' )
00929 {
00930
if ( '' != $align ) { $a = ' align=
"'.$align.'"'; }
00931
else { $a = ''; }
00932
00933 $mp =
wfMsg( 'mainpage' );
00934 $titleObj = Title::newFromText( $mp );
00935
$s = '<a href=
"' . $titleObj->escapeLocalURL()
00936
. '"><img'.$a.' src=
"'
00937
. $this->getLogo() . '" alt=
"' . "[{$mp}]\
" /></a>";
00938
return $s;
00939 }
00940
00941 function quickBar()
00942 {
00943 global
$wgOut,
$wgTitle,
$wgUser,
$wgRequest,
$wgLang;
00944 global
$wgDisableUploads,
$wgRemoteUploads;
00945
00946 $fname = 'Skin::quickBar';
00947
wfProfileIn( $fname );
00948
00949
$action =
$wgRequest->getText( 'action' );
00950 $wpPreview =
$wgRequest->getBool( 'wpPreview' );
00951 $tns=
$wgTitle->getNamespace();
00952
00953
$s =
"\n<div id='quickbar'>";
00954
$s .=
"\n" . $this->logoText() .
"\n<hr class='sep' />";
00955
00956
$sep =
"\n<br />";
00957
$s .= $this->mainPageLink()
00958 .
$sep . $this->specialLink( 'recentchanges' )
00959 .
$sep . $this->specialLink( 'randompage' );
00960
if (
$wgUser->getID()) {
00961
$s.=
$sep . $this->specialLink( 'watchlist' ) ;
00962
$s .=
$sep .$this->makeKnownLink( $wgLang->specialPage( 'Contributions' ),
00963
wfMsg( 'mycontris' ), 'target=' .
wfUrlencode($wgUser->getName() ) );
00964
00965 }
00966
00967
if (
wfMsg ( 'currentevents' ) !=
'-' )
$s .=
$sep . $this->makeKnownLink(
wfMsg( 'currentevents' ), '' ) ;
00968
$s .=
"\n<br /><hr class='sep' />";
00969 $articleExists =
$wgTitle->getArticleId();
00970
if (
$wgOut->isArticle() ||
$action =='edit' ||
$action =='history' || $wpPreview) {
00971
if(
$wgOut->isArticle()) {
00972
$s .= '<strong>' . $this->editThisPage() . '</strong>';
00973 }
else { # backlink to the article in edit or history mode
00974
if($articleExists){ # no backlink
if no article
00975
switch($tns) {
00976
case 0:
00977 $text =
wfMsg('articlepage');
00978
break;
00979
case 1:
00980 $text =
wfMsg('viewtalkpage');
00981
break;
00982
case 2:
00983 $text =
wfMsg('userpage');
00984
break;
00985
case 3:
00986 $text =
wfMsg('viewtalkpage');
00987
break;
00988
case 4:
00989 $text =
wfMsg('wikipediapage');
00990
break;
00991
case 5:
00992 $text =
wfMsg('viewtalkpage');
00993
break;
00994
case 6:
00995 $text =
wfMsg('imagepage');
00996
break;
00997
case 7:
00998 $text =
wfMsg('viewtalkpage');
00999
break;
01000
default:
01001 $text=
wfMsg('articlepage');
01002 }
01003
01004 $link =
$wgTitle->getText();
01005
if ($nstext =
$wgLang->getNsText($tns) ) { # add
namespace if necessary
01006 $link = $nstext .
':' . $link ;
01007 }
01008
01009
$s .= $this->makeLink( $link, $text );
01010 } elseif( $wgTitle->getNamespace() !=
Namespace::getSpecial() ) {
01011
# we just throw in a "New page" text to tell the user that he's in edit mode,
01012
# and to avoid messing with the separator that is prepended to the next item
01013
$s .= '<strong>' .
wfMsg('newpage') . '</strong>';
01014 }
01015
01016 }
01017
01018
01019
if( $tns%2 &&
$action!='edit' && !$wpPreview) {
01020
$s.= '<br />'.$this->makeKnownLink($wgTitle->getPrefixedText(),
wfMsg('postcomment'),'action=edit§ion=
new');
01021 }
01022
01023
01024
01025
01026
01027
01028
01029
if ( 0 !=
$wgUser->getID() && $articleExists) {
01030
if(
$action!='edit' &&
$action != 'submit' )
01031 {
01032
$s .=
$sep . $this->watchThisPage();
01033 }
01034
if (
$wgTitle->userCanEdit() )
01035
$s .=
$sep . $this->moveThisPage();
01036 }
01037
if (
$wgUser->isSysop() and $articleExists ) {
01038
$s .=
$sep . $this->deleteThisPage() .
01039
$sep . $this->protectThisPage();
01040 }
01041
$s .=
$sep . $this->talkLink();
01042
if ($articleExists &&
$action !='history') {
01043
$s .=
$sep . $this->historyLink();
01044 }
01045
$s.=
$sep . $this->whatLinksHere();
01046
01047
if(
$wgOut->isArticleRelated()) {
01048
$s .=
$sep . $this->watchPageLinksLink();
01049 }
01050
01051
if (
Namespace::getUser() ==
$wgTitle->getNamespace()
01052 ||
$wgTitle->getNamespace() ==
Namespace::getTalk(Namespace::getUser())
01053 ) {
01054
01055 $id=User::idFromName($wgTitle->getText());
01056 $ip=User::isIP($wgTitle->getText());
01057
01058
if($id||$ip) {
01059
$s .=
$sep . $this->userContribsLink();
01060 }
01061
if ( 0 !=
$wgUser->getID() ) {
01062
if($id) { # can only email real users
01063
$s .=
$sep . $this->emailUserLink();
01064 }
01065 }
01066 }
01067
$s .=
"\n<br /><hr class='sep' />";
01068 }
01069
01070
if ( 0 !=
$wgUser->getID() && ( !
$wgDisableUploads ||
$wgRemoteUploads ) ) {
01071
$s .= $this->specialLink( 'upload' ) .
$sep;
01072 }
01073
$s .= $this->specialLink( 'specialpages' )
01074 .
$sep . $this->bugReportsLink();
01075
01076 global
$wgSiteSupportPage;
01077
if(
$wgSiteSupportPage ) {
01078
$s .=
"\n<br /><a href=\"" . htmlspecialchars( $wgSiteSupportPage ) .
01079 '
" class="internal
">' . wfMsg( 'sitesupport' ) . '</a>';
01080
}
01081
01082
$s .= "\
n<br /></div>\
n";
01083
wfProfileOut( $fname );
01084
return $s;
01085
}
01086
01087
function specialPagesList()
01088
{
01089
global $wgUser, $wgOut, $wgLang, $wgServer, $wgRedirectScript;
01090
require_once('SpecialPage.php');
01091
$a = array();
01092
$pages = SpecialPage::getPages();
01093
01094
foreach ( $pages[''] as $name => $page ) {
01095
$a[$name] = $page->getDescription();
01096
}
01097
if ( $wgUser->isSysop() )
01098
{
01099
foreach ( $pages['sysop'] as $name => $page ) {
01100
$a[$name] = $page->getDescription();
01101
}
01102
}
01103
if ( $wgUser->isDeveloper() )
01104
{
01105
foreach ( $pages['developer'] as $name => $page ) {
01106
$a[$name] = $page->getDescription() ;
01107
}
01108
}
01109
$go = wfMsg( 'go' );
01110
$sp = wfMsg( 'specialpages' );
01111
$spp = $wgLang->specialPage( 'Specialpages' );
01112
01113
$s = '<form id="specialpages
" method="get
" class="inline" ' .
01114
'action="' . htmlspecialchars(
"{$wgServer}{$wgRedirectScript}" ) .
"\">\n";
01115
$s .=
"<select name=\"wpDropdown\">\n";
01116
$s .=
"<option value=\"{$spp}\">{$sp}</option>\n";
01117
01118 foreach ( $a as $name => $desc ) {
01119 $p =
$wgLang->specialPage( $name );
01120
$s .=
"<option value=\"{$p}\">{$desc}</option>\n";
01121 }
01122
$s .=
"</select>\n";
01123
$s .=
"<input type='submit' value=\"{$go}\" name='redirect' />\n";
01124
$s .=
"</form>\n";
01125
return $s;
01126 }
01127
01128 function mainPageLink()
01129 {
01130 $mp =
wfMsg( 'mainpage' );
01131
$s = $this->makeKnownLink( $mp, $mp );
01132
return $s;
01133 }
01134
01135 function copyrightLink()
01136 {
01137
$s = $this->makeKnownLink(
wfMsg( 'copyrightpage' ),
01138
wfMsg( 'copyrightpagename' ) );
01139
return $s;
01140 }
01141
01142 function aboutLink()
01143 {
01144
$s = $this->makeKnownLink(
wfMsg( 'aboutpage' ),
01145
wfMsg( 'aboutwikipedia' ) );
01146
return $s;
01147 }
01148
01149
01150 function disclaimerLink()
01151 {
01152
$s = $this->makeKnownLink(
wfMsg( 'disclaimerpage' ),
01153
wfMsg( 'disclaimers' ) );
01154
return $s;
01155 }
01156
01157 function editThisPage()
01158 {
01159 global
$wgOut,
$wgTitle,
$wgRequest;
01160
01161 $oldid =
$wgRequest->getVal( 'oldid' );
01162 $diff =
$wgRequest->getVal( 'diff' );
01163 $redirect =
$wgRequest->getVal( 'redirect' );
01164
01165
if ( !
$wgOut->isArticleRelated() ) {
01166
$s =
wfMsg( 'protectedpage' );
01167 }
else {
01168
$n =
$wgTitle->getPrefixedText();
01169
if (
$wgTitle->userCanEdit() ) {
01170 $t =
wfMsg( 'editthispage' );
01171 }
else {
01172
#$t = wfMsg( "protectedpage" );
01173
$t =
wfMsg( 'viewsource' );
01174 }
01175 $oid = $red = '';
01176
01177
if ( !is_null( $redirect ) ) { $red =
"&redirect={$redirect}"; }
01178
if ( $oldid && ! isset( $diff ) ) {
01179 $oid =
"&oldid={$oldid}";
01180 }
01181
$s = $this->makeKnownLink( $n, $t,
"action=edit{$oid}{$red}" );
01182 }
01183
return $s;
01184 }
01185
01186 function deleteThisPage()
01187 {
01188 global
$wgUser,
$wgOut,
$wgTitle,
$wgRequest;
01189
01190 $diff =
$wgRequest->getVal( 'diff' );
01191
if (
$wgTitle->getArticleId() && ( ! $diff ) &&
$wgUser->isSysop() ) {
01192
$n =
$wgTitle->getPrefixedText();
01193 $t =
wfMsg( 'deletethispage' );
01194
01195
$s = $this->makeKnownLink( $n, $t, 'action=
delete' );
01196 }
else {
01197
$s = '';
01198 }
01199
return $s;
01200 }
01201
01202 function protectThisPage()
01203 {
01204 global
$wgUser,
$wgOut,
$wgTitle,
$wgRequest;
01205
01206 $diff =
$wgRequest->getVal( 'diff' );
01207
if (
$wgTitle->getArticleId() && ( ! $diff ) &&
$wgUser->isSysop() ) {
01208
$n =
$wgTitle->getPrefixedText();
01209
01210
if (
$wgTitle->isProtected() ) {
01211 $t =
wfMsg( 'unprotectthispage' );
01212 $q = 'action=unprotect';
01213 }
else {
01214 $t =
wfMsg( 'protectthispage' );
01215 $q = 'action=protect';
01216 }
01217
$s = $this->makeKnownLink( $n, $t, $q );
01218 }
else {
01219
$s = '';
01220 }
01221
return $s;
01222 }
01223
01224 function watchThisPage()
01225 {
01226 global
$wgUser,
$wgOut,
$wgTitle;
01227
01228
if (
$wgOut->isArticleRelated() ) {
01229
$n =
$wgTitle->getPrefixedText();
01230
01231
if (
$wgTitle->userIsWatching() ) {
01232 $t =
wfMsg( 'unwatchthispage' );
01233 $q = 'action=unwatch';
01234 }
else {
01235 $t =
wfMsg( 'watchthispage' );
01236 $q = 'action=watch';
01237 }
01238
$s = $this->makeKnownLink( $n, $t, $q );
01239 }
else {
01240
$s =
wfMsg( 'notanarticle' );
01241 }
01242
return $s;
01243 }
01244
01245 function moveThisPage()
01246 {
01247 global
$wgTitle,
$wgLang;
01248
01249
if (
$wgTitle->userCanEdit() ) {
01250
$s = $this->makeKnownLink( $wgLang->specialPage( 'Movepage' ),
01251
wfMsg( 'movethispage' ), 'target=' .
$wgTitle->getPrefixedURL() );
01252 }
01253
return $s;
01254 }
01255
01256 function historyLink()
01257 {
01258 global
$wgTitle;
01259
01260
$s = $this->makeKnownLink( $wgTitle->getPrefixedText(),
01261
wfMsg( 'history' ), 'action=history' );
01262
return $s;
01263 }
01264
01265 function whatLinksHere()
01266 {
01267 global
$wgTitle,
$wgLang;
01268
01269
$s = $this->makeKnownLink( $wgLang->specialPage( 'Whatlinkshere' ),
01270
wfMsg( 'whatlinkshere' ), 'target=' .
$wgTitle->getPrefixedURL() );
01271
return $s;
01272 }
01273
01274 function userContribsLink()
01275 {
01276 global
$wgTitle,
$wgLang;
01277
01278
$s = $this->makeKnownLink( $wgLang->specialPage( 'Contributions' ),
01279
wfMsg( 'contributions' ), 'target=' .
$wgTitle->getPartialURL() );
01280
return $s;
01281 }
01282
01283 function emailUserLink()
01284 {
01285 global
$wgTitle,
$wgLang;
01286
01287
$s = $this->makeKnownLink( $wgLang->specialPage( 'Emailuser' ),
01288
wfMsg( 'emailuser' ), 'target=' .
$wgTitle->getPartialURL() );
01289
return $s;
01290 }
01291
01292 function watchPageLinksLink()
01293 {
01294 global
$wgOut,
$wgTitle,
$wgLang;
01295
01296
if ( !
$wgOut->isArticleRelated() ) {
01297
$s =
'(' .
wfMsg( 'notanarticle' ) .
')';
01298 }
else {
01299
$s = $this->makeKnownLink( $wgLang->specialPage(
01300 'Recentchangeslinked' ),
wfMsg( 'recentchangeslinked' ),
01301 'target=' .
$wgTitle->getPrefixedURL() );
01302 }
01303
return $s;
01304 }
01305
01306 function otherLanguages()
01307 {
01308 global
$wgOut,
$wgLang,
$wgTitle, $wgUseNewInterlanguage;
01309
01310 $a =
$wgOut->getLanguageLinks();
01311
if ( 0 == count( $a ) ) {
01312
if ( !$wgUseNewInterlanguage )
return '';
01313 $ns =
$wgLang->getNsIndex ( $wgTitle->getNamespace () ) ;
01314
if ( $ns != 0 AND $ns != 1 )
return '' ;
01315 $pn = 'Intl' ;
01316 $x = 'mode=addlink&xt='.$wgTitle->getDBkey() ;
01317
return $this->makeKnownLink( $wgLang->specialPage( $pn ),
01318
wfMsg( 'intl' ) , $x );
01319 }
01320
01321
if ( !$wgUseNewInterlanguage ) {
01322
$s =
wfMsg( 'otherlanguages' ) . ': ';
01323 }
else {
01324 global
$wgLanguageCode ;
01325 $x = 'mode=zoom&xt='.$wgTitle->getDBkey() ;
01326 $x .= '&xl='.$wgLanguageCode ;
01327
$s = $this->makeKnownLink( $wgLang->specialPage( 'Intl' ),
01328
wfMsg( 'otherlanguages' ) , $x ) . ': ' ;
01329 }
01330
01331
$s =
wfMsg( 'otherlanguages' ) . ': ';
01332
$first =
true;
01333
if(
$wgLang->isRTL())
$s .= '<span dir=
"LTR">';
01334 foreach( $a as $l ) {
01335
if ( !
$first ) {
$s .= ' | '; }
01336
$first =
false;
01337
01338 $nt = Title::newFromText( $l );
01339
$url = $nt->getFullURL();
01340 $text =
$wgLang->getLanguageName( $nt->getInterwiki() );
01341
01342
if ( '' == $text ) { $text = $l; }
01343 $style = $this->getExternalLinkAttributes( $l, $text );
01344
$s .=
"<a href=\"{$url}\"{$style}>{$text}</a>";
01345 }
01346
if(
$wgLang->isRTL())
$s .= '</span>';
01347
return $s;
01348 }
01349
01350 function bugReportsLink()
01351 {
01352
$s = $this->makeKnownLink(
wfMsg( 'bugreportspage' ),
01353
wfMsg( 'bugreports' ) );
01354
return $s;
01355 }
01356
01357 function dateLink()
01358 {
01359 global
$wgLinkCache;
01360 $t1 = Title::newFromText( gmdate( 'F j' ) );
01361 $t2 = Title::newFromText( gmdate(
'Y' ) );
01362
01363
$wgLinkCache->suspend();
01364 $id = $t1->getArticleID();
01365
$wgLinkCache->resume();
01366
01367
if ( 0 == $id ) {
01368
$s = $this->makeBrokenLink( $t1->getText() );
01369 }
else {
01370
$s = $this->makeKnownLink( $t1->getText() );
01371 }
01372
$s .= ', ';
01373
01374
$wgLinkCache->suspend();
01375 $id = $t2->getArticleID();
01376
$wgLinkCache->resume();
01377
01378
if ( 0 == $id ) {
01379
$s .= $this->makeBrokenLink( $t2->getText() );
01380 }
else {
01381
$s .= $this->makeKnownLink( $t2->getText() );
01382 }
01383
return $s;
01384 }
01385
01386 function talkLink()
01387 {
01388 global
$wgLang,
$wgTitle,
$wgLinkCache;
01389
01390 $tns =
$wgTitle->getNamespace();
01391
if ( -1 == $tns ) {
return ''; }
01392
01393 $pn =
$wgTitle->getText();
01394 $tp =
wfMsg( 'talkpage' );
01395
if (
Namespace::isTalk( $tns ) ) {
01396 $lns =
Namespace::getSubject( $tns );
01397
switch($tns) {
01398
case 1:
01399 $text =
wfMsg('articlepage');
01400
break;
01401
case 3:
01402 $text =
wfMsg('userpage');
01403
break;
01404
case 5:
01405 $text =
wfMsg('wikipediapage');
01406
break;
01407
case 7:
01408 $text =
wfMsg('imagepage');
01409
break;
01410
default:
01411 $text=
wfMsg('articlepage');
01412 }
01413 }
else {
01414
01415 $lns =
Namespace::getTalk( $tns );
01416 $text=$tp;
01417 }
01418
$n =
$wgLang->getNsText( $lns );
01419
if ( '' ==
$n ) { $link = $pn; }
01420
else { $link =
$n.
':'.$pn; }
01421
01422
$wgLinkCache->suspend();
01423
$s = $this->makeLink( $link, $text );
01424
$wgLinkCache->resume();
01425
01426
return $s;
01427 }
01428
01429 function commentLink()
01430 {
01431 global
$wgLang,
$wgTitle,
$wgLinkCache;
01432
01433 $tns =
$wgTitle->getNamespace();
01434
if ( -1 == $tns ) {
return ''; }
01435
01436 $lns = (
Namespace::isTalk( $tns ) ) ? $tns :
Namespace::getTalk( $tns );
01437
01438
# assert Namespace::isTalk( $lns )
01439
01440
$n =
$wgLang->getNsText( $lns );
01441 $pn =
$wgTitle->getText();
01442
01443 $link =
$n.
':'.$pn;
01444
01445
$wgLinkCache->suspend();
01446
$s = $this->makeKnownLink($link,
wfMsg('postcomment'), 'action=edit§ion=
new');
01447
$wgLinkCache->resume();
01448
01449
return $s;
01450 }
01451
01452
# After all the page content is transformed into HTML, it makes
01453
# a final pass through here for things like table backgrounds.
01454
#
01455
function transformContent( $text )
01456 {
01457
return $text;
01458 }
01459
01460
# Note: This function MUST call getArticleID() on the link,
01461
# otherwise the cache won't get updated properly. See LINKCACHE.DOC.
01462
#
01463
function makeLink( $title, $text = '', $query = '', $trail = '' ) {
01464
wfProfileIn( 'Skin::makeLink' );
01465 $nt = Title::newFromText( $title );
01466
if ($nt) {
01467 $result = $this->makeLinkObj( Title::newFromText( $title ), $text, $query, $trail );
01468 }
else {
01469
wfDebug( 'Invalid title passed to Skin::makeLink():
"'.$title."\
"\n" );
01470 $result = $text ==
"" ?
$title : $text;
01471 }
01472
01473
wfProfileOut( 'Skin::makeLink' );
01474
return $result;
01475 }
01476
01477 function makeKnownLink( $title, $text = '', $query = '', $trail = '', $prefix = '',$aprops = '') {
01478 $nt = Title::newFromText( $title );
01479
if ($nt) {
01480
return $this->makeKnownLinkObj( Title::newFromText( $title ), $text, $query, $trail, $prefix , $aprops );
01481 }
else {
01482
wfDebug( 'Invalid title passed to Skin::makeKnownLink():
"'.$title."\
"\n" );
01483
return $text == '' ?
$title : $text;
01484 }
01485 }
01486
01487 function makeBrokenLink( $title, $text = '', $query = '', $trail = '' ) {
01488 $nt = Title::newFromText( $title );
01489
if ($nt) {
01490
return $this->makeBrokenLinkObj( Title::newFromText( $title ), $text, $query, $trail );
01491 }
else {
01492
wfDebug( 'Invalid title passed to Skin::makeBrokenLink():
"'.$title."\
"\n" );
01493
return $text == '' ?
$title : $text;
01494 }
01495 }
01496
01497 function makeStubLink( $title, $text = '', $query = '', $trail = '' ) {
01498 $nt = Title::newFromText( $title );
01499
if ($nt) {
01500
return $this->makeStubLinkObj( Title::newFromText( $title ), $text, $query, $trail );
01501 }
else {
01502
wfDebug( 'Invalid title passed to Skin::makeStubLink():
"'.$title."\
"\n" );
01503
return $text == '' ?
$title : $text;
01504 }
01505 }
01506
01507
# Pass a title object, not a title string
01508
function makeLinkObj( &$nt, $text= '', $query = '', $trail = '', $prefix = '' )
01509 {
01510 global
$wgOut,
$wgUser;
01511
if ( $nt->isExternal() ) {
01512 $u = $nt->getFullURL();
01513 $link = $nt->getPrefixedURL();
01514
if ( '' == $text ) { $text = $nt->getPrefixedText(); }
01515 $style = $this->getExternalLinkAttributes( $link, $text, 'extiw' );
01516
01517 $inside = '';
01518
if ( '' != $trail ) {
01519
if ( preg_match( '/^([a-z]+)(.*)$$/sD', $trail, $m ) ) {
01520 $inside = $m[1];
01521 $trail = $m[2];
01522 }
01523 }
01524 $retVal =
"<a href=\"{$u}\"{$style}>{$text}{$inside}</a>{$trail}";
01525 } elseif ( 0 == $nt->getNamespace() &&
"" == $nt->getText() ) {
01526 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
01527 } elseif ( ( -1 == $nt->getNamespace() ) ||
01528 (
Namespace::getImage() == $nt->getNamespace() ) ) {
01529 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
01530 }
else {
01531 $aid = $nt->getArticleID() ;
01532
if ( 0 == $aid ) {
01533 $retVal = $this->makeBrokenLinkObj( $nt, $text, $query, $trail, $prefix );
01534 }
else {
01535 $threshold =
$wgUser->getOption('stubthreshold') ;
01536
if ( $threshold > 0 ) {
01537
$res =
wfQuery (
"SELECT LENGTH(cur_text) AS x, cur_namespace, cur_is_redirect FROM cur WHERE cur_id='{$aid}'", DB_READ ) ;
01538
01539
if (
wfNumRows( $res ) > 0 ) {
01540
$s =
wfFetchObject( $res );
01541 $size =
$s->x;
01542
if (
$s->cur_is_redirect OR
$s->cur_namespace != 0 ) {
01543 $size = $threshold*2 ; # Really big
01544 }
01545
wfFreeResult( $res );
01546 }
else {
01547 $size = $threshold*2 ; # Really big
01548 }
01549 }
else {
01550 $size = 1 ;
01551 }
01552
if ( $size < $threshold ) {
01553 $retVal = $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix );
01554 }
else {
01555 $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
01556 }
01557 }
01558 }
01559
return $retVal;
01560 }
01561
01562
# Pass a title object, not a title string
01563
function makeKnownLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '')
01564 {
01565 global
$wgOut,
$wgTitle,
$wgInputEncoding;
01566
01567 $fname = 'Skin::makeKnownLinkObj';
01568
wfProfileIn( $fname );
01569
01570 $link = $nt->getPrefixedURL();
01571
01572
if ( '' == $link ) {
01573 $u = '';
01574
if ( '' == $text ) {
01575 $text = htmlspecialchars( $nt->getFragment() );
01576 }
01577 }
else {
01578 $u = $nt->escapeLocalURL( $query );
01579 }
01580
if ( '' != $nt->getFragment() ) {
01581 $anchor = urlencode(
do_html_entity_decode( str_replace(
' ',
'_', $nt->getFragment()), ENT_COMPAT,
$wgInputEncoding ) );
01582 $replacearray = array(
01583 '%3A' =>
':',
01584
'%' =>
'.'
01585 );
01586 $u .=
'#' . str_replace(array_keys($replacearray),array_values($replacearray),$anchor);
01587 }
01588
if ( '' == $text ) {
01589 $text = htmlspecialchars( $nt->getPrefixedText() );
01590 }
01591 $style = $this->getInternalLinkAttributesObj( $nt, $text );
01592
01593 $inside = '';
01594
if ( '' != $trail ) {
01595
if ( preg_match( $this->linktrail, $trail, $m ) ) {
01596 $inside = $m[1];
01597 $trail = $m[2];
01598 }
01599 }
01600 $r =
"<a href=\"{$u}\"{$style}{$aprops}>{$prefix}{$text}{$inside}</a>{$trail}";
01601
wfProfileOut( $fname );
01602
return $r;
01603 }
01604
01605
# Pass a title object, not a title string
01606
function makeBrokenLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' )
01607 {
01608 global
$wgOut,
$wgUser;
01609
01610 $fname = 'Skin::makeBrokenLinkObj';
01611
wfProfileIn( $fname );
01612
01613
if ( '' == $query ) {
01614 $q = 'action=edit';
01615 }
else {
01616 $q = 'action=edit&'.$query;
01617 }
01618 $u = $nt->escapeLocalURL( $q );
01619
01620
if ( '' == $text ) {
01621 $text = htmlspecialchars( $nt->getPrefixedText() );
01622 }
01623 $style = $this->getInternalLinkAttributesObj( $nt, $text,
"yes" );
01624
01625 $inside = '';
01626
if ( '' != $trail ) {
01627
if ( preg_match( $this->linktrail, $trail, $m ) ) {
01628 $inside = $m[1];
01629 $trail = $m[2];
01630 }
01631 }
01632
if (
$wgUser->getOption( 'highlightbroken' ) ) {
01633
$s =
"<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
01634 }
else {
01635
$s =
"{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>?</a>{$trail}";
01636 }
01637
01638
wfProfileOut( $fname );
01639
return $s;
01640 }
01641
01642
# Pass a title object, not a title string
01643
function makeStubLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' )
01644 {
01645 global
$wgOut,
$wgUser;
01646
01647 $link = $nt->getPrefixedURL();
01648
01649 $u = $nt->escapeLocalURL( $query );
01650
01651
if ( '' == $text ) {
01652 $text = htmlspecialchars( $nt->getPrefixedText() );
01653 }
01654 $style = $this->getInternalLinkAttributesObj( $nt, $text, 'stub' );
01655
01656 $inside = '';
01657
if ( '' != $trail ) {
01658
if ( preg_match( $this->linktrail, $trail, $m ) ) {
01659 $inside = $m[1];
01660 $trail = $m[2];
01661 }
01662 }
01663
if (
$wgUser->getOption( 'highlightbroken' ) ) {
01664
$s =
"<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
01665 }
else {
01666
$s =
"{$prefix}{$text}{$inside}<a href=\"{$u}\"{$style}>!</a>{$trail}";
01667 }
01668
return $s;
01669 }
01670
01671 function makeSelfLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' )
01672 {
01673 $u = $nt->escapeLocalURL( $query );
01674
if ( '' == $text ) {
01675 $text = htmlspecialchars( $nt->getPrefixedText() );
01676 }
01677 $inside = '';
01678
if ( '' != $trail ) {
01679
if ( preg_match( $this->linktrail, $trail, $m ) ) {
01680 $inside = $m[1];
01681 $trail = $m[2];
01682 }
01683 }
01684
return "<strong>{$prefix}{$text}{$inside}</strong>{$trail}";
01685 }
01686
01687
01688 function makeSpecialUrl( $name, $urlaction='' ) {
01689
$title = Title::makeTitle( NS_SPECIAL, $name );
01690 $this->checkTitle($title, $name);
01691
return $title->getLocalURL( $urlaction );
01692 }
01693 function makeTalkUrl ( $name, $urlaction='' ) {
01694
$title = Title::newFromText( $name );
01695
$title =
$title->getTalkPage();
01696 $this->checkTitle($title, $name);
01697
return $title->getLocalURL( $urlaction );
01698 }
01699 function makeArticleUrl ( $name, $urlaction='' ) {
01700
$title = Title::newFromText( $name );
01701
$title=
$title->getSubjectPage();
01702 $this->checkTitle($title, $name);
01703
return $title->getLocalURL( $urlaction );
01704 }
01705 function makeI18nUrl ( $name, $urlaction='' ) {
01706
$title = Title::newFromText(
wfMsg($name) );
01707 $this->checkTitle($title, $name);
01708
return $title->getLocalURL( $urlaction );
01709 }
01710 function makeUrl ( $name, $urlaction='' ) {
01711
$title = Title::newFromText( $name );
01712 $this->checkTitle($title, $name);
01713
return $title->getLocalURL( $urlaction );
01714 }
01715
# this can be passed the NS number as defined in Language.php
01716
function makeNSUrl( $name, $urlaction='', $
namespace=0 ) {
01717
$title = Title::makeTitle( $
namespace, $name );
01718 $this->checkTitle($title, $name);
01719
return $title->getLocalURL( $urlaction );
01720 }
01721
01722
01723 function makeUrlDetails ( $name, $urlaction='' ) {
01724
$title = Title::newFromText( $name );
01725 $this->checkTitle($title, $name);
01726
return array(
01727 'href' => $
title->getLocalURL( $urlaction ),
01728 'exists' =>
$title->getArticleID() != 0?
true:
false
01729 );
01730 }
01731 function makeTalkUrlDetails ( $name, $urlaction='' ) {
01732
$title = Title::newFromText( $name );
01733
$title =
$title->getTalkPage();
01734 $this->checkTitle($title, $name);
01735
return array(
01736 'href' => $
title->getLocalURL( $urlaction ),
01737 'exists' =>
$title->getArticleID() != 0?
true:
false
01738 );
01739 }
01740 function makeArticleUrlDetails ( $name, $urlaction='' ) {
01741
$title = Title::newFromText( $name );
01742
$title=
$title->getSubjectPage();
01743 $this->checkTitle($title, $name);
01744
return array(
01745 'href' => $
title->getLocalURL( $urlaction ),
01746 'exists' =>
$title->getArticleID() != 0?
true:
false
01747 );
01748 }
01749 function makeI18nUrlDetails ( $name, $urlaction='' ) {
01750
$title = Title::newFromText(
wfMsg($name) );
01751 $this->checkTitle($title, $name);
01752
return array(
01753 'href' => $
title->getLocalURL( $urlaction ),
01754 'exists' =>
$title->getArticleID() != 0?
true:
false
01755 );
01756 }
01757
01758
# make sure we have some title to operate on
01759
function checkTitle ( &$title, &$name ) {
01760
if(!is_object($title)) {
01761
$title = Title::newFromText( $name );
01762
if(!is_object($title)) {
01763
$title = Title::newFromText( '<error: link target missing>' );
01764 }
01765 }
01766 }
01767
01768 function fnamePart( $url )
01769 {
01770 $basename = strrchr( $url,
'/' );
01771
if (
false === $basename ) { $basename =
$url; }
01772
else { $basename = substr( $basename, 1 ); }
01773
return wfEscapeHTML( $basename );
01774 }
01775
01776 function makeImage( $url, $alt = '' )
01777 {
01778 global
$wgOut;
01779
01780
if ( '' == $alt ) { $alt = $this->fnamePart( $url ); }
01781
$s = '<img src=
"'.$url.'" alt=
"'.$alt.'" />';
01782
return $s;
01783 }
01784
01785 function makeImageLink( $name, $url, $alt = '' ) {
01786 $nt = Title::makeTitle( Namespace::getImage(), $name );
01787
return $this->makeImageLinkObj( $nt, $alt );
01788 }
01789
01790 function makeImageLinkObj( $nt, $alt = '' ) {
01791 global
$wgLang,
$wgUseImageResize;
01792 $img =
Image::newFromTitle( $nt );
01793
$url = $img->getURL();
01794
01795 $align = '';
01796 $prefix = $postfix = '';
01797
01798
if (
$wgUseImageResize ) {
01799
# Check if the alt text is of the form "options|alt text"
01800
# Options are:
01801
# * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang
01802
# * left no resizing, just left align. label is used for alt= only
01803
# * right same, but right aligned
01804
# * none same, but not aligned
01805
# * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox
01806
# * center center the image
01807
# * framed Keep original image size, no magnify-button.
01808
01809 $part = explode(
'|', $alt);
01810
01811 $mwThumb =& MagicWord::get( MAG_IMG_THUMBNAIL );
01812 $mwLeft =& MagicWord::get( MAG_IMG_LEFT );
01813 $mwRight =& MagicWord::get( MAG_IMG_RIGHT );
01814 $mwNone =& MagicWord::get( MAG_IMG_NONE );
01815 $mwWidth =& MagicWord::get( MAG_IMG_WIDTH );
01816 $mwCenter =& MagicWord::get( MAG_IMG_CENTER );
01817 $mwFramed =& MagicWord::get( MAG_IMG_FRAMED );
01818 $alt = $part[count($part)-1];
01819
01820 $height = $framed = $thumb =
false;
01821
01822 foreach( $part as $key => $val ) {
01823
if ( ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) {
01824 $thumb=
true;
01825 } elseif ( ! is_null( $mwRight->matchVariableStartToEnd($val) ) ) {
01826
# remember to set an alignment, don't render immediately
01827
$align = 'right';
01828 } elseif ( ! is_null( $mwLeft->matchVariableStartToEnd($val) ) ) {
01829
# remember to set an alignment, don't render immediately
01830
$align = 'left';
01831 } elseif ( ! is_null( $mwCenter->matchVariableStartToEnd($val) ) ) {
01832
# remember to set an alignment, don't render immediately
01833
$align = 'center';
01834 } elseif ( ! is_null( $mwNone->matchVariableStartToEnd($val) ) ) {
01835
# remember to set an alignment, don't render immediately
01836
$align = 'none';
01837 } elseif ( ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) {
01838
# $match is the image width in pixels
01839
if ( preg_match( '/^([0-9]*)x([0-9]*)$/', $match, $m ) ) {
01840
$width = intval( $m[1] );
01841 $height = intval( $m[2] );
01842 }
else {
01843
$width = intval($match);
01844 }
01845 } elseif ( ! is_null( $mwFramed->matchVariableStartToEnd($val) ) ) {
01846 $framed=
true;
01847 }
01848 }
01849
if ( 'center' == $align )
01850 {
01851 $prefix = '<span style=
"text-align: center">';
01852 $postfix = '</span>';
01853 $align = 'none';
01854 }
01855
01856
if ( $thumb || $framed ) {
01857
01858
# Create a thumbnail. Alignment depends on language
01859
# writing direction, # right aligned for left-to-right-
01860
# languages ("Western languages"), left-aligned
01861
# for right-to-left-languages ("Semitic languages")
01862
#
01863
# If thumbnail width has not been provided, it is set
01864
# here to 180 pixels
01865
if ( $align == '' ) {
01866 $align =
$wgLang->isRTL() ? 'left' : 'right';
01867 }
01868
if ( ! isset($width) ) {
01869
$width = 180;
01870 }
01871
return $prefix.$this->makeThumbLinkObj( $img, $alt, $align, $width, $height, $framed ).$postfix;
01872
01873 } elseif ( isset($width) ) {
01874
01875
# Create a resized image, without the additional thumbnail
01876
# features
01877
01878
if ( ( ! $height ===
false )
01879 && ( $img->getHeight() *
$width / $img->getWidth() > $height ) ) {
01880 print
"height=$height<br>\nimg->getHeight() = ".$img->getHeight().
"<br>\n";
01881 print 'rescaling by factor '. $height / $img->getHeight() .
"<br>\n";
01882
$width = $img->getWidth() * $height / $img->getHeight();
01883 }
01884
$url = $img->createThumb( $width );
01885 }
01886 } # endif
$wgUseImageResize
01887
01888
if ( empty( $alt ) ) {
01889 $alt = preg_replace( '/\.(.+?)^/', '', $img->getName() );
01890 }
01891 $alt = htmlspecialchars( $alt );
01892
01893 $u = $nt->escapeLocalURL();
01894
if (
$url == '' )
01895 {
01896
$s = str_replace(
"$1", $img->getName(),
wfMsg('missingimage') );
01897
$s .=
"<br>{$alt}<br>{$url}<br>\n";
01898 }
else {
01899
$s = '<a href=
"'.$u.'" class=
"image" title=
"'.$alt.'">' .
01900 '<img src=
"'.$url.'" alt=
"'.$alt.'" /></a>';
01901 }
01902
if ( '' != $align ) {
01903
$s =
"<div class=\"float{$align}\"><span>{$s}</span></div>";
01904 }
01905
return str_replace(
"\n",
' ',$prefix.$s.$postfix);
01906 }
01907
01908
01909 function makeThumbLinkObj( $img, $label = '', $align = 'right', $boxwidth = 180, $boxheight=
false, $framed=
false ) {
01910 global
$wgStylePath,
$wgLang;
01911
# $image = Title::makeTitle( Namespace::getImage(), $name );
01912
$url = $img->getURL();
01913
01914
#$label = htmlspecialchars( $label );
01915
$alt = preg_replace( '/<[^>]*>/', '', $label);
01916 $alt = htmlspecialchars( $alt );
01917
01918
if ( $img->exists() )
01919 {
01920
$width = $img->getWidth();
01921 $height = $img->getHeight();
01922 }
else {
01923
$width = $height = 200;
01924 }
01925
if ( $framed )
01926 {
01927
01928 $boxwidth =
$width;
01929 $oboxwidth = $boxwidth + 2;
01930 $boxheight = $height;
01931 $thumbUrl =
$url;
01932 }
else {
01933 $h = intval( $height/($width/$boxwidth) );
01934 $oboxwidth = $boxwidth + 2;
01935
if ( ( ! $boxheight ===
false ) && ( $h > $boxheight ) )
01936 {
01937 $boxwidth *= $boxheight/$h;
01938 }
else {
01939 $boxheight = $h;
01940 }
01941 $thumbUrl = $img->createThumb( $boxwidth );
01942 }
01943
01944 $u = $img->getEscapeLocalURL();
01945
01946 $more = htmlspecialchars(
wfMsg( 'thumbnail-more' ) );
01947 $magnifyalign =
$wgLang->isRTL() ? 'left' : 'right';
01948 $textalign =
$wgLang->isRTL() ? ' style=
"text-align:right"' : '';
01949
01950
$s =
"<div class=\"thumb t{$align}\"><div style=\"width:{$oboxwidth}px;\">";
01951
if ( $thumbUrl == '' ) {
01952
$s .= str_replace(
"$1", $img->getName(),
wfMsg('missingimage') );
01953 $zoomicon = '';
01954 }
else {
01955
$s .= '<a href=
"'.$u.'" class=
"internal" title=
"'.$alt.'">'.
01956 '<img src=
"'.$thumbUrl.'" alt=
"'.$alt.'" ' .
01957 'width=
"'.$boxwidth.'" height=
"'.$boxheight.'" /></a>';
01958
if ( $framed ) {
01959 $zoomicon=
"";
01960 }
else {
01961 $zoomicon = '<div
class=
"magnify" style=
"float:'.$magnifyalign.'">'.
01962 '<a href=
"'.$u.'" class=
"internal" title=
"'.$more.'">'.
01963 '<img src=
"'.$wgStylePath.'/images/magnify-clip.png" ' .
01964 'width=
"15" height=
"11" alt=
"'.$more.'" /></a></div>';
01965 }
01966 }
01967
$s .= ' <div
class=
"thumbcaption" '.$textalign.
'>'.$zoomicon.$label.
"</div></div></div>";
01968
return str_replace(
"\n",
' ', $s);
01969 }
01970
01971 function makeMediaLink( $name, $url, $alt =
"" ) {
01972 $nt = Title::makeTitle( Namespace::getMedia(), $name );
01973
return $this->makeMediaLinkObj( $nt, $alt );
01974 }
01975
01976 function makeMediaLinkObj( $nt, $alt =
"" )
01977 {
01978
if ( ! isset( $nt ) )
01979 {
01980
### HOTFIX. Instead of breaking, return empry string.
01981
$s = $alt;
01982 }
else {
01983 $name = $nt->getDBKey();
01984
$url =
Image::wfImageUrl( $name );
01985
if ( empty( $alt ) ) {
01986 $alt = preg_replace( '/\.(.+?)^/', '', $name );
01987 }
01988
01989 $u = htmlspecialchars( $url );
01990
$s =
"<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$alt}</a>";
01991 }
01992
return $s;
01993 }
01994
01995 function specialLink( $name, $key =
"" )
01996 {
01997 global
$wgLang;
01998
01999
if ( '' == $key ) { $key = strtolower( $name ); }
02000 $pn =
$wgLang->ucfirst( $name );
02001
return $this->makeKnownLink( $wgLang->specialPage( $pn ),
02002
wfMsg( $key ) );
02003 }
02004
02005 function makeExternalLink( $url, $text, $escape =
true ) {
02006 $style = $this->getExternalLinkAttributes( $url, $text );
02007
$url = htmlspecialchars( $url );
02008
if( $escape ) {
02009 $text = htmlspecialchars( $text );
02010 }
02011
return '<a href=
"'.$url.'"'.$style.
'>'.$text.'</a>';
02012 }
02013
02014
# Called by history lists and recent changes
02015
#
02016
02017
# Returns text for the start of the tabular part of RC
02018
function beginRecentChangesList()
02019 {
02020 $this->rc_cache = array() ;
02021 $this->rcMoveIndex = 0;
02022 $this->rcCacheIndex = 0 ;
02023 $this->lastdate = '';
02024 $this->rclistOpen =
false;
02025
return '';
02026 }
02027
02028 function beginImageHistoryList()
02029 {
02030
$s =
"\n<h2>" .
wfMsg( 'imghistory' ) .
"</h2>\n" .
02031
"<p>" .
wfMsg( 'imghistlegend' ) .
"</p>\n".'<ul
class=
"special">';
02032
return $s;
02033 }
02034
02035
# Returns text for the end of RC
02036
# If enhanced RC is in use, returns pretty much all the text
02037
function endRecentChangesList()
02038 {
02039
$s = $this->recentChangesBlock() ;
02040
if( $this->rclistOpen ) {
02041
$s .=
"</ul>\n";
02042 }
02043
return $s;
02044 }
02045
02046
# Enhanced RC ungrouped line
02047
function recentChangesBlockLine ( $rcObj )
02048 {
02049 global
$wgStylePath,
$wgLang ;
02050
02051
# Get rc_xxxx variables
02052
extract( $rcObj->mAttribs ) ;
02053 $curIdEq = 'curid='.$rc_cur_id;
02054
02055
# Spacer image
02056
$r = '' ;
02057
02058 $r .= '<img src=
"'.$wgStylePath.'/images/Arr_.png" width=
"12" height=
"12" border=
"0" />' ;
02059 $r .= '<tt>' ;
02060
02061
if ( $rc_type ==
RC_MOVE || $rc_type ==
RC_MOVE_OVER_REDIRECT ) {
02062 $r .= ' ';
02063 }
else {
02064
# M & N (minor & new)
02065
$M =
wfMsg( 'minoreditletter' );
02066 $N =
wfMsg( 'newpageletter' );
02067
02068
if ( $rc_type ==
RC_NEW ) {
02069 $r .= $N ;
02070 }
else {
02071 $r .= ' ' ;
02072 }
02073
if ( $rc_minor ) {
02074 $r .= $M ;
02075 }
else {
02076 $r .= ' ' ;
02077 }
02078 }
02079
02080
# Timestamp
02081
$r .=
' '.$rcObj->timestamp.
' ' ;
02082 $r .= '</tt>' ;
02083
02084
# Article link
02085
$link = $rcObj->link ;
02086
if ( $rcObj->watched ) $link = '<strong>'.$link.'</strong>' ;
02087 $r .= $link ;
02088
02089
# Cur
02090
$r .= ' (' ;
02091 $r .= $rcObj->curlink ;
02092 $r .= '; ' ;
02093
02094
# Hist
02095
$r .= $this->makeKnownLinkObj( $rcObj->getTitle(),
wfMsg( 'hist' ), $curIdEq.'&action=history' );
02096
02097
# User/talk
02098
$r .= ') . . '.$rcObj->userlink ;
02099 $r .= $rcObj->usertalklink ;
02100
02101
# Comment
02102
if ( $rc_comment != '' && $rc_type !=
RC_MOVE && $rc_type !=
RC_MOVE_OVER_REDIRECT ) {
02103 $rc_comment=$this->formatComment($rc_comment);
02104 $r .=
$wgLang->emphasize( ' ('.$rc_comment.
')' );
02105 }
02106
02107 $r .=
"<br />\n" ;
02108
return $r ;
02109 }
02110
02111
# Enhanced RC group
02112
function recentChangesBlockGroup ( $block )
02113 {
02114 global
$wgStylePath,
$wgLang ;
02115
02116 $r = '' ;
02117 $M =
wfMsg( 'minoreditletter' );
02118 $N =
wfMsg( 'newpageletter' );
02119
02120
# Collate list of users
02121
$isnew =
false ;
02122 $userlinks = array () ;
02123 foreach ( $block AS $rcObj ) {
02124 $oldid = $rcObj->mAttribs['rc_last_oldid'];
02125
if ( $rcObj->mAttribs['rc_new'] ) $isnew =
true ;
02126 $u = $rcObj->userlink ;
02127
if ( !isset ( $userlinks[$u] ) ) $userlinks[$u] = 0 ;
02128 $userlinks[$u]++ ;
02129 }
02130
02131
# Sort the list and convert to text
02132
krsort ( $userlinks ) ;
02133 asort ( $userlinks ) ;
02134 $users = array () ;
02135 foreach ( $userlinks as $userlink => $count) {
02136 $text = $userlink ;
02137
if (
$count > 1 ) $text .=
" ({$count}×)" ;
02138 array_push ( $users , $text ) ;
02139 }
02140 $users = ' <font size=
"-1">['.implode('; ',$users).']</font>' ;
02141
02142
# Arrow
02143
$rci = 'RCI'.$this->rcCacheIndex ;
02144 $rcl = 'RCL'.$this->rcCacheIndex ;
02145 $rcm = 'RCM'.$this->rcCacheIndex ;
02146 $toggleLink =
"javascript:toggleVisibility('$rci','$rcm','$rcl')" ;
02147 $arrowdir =
$wgLang->isRTL() ?
'l' :
'r';
02148 $tl = '<span
id=
"'.$rcm.'"><a href=
"'.$toggleLink.'"><img src=
"'.$wgStylePath.'/images/Arr_'.$arrowdir.'.png" width=
"12" height=
"12" /></a></span>' ;
02149 $tl .= '<span
id=
"'.$rcl.'" style=
"display:none"><a href=
"'.$toggleLink.'"><img src=
"'.$wgStylePath.'/images/Arr_d.png" width=
"12" height=
"12" /></a></span>' ;
02150 $r .= $tl ;
02151
02152
# Main line
02153
# M/N
02154
$r .= '<tt>' ;
02155
if ( $isnew ) $r .= $N ;
02156
else $r .= ' ' ;
02157 $r .= ' ' ; # Minor
02158
02159
# Timestamp
02160
$r .=
' '.$block[0]->timestamp.
' ' ;
02161 $r .= '</tt>' ;
02162
02163
# Article link
02164
$link = $block[0]->link ;
02165
if ( $block[0]->watched ) $link = '<strong>'.$link.'</strong>' ;
02166 $r .= $link ;
02167
02168 $curIdEq = 'curid=' . $block[0]->mAttribs['rc_cur_id'];
02169
if ( $block[0]->mAttribs['rc_type'] !=
RC_LOG ) {
02170
# Changes
02171
$r .= ' ('.count($block).
' ' ;
02172
if ( $isnew ) $r .=
wfMsg('changes');
02173
else $r .= $this->makeKnownLinkObj( $block[0]->getTitle() ,
wfMsg('changes') ,
02174 $curIdEq.'&diff=0&oldid='.$oldid ) ;
02175 $r .= '; ' ;
02176
02177
# History
02178
$r .= $this->makeKnownLinkObj( $block[0]->getTitle(),
wfMsg( 'history' ), $curIdEq.'&action=history' );
02179 $r .=
')' ;
02180 }
02181
02182 $r .= $users ;
02183 $r .=
"<br />\n" ;
02184
02185
# Sub-entries
02186
$r .= '<div
id=
"'.$rci.'" style=
"display:none">' ;
02187 foreach ( $block AS $rcObj ) {
02188
# Get rc_xxxx variables
02189
extract( $rcObj->mAttribs );
02190
02191 $r .= '<img src=
"'.$wgStylePath.'/images/Arr_.png" width=
"12" height=
"12" />';
02192 $r .= '<tt> ' ;
02193
if ( $rc_new ) $r .= $N ;
02194
else $r .= ' ' ;
02195
if ( $rc_minor ) $r .= $M ;
02196
else $r .= ' ' ;
02197 $r .= '</tt>' ;
02198
02199 $o = '' ;
02200
if ( $rc_last_oldid != 0 ) {
02201 $o = 'oldid='.$rc_last_oldid ;
02202 }
02203
if ( $rc_type ==
RC_LOG ) {
02204 $link = $rcObj->timestamp ;
02205 }
else {
02206 $link = $this->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp ,
"{$curIdEq}&$o" ) ;
02207 }
02208 $link = '<tt>'.$link.'</tt>' ;
02209
02210 $r .= $link ;
02211 $r .= ' (' ;
02212 $r .= $rcObj->curlink ;
02213 $r .= '; ' ;
02214 $r .= $rcObj->lastlink ;
02215 $r .= ') . . '.$rcObj->userlink ;
02216 $r .= $rcObj->usertalklink ;
02217
if ( $rc_comment != '' ) {
02218 $rc_comment=$this->formatComment($rc_comment);
02219 $r .=
$wgLang->emphasize( ' ('.$rc_comment.
')' ) ;
02220 }
02221 $r .=
"<br />\n" ;
02222 }
02223 $r .=
"</div>\n" ;
02224
02225 $this->rcCacheIndex++ ;
02226
return $r ;
02227 }
02228
02229
# If enhanced RC is in use, this function takes the previously cached
02230
# RC lines, arranges them, and outputs the HTML
02231
function recentChangesBlock ()
02232 {
02233 global
$wgStylePath ;
02234
if ( count ( $this->rc_cache ) == 0 )
return '' ;
02235 $blockOut = '';
02236 foreach ( $this->rc_cache AS $secureName => $block ) {
02237
if ( count ( $block ) < 2 ) {
02238 $blockOut .= $this->recentChangesBlockLine ( array_shift ( $block ) ) ;
02239 }
else {
02240 $blockOut .= $this->recentChangesBlockGroup ( $block ) ;
02241 }
02242 }
02243
02244
return '<div>'.$blockOut.'</div>' ;
02245 }
02246
02247
# Called in a loop over all displayed RC entries
02248
# Either returns the line, or caches it for later use
02249
function recentChangesLine( &$rc, $watched =
false )
02250 {
02251 global
$wgUser ;
02252 $usenew =
$wgUser->getOption( 'usenewrc' );
02253
if ( $usenew )
02254
$line = $this->recentChangesLineNew ( $rc, $watched ) ;
02255
else
02256
$line = $this->recentChangesLineOld ( $rc, $watched ) ;
02257
return $line ;
02258 }
02259
02260 function recentChangesLineOld( &$rc, $watched =
false )
02261 {
02262 global
$wgTitle,
$wgLang,
$wgUser, $wgRCSeconds;
02263
02264
# Extract DB fields into local scope
02265
extract( $rc->mAttribs );
02266 $curIdEq = 'curid=' . $rc_cur_id;
02267
02268
# Make date header if necessary
02269
$date =
$wgLang->date( $rc_timestamp,
true);
02270
$s = '';
02271
if ( $date != $this->lastdate ) {
02272
if ( '' != $this->lastdate ) {
$s .=
"</ul>\n"; }
02273
$s .=
"<h4>{$date}</h4>\n<ul class='special'>";
02274 $this->lastdate = $date;
02275 $this->rclistOpen =
true;
02276 }
02277
$s .= '<li> ';
02278
02279
if ( $rc_type ==
RC_MOVE || $rc_type ==
RC_MOVE_OVER_REDIRECT ) {
02280
# Diff
02281
$s .=
'(' .
wfMsg( 'diff' ) . ') (';
02282
# Hist
02283
$s .= $this->makeKnownLinkObj( $rc->getMovedToTitle(),
wfMsg( 'hist' ), 'action=history' ) .
02284 ') . . ';
02285
02286
# "[[x]] moved to [[y]]"
02287
if ( $rc_type ==
RC_MOVE ) {
02288 $msg = '1movedto2';
02289 }
else {
02290 $msg = '1movedto2_redir';
02291 }
02292
$s .=
wfMsg( $msg, $this->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
02293 $this->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
02294 }
else {
02295
# Diff link
02296
if ( $rc_type ==
RC_NEW || $rc_type ==
RC_LOG ) {
02297 $diffLink =
wfMsg( 'diff' );
02298 }
else {
02299 $diffLink = $this->makeKnownLinkObj( $rc->getTitle(),
wfMsg( 'diff' ),
02300 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid ,'' ,'' , ' tabindex=
"'.$rc->counter.'"');
02301 }
02302
$s .=
'('.$diffLink.') (';
02303
02304
# History link
02305
$s .= $this->makeKnownLinkObj( $rc->getTitle(),
wfMsg( 'hist' ), $curIdEq.'&action=history' );
02306
$s .= ') . . ';
02307
02308
# M and N (minor and new)
02309
$M =
wfMsg( 'minoreditletter' );
02310 $N =
wfMsg( 'newpageletter' );
02311
if ( $rc_minor ) {
$s .= ' <strong>'.$M.'</strong>'; }
02312
if ( $rc_type ==
RC_NEW ) {
$s .= '<strong>'.$N.'</strong>'; }
02313
02314
# Article link
02315
$articleLink = $this->makeKnownLinkObj( $rc->getTitle(), '' );
02316
02317
if ( $watched ) {
02318 $articleLink = '<strong>'.$articleLink.'</strong>';
02319 }
02320
$s .=
' '.$articleLink;
02321
02322 }
02323
02324
# Timestamp
02325
$s .= '; ' .
$wgLang->time( $rc_timestamp,
true, $wgRCSeconds ) . ' . . ';
02326
02327
# User link (or contributions for unregistered users)
02328
if ( 0 == $rc_user ) {
02329 $userLink = $this->makeKnownLink( $wgLang->specialPage( 'Contributions' ),
02330 $rc_user_text, 'target=' . $rc_user_text );
02331 }
else {
02332 $userLink = $this->makeLink( $wgLang->getNsText( NS_USER ) .
':'.$rc_user_text, $rc_user_text );
02333 }
02334
$s .= $userLink;
02335
02336
# User talk link
02337
$talkname=
$wgLang->getNsText(NS_TALK); # use the shorter
name
02338 global
$wgDisableAnonTalk;
02339
if( 0 == $rc_user &&
$wgDisableAnonTalk ) {
02340 $userTalkLink = '';
02341 }
else {
02342 $utns=
$wgLang->getNsText(NS_USER_TALK);
02343 $userTalkLink= $this->makeLink($utns .
':'.$rc_user_text, $talkname );
02344 }
02345
# Block link
02346
$blockLink='';
02347
if ( ( 0 == $rc_user ) &&
$wgUser->isSysop() ) {
02348 $blockLink = $this->makeKnownLink( $wgLang->specialPage(
02349 'Blockip' ),
wfMsg( 'blocklink' ), 'ip='.$rc_user_text );
02350
02351 }
02352
if($blockLink) {
02353
if($userTalkLink) $userTalkLink .= ' | ';
02354 $userTalkLink .= $blockLink;
02355 }
02356
if($userTalkLink)
$s.=' ('.$userTalkLink.
')';
02357
02358
# Add comment
02359
if ( '' != $rc_comment &&
'*' != $rc_comment && $rc_type !=
RC_MOVE ) {
02360 $rc_comment=$this->formatComment($rc_comment);
02361
$s .=
$wgLang->emphasize(' (' . $rc_comment .
')');
02362 }
02363 $s .=
"</li>\n";
02364
02365
return $s;
02366 }
02367
02368 # function recentChangesLineNew( $ts, $u, $ut, $ns, $ttl, $c, $isminor, $isnew, $watched =
false, $oldid = 0 , $diffid = 0 )
02369 function recentChangesLineNew( &$baseRC, $watched =
false )
02370 {
02371 global $wgTitle, $wgLang, $wgUser, $wgRCSeconds;
02372
02373 # Create a specialised object
02374 $rc = RCCacheEntry::newFromParent( $baseRC ) ;
02375
02376 # Extract fields from DB into the function scope (rc_xxxx variables)
02377 extract( $rc->mAttribs );
02378 $curIdEq = 'curid=' . $rc_cur_id;
02379
02380 # If it's a
new day, add the headline and flush the cache
02381 $date = $wgLang->date( $rc_timestamp,
true);
02382 $ret = '' ;
02383
if ( $date != $this->lastdate ) {
02384
# Process current cache
02385
$ret = $this->recentChangesBlock () ;
02386 $this->rc_cache = array() ;
02387 $ret .=
"<h4>{$date}</h4>\n";
02388 $this->lastdate = $date;
02389 }
02390
02391
# Make article link
02392
if ( $rc_type ==
RC_MOVE ) {
02393 $clink = $this->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' );
02394 $clink .=
' ' .
wfMsg('movedto') .
' ';
02395 $clink .= $this->makeKnownLinkObj( $rc->getMovedToTitle(), '' );
02396 }
else {
02397 $clink = $this->makeKnownLinkObj( $rc->getTitle(), '' ) ;
02398 }
02399
02400 $time =
$wgLang->time( $rc_timestamp,
true, $wgRCSeconds );
02401 $rc->watched = $watched ;
02402 $rc->link = $clink ;
02403 $rc->timestamp = $time;
02404
02405
# Make "cur" link
02406
if ( ( $rc_type ==
RC_NEW && $rc_this_oldid == 0 ) || $rc_type ==
RC_LOG || $rc_type ==
RC_MOVE) {
02407 $curLink =
wfMsg( 'cur' );
02408 }
else {
02409 $curLink = $this->makeKnownLinkObj( $rc->getTitle(),
wfMsg( 'cur' ),
02410 $curIdEq.'&diff=0&oldid='.$rc_this_oldid ,'' ,'' , ' tabindex=
"'.$baseRC->counter.'"' );
02411 }
02412
02413
# Make "last" link
02414
$titleObj = $rc->getTitle();
02415
if ( $rc_last_oldid == 0 || $rc_type ==
RC_LOG || $rc_type ==
RC_MOVE ) {
02416 $lastLink =
wfMsg( 'last' );
02417 }
else {
02418 $lastLink = $this->makeKnownLinkObj( $rc->getTitle(),
wfMsg( 'last' ),
02419 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid );
02420 }
02421
02422
# Make user link (or user contributions for unregistered users)
02423
if ( 0 == $rc_user ) {
02424 $userLink = $this->makeKnownLink( $wgLang->specialPage( 'Contributions' ),
02425 $rc_user_text, 'target=' . $rc_user_text );
02426 }
else {
02427 $userLink = $this->makeLink( $wgLang->getNsText(
02428 Namespace::getUser() ) .
':'.$rc_user_text, $rc_user_text );
02429 }
02430
02431 $rc->userlink = $userLink ;
02432 $rc->lastlink = $lastLink ;
02433 $rc->curlink = $curLink ;
02434
02435
# Make user talk link
02436
$utns=
$wgLang->getNsText(NS_USER_TALK);
02437 $talkname=
$wgLang->getNsText(NS_TALK); # use the shorter
name
02438 $userTalkLink= $this->makeLink($utns .
':'.$rc_user_text, $talkname );
02439
02440 global
$wgDisableAnonTalk;
02441
if ( ( 0 == $rc_user ) &&
$wgUser->isSysop() ) {
02442 $blockLink = $this->makeKnownLink( $wgLang->specialPage(
02443 'Blockip' ),
wfMsg( 'blocklink' ), 'ip='.$rc_user_text );
02444
if(
$wgDisableAnonTalk )
02445 $rc->usertalklink = ' ('.$blockLink.
')';
02446
else
02447 $rc->usertalklink = ' ('.$userTalkLink.' | '.$blockLink.
')';
02448 }
else {
02449
if(
$wgDisableAnonTalk && ($rc_user == 0) )
02450 $rc->usertalklink = '';
02451
else
02452 $rc->usertalklink = ' ('.$userTalkLink.
')';
02453 }
02454
02455
# Put accumulated information into the cache, for later display
02456
# Page moves go on their own line
02457
$title = $rc->getTitle();
02458 $secureName =
$title->getPrefixedDBkey();
02459
if ( $rc_type ==
RC_MOVE ) {
02460
# Use an @ character to prevent collision with page names
02461
$this->rc_cache['@@' . ($this->rcMoveIndex++)] = array($rc);
02462 }
else {
02463
if ( !isset ( $this->rc_cache[$secureName] ) ) $this->rc_cache[$secureName] = array() ;
02464 array_push ( $this->rc_cache[$secureName] , $rc ) ;
02465 }
02466
return $ret;
02467 }
02468
02469 function endImageHistoryList()
02470 {
02471
$s =
"</ul>\n";
02472
return $s;
02473 }
02474
02475
02476
02477
02478
02479
02480
02481 function formatComment($comment)
02482 {
02483 global
$wgLang;
02484
$comment=
wfEscapeHTML($comment);
02485
02486
# The pattern for autogen comments is / * foo * /, which makes for
02487
# some nasty regex.
02488
# We look for all comments, match any text before and after the comment,
02489
# add a separator where needed and format the comment itself with CSS
02490
while (preg_match('/(.*)\/\*\s*(.*?)\s*\*\/(.*)/', $comment,$match)) {
02491 $pre=$match[1];
02492 $auto=$match[2];
02493 $post=$match[3];
02494
$sep=
'-';
02495
if($pre) { $auto =
$sep.
' '.$auto; }
02496
if($post) { $auto .=
' '.$sep; }
02497 $auto='<span
class=
"autocomment">'.$auto.'</span>';
02498
$comment=$pre.$auto.$post;
02499 }
02500
02501
# format regular and media links - all other wiki formatting
02502
# is ignored
02503
while(preg_match('/\[\[(.*?)(\|(.*?))*\]\]/',$comment,$match)) {
02504
02505 $medians =
$wgLang->getNsText(Namespace::getMedia()).
':';
02506 $func='makeLink';
02507
if(preg_match('/^'.$medians.'/i',$match[1])) {
02508 $func='makeMediaLink';
02509 }
02510
# Handle link renaming [[foo|text]] will show link as "text"
02511
if(isset($match[3]) ) {
02512
$comment=
02513 preg_replace('/\[\[(.*?)\]\]/',
02514 $this->$func($match[1],$match[3]),
$comment,1);
02515 }
else {
02516
$comment=
02517 preg_replace('/\[\[(.*?)\]\]/',
02518 $this->$func($match[1],$match[1]),
$comment,1);
02519 }
02520 }
02521
02522
return $comment;
02523
02524 }
02525
02526 function imageHistoryLine( $iscur, $timestamp, $img, $user, $usertext, $size, $description )
02527 {
02528 global
$wgUser,
$wgLang,
$wgTitle;
02529
02530 $datetime =
$wgLang->timeanddate( $timestamp,
true );
02531 $del =
wfMsg( 'deleteimg' );
02532 $cur =
wfMsg( 'cur' );
02533
02534
if ( $iscur ) {
02535
$url =
Image::wfImageUrl( $img );
02536 $rlink = $cur;
02537
if (
$wgUser->isSysop() ) {
02538 $link =
$wgTitle->escapeLocalURL( 'image=' . $wgTitle->getPartialURL() .
02539 '&action=
delete' );
02540 $style = $this->getInternalLinkAttributes( $link, $del );
02541
02542 $dlink = '<a href=
"'.$link.'"'.$style.
'>'.$del.'</a>';
02543 }
else {
02544 $dlink = $del;
02545 }
02546 }
else {
02547
$url =
wfEscapeHTML(
wfImageArchiveUrl( $img ) );
02548
if(
$wgUser->getID() != 0 ) {
02549 $rlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
02550
wfMsg( 'revertimg' ), 'action=revert&oldimage=' .
02551 urlencode( $img ) );
02552 $dlink = $this->makeKnownLink( $wgTitle->getPrefixedText(),
02553 $del, 'action=
delete&oldimage=' . urlencode( $img ) );
02554 }
else {
02555
# Having live active links for non-logged in users
02556
# means that bots and spiders crawling our site can
02557
# inadvertently change content. Baaaad idea.
02558
$rlink =
wfMsg( 'revertimg' );
02559 $dlink = $del;
02560 }
02561 }
02562
if ( 0 ==
$user ) {
02563 $userlink = $usertext;
02564 }
else {
02565 $userlink = $this->makeLink( $wgLang->getNsText( Namespace::getUser() ) .
02566
':'.$usertext, $usertext );
02567 }
02568 $nbytes =
wfMsg( 'nbytes', $size );
02569 $style = $this->getInternalLinkAttributes( $url, $datetime );
02570
02571
$s =
"<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$datetime}</a>"
02572 .
" . . {$userlink} ({$nbytes})";
02573
02574
if ( '' != $description &&
'*' != $description ) {
02575 $sk=
$wgUser->getSkin();
02576
$s .=
$wgLang->emphasize(' (' . $sk->formatComment($description) .
')');
02577 }
02578
$s .=
"</li>\n";
02579
return $s;
02580 }
02581
02582 function tocIndent($level) {
02583
return str_repeat( '<div
class=
"tocindent">'.
"\n", $level>0 ? $level : 0 );
02584 }
02585
02586 function tocUnindent($level) {
02587
return str_repeat(
"</div>\n", $level>0 ? $level : 0 );
02588 }
02589
02590
# parameter level defines if we are on an indentation level
02591
function tocLine( $anchor, $tocline, $level ) {
02592 $link = '<a href=
"#'.$anchor.'">'.$tocline.'</a><br />';
02593
if($level) {
02594
return $link.
"\n";
02595 }
else {
02596
return '<div
class=
"tocline">'.$link.
"</div>\n";
02597 }
02598
02599 }
02600
02601 function tocTable($toc) {
02602
# note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
02603
# try min-width & co when somebody gets a chance
02604
$hideline = ' <script type=
"text/javascript">showTocToggle(
"' . addslashes( wfMsg('showtoc') ) . '",
"' . addslashes( wfMsg('hidetoc') ) . '")</script>';
02605
return
02606 '<table border=
"0" id=
"toc"><tr
id=
"toctitle"><td align=
"center">'.
"\n".
02607 '<b>'.wfMsg('toc').'</b>' .
02608 $hideline .
02609 '</td></tr><tr
id=
"tocinside"><td>'.
"\n".
02610 $toc.
"</td></tr></table>\n";
02611 }
02612
02613
# These two do not check for permissions: check $wgTitle->userCanEdit before calling them
02614
function editSectionScript( $section, $head ) {
02615 global
$wgTitle,
$wgRequest;
02616
if(
$wgRequest->getInt( 'oldid' ) && (
$wgRequest->getVal( 'diff' ) !=
'0' ) ) {
02617
return $head;
02618 }
02619
$url =
$wgTitle->escapeLocalURL( 'action=edit§ion='.$section );
02620
return '<span oncontextmenu=\'document.location=
"'.$url.'";
return false;\
'>'.$head.'</span>';
02621 }
02622
02623 function editSectionLink( $section ) {
02624 global
$wgRequest;
02625 global
$wgTitle,
$wgUser,
$wgLang;
02626
02627
if(
$wgRequest->getInt( 'oldid' ) && (
$wgRequest->getVal( 'diff' ) !=
'0' ) ) {
02628
# Section edit links would be out of sync on an old page.
02629
# But, if we're diffing to the current page, they'll be
02630
# correct.
02631
return '';
02632 }
02633
02634 $editurl = '§ion='.$section;
02635
$url = $this->makeKnownLink($wgTitle->getPrefixedText(),
wfMsg('editsection'),'action=edit'.$editurl);
02636
02637
if(
$wgLang->isRTL() ) {
02638 $farside = 'left';
02639 $nearside = 'right';
02640 }
else {
02641 $farside = 'right';
02642 $nearside = 'left';
02643 }
02644
return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url.
"]</div>";
02645
02646 }
02647
02648
02649
02650
02651 function getEditToolbar() {
02652 global
$wgStylePath,
$wgLang,
$wgMimeType;
02653
02654
02655
02656
02657
02658
02659
02660
02661
02662
02663 $toolarray=array(
02664 array( 'image'=>'button_bold.png',
02665 'open'=>
"\'\'\'",
02666 'close'=>
"\'\'\'",
02667 'sample'=>
wfMsg('bold_sample'),
02668 'tip'=>
wfMsg('bold_tip'),
02669 'key'=>
'B'
02670 ),
02671 array(
"image"=>
"button_italic.png",
02672
"open"=>
"\'\'",
02673
"close"=>
"\'\'",
02674
"sample"=>
wfMsg(
"italic_sample"),
02675
"tip"=>
wfMsg(
"italic_tip"),
02676
"key"=>
"I"
02677 ),
02678 array(
"image"=>
"button_link.png",
02679
"open"=>
"[[",
02680
"close"=>
"]]",
02681
"sample"=>
wfMsg(
"link_sample"),
02682
"tip"=>
wfMsg(
"link_tip"),
02683
"key"=>
"L"
02684 ),
02685 array(
"image"=>
"button_extlink.png",
02686
"open"=>
"[",
02687
"close"=>
"]",
02688
"sample"=>
wfMsg(
"extlink_sample"),
02689
"tip"=>
wfMsg(
"extlink_tip"),
02690
"key"=>
"X"
02691 ),
02692 array(
"image"=>
"button_headline.png",
02693
"open"=>
"\\n== ",
02694
"close"=>
" ==\\n",
02695
"sample"=>
wfMsg(
"headline_sample"),
02696
"tip"=>
wfMsg(
"headline_tip"),
02697
"key"=>
"H"
02698 ),
02699 array(
"image"=>
"button_image.png",
02700
"open"=>
"[[".$wgLang->getNsText(NS_IMAGE).
":",
02701
"close"=>
"]]",
02702
"sample"=>
wfMsg(
"image_sample"),
02703
"tip"=>
wfMsg(
"image_tip"),
02704
"key"=>
"D"
02705 ),
02706 array(
"image"=>
"button_media.png",
02707
"open"=>
"[[".$wgLang->getNsText(NS_MEDIA).
":",
02708
"close"=>
"]]",
02709
"sample"=>
wfMsg(
"media_sample"),
02710
"tip"=>
wfMsg(
"media_tip"),
02711
"key"=>
"M"
02712 ),
02713 array(
"image"=>
"button_math.png",
02714
"open"=>
"\\<math\\>",
02715
"close"=>
"\\</math\\>",
02716
"sample"=>
wfMsg(
"math_sample"),
02717
"tip"=>
wfMsg(
"math_tip"),
02718
"key"=>
"C"
02719 ),
02720 array(
"image"=>
"button_nowiki.png",
02721
"open"=>
"\\<nowiki\\>",
02722
"close"=>
"\\</nowiki\\>",
02723
"sample"=>
wfMsg(
"nowiki_sample"),
02724
"tip"=>
wfMsg(
"nowiki_tip"),
02725
"key"=>
"N"
02726 ),
02727 array(
"image"=>
"button_sig.png",
02728
"open"=>
"--~~~~",
02729
"close"=>
"",
02730
"sample"=>
"",
02731
"tip"=>
wfMsg(
"sig_tip"),
02732
"key"=>
"Y"
02733 ),
02734 array(
"image"=>
"button_hr.png",
02735
"open"=>
"\\n----\\n",
02736
"close"=>
"",
02737
"sample"=>
"",
02738
"tip"=>
wfMsg(
"hr_tip"),
02739
"key"=>
"R"
02740 )
02741 );
02742 $toolbar =
"<script type='text/javascript'>\n/*<![CDATA[*/\n";
02743
02744 $toolbar.=
"document.writeln(\"<div id='toolbar'>\");\n";
02745 foreach($toolarray as $tool) {
02746
02747 $image=
$wgStylePath.'/images/'.$tool['image'];
02748 $open=$tool['open'];
02749 $close=$tool['close'];
02750 $sample = addslashes( $tool['sample'] );
02751
02752
02753
02754
02755
02756 $tip = addslashes( $tool['tip'] );
02757
02758
#$key = $tool["key"];
02759
02760 $toolbar.=
"addButton('$image','$tip','$open','$close','$sample');\n";
02761 }
02762
02763 $toolbar.=
"addInfobox('" . addslashes(
wfMsg(
"infobox" ) ) .
"','" . addslashes(
wfMsg(
"infobox_alert")) .
"');\n";
02764 $toolbar.=
"document.writeln(\"</div>\");\n";
02765
02766 $toolbar.=
"/*]]>*/\n</script>";
02767
return $toolbar;
02768 }
02769
02770 }
02771 ?>