d7639d95451b4d33a6e29545e1d699ad66c737d7
8 if( !defined( 'MEDIAWIKI' ) )
12 * Special handling for image description pages
14 class ImagePage
extends Article
{
16 /* private */ var $img; // Image object this page is shown for
17 var $mExtraDescription = false;
20 * Handler for action=render
21 * Include body text only; none of the image extras
25 $wgOut->setArticleBodyOnly( true );
26 $wgOut->addSecondaryWikitext( $this->getContent() );
30 global $wgOut, $wgShowEXIF, $wgRequest, $wgUser;
32 $this->img
= new Image( $this->mTitle
);
34 $diff = $wgRequest->getVal( 'diff' );
35 $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) );
37 if ( $this->mTitle
->getNamespace() != NS_IMAGE ||
( isset( $diff ) && $diffOnly ) )
38 return Article
::view();
40 if ($wgShowEXIF && $this->img
->exists()) {
41 $exif = $this->img
->getExifData();
42 $showmeta = count($exif) ?
true : false;
48 if ($this->img
->exists())
49 $wgOut->addHTML($this->showTOC($showmeta));
51 $this->openShowImage();
53 # No need to display noarticletext, we use our own message, output in openShowImage()
54 if ( $this->getID() ) {
57 # Just need to set the right headers
58 $wgOut->setArticleFlag( true );
59 $wgOut->setRobotpolicy( 'index,follow' );
60 $wgOut->setPageTitle( $this->mTitle
->getPrefixedText() );
64 # Show shared description, if needed
65 if ( $this->mExtraDescription
) {
66 $fol = wfMsg( 'shareddescriptionfollows' );
67 if( $fol != '-' && !wfEmptyMsg( 'shareddescriptionfollows', $fol ) ) {
68 $wgOut->addWikiText( $fol );
70 $wgOut->addHTML( '<div id="shared-image-desc">' . $this->mExtraDescription
. '</div>' );
73 $this->closeShowImage();
74 $this->imageHistory();
78 global $wgStylePath, $wgStyleVersion;
79 $expand = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-expand' ) ) );
80 $collapse = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-collapse' ) ) );
81 $wgOut->addHTML( Xml
::element( 'h2', array( 'id' => 'metadata' ), wfMsg( 'metadata' ) ). "\n" );
82 $wgOut->addWikiText( $this->makeMetadataTable( $exif ) );
84 "<script type=\"text/javascript\" src=\"$wgStylePath/common/metadata.js?$wgStyleVersion\"></script>\n" .
85 "<script type=\"text/javascript\">attachMetadataToggle('mw_metadata', '$expand', '$collapse');</script>\n" );
94 * @param bool $metadata Whether or not to show the metadata link
97 function showTOC( $metadata ) {
99 $r = '<ul id="filetoc">
100 <li><a href="#file">' . $wgLang->getNsText( NS_IMAGE
) . '</a></li>
101 <li><a href="#filehistory">' . wfMsgHtml( 'imghistory' ) . '</a></li>
102 <li><a href="#filelinks">' . wfMsgHtml( 'imagelinks' ) . '</a></li>' .
103 ($metadata ?
'<li><a href="#metadata">' . wfMsgHtml( 'metadata' ) . '</a></li>' : '') . '
109 * Make a table with metadata to be shown in the output page.
113 * @param array $exif The array containing the EXIF data
116 function makeMetadataTable( $exif ) {
117 $r = wfMsg( 'metadata-help' ) . "\n\n";
118 $r .= "{| id=mw_metadata class=mw_metadata\n";
119 $visibleFields = $this->visibleMetadataFields();
120 foreach( $exif as $k => $v ) {
121 $tag = strtolower( $k );
122 $msg = wfMsg( "exif-$tag" );
123 $class = "exif-$tag";
124 if( !in_array( $tag, $visibleFields ) ) {
125 $class .= ' collapsable';
127 $r .= "|- class=\"$class\"\n";
136 * Get a list of EXIF metadata items which should be displayed when
137 * the metadata table is collapsed.
139 * @return array of strings
142 function visibleMetadataFields() {
144 $lines = explode( "\n", wfMsgForContent( 'metadata-fields' ) );
145 foreach( $lines as $line ) {
147 if( preg_match( '/^\\*\s*(.*?)\s*$/', $line, $matches ) ) {
148 $fields[] = $matches[1];
155 * Overloading Article's getContent method.
157 * Omit noarticletext if sharedupload; text will be fetched from the
158 * shared upload server if possible.
160 function getContent() {
161 if( $this->img
&& $this->img
->fromSharedDirectory
&& 0 == $this->getID() ) {
164 return Article
::getContent();
167 function openShowImage() {
168 global $wgOut, $wgUser, $wgImageLimits, $wgRequest, $wgLang;
169 global $wgUseImageResize, $wgGenerateThumbnailOnParse;
171 $full_url = $this->img
->getURL();
174 $sizeSel = intval( $wgUser->getOption( 'imagesize') );
175 if( !isset( $wgImageLimits[$sizeSel] ) ) {
176 $sizeSel = User
::getDefaultOption( 'imagesize' );
178 // The user offset might still be incorrect, specially if
179 // $wgImageLimits got changed (see bug #8858).
180 if( !isset( $wgImageLimits[$sizeSel] ) ) {
181 // Default to the first offset in $wgImageLimits
185 $max = $wgImageLimits[$sizeSel];
187 $maxHeight = $max[1];
188 $sk = $wgUser->getSkin();
190 if ( $this->img
->exists() ) {
192 $page = $wgRequest->getIntOrNull( 'page' );
193 if ( ! is_null( $page ) ) {
194 $this->img
->selectPage( $page );
198 $width_orig = $this->img
->getWidth();
199 $width = $width_orig;
200 $height_orig = $this->img
->getHeight();
201 $height = $height_orig;
202 $mime = $this->img
->getMimeType();
205 if ( $this->img
->allowInlineDisplay() and $width and $height) {
208 # "Download high res version" link below the image
209 $msgbig = wfMsgHtml('show-big-image');
210 $msgsize = wfMsgHtml('file-info-size', $width_orig, $height_orig, $sk->formatSize( $this->img
->getSize() ), $mime );
211 # We'll show a thumbnail of this image
212 if ( $width > $maxWidth ||
$height > $maxHeight ) {
213 # Calculate the thumbnail size.
214 # First case, the limiting factor is the width, not the height.
215 if ( $width / $height >= $maxWidth / $maxHeight ) {
216 $height = round( $height * $maxWidth / $width);
218 # Note that $height <= $maxHeight now.
220 $newwidth = floor( $width * $maxHeight / $height);
221 $height = round( $height * $newwidth / $width );
223 # Note that $height <= $maxHeight now, but might not be identical
224 # because of rounding.
227 if( $wgUseImageResize ) {
228 $thumbnail = $this->img
->getThumbnail( $width, -1, $wgGenerateThumbnailOnParse );
229 if ( $thumbnail == null ) {
230 $url = $this->img
->getViewURL();
232 $url = $thumbnail->getURL();
235 # No resize ability? Show the full image, but scale
236 # it down in the browser so it fits on the page.
237 $url = $this->img
->getViewURL();
239 $anchoropen = "<a href=\"{$full_url}\">";
240 $anchorclose = "</a><br />";
241 if( $this->img
->mustRender() ) {
244 $anchorclose .= wfMsg('show-big-image-thumb', $width, $height ) .
245 '<br />' . "\n$anchoropen{$msgbig}</a> " . $msgsize;
248 $url = $this->img
->getViewURL();
252 if ( $this->img
->isMultipage() ) {
253 $wgOut->addHTML( '<table class="multipageimage"><tr><td>' );
256 $wgOut->addHTML( '<div class="fullImageLink" id="file">' . $anchoropen .
257 "<img border=\"0\" src=\"{$url}\" width=\"{$width}\" height=\"{$height}\" alt=\"" .
258 htmlspecialchars( $this->img
->getTitle()->getPrefixedText() ).'" />' . $anchorclose . '</div>' );
260 if ( $this->img
->isMultipage() ) {
261 $count = $this->img
->pageCount();
264 $label = $wgOut->parse( wfMsg( 'imgmultipageprev' ), false );
265 $link = $sk->makeLinkObj( $this->mTitle
, $label, 'page='. ($page-1) );
266 $this->img
->selectPage( $page - 1 );
267 $thumb1 = $sk->makeThumbLinkObj( $this->img
, $link, $label, 'none' );
272 if ( $page < $count ) {
273 $label = wfMsg( 'imgmultipagenext' );
274 $this->img
->selectPage( $page +
1 );
275 $link = $sk->makeLinkObj( $this->mTitle
, $label, 'page='. ($page+
1) );
276 $thumb2 = $sk->makeThumbLinkObj( $this->img
, $link, $label, 'none' );
282 $select = '<form name="pageselector" action="' .
283 htmlspecialchars( $wgScript ) .
284 '" method="get" onchange="document.pageselector.submit();">' .
285 Xml
::hidden( 'title', $this->getTitle()->getPrefixedDbKey() );
286 $select .= $wgOut->parse( wfMsg( 'imgmultigotopre' ), false ) .
287 ' <select id="pageselector" name="page">';
288 for ( $i=1; $i <= $count; $i++
) {
289 $select .= Xml
::option( $wgLang->formatNum( $i ), $i,
292 $select .= '</select>' . $wgOut->parse( wfMsg( 'imgmultigotopost' ), false ) .
293 '<input type="submit" value="' .
294 htmlspecialchars( wfMsg( 'imgmultigo' ) ) . '"></form>';
296 $wgOut->addHTML( '</td><td><div class="multipageimagenavbox">' .
297 "$select<hr />$thumb1\n$thumb2<br clear=\"all\" /></div></td></tr></table>" );
300 #if direct link is allowed but it's not a renderable image, show an icon.
301 if ($this->img
->isSafeFile()) {
302 $icon= $this->img
->iconThumb();
304 $wgOut->addHTML( '<div class="fullImageLink" id="file"><a href="' . $full_url . '">' .
314 // Hacky workaround: for some reason we use the incorrect MIME type
315 // image/svg for SVG. This should be fixed internally, but at least
316 // make the displayed type right.
317 if ($mime == 'image/svg') $mime = 'image/svg+xml';
319 $filename = wfEscapeWikiText( $this->img
->getName() );
320 $info = wfMsg( 'file-info', $sk->formatSize( $this->img
->getSize() ), $mime );
323 // Check for MIME type. Other types may have more information in the future.
324 if (substr($mime,0,9) == 'image/svg' ) {
325 $infores = wfMsg('file-svg', $width_orig, $height_orig ) . '<br />';
326 } elseif ( substr($mime,0,5) == 'image' ) {
327 $infores = wfMsg('file-nohires') . '<br />';
330 $width_orig, $height_orig,
331 $sk->formatSize( $this->img
->getSize() ),
336 $dirmark = $wgContLang->getDirMark();
337 if (!$this->img
->isSafeFile()) {
338 $warning = wfMsg( 'mediawarning' );
339 $wgOut->addWikiText( <<<END
340 <div class="fullMedia">$infores
341 <span class="dangerousLink">[[Media:$filename|$filename]]</span>$dirmark
342 <span class="fileInfo"> $info</span>
345 <div class="mediaWarning">$warning</div>
349 $wgOut->addWikiText( <<<END
350 <div class="fullMedia">$infores
351 [[Media:$filename|$filename]]$dirmark <span class="fileInfo"> $info</span>
358 if($this->img
->fromSharedDirectory
) {
359 $this->printSharedImageText();
362 # Image does not exist
364 $title = SpecialPage
::getTitleFor( 'Upload' );
365 $link = $sk->makeKnownLinkObj($title, wfMsgHtml('noimage-linktext'),
366 'wpDestFile=' . urlencode( $this->img
->getName() ) );
367 $wgOut->addHTML( wfMsgWikiHtml( 'noimage', $link ) );
371 function printSharedImageText() {
372 global $wgRepositoryBaseUrl, $wgFetchCommonsDescriptions, $wgOut, $wgUser;
374 $url = $wgRepositoryBaseUrl . urlencode($this->mTitle
->getDBkey());
375 $sharedtext = "<div class='sharedUploadNotice'>" . wfMsgWikiHtml("sharedupload");
376 if ($wgRepositoryBaseUrl && !$wgFetchCommonsDescriptions) {
378 $sk = $wgUser->getSkin();
379 $title = SpecialPage
::getTitleFor( 'Upload' );
380 $link = $sk->makeKnownLinkObj($title, wfMsgHtml('shareduploadwiki-linktext'),
381 array( 'wpDestFile' => urlencode( $this->img
->getName() )));
382 $sharedtext .= " " . wfMsgWikiHtml('shareduploadwiki', $link);
384 $sharedtext .= "</div>";
385 $wgOut->addHTML($sharedtext);
387 if ($wgRepositoryBaseUrl && $wgFetchCommonsDescriptions) {
388 $renderUrl = wfAppendQuery( $url, 'action=render' );
389 wfDebug( "Fetching shared description from $renderUrl\n" );
390 $text = Http
::get( $renderUrl );
392 $this->mExtraDescription
= $text;
396 function getUploadUrl() {
398 $uploadTitle = SpecialPage
::getTitleFor( 'Upload' );
399 return $wgServer . $uploadTitle->getLocalUrl( 'wpDestFile=' . urlencode( $this->img
->getName() ) );
403 * Print out the various links at the bottom of the image page, e.g. reupload,
404 * external editing (and instructions link) etc.
406 function uploadLinksBox() {
407 global $wgUser, $wgOut;
409 if( $this->img
->fromSharedDirectory
)
412 $sk = $wgUser->getSkin();
414 $wgOut->addHtml( '<br /><ul>' );
416 # "Upload a new version of this file" link
417 if( $wgUser->isAllowed( 'reupload' ) ) {
418 $ulink = $sk->makeExternalLink( $this->getUploadUrl(), wfMsg( 'uploadnewversion-linktext' ) );
419 $wgOut->addHtml( "<li><div class='plainlinks'>{$ulink}</div></li>" );
422 # External editing link
423 $elink = $sk->makeKnownLinkObj( $this->mTitle
, wfMsgHtml( 'edit-externally' ), 'action=edit&externaledit=true&mode=file' );
424 $wgOut->addHtml( '<li>' . $elink . '<div>' . wfMsgWikiHtml( 'edit-externally-help' ) . '</div></li>' );
426 $wgOut->addHtml( '</ul>' );
429 function closeShowImage()
436 * If the page we've just displayed is in the "Image" namespace,
437 * we follow it with an upload history of the image and its usage.
439 function imageHistory()
441 global $wgUser, $wgOut, $wgUseExternalEditor;
443 $sk = $wgUser->getSkin();
445 $line = $this->img
->nextHistoryLine();
448 $list = new ImageHistoryList( $sk );
449 $s = $list->beginImageHistoryList() .
450 $list->imageHistoryLine( true, wfTimestamp(TS_MW
, $line->img_timestamp
),
451 $this->mTitle
->getDBkey(), $line->img_user
,
452 $line->img_user_text
, $line->img_size
, $line->img_description
,
453 $line->img_width
, $line->img_height
456 while ( $line = $this->img
->nextHistoryLine() ) {
457 $s .= $list->imageHistoryLine( false, $line->img_timestamp
,
458 $line->oi_archive_name
, $line->img_user
,
459 $line->img_user_text
, $line->img_size
, $line->img_description
,
460 $line->img_width
, $line->img_height
463 $s .= $list->endImageHistoryList();
465 $wgOut->addHTML( $s );
467 # Exist check because we don't want to show this on pages where an image
468 # doesn't exist along with the noimage message, that would suck. -ævar
469 if( $wgUseExternalEditor && $this->img
->exists() ) {
470 $this->uploadLinksBox();
475 function imageLinks()
477 global $wgUser, $wgOut;
479 $wgOut->addHTML( Xml
::element( 'h2', array( 'id' => 'filelinks' ), wfMsg( 'imagelinks' ) ) . "\n" );
481 $dbr = wfGetDB( DB_SLAVE
);
482 $page = $dbr->tableName( 'page' );
483 $imagelinks = $dbr->tableName( 'imagelinks' );
485 $sql = "SELECT page_namespace,page_title FROM $imagelinks,$page WHERE il_to=" .
486 $dbr->addQuotes( $this->mTitle
->getDBkey() ) . " AND il_from=page_id";
487 $sql = $dbr->limitResult($sql, 500, 0);
488 $res = $dbr->query( $sql, "ImagePage::imageLinks" );
490 if ( 0 == $dbr->numRows( $res ) ) {
491 $wgOut->addHtml( '<p>' . wfMsg( "nolinkstoimage" ) . "</p>\n" );
494 $wgOut->addHTML( '<p>' . wfMsg( 'linkstoimage' ) . "</p>\n<ul>" );
496 $sk = $wgUser->getSkin();
497 while ( $s = $dbr->fetchObject( $res ) ) {
498 $name = Title
::MakeTitle( $s->page_namespace
, $s->page_title
);
499 $link = $sk->makeKnownLinkObj( $name, "" );
500 $wgOut->addHTML( "<li>{$link}</li>\n" );
502 $wgOut->addHTML( "</ul>\n" );
507 global $wgUser, $wgOut, $wgRequest;
509 $confirm = $wgRequest->wasPosted();
510 $reason = $wgRequest->getVal( 'wpReason' );
511 $image = $wgRequest->getVal( 'image' );
512 $oldimage = $wgRequest->getVal( 'oldimage' );
514 # Only sysops can delete images. Previously ordinary users could delete
515 # old revisions, but this is no longer the case.
516 if ( !$wgUser->isAllowed('delete') ) {
517 $wgOut->permissionRequired( 'delete' );
520 if ( $wgUser->isBlocked() ) {
521 return $this->blockedIPpage();
523 if ( wfReadOnly() ) {
524 $wgOut->readOnlyPage();
528 # Better double-check that it hasn't been deleted yet!
529 $wgOut->setPagetitle( wfMsg( 'confirmdelete' ) );
530 if ( ( !is_null( $image ) )
531 && ( '' == trim( $image ) ) ) {
532 $wgOut->showFatalError( wfMsg( 'cannotdelete' ) );
536 $this->img
= new Image( $this->mTitle
);
538 # Deleting old images doesn't require confirmation
539 if ( !is_null( $oldimage ) ||
$confirm ) {
540 if( $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ), $oldimage ) ) {
541 $this->doDelete( $reason );
543 $wgOut->showFatalError( wfMsg( 'sessionfailure' ) );
548 if ( !is_null( $image ) ) {
549 $q = '&image=' . urlencode( $image );
550 } else if ( !is_null( $oldimage ) ) {
551 $q = '&oldimage=' . urlencode( $oldimage );
555 return $this->confirmDelete( $q, $wgRequest->getText( 'wpReason' ) );
560 * @param $reason User provided reason for deletion.
562 function doDelete( $reason ) {
563 global $wgOut, $wgRequest;
565 $oldimage = $wgRequest->getVal( 'oldimage' );
567 if ( !is_null( $oldimage ) ) {
568 if ( strlen( $oldimage ) < 16 ) {
569 $wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
572 if ( strstr( $oldimage, "/" ) ||
strstr( $oldimage, "\\" ) ) {
573 $wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
576 if ( !$this->doDeleteOldImage( $oldimage ) ) {
579 $deleted = $oldimage;
581 $ok = $this->img
->delete( $reason );
583 # If the deletion operation actually failed, bug out:
584 $wgOut->showFileDeleteError( $this->img
->getName() );
588 # Image itself is now gone, and database is cleaned.
589 # Now we remove the image description page.
591 $article = new Article( $this->mTitle
);
592 $article->doDeleteArticle( $reason ); # ignore errors
594 $deleted = $this->img
->getName();
597 $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
598 $wgOut->setRobotpolicy( 'noindex,nofollow' );
600 $loglink = '[[Special:Log/delete|' . wfMsg( 'deletionlog' ) . ']]';
601 $text = wfMsg( 'deletedtext', $deleted, $loglink );
603 $wgOut->addWikiText( $text );
605 $wgOut->returnToMain( false, $this->mTitle
->getPrefixedText() );
611 function doDeleteOldImage( $oldimage )
615 $ok = $this->img
->deleteOld( $oldimage, '' );
617 # If we actually have a file and can't delete it, throw an error.
618 # Something went awry...
619 $wgOut->showFileDeleteError( "$oldimage" );
622 $log = new LogPage( 'delete' );
623 $log->addEntry( 'delete', $this->mTitle
, wfMsg('deletedrevision',$oldimage) );
629 global $wgOut, $wgRequest, $wgUser;
631 $oldimage = $wgRequest->getText( 'oldimage' );
632 if ( strlen( $oldimage ) < 16 ) {
633 $wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
636 if ( strstr( $oldimage, "/" ) ||
strstr( $oldimage, "\\" ) ) {
637 $wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
641 if ( wfReadOnly() ) {
642 $wgOut->readOnlyPage();
645 if( $wgUser->isAnon() ) {
646 $wgOut->showErrorPage( 'uploadnologin', 'uploadnologintext' );
649 if ( ! $this->mTitle
->userCan( 'edit' ) ) {
650 $wgOut->readOnlyPage( $this->getContent(), true );
653 if ( $wgUser->isBlocked() ) {
654 return $this->blockedIPpage();
656 if( !$wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ), $oldimage ) ) {
657 $wgOut->showErrorPage( 'internalerror', 'sessionfailure' );
660 $name = substr( $oldimage, 15 );
662 $dest = wfImageDir( $name );
663 $archive = wfImageArchiveDir( $name );
664 $curfile = "{$dest}/{$name}";
666 if ( !is_dir( $dest ) ) wfMkdirParents( $dest );
667 if ( !is_dir( $archive ) ) wfMkdirParents( $archive );
669 if ( ! is_file( $curfile ) ) {
670 $wgOut->showFileNotFoundError( htmlspecialchars( $curfile ) );
673 $oldver = wfTimestampNow() . "!{$name}";
675 if ( ! rename( $curfile, "${archive}/{$oldver}" ) ) {
676 $wgOut->showFileRenameError( $curfile, "${archive}/{$oldver}" );
679 if ( ! copy( "{$archive}/{$oldimage}", $curfile ) ) {
680 $wgOut->showFileCopyError( "${archive}/{$oldimage}", $curfile );
684 # Record upload and update metadata cache
685 $img = Image
::newFromName( $name );
686 $img->recordUpload( $oldver, wfMsg( "reverted" ) );
688 $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
689 $wgOut->setRobotpolicy( 'noindex,nofollow' );
690 $wgOut->addHTML( wfMsg( 'imagereverted' ) );
692 $descTitle = $img->getTitle();
693 $wgOut->returnToMain( false, $descTitle->getPrefixedText() );
696 function blockedIPpage() {
697 $edit = new EditPage( $this );
698 return $edit->blockedIPpage();
702 * Override handling of action=purge
705 $this->img
= new Image( $this->mTitle
);
706 if( $this->img
->exists() ) {
707 wfDebug( "ImagePage::doPurge purging " . $this->img
->getName() . "\n" );
708 $update = new HTMLCacheUpdate( $this->mTitle
, 'imagelinks' );
710 $this->img
->purgeCache();
712 wfDebug( "ImagePage::doPurge no image\n" );
722 class ImageHistoryList
{
723 function ImageHistoryList( &$skin ) {
724 $this->skin
=& $skin;
727 function beginImageHistoryList() {
729 Xml
::element( 'h2', array( 'id' => 'filehistory' ), wfMsg( 'imghistory' ) ) .
730 "\n<p>" . wfMsg( 'imghistlegend' ) . "</p>\n".'<ul class="special">';
734 function endImageHistoryList() {
739 function imageHistoryLine( $iscur, $timestamp, $img, $user, $usertext, $size, $description, $width, $height ) {
740 global $wgUser, $wgLang, $wgTitle, $wgContLang;
742 $datetime = $wgLang->timeanddate( $timestamp, true );
743 $del = wfMsgHtml( 'deleteimg' );
744 $delall = wfMsgHtml( 'deleteimgcompletely' );
745 $cur = wfMsgHtml( 'cur' );
748 $url = Image
::imageUrl( $img );
750 if ( $wgUser->isAllowed('delete') ) {
751 $link = $wgTitle->escapeLocalURL( 'image=' . $wgTitle->getPartialURL() .
753 $style = $this->skin
->getInternalLinkAttributes( $link, $delall );
755 $dlink = '<a href="'.$link.'"'.$style.'>'.$delall.'</a>';
760 $url = htmlspecialchars( wfImageArchiveUrl( $img ) );
761 if( $wgUser->getID() != 0 && $wgTitle->userCan( 'edit' ) ) {
762 $token = urlencode( $wgUser->editToken( $img ) );
763 $rlink = $this->skin
->makeKnownLinkObj( $wgTitle,
764 wfMsgHtml( 'revertimg' ), 'action=revert&oldimage=' .
765 urlencode( $img ) . "&wpEditToken=$token" );
766 $dlink = $this->skin
->makeKnownLinkObj( $wgTitle,
767 $del, 'action=delete&oldimage=' . urlencode( $img ) .
768 "&wpEditToken=$token" );
770 # Having live active links for non-logged in users
771 # means that bots and spiders crawling our site can
772 # inadvertently change content. Baaaad idea.
773 $rlink = wfMsgHtml( 'revertimg' );
778 $userlink = $this->skin
->userLink( $user, $usertext ) . $this->skin
->userToolLinks( $user, $usertext );
779 $nbytes = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ),
780 $wgLang->formatNum( $size ) );
781 $widthheight = wfMsgHtml( 'widthheight', $width, $height );
782 $style = $this->skin
->getInternalLinkAttributes( $url, $datetime );
784 $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$datetime}</a> . . {$userlink} . . {$widthheight} ({$nbytes})";
786 $s .= $this->skin
->commentBlock( $description, $wgTitle );