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