- global $wgUser;
- $sk = $wgUser->getSkin();
-
- // Check for uppercase extension. We allow these filenames but check if an image
- // with lowercase extension exists already
- if ( $finalExt != strtolower( $finalExt ) ) {
- $nt_lc = Title::newFromText( $partname . '.' . strtolower( $finalExt ) );
- $image_lc = wfLocalFile( $nt_lc );
- }
-
- if( $this->mLocalFile->exists() ) {
- $dlink = $sk->makeKnownLinkObj( $nt );
- if ( $this->mLocalFile->allowInlineDisplay() ) {
- $dlink2 = $sk->makeImageLinkObj( $nt, wfMsgExt( 'fileexists-thumb', 'parseinline', $dlink ),
- $nt->getText(), 'right', array(), false, true );
- } elseif ( !$this->mLocalFile->allowInlineDisplay() && $this->mLocalFile->isSafeFile() ) {
- $icon = $this->mLocalFile->iconThumb();
- $dlink2 = '<div style="float:right" id="mw-media-icon"><a href="' . $this->mLocalFile->getURL() . '">' .
- $icon->toHtml() . '</a><br />' . $dlink . '</div>';
- } else {
- $dlink2 = '';
- }
-
- $warning .= '<li>' . wfMsgExt( 'fileexists', 'parseline', $dlink ) . '</li>' . $dlink2;
-
- } elseif ( isset( $image_lc) && $image_lc->exists() ) {
- # Check if image with lowercase extension exists.
- # It's not forbidden but in 99% it makes no sense to upload the same filename with uppercase extension
- $dlink = $sk->makeKnownLinkObj( $nt_lc );
- if ( $image_lc->allowInlineDisplay() ) {
- $dlink2 = $sk->makeImageLinkObj( $nt_lc, wfMsgExt( 'fileexists-thumb', 'parseinline', $dlink ),
- $nt_lc->getText(), 'right', array(), false, true );
- } elseif ( !$image_lc->allowInlineDisplay() && $image_lc->isSafeFile() ) {
- $icon = $image_lc->iconThumb();
- $dlink2 = '<div style="float:right" id="mw-media-icon"><a href="' . $image_lc->getURL() . '">' .
- $icon->toHtml() . '</a><br />' . $dlink . '</div>';
- } else {
- $dlink2 = '';
- }
-
- $warning .= '<li>' . wfMsgExt( 'fileexists-extension', 'parsemag' , $partname . '.'
- . $finalExt , $dlink ) . '</li>' . $dlink2;
-
- } elseif ( ( substr( $partname , 3, 3 ) == 'px-' || substr( $partname , 2, 3 ) == 'px-' )
- && ereg( "[0-9]{2}" , substr( $partname , 0, 2) ) )
- {
- # Check for filenames like 50px- or 180px-, these are mostly thumbnails
- $nt_thb = Title::newFromText( substr( $partname , strpos( $partname , '-' ) +1 ) . '.' . $finalExt );
- $image_thb = wfLocalFile( $nt_thb );
- if ($image_thb->exists() ) {
- # Check if an image without leading '180px-' (or similiar) exists
- $dlink = $sk->makeKnownLinkObj( $nt_thb);
- if ( $image_thb->allowInlineDisplay() ) {
- $dlink2 = $sk->makeImageLinkObj( $nt_thb,
- wfMsgExt( 'fileexists-thumb', 'parseinline', $dlink ),
- $nt_thb->getText(), 'right', array(), false, true );
- } elseif ( !$image_thb->allowInlineDisplay() && $image_thb->isSafeFile() ) {
- $icon = $image_thb->iconThumb();
- $dlink2 = '<div style="float:right" id="mw-media-icon"><a href="' .
- $image_thb->getURL() . '">' . $icon->toHtml() . '</a><br />' .
- $dlink . '</div>';
- } else {
- $dlink2 = '';
- }
-
- $warning .= '<li>' . wfMsgExt( 'fileexists-thumbnail-yes', 'parsemag', $dlink ) .
- '</li>' . $dlink2;
- } else {
- # Image w/o '180px-' does not exists, but we do not like these filenames
- $warning .= '<li>' . wfMsgExt( 'file-thumbnail-no', 'parseinline' ,
- substr( $partname , 0, strpos( $partname , '-' ) +1 ) ) . '</li>';
- }
- }
- if ( $this->mLocalFile->wasDeleted() ) {
- # If the file existed before and was deleted, warn the user of this
- # Don't bother doing so if the image exists now, however
- $ltitle = SpecialPage::getTitleFor( 'Log' );
- $llink = $sk->makeKnownLinkObj( $ltitle, wfMsgHtml( 'deletionlog' ),
- 'type=delete&page=' . $nt->getPrefixedUrl() );
- $warning .= wfOpenElement( 'li' ) . wfMsgWikiHtml( 'filewasdeleted', $llink ) .
- wfCloseElement( 'li' );