fixes for action=render on image pages
[lhc/web/wiklou.git] / includes / ImagePage.php
1 <?php
2 /**
3 * @package MediaWiki
4 */
5
6 /**
7 *
8 */
9 if( !defined( 'MEDIAWIKI' ) )
10 die();
11
12 require_once( 'Image.php' );
13
14 /**
15 * Special handling for image description pages
16 * @package MediaWiki
17 */
18 class ImagePage extends Article {
19
20 /* private */ var $img; // Image object this page is shown for
21
22 function render() {
23 global $wgOut;
24 $wgOut->setArticleBodyOnly(true);
25 $wgOut->addWikitext($this->getContent(true));
26 }
27
28 function view() {
29 global $wgUseExternalEditor, $wgOut, $wgShowEXIF;
30
31 $this->img = new Image( $this->mTitle );
32
33 if( $this->mTitle->getNamespace() == NS_IMAGE ) {
34 if ($wgShowEXIF && $this->img->exists()) {
35 $exif = $this->img->getExifData();
36 $showmeta = count($exif) ? true : false;
37 } else {
38 $exif = false;
39 $showmeta = false;
40 }
41
42 if ($this->img->exists())
43 $wgOut->addHTML($this->showTOC($showmeta));
44
45 $this->openShowImage();
46 if ($exif)
47 $wgOut->addWikiText($this->makeMetadataTable($exif));
48
49 # No need to display noarticletext, we use our own message, output in openShowImage()
50 if( $this->getID() ) {
51 Article::view();
52 } else {
53 # Just need to set the right headers
54 $wgOut->setArticleFlag( true );
55 $wgOut->setRobotpolicy( 'index,follow' );
56 $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
57 $wgOut->addMetaTags();
58 $this->viewUpdates();
59 }
60
61 $this->closeShowImage();
62 $this->imageHistory();
63 $this->imageLinks();
64 } else {
65 Article::view();
66 }
67 }
68
69 /**
70 * Create the TOC
71 *
72 * @access private
73 *
74 * @param bool $metadata Whether or not to show the metadata link
75 * @return string
76 */
77 function showTOC( $metadata ) {
78 global $wgLang;
79 $r = '<ul id="filetoc">
80 <li><a href="#file">' . $wgLang->getNsText( NS_IMAGE ) . '</a></li>' .
81 ($metadata ? '<li><a href="#metadata">' . wfMsg( 'metadata' ) . '</a></li>' : '') . '
82 <li><a href="#filehistory">' . wfMsg( 'imghistory' ) . '</a></li>
83 <li><a href="#filelinks">' . wfMsg( 'imagelinks' ) . '</a></li>
84 </ul>';
85 return $r;
86 }
87
88 /**
89 * Make a table with metadata to be shown in the output page.
90 *
91 * @access private
92 *
93 * @param array $exif The array containing the EXIF data
94 * @return string
95 */
96 function makeMetadataTable( $exif ) {
97 $r = "{| class=metadata align=right width=250px\n";
98 $r .= '|+ id=metadata | '. htmlspecialchars( wfMsg( 'metadata' ) ) . "\n";
99 foreach( $exif as $k => $v ) {
100 $tag = strtolower( $k );
101 $r .= "! class=$tag |" . wfMsg( "exif-$tag" ) . "\n";
102 $r .= "| class=$tag |" . htmlspecialchars( $v ) . "\n";
103 $r .= "|-\n";
104 }
105 return substr($r, 0, -3) . '|}';
106 }
107
108 /**
109 * Overloading Article's getContent method.
110 * Omit noarticletext if sharedupload
111 *
112 * @param $noredir If true, do not follow redirects
113 */
114 function getContent( $noredir )
115 {
116 if ( $this->img && $this->img->fromSharedDirectory && 0 == $this->getID() ) {
117 return '';
118 }
119 return Article::getContent( $noredir );
120 }
121
122 function openShowImage()
123 {
124 global $wgOut, $wgUser, $wgImageLimits, $wgRequest,
125 $wgUseImageResize, $wgRepositoryBaseUrl,
126 $wgUseExternalEditor, $wgServer, $wgFetchCommonsDescriptions;
127 $full_url = $this->img->getViewURL();
128 $anchoropen = '';
129 $anchorclose = '';
130
131 if( $wgUser->getOption( 'imagesize' ) == '' ) {
132 $sizeSel = User::getDefaultOption( 'imagesize' );
133 } else {
134 $sizeSel = IntVal( $wgUser->getOption( 'imagesize' ) );
135 }
136 if( !isset( $wgImageLimits[$sizeSel] ) ) {
137 $sizeSel = User::getDefaultOption( 'imagesize' );
138 }
139 $max = $wgImageLimits[$sizeSel];
140 $maxWidth = $max[0];
141 $maxHeight = $max[1];
142 $sk = $wgUser->getSkin();
143
144 if ( $this->img->exists() ) {
145 if($this->img->fromSharedDirectory
146 && $wgRepositoryBaseUrl && $wgFetchCommonsDescriptions) {
147 $this->printSharedImageText();
148 return;
149 }
150
151 # image
152 $width = $this->img->getWidth();
153 $height = $this->img->getHeight();
154 $showLink = false;
155
156 if ( $this->img->allowInlineDisplay() and $width and $height) {
157 # image
158
159 # "Download high res version" link below the image
160 $msg = wfMsg('showbigimage', $width, $height, intval( $this->img->getSize()/1024 ) );
161 if ( $width > $maxWidth ) {
162 $height = floor( $height * $maxWidth / $width );
163 $width = $maxWidth;
164 }
165 if ( $height > $maxHeight ) {
166 $width = floor( $width * $maxHeight / $height );
167 $height = $maxHeight;
168 }
169 if ( !$this->img->mustRender()
170 && ( $width != $this->img->getWidth() || $height != $this->img->getHeight() ) ) {
171 if( $wgUseImageResize ) {
172 $thumbnail = $this->img->getThumbnail( $width );
173 if ( $thumbnail == null ) {
174 $url = $full_url;
175 } else {
176 $url = $thumbnail->getUrl();
177 }
178 } else {
179 # No resize ability? Show the full image, but scale
180 # it down in the browser so it fits on the page.
181 $url = $full_url;
182 }
183 $anchoropen = "<a href=\"{$full_url}\">";
184 $anchorclose = "</a><br />\n$anchoropen{$msg}</a>";
185 } else {
186 $url = $full_url;
187 $showLink = $this->img->mustRender();
188 }
189 $wgOut->addHTML( '<div class="fullImageLink" id="file">' . $anchoropen .
190 "<img border=\"0\" src=\"{$url}\" width=\"{$width}\" height=\"{$height}\" alt=\"" .
191 htmlspecialchars( $wgRequest->getVal( 'image' ) ).'" />' . $anchorclose . '</div>' );
192 } else {
193 #if direct link is allowed but it's not a renderable image, show an icon.
194 if ($this->img->isSafeFile()) {
195 $icon= $this->img->iconThumb();
196
197 $wgOut->addHTML( '<div class="fullImageLink" id="file"><a href="' . $full_url . '">' .
198 $icon->toHtml() .
199 '</a></div>' );
200 }
201
202 $showLink = true;
203 }
204
205
206 if ($showLink) {
207 $s= $sk->makeMediaLink( $this->img->getName(), '', '', true );
208 $info= wfMsg( 'fileinfo', ceil($this->img->getSize()/1024.0), $this->img->getMimeType() );
209
210 if (!$this->img->isSafeFile()) {
211 $wgOut->addHTML("<div class=\"fullMedia\">");
212 $wgOut->addHTML("<span class=\"dangerousLink\">");
213 $wgOut->addHTML($s);
214 $wgOut->addHTML("</span>");
215
216 $wgOut->addHTML("<span class=\"fileInfo\"> (");
217 $wgOut->addWikiText( $info, false );
218 $wgOut->addHTML(")</span>");
219 $wgOut->addHTML("</div>");
220
221 #this should be formated a little nicer. Is CSS sufficient?
222 $wgOut->addHTML("<div class=\"mediaWarning\">");
223 $wgOut->addWikiText( wfMsg( 'mediawarning' ) );
224 $wgOut->addHTML('</div>');
225
226 } else {
227 $wgOut->addHTML("<div class=\"fullMedia\">");
228 $wgOut->addHTML($s);
229
230 $wgOut->addHTML("<span class=\"fileInfo\"> (");
231 $wgOut->addWikiText( $info, false );
232 $wgOut->addHTML(")</span>");
233
234 $wgOut->addHTML("</div>");
235 }
236 }
237
238 if($this->img->fromSharedDirectory) {
239 $this->printSharedImageText();
240 }
241 } else {
242 # Image does not exist
243 $wgOut->addWikiText( wfMsg( 'noimage', $this->getUploadUrl() ) );
244 }
245 }
246
247 function printSharedImageText() {
248 global $wgRepositoryBaseUrl, $wgFetchCommonsDescriptions, $wgOut;
249
250 $url = $wgRepositoryBaseUrl . urlencode($this->mTitle->getDBkey());
251 $sharedtext = "<div class='sharedUploadNotice'>" . wfMsg("sharedupload");
252 if ($wgRepositoryBaseUrl) {
253 $sharedtext .= " " . wfMsg("shareduploadwiki", $url);
254 }
255 $sharedtext .= "</div>";
256 $wgOut->addWikiText($sharedtext);
257
258 if ($wgRepositoryBaseUrl && $wgFetchCommonsDescriptions) {
259 $ur = ini_set('allow_url_fopen', true);
260 $text = @file_get_contents($url);
261 ini_set('allow_url_fopen', $ur);
262 if ($text)
263 $wgOut->addHTML($text);
264 }
265 }
266
267 function getUploadUrl() {
268 global $wgServer;
269 $uploadTitle = Title::makeTitle( NS_SPECIAL, 'Upload' );
270 return $wgServer . $uploadTitle->getLocalUrl( 'wpDestFile=' . urlencode( $this->img->getName() ) );
271 }
272
273
274 function uploadLinksBox()
275 {
276 global $wgUser,$wgOut;
277 $sk = $wgUser->getSkin();
278 $wgOut->addHTML( '<br /><ul><li>' );
279 $wgOut->addWikiText( '<div>'. wfMsg( 'uploadnewversion', $this->getUploadUrl() ) .'</div>' );
280 $wgOut->addHTML( '</li><li>' );
281 $wgOut->addHTML( $sk->makeKnownLinkObj( $this->mTitle,
282 wfMsg( 'edit-externally' ), "action=edit&externaledit=true&mode=file" ) );
283 $wgOut->addWikiText( '<div>' . wfMsg('edit-externally-help') . '</div>' );
284 $wgOut->addHTML( '</li></ul>' );
285 }
286
287 function closeShowImage()
288 {
289 # For overloading
290
291 }
292
293 /**
294 * If the page we've just displayed is in the "Image" namespace,
295 * we follow it with an upload history of the image and its usage.
296 */
297 function imageHistory()
298 {
299 global $wgUser, $wgOut, $wgUseExternalEditor;
300
301 $sk = $wgUser->getSkin();
302
303 $line = $this->img->nextHistoryLine();
304
305 if ( $line ) {
306 $list =& new ImageHistoryList( $sk );
307 $s = $list->beginImageHistoryList() .
308 $list->imageHistoryLine( true, $line->img_timestamp,
309 $this->mTitle->getDBkey(), $line->img_user,
310 $line->img_user_text, $line->img_size, $line->img_description );
311
312 while ( $line = $this->img->nextHistoryLine() ) {
313 $s .= $list->imageHistoryLine( false, $line->img_timestamp,
314 $line->oi_archive_name, $line->img_user,
315 $line->img_user_text, $line->img_size, $line->img_description );
316 }
317 $s .= $list->endImageHistoryList();
318 } else { $s=''; }
319 $wgOut->addHTML( $s );
320
321 # Exist check because we don't want to show this on pages where an image
322 # doesn't exist along with the noimage message, that would suck. -ævar
323 if( $wgUseExternalEditor && $this->img->exists() ) {
324 $this->uploadLinksBox();
325 }
326
327 }
328
329 function imageLinks()
330 {
331 global $wgUser, $wgOut;
332
333 $wgOut->addHTML( '<h2 id="filelinks">' . wfMsg( 'imagelinks' ) . "</h2>\n" );
334
335 $dbr =& wfGetDB( DB_SLAVE );
336 $page = $dbr->tableName( 'page' );
337 $imagelinks = $dbr->tableName( 'imagelinks' );
338
339 $sql = "SELECT page_namespace,page_title FROM $imagelinks,$page WHERE il_to=" .
340 $dbr->addQuotes( $this->mTitle->getDBkey() ) . " AND il_from=page_id"
341 . " LIMIT 500"; # quickie emergency brake
342 $res = $dbr->query( $sql, "ImagePage::imageLinks" );
343
344 if ( 0 == $dbr->numRows( $res ) ) {
345 $wgOut->addHtml( '<p>' . wfMsg( "nolinkstoimage" ) . "</p>\n" );
346 return;
347 }
348 $wgOut->addHTML( '<p>' . wfMsg( 'linkstoimage' ) . "</p>\n<ul>" );
349
350 $sk = $wgUser->getSkin();
351 while ( $s = $dbr->fetchObject( $res ) ) {
352 $name = Title::MakeTitle( $s->page_namespace, $s->page_title );
353 $link = $sk->makeKnownLinkObj( $name, "" );
354 $wgOut->addHTML( "<li>{$link}</li>\n" );
355 }
356 $wgOut->addHTML( "</ul>\n" );
357 }
358
359 function delete()
360 {
361 global $wgUser, $wgOut, $wgRequest;
362
363 $confirm = $wgRequest->getBool( 'wpConfirmB' );
364 $image = $wgRequest->getVal( 'image' );
365 $oldimage = $wgRequest->getVal( 'oldimage' );
366
367 # Only sysops can delete images. Previously ordinary users could delete
368 # old revisions, but this is no longer the case.
369 if ( !$wgUser->isAllowed('delete') ) {
370 $wgOut->sysopRequired();
371 return;
372 }
373 if ( $wgUser->isBlocked() ) {
374 return $this->blockedIPpage();
375 }
376 if ( wfReadOnly() ) {
377 $wgOut->readOnlyPage();
378 return;
379 }
380
381 # Better double-check that it hasn't been deleted yet!
382 $wgOut->setPagetitle( wfMsg( 'confirmdelete' ) );
383 if ( ( !is_null( $image ) )
384 && ( '' == trim( $image ) ) ) {
385 $wgOut->fatalError( wfMsg( 'cannotdelete' ) );
386 return;
387 }
388
389 $this->img = new Image( $this->mTitle );
390
391 # Deleting old images doesn't require confirmation
392 if ( !is_null( $oldimage ) || $confirm ) {
393 if( $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ), $oldimage ) ) {
394 $this->doDelete();
395 } else {
396 $wgOut->fatalError( wfMsg( 'sessionfailure' ) );
397 }
398 return;
399 }
400
401 if ( !is_null( $image ) ) {
402 $q = '&image=' . urlencode( $image );
403 } else if ( !is_null( $oldimage ) ) {
404 $q = '&oldimage=' . urlencode( $oldimage );
405 } else {
406 $q = '';
407 }
408 return $this->confirmDelete( $q, $wgRequest->getText( 'wpReason' ) );
409 }
410
411 function doDelete()
412 {
413 global $wgOut, $wgUser, $wgContLang, $wgRequest;
414 global $wgUseSquid, $wgInternalServer, $wgPostCommitUpdateList;
415 $fname = 'ImagePage::doDelete';
416
417 $reason = $wgRequest->getVal( 'wpReason' );
418 $oldimage = $wgRequest->getVal( 'oldimage' );
419
420 $dbw =& wfGetDB( DB_MASTER );
421
422 if ( !is_null( $oldimage ) ) {
423 if ( strlen( $oldimage ) < 16 ) {
424 $wgOut->unexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
425 return;
426 }
427 if ( strstr( $oldimage, "/" ) || strstr( $oldimage, "\\" ) ) {
428 $wgOut->unexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
429 return;
430 }
431
432 # Invalidate description page cache
433 $this->mTitle->invalidateCache();
434
435 # Squid purging
436 if ( $wgUseSquid ) {
437 $urlArr = Array(
438 $wgInternalServer.wfImageArchiveUrl( $oldimage ),
439 $wgInternalServer.$this->mTitle->getFullURL()
440 );
441 wfPurgeSquidServers($urlArr);
442 }
443 $this->doDeleteOldImage( $oldimage );
444 $dbw->delete( 'oldimage', array( 'oi_archive_name' => $oldimage ) );
445 $deleted = $oldimage;
446 } else {
447 $image = $this->mTitle->getDBkey();
448 $dest = wfImageDir( $image );
449 $archive = wfImageDir( $image );
450
451 # Delete the image file if it exists; due to sync problems
452 # or manual trimming sometimes the file will be missing.
453 $targetFile = "{$dest}/{$image}";
454 if( file_exists( $targetFile ) && ! @unlink( $targetFile ) ) {
455 # If the deletion operation actually failed, bug out:
456 $wgOut->fileDeleteError( $targetFile );
457 return;
458 }
459 $dbw->delete( 'image', array( 'img_name' => $image ) );
460 $res = $dbw->select( 'oldimage', array( 'oi_archive_name' ), array( 'oi_name' => $image ) );
461
462 # Purge archive URLs from the squid
463 $urlArr = Array();
464 while ( $s = $dbw->fetchObject( $res ) ) {
465 $this->doDeleteOldImage( $s->oi_archive_name );
466 $urlArr[] = $wgInternalServer.wfImageArchiveUrl( $s->oi_archive_name );
467 }
468
469 # And also the HTML of all pages using this image
470 $linksTo = $this->img->getLinksTo();
471 if ( $wgUseSquid ) {
472 $u = SquidUpdate::newFromTitles( $linksTo, $urlArr );
473 array_push( $wgPostCommitUpdateList, $u );
474 }
475
476 $dbw->delete( 'oldimage', array( 'oi_name' => $image ) );
477
478 # Image itself is now gone, and database is cleaned.
479 # Now we remove the image description page.
480
481 $article = new Article( $this->mTitle );
482 $article->doDeleteArticle( $reason ); # ignore errors
483
484 # Invalidate parser cache and client cache for pages using this image
485 # This is left until relatively late to reduce lock time
486 Title::touchArray( $linksTo );
487
488 /* Delete thumbnails and refresh image metadata cache */
489 $this->img->purgeCache();
490
491
492 $deleted = $image;
493 }
494
495 $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
496 $wgOut->setRobotpolicy( 'noindex,nofollow' );
497
498 $loglink = '[[Special:Log/delete|' . wfMsg( 'deletionlog' ) . ']]';
499 $text = wfMsg( 'deletedtext', $deleted, $loglink );
500
501 $wgOut->addWikiText( $text );
502
503 $wgOut->returnToMain( false, $this->mTitle->getPrefixedText() );
504 }
505
506 function doDeleteOldImage( $oldimage )
507 {
508 global $wgOut;
509
510 $name = substr( $oldimage, 15 );
511 $archive = wfImageArchiveDir( $name );
512
513 # Delete the image if it exists. Sometimes the file will be missing
514 # due to manual intervention or weird sync problems; treat that
515 # condition gracefully and continue to delete the database entry.
516 # Also some records may end up with an empty oi_archive_name field
517 # if the original file was missing when a new upload was made;
518 # don't try to delete the directory then!
519 #
520 $targetFile = "{$archive}/{$oldimage}";
521 if( $oldimage != '' && file_exists( $targetFile ) && !@unlink( $targetFile ) ) {
522 # If we actually have a file and can't delete it, throw an error.
523 $wgOut->fileDeleteError( "{$archive}/{$oldimage}" );
524 } else {
525 # Log the deletion
526 $log = new LogPage( 'delete' );
527 $log->addEntry( 'delete', $this->mTitle, wfMsg('deletedrevision',$oldimage) );
528 }
529 }
530
531 function revert()
532 {
533 global $wgOut, $wgRequest, $wgUser;
534 global $wgUseSquid, $wgInternalServer, $wgDeferredUpdateList;
535
536 $oldimage = $wgRequest->getText( 'oldimage' );
537 if ( strlen( $oldimage ) < 16 ) {
538 $wgOut->unexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
539 return;
540 }
541 if ( strstr( $oldimage, "/" ) || strstr( $oldimage, "\\" ) ) {
542 $wgOut->unexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
543 return;
544 }
545
546 if ( wfReadOnly() ) {
547 $wgOut->readOnlyPage();
548 return;
549 }
550 if( $wgUser->isAnon() ) {
551 $wgOut->errorpage( 'uploadnologin', 'uploadnologintext' );
552 return;
553 }
554 if ( ! $this->mTitle->userCanEdit() ) {
555 $wgOut->sysopRequired();
556 return;
557 }
558 if ( $wgUser->isBlocked() ) {
559 return $this->blockedIPpage();
560 }
561 if( !$wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ), $oldimage ) ) {
562 $wgOut->errorpage( 'internalerror', 'sessionfailure' );
563 return;
564 }
565 $name = substr( $oldimage, 15 );
566
567 $dest = wfImageDir( $name );
568 $archive = wfImageArchiveDir( $name );
569 $curfile = "{$dest}/{$name}";
570
571 if ( ! is_file( $curfile ) ) {
572 $wgOut->fileNotFoundError( htmlspecialchars( $curfile ) );
573 return;
574 }
575 $oldver = wfTimestampNow() . "!{$name}";
576
577 $dbr =& wfGetDB( DB_SLAVE );
578 $size = $dbr->selectField( 'oldimage', 'oi_size', array( 'oi_archive_name' => $oldimage ) );
579
580 if ( ! rename( $curfile, "${archive}/{$oldver}" ) ) {
581 $wgOut->fileRenameError( $curfile, "${archive}/{$oldver}" );
582 return;
583 }
584 if ( ! copy( "{$archive}/{$oldimage}", $curfile ) ) {
585 $wgOut->fileCopyError( "${archive}/{$oldimage}", $curfile );
586 }
587
588 # Record upload and update metadata cache
589 $img = Image::newFromName( $name );
590 $img->recordUpload( $oldver, wfMsg( "reverted" ) );
591
592 $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
593 $wgOut->setRobotpolicy( 'noindex,nofollow' );
594 $wgOut->addHTML( wfMsg( 'imagereverted' ) );
595
596 $descTitle = $img->getTitle();
597 $wgOut->returnToMain( false, $descTitle->getPrefixedText() );
598 }
599
600 function blockedIPpage() {
601 require_once( 'EditPage.php' );
602 $edit = new EditPage( $this );
603 return $edit->blockedIPpage();
604 }
605
606 }
607
608 /**
609 * @todo document
610 * @package MediaWiki
611 */
612 class ImageHistoryList {
613 function ImageHistoryList( &$skin ) {
614 $this->skin =& $skin;
615 }
616
617 function beginImageHistoryList() {
618 $s = "\n<h2 id=\"filehistory\">" . wfMsg( 'imghistory' ) . "</h2>\n" .
619 "<p>" . wfMsg( 'imghistlegend' ) . "</p>\n".'<ul class="special">';
620 return $s;
621 }
622
623 function endImageHistoryList() {
624 $s = "</ul>\n";
625 return $s;
626 }
627
628 function imageHistoryLine( $iscur, $timestamp, $img, $user, $usertext, $size, $description ) {
629 global $wgUser, $wgLang, $wgContLang, $wgTitle;
630
631 $datetime = $wgLang->timeanddate( $timestamp, true );
632 $del = wfMsg( 'deleteimg' );
633 $delall = wfMsg( 'deleteimgcompletely' );
634 $cur = wfMsg( 'cur' );
635
636 if ( $iscur ) {
637 $url = Image::imageUrl( $img );
638 $rlink = $cur;
639 if ( $wgUser->isAllowed('delete') ) {
640 $link = $wgTitle->escapeLocalURL( 'image=' . $wgTitle->getPartialURL() .
641 '&action=delete' );
642 $style = $this->skin->getInternalLinkAttributes( $link, $delall );
643
644 $dlink = '<a href="'.$link.'"'.$style.'>'.$delall.'</a>';
645 } else {
646 $dlink = $del;
647 }
648 } else {
649 $url = htmlspecialchars( wfImageArchiveUrl( $img ) );
650 if( $wgUser->getID() != 0 && $wgTitle->userCanEdit() ) {
651 $token = urlencode( $wgUser->editToken( $img ) );
652 $rlink = $this->skin->makeKnownLinkObj( $wgTitle,
653 wfMsg( 'revertimg' ), 'action=revert&oldimage=' .
654 urlencode( $img ) . "&wpEditToken=$token" );
655 $dlink = $this->skin->makeKnownLinkObj( $wgTitle,
656 $del, 'action=delete&oldimage=' . urlencode( $img ) .
657 "&wpEditToken=$token" );
658 } else {
659 # Having live active links for non-logged in users
660 # means that bots and spiders crawling our site can
661 # inadvertently change content. Baaaad idea.
662 $rlink = wfMsg( 'revertimg' );
663 $dlink = $del;
664 }
665 }
666 if ( 0 == $user ) {
667 $userlink = $usertext;
668 } else {
669 $userlink = $this->skin->makeLinkObj(
670 Title::makeTitle( NS_USER, $usertext ),
671 $usertext );
672 }
673 $nbytes = wfMsg( 'nbytes', $size );
674 $style = $this->skin->getInternalLinkAttributes( $url, $datetime );
675
676 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$datetime}</a>"
677 . " . . {$userlink} ({$nbytes})";
678
679 $s .= $this->skin->commentBlock( $description, $wgTitle );
680 $s .= "</li>\n";
681 return $s;
682 }
683
684 }
685
686
687 ?>