f950dcaa1e1f9397701838b28f8cbd5f72d5ab8d
[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 # 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 printSharedImageText() {
242 global $wgRepositoryBaseUrl, $wgFetchCommonsDescriptions, $wgOut;
243
244 $url = $wgRepositoryBaseUrl . urlencode($this->mTitle->getDBkey());
245 $sharedtext = "<div class='sharedUploadNotice'>" . wfMsg("sharedupload");
246 if ($wgRepositoryBaseUrl && !$wgFetchCommonsDescriptions) {
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_get_contents($url . '?action=render');
255 ini_set('allow_url_fopen', $ur);
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
272 if ($this->img->fromSharedDirectory)
273 return;
274
275 $sk = $wgUser->getSkin();
276 $wgOut->addHTML( '<br /><ul><li>' );
277 $wgOut->addWikiText( '<div>'. wfMsg( 'uploadnewversion', $this->getUploadUrl() ) .'</div>' );
278 $wgOut->addHTML( '</li><li>' );
279 $wgOut->addHTML( $sk->makeKnownLinkObj( $this->mTitle,
280 wfMsg( 'edit-externally' ), "action=edit&externaledit=true&mode=file" ) );
281 $wgOut->addWikiText( '<div>' . wfMsg('edit-externally-help') . '</div>' );
282 $wgOut->addHTML( '</li></ul>' );
283 }
284
285 function closeShowImage()
286 {
287 # For overloading
288
289 }
290
291 /**
292 * If the page we've just displayed is in the "Image" namespace,
293 * we follow it with an upload history of the image and its usage.
294 */
295 function imageHistory()
296 {
297 global $wgUser, $wgOut, $wgUseExternalEditor;
298
299 $sk = $wgUser->getSkin();
300
301 $line = $this->img->nextHistoryLine();
302
303 if ( $line ) {
304 $list =& new ImageHistoryList( $sk );
305 $s = $list->beginImageHistoryList() .
306 $list->imageHistoryLine( true, $line->img_timestamp,
307 $this->mTitle->getDBkey(), $line->img_user,
308 $line->img_user_text, $line->img_size, $line->img_description );
309
310 while ( $line = $this->img->nextHistoryLine() ) {
311 $s .= $list->imageHistoryLine( false, $line->img_timestamp,
312 $line->oi_archive_name, $line->img_user,
313 $line->img_user_text, $line->img_size, $line->img_description );
314 }
315 $s .= $list->endImageHistoryList();
316 } else { $s=''; }
317 $wgOut->addHTML( $s );
318
319 # Exist check because we don't want to show this on pages where an image
320 # doesn't exist along with the noimage message, that would suck. -ævar
321 if( $wgUseExternalEditor && $this->img->exists() ) {
322 $this->uploadLinksBox();
323 }
324
325 }
326
327 function imageLinks()
328 {
329 global $wgUser, $wgOut;
330
331 $wgOut->addHTML( '<h2 id="filelinks">' . wfMsg( 'imagelinks' ) . "</h2>\n" );
332
333 $dbr =& wfGetDB( DB_SLAVE );
334 $page = $dbr->tableName( 'page' );
335 $imagelinks = $dbr->tableName( 'imagelinks' );
336
337 $sql = "SELECT page_namespace,page_title FROM $imagelinks,$page WHERE il_to=" .
338 $dbr->addQuotes( $this->mTitle->getDBkey() ) . " AND il_from=page_id"
339 . " LIMIT 500"; # quickie emergency brake
340 $res = $dbr->query( $sql, "ImagePage::imageLinks" );
341
342 if ( 0 == $dbr->numRows( $res ) ) {
343 $wgOut->addHtml( '<p>' . wfMsg( "nolinkstoimage" ) . "</p>\n" );
344 return;
345 }
346 $wgOut->addHTML( '<p>' . wfMsg( 'linkstoimage' ) . "</p>\n<ul>" );
347
348 $sk = $wgUser->getSkin();
349 while ( $s = $dbr->fetchObject( $res ) ) {
350 $name = Title::MakeTitle( $s->page_namespace, $s->page_title );
351 $link = $sk->makeKnownLinkObj( $name, "" );
352 $wgOut->addHTML( "<li>{$link}</li>\n" );
353 }
354 $wgOut->addHTML( "</ul>\n" );
355 }
356
357 function delete()
358 {
359 global $wgUser, $wgOut, $wgRequest;
360
361 $confirm = $wgRequest->getBool( 'wpConfirmB' );
362 $image = $wgRequest->getVal( 'image' );
363 $oldimage = $wgRequest->getVal( 'oldimage' );
364
365 # Only sysops can delete images. Previously ordinary users could delete
366 # old revisions, but this is no longer the case.
367 if ( !$wgUser->isAllowed('delete') ) {
368 $wgOut->sysopRequired();
369 return;
370 }
371 if ( $wgUser->isBlocked() ) {
372 return $this->blockedIPpage();
373 }
374 if ( wfReadOnly() ) {
375 $wgOut->readOnlyPage();
376 return;
377 }
378
379 # Better double-check that it hasn't been deleted yet!
380 $wgOut->setPagetitle( wfMsg( 'confirmdelete' ) );
381 if ( ( !is_null( $image ) )
382 && ( '' == trim( $image ) ) ) {
383 $wgOut->fatalError( wfMsg( 'cannotdelete' ) );
384 return;
385 }
386
387 $this->img = new Image( $this->mTitle );
388
389 # Deleting old images doesn't require confirmation
390 if ( !is_null( $oldimage ) || $confirm ) {
391 if( $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ), $oldimage ) ) {
392 $this->doDelete();
393 } else {
394 $wgOut->fatalError( wfMsg( 'sessionfailure' ) );
395 }
396 return;
397 }
398
399 if ( !is_null( $image ) ) {
400 $q = '&image=' . urlencode( $image );
401 } else if ( !is_null( $oldimage ) ) {
402 $q = '&oldimage=' . urlencode( $oldimage );
403 } else {
404 $q = '';
405 }
406 return $this->confirmDelete( $q, $wgRequest->getText( 'wpReason' ) );
407 }
408
409 function doDelete()
410 {
411 global $wgOut, $wgUser, $wgContLang, $wgRequest;
412 global $wgUseSquid, $wgInternalServer, $wgPostCommitUpdateList;
413 $fname = 'ImagePage::doDelete';
414
415 $reason = $wgRequest->getVal( 'wpReason' );
416 $oldimage = $wgRequest->getVal( 'oldimage' );
417
418 $dbw =& wfGetDB( DB_MASTER );
419
420 if ( !is_null( $oldimage ) ) {
421 if ( strlen( $oldimage ) < 16 ) {
422 $wgOut->unexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
423 return;
424 }
425 if ( strstr( $oldimage, "/" ) || strstr( $oldimage, "\\" ) ) {
426 $wgOut->unexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
427 return;
428 }
429
430 # Invalidate description page cache
431 $this->mTitle->invalidateCache();
432
433 # Squid purging
434 if ( $wgUseSquid ) {
435 $urlArr = Array(
436 $wgInternalServer.wfImageArchiveUrl( $oldimage ),
437 $wgInternalServer.$this->mTitle->getFullURL()
438 );
439 wfPurgeSquidServers($urlArr);
440 }
441 $this->doDeleteOldImage( $oldimage );
442 $dbw->delete( 'oldimage', array( 'oi_archive_name' => $oldimage ) );
443 $deleted = $oldimage;
444 } else {
445 $image = $this->mTitle->getDBkey();
446 $dest = wfImageDir( $image );
447 $archive = wfImageDir( $image );
448
449 # Delete the image file if it exists; due to sync problems
450 # or manual trimming sometimes the file will be missing.
451 $targetFile = "{$dest}/{$image}";
452 if( file_exists( $targetFile ) && ! @unlink( $targetFile ) ) {
453 # If the deletion operation actually failed, bug out:
454 $wgOut->fileDeleteError( $targetFile );
455 return;
456 }
457 $dbw->delete( 'image', array( 'img_name' => $image ) );
458 $res = $dbw->select( 'oldimage', array( 'oi_archive_name' ), array( 'oi_name' => $image ) );
459
460 # Purge archive URLs from the squid
461 $urlArr = Array();
462 while ( $s = $dbw->fetchObject( $res ) ) {
463 $this->doDeleteOldImage( $s->oi_archive_name );
464 $urlArr[] = $wgInternalServer.wfImageArchiveUrl( $s->oi_archive_name );
465 }
466
467 # And also the HTML of all pages using this image
468 $linksTo = $this->img->getLinksTo();
469 if ( $wgUseSquid ) {
470 $u = SquidUpdate::newFromTitles( $linksTo, $urlArr );
471 array_push( $wgPostCommitUpdateList, $u );
472 }
473
474 $dbw->delete( 'oldimage', array( 'oi_name' => $image ) );
475
476 # Image itself is now gone, and database is cleaned.
477 # Now we remove the image description page.
478
479 $article = new Article( $this->mTitle );
480 $article->doDeleteArticle( $reason ); # ignore errors
481
482 # Invalidate parser cache and client cache for pages using this image
483 # This is left until relatively late to reduce lock time
484 Title::touchArray( $linksTo );
485
486 /* Delete thumbnails and refresh image metadata cache */
487 $this->img->purgeCache();
488
489
490 $deleted = $image;
491 }
492
493 $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
494 $wgOut->setRobotpolicy( 'noindex,nofollow' );
495
496 $loglink = '[[Special:Log/delete|' . wfMsg( 'deletionlog' ) . ']]';
497 $text = wfMsg( 'deletedtext', $deleted, $loglink );
498
499 $wgOut->addWikiText( $text );
500
501 $wgOut->returnToMain( false, $this->mTitle->getPrefixedText() );
502 }
503
504 function doDeleteOldImage( $oldimage )
505 {
506 global $wgOut;
507
508 $name = substr( $oldimage, 15 );
509 $archive = wfImageArchiveDir( $name );
510
511 # Delete the image if it exists. Sometimes the file will be missing
512 # due to manual intervention or weird sync problems; treat that
513 # condition gracefully and continue to delete the database entry.
514 # Also some records may end up with an empty oi_archive_name field
515 # if the original file was missing when a new upload was made;
516 # don't try to delete the directory then!
517 #
518 $targetFile = "{$archive}/{$oldimage}";
519 if( $oldimage != '' && file_exists( $targetFile ) && !@unlink( $targetFile ) ) {
520 # If we actually have a file and can't delete it, throw an error.
521 $wgOut->fileDeleteError( "{$archive}/{$oldimage}" );
522 } else {
523 # Log the deletion
524 $log = new LogPage( 'delete' );
525 $log->addEntry( 'delete', $this->mTitle, wfMsg('deletedrevision',$oldimage) );
526 }
527 }
528
529 function revert()
530 {
531 global $wgOut, $wgRequest, $wgUser;
532 global $wgUseSquid, $wgInternalServer, $wgDeferredUpdateList;
533
534 $oldimage = $wgRequest->getText( 'oldimage' );
535 if ( strlen( $oldimage ) < 16 ) {
536 $wgOut->unexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
537 return;
538 }
539 if ( strstr( $oldimage, "/" ) || strstr( $oldimage, "\\" ) ) {
540 $wgOut->unexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
541 return;
542 }
543
544 if ( wfReadOnly() ) {
545 $wgOut->readOnlyPage();
546 return;
547 }
548 if( $wgUser->isAnon() ) {
549 $wgOut->errorpage( 'uploadnologin', 'uploadnologintext' );
550 return;
551 }
552 if ( ! $this->mTitle->userCanEdit() ) {
553 $wgOut->sysopRequired();
554 return;
555 }
556 if ( $wgUser->isBlocked() ) {
557 return $this->blockedIPpage();
558 }
559 if( !$wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ), $oldimage ) ) {
560 $wgOut->errorpage( 'internalerror', 'sessionfailure' );
561 return;
562 }
563 $name = substr( $oldimage, 15 );
564
565 $dest = wfImageDir( $name );
566 $archive = wfImageArchiveDir( $name );
567 $curfile = "{$dest}/{$name}";
568
569 if ( ! is_file( $curfile ) ) {
570 $wgOut->fileNotFoundError( htmlspecialchars( $curfile ) );
571 return;
572 }
573 $oldver = wfTimestampNow() . "!{$name}";
574
575 $dbr =& wfGetDB( DB_SLAVE );
576 $size = $dbr->selectField( 'oldimage', 'oi_size', array( 'oi_archive_name' => $oldimage ) );
577
578 if ( ! rename( $curfile, "${archive}/{$oldver}" ) ) {
579 $wgOut->fileRenameError( $curfile, "${archive}/{$oldver}" );
580 return;
581 }
582 if ( ! copy( "{$archive}/{$oldimage}", $curfile ) ) {
583 $wgOut->fileCopyError( "${archive}/{$oldimage}", $curfile );
584 }
585
586 # Record upload and update metadata cache
587 $img = Image::newFromName( $name );
588 $img->recordUpload( $oldver, wfMsg( "reverted" ) );
589
590 $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
591 $wgOut->setRobotpolicy( 'noindex,nofollow' );
592 $wgOut->addHTML( wfMsg( 'imagereverted' ) );
593
594 $descTitle = $img->getTitle();
595 $wgOut->returnToMain( false, $descTitle->getPrefixedText() );
596 }
597
598 function blockedIPpage() {
599 require_once( 'EditPage.php' );
600 $edit = new EditPage( $this );
601 return $edit->blockedIPpage();
602 }
603
604 }
605
606 /**
607 * @todo document
608 * @package MediaWiki
609 */
610 class ImageHistoryList {
611 function ImageHistoryList( &$skin ) {
612 $this->skin =& $skin;
613 }
614
615 function beginImageHistoryList() {
616 $s = "\n<h2 id=\"filehistory\">" . wfMsg( 'imghistory' ) . "</h2>\n" .
617 "<p>" . wfMsg( 'imghistlegend' ) . "</p>\n".'<ul class="special">';
618 return $s;
619 }
620
621 function endImageHistoryList() {
622 $s = "</ul>\n";
623 return $s;
624 }
625
626 function imageHistoryLine( $iscur, $timestamp, $img, $user, $usertext, $size, $description ) {
627 global $wgUser, $wgLang, $wgContLang, $wgTitle;
628
629 $datetime = $wgLang->timeanddate( $timestamp, true );
630 $del = wfMsg( 'deleteimg' );
631 $delall = wfMsg( 'deleteimgcompletely' );
632 $cur = wfMsg( 'cur' );
633
634 if ( $iscur ) {
635 $url = Image::imageUrl( $img );
636 $rlink = $cur;
637 if ( $wgUser->isAllowed('delete') ) {
638 $link = $wgTitle->escapeLocalURL( 'image=' . $wgTitle->getPartialURL() .
639 '&action=delete' );
640 $style = $this->skin->getInternalLinkAttributes( $link, $delall );
641
642 $dlink = '<a href="'.$link.'"'.$style.'>'.$delall.'</a>';
643 } else {
644 $dlink = $del;
645 }
646 } else {
647 $url = htmlspecialchars( wfImageArchiveUrl( $img ) );
648 if( $wgUser->getID() != 0 && $wgTitle->userCanEdit() ) {
649 $token = urlencode( $wgUser->editToken( $img ) );
650 $rlink = $this->skin->makeKnownLinkObj( $wgTitle,
651 wfMsg( 'revertimg' ), 'action=revert&oldimage=' .
652 urlencode( $img ) . "&wpEditToken=$token" );
653 $dlink = $this->skin->makeKnownLinkObj( $wgTitle,
654 $del, 'action=delete&oldimage=' . urlencode( $img ) .
655 "&wpEditToken=$token" );
656 } else {
657 # Having live active links for non-logged in users
658 # means that bots and spiders crawling our site can
659 # inadvertently change content. Baaaad idea.
660 $rlink = wfMsg( 'revertimg' );
661 $dlink = $del;
662 }
663 }
664 if ( 0 == $user ) {
665 $userlink = $usertext;
666 } else {
667 $userlink = $this->skin->makeLinkObj(
668 Title::makeTitle( NS_USER, $usertext ),
669 $usertext );
670 }
671 $nbytes = wfMsg( 'nbytes', $size );
672 $style = $this->skin->getInternalLinkAttributes( $url, $datetime );
673
674 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$datetime}</a>"
675 . " . . {$userlink} ({$nbytes})";
676
677 $s .= $this->skin->commentBlock( $description, $wgTitle );
678 $s .= "</li>\n";
679 return $s;
680 }
681
682 }
683
684
685 ?>