X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FImagePage.php;h=6abf063e859e0e4e08d9b9ca2dfa5f82959beb6d;hb=0ee9a04366b22971725e45af9abd6b28827880dc;hp=6e8d72b6c20ef299909dee0131cbab2518183e70;hpb=ae2557057f963099ed911057364a9aa6f1c7ecf3;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 6e8d72b6c2..6abf063e85 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -1,81 +1,208 @@ mTitle->getNamespace() ) { - $this->openShowImage(); - } + global $wgUseExternalEditor, $wgOut ; - Article::view(); - - # If the article we've just shown is in the "Image" namespace, - # follow it with the history list and link list for the image - # it describes. + $this->img = new Image( $this->mTitle ); - if ( Namespace::getImage() == $this->mTitle->getNamespace() ) { + if( $this->mTitle->getNamespace() == NS_IMAGE ) { + $this->openShowImage(); + if ( $this->img->exists() ) $this->showEXIFdata(); + + # No need to display noarticletext, we use our own message, output in openShowImage() + if ( $this->getID() ) { + Article::view(); + } else { + # Just need to set the right headers + $wgOut->setArticleFlag( true ); + $wgOut->setRobotpolicy( 'index,follow' ); + $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); + $wgOut->addMetaTags(); + $this->viewUpdates(); + } + + if ( $this->img->exists() ) { + $this->uploadNewVersionLink(); + if ( $wgUseExternalEditor && $this->img->exists() ) { + $this->externalEditorLink(); + } + } $this->closeShowImage(); $this->imageHistory(); $this->imageLinks(); + } else { + Article::view(); } } + + function showEXIFdata() { + global $wgOut, $wgShowEXIF; + if ( ! $wgShowEXIF ) return; + + # Get the EXIF data + $exif = $this->img->getExifData(); + if ( count ( $exif ) == 0 ) return; # No EXIF data available + + # Create the table + $r = "{| class=exif\n" ; + $r .= '|+ ' . wfMsg( 'exifdata' ) . "\n|-\n" ; + foreach ( $exif as $k => $v ) { + $r .= "! $k\n"; + $r .= '| ' . htmlspecialchars($v) . "\n|-\n"; + } + $wgOut->addWikiText( substr($r, 0, -3) . '|}' ); + } function openShowImage() { - global $wgOut, $wgUser,$wgRequest; - $this->img = Image::newFromTitle( $this->mTitle ); - $url = $this->img->getUrl(); + global $wgOut, $wgUser, $wgImageLimits, $wgRequest, + $wgUseImageResize, $wgRepositoryBaseUrl, + $wgUseExternalEditor, $wgServer; + $full_url = $this->img->getViewURL(); + $anchoropen = ''; + $anchorclose = ''; + + if( $wgUser->getOption( 'imagesize' ) == '' ) { + $sizeSel = User::getDefaultOption( 'imagesize' ); + } else { + $sizeSel = IntVal( $wgUser->getOption( 'imagesize' ) ); + } + if( !isset( $wgImageLimits[$sizeSel] ) ) { + $sizeSel = User::getDefaultOption( 'imagesize' ); + } + $max = $wgImageLimits[$sizeSel]; + $maxWidth = $max[0]; + $maxHeight = $max[1]; + $sk = $wgUser->getSkin(); if ( $this->img->exists() ) { - - $sk = $wgUser->getSkin(); - - if ( $this->img->getType() != "" ) { + if ( $this->img->getType() != '' ) { # image - $s = "
" . - "img->getWidth() . "\" height=\"" . $this->img->getHeight() . - "\" alt=\"".$wgRequest->getVal( 'image' )."\" />
"; + $width = $this->img->getWidth(); + $height = $this->img->getHeight(); + $msg = wfMsg('showbigimage', $width, $height, intval( $this->img->getSize()/1024 ) ); + if ( $width > $maxWidth ) { + $height = floor( $height * $maxWidth / $width ); + $width = $maxWidth; + } + if ( $height > $maxHeight ) { + $width = floor( $width * $maxHeight / $height ); + $height = $maxHeight; + } + if ( $width != $this->img->getWidth() || $height != $this->img->getHeight() ) { + if( $wgUseImageResize ) { + $thumbnail = $this->img->getThumbnail( $width ); + $url = $thumbnail->getUrl(); + } else { + # No resize ability? Show the full image, but scale + # it down in the browser so it fits on the page. + $url = $full_url; + } + $anchoropen = ""; + $anchorclose = "
\n$anchoropen{$msg}"; + } else { + $url = $full_url; + } + $s = ''; } else { - $s = "
".$sk->makeMediaLink($this->img->getName(),"")."
"; + $s = "
" . $sk->makeMediaLink( $this->img->getName(),'' ) . '
'; } $wgOut->addHTML( $s ); + if($this->img->fromSharedDirectory) { + $sharedtext="
" . wfMsg("sharedupload"); + if($wgRepositoryBaseUrl) { + $sharedtext .= " ". wfMsg("shareduploadwiki",$wgRepositoryBaseUrl . urlencode($this->mTitle->getDBkey())); + } + $sharedtext.="
"; + $wgOut->addWikiText($sharedtext); + } + + } else { + # Image does not exist + $wgOut->addWikiText( wfMsg( 'noimage', $this->getUploadUrl() ) ); } } + function getUploadUrl() { + global $wgServer; + $uploadTitle = Title::makeTitle( NS_SPECIAL, 'Upload' ); + return $wgServer . $uploadTitle->getLocalUrl( 'wpDestFile=' . urlencode( $this->img->getName() ) ); + } + + + function uploadNewVersionLink() { + global $wgOut; + $wgOut->addHTML("
"); + $wgOut->addWikiText( wfMsg( 'uploadnewversion', $this->getUploadUrl() ) ); + $wgOut->addHTML("

"); + } + + function externalEditorLink() + { + global $wgUser,$wgOut; + $sk = $wgUser->getSkin(); + $wgOut->addHTML( '
' ); + $wgOut->addHTML( $sk->makeKnownLinkObj( $this->mTitle, + wfMsg( 'edit-externally' ), + "action=edit&externaledit=true&mode=file" ) ); + $wgOut->addWikiText( '
' . + wfMsg('edit-externally-help') . '
' ); + $wgOut->addHTML( '

' ); + } + function closeShowImage() { # For overloading + } - # If the page we've just displayed is in the "Image" namespace, - # we follow it with an upload history of the image and its usage. - + /** + * If the page we've just displayed is in the "Image" namespace, + * we follow it with an upload history of the image and its usage. + */ function imageHistory() { global $wgUser, $wgOut; $sk = $wgUser->getSkin(); - $s = $sk->beginImageHistoryList(); $line = $this->img->nextHistoryLine(); - $s .= $sk->imageHistoryLine( true, $line->img_timestamp, - $this->mTitle->getDBkey(), $line->img_user, - $line->img_user_text, $line->img_size, $line->img_description ); - - while ( $line = $this->img->nextHistoryLine() ) { - $s .= $sk->imageHistoryLine( false, $line->img_timestamp, - $line->oi_archive_name, $line->img_user, - $line->img_user_text, $line->img_size, $line->img_description ); - } - $s .= $sk->endImageHistoryList(); + if ( $line ) { + $list =& new ImageHistoryList( $sk ); + $s = $list->beginImageHistoryList() . + $list->imageHistoryLine( true, $line->img_timestamp, + $this->mTitle->getDBkey(), $line->img_user, + $line->img_user_text, $line->img_size, $line->img_description ); + + while ( $line = $this->img->nextHistoryLine() ) { + $s .= $list->imageHistoryLine( false, $line->img_timestamp, + $line->oi_archive_name, $line->img_user, + $line->img_user_text, $line->img_size, $line->img_description ); + } + $s .= $list->endImageHistoryList(); + } else { $s=''; } $wgOut->addHTML( $s ); } @@ -83,21 +210,26 @@ class ImagePage extends Article { { global $wgUser, $wgOut; - $wgOut->addHTML( "

" . wfMsg( "imagelinks" ) . "

\n" ); + $wgOut->addHTML( '

' . wfMsg( 'imagelinks' ) . "

\n" ); - $sql = "SELECT cur_namespace,cur_title FROM imagelinks,cur WHERE il_to='" . - wfStrencode( $this->mTitle->getDBkey() ) . "' AND il_from=cur_id"; - $res = wfQuery( $sql, DB_READ, "Article::imageLinks" ); + $dbr =& wfGetDB( DB_SLAVE ); + $page = $dbr->tableName( 'page' ); + $imagelinks = $dbr->tableName( 'imagelinks' ); + + $sql = "SELECT page_namespace,page_title FROM $imagelinks,$page WHERE il_to=" . + $dbr->addQuotes( $this->mTitle->getDBkey() ) . " AND il_from=page_id" + . " LIMIT 500"; # quickie emergency brake + $res = $dbr->query( $sql, "ImagePage::imageLinks" ); - if ( 0 == wfNumRows( $res ) ) { - $wgOut->addHtml( "

" . wfMsg( "nolinkstoimage" ) . "

\n" ); + if ( 0 == $dbr->numRows( $res ) ) { + $wgOut->addHtml( '

' . wfMsg( "nolinkstoimage" ) . "

\n" ); return; } - $wgOut->addHTML( "

" . wfMsg( "linkstoimage" ) . "

\n