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