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