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