X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FImagePage.php;h=d0285e8960aea5a8c3ff1e47eb70d412f0e4310b;hb=cd724523d697bdbaa2c86d222f81ff660d05d51e;hp=9f0eab9758a5a2a3a209dc2937d619773f4e2fbb;hpb=5f4b3ec0642d1b16524bd614b18a34ca1e6b086a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 9f0eab9758..d0285e8960 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -1,18 +1,27 @@ mTitle->getNamespace() ) { + if( $this->mTitle->getNamespace() == NS_IMAGE ) { $this->openShowImage(); } @@ -22,7 +31,7 @@ class ImagePage extends Article { # follow it with the history list and link list for the image # it describes. - if ( Namespace::getImage() == $this->mTitle->getNamespace() ) { + if( $this->mTitle->getNamespace() == NS_IMAGE ) { $this->closeShowImage(); $this->imageHistory(); $this->imageLinks(); @@ -31,35 +40,82 @@ class ImagePage extends Article { function openShowImage() { - global $wgOut, $wgUser, $wgRequest, $wgMaxImageWidth, $wgUseImageResize; + global $wgOut, $wgUser, $wgImageLimits, $wgRequest, + $wgUseImageResize, $wgRepositoryBaseUrl; $this->img = Image::newFromTitle( $this->mTitle ); - $url = $this->img->getUrl(); - $anchoropen = ""; - $anchorclose = ""; + $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]; if ( $this->img->exists() ) { $sk = $wgUser->getSkin(); - if ( $this->img->getType() != "" ) { + if ( $this->img->getType() != '' ) { # image $width = $this->img->getWidth(); $height = $this->img->getHeight(); - if ( $width > $wgMaxImageWidth && $wgUseImageResize ) { - $anchoropen = ""; - $anchorclose = ''; - $url=$this->img->createThumb( $wgMaxImageWidth ); - $height = floor( $height * $wgMaxImageWidth / $width ); - $width = $wgMaxImageWidth; + $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 ); + + if ( ( ! $this->img->mustRender() ) + && ( $thumbnail->getSize() > $this->img->getSize() ) ) { + # the thumbnail is bigger thatn the original image. + # show the original image instead of the thumb. + $url = $full_url; + $width = $this->img->getWidth(); + $height = $this->img->getHeight(); + } else { + $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 = "
" . $anchoropen . + $s = '"; + htmlspecialchars( $wgRequest->getVal( 'image' ) ).'" />' . $anchorclose . '
'; } 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); + } } } @@ -68,28 +124,32 @@ class ImagePage extends Article { # 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 ); } @@ -97,25 +157,26 @@ class ImagePage extends Article { { global $wgUser, $wgOut; - $wgOut->addHTML( "

" . wfMsg( "imagelinks" ) . "

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

' . wfMsg( 'imagelinks' ) . "

\n" ); $dbr =& wfGetDB( DB_SLAVE ); - $cur = $dbr->tableName( 'cur' ); + $page = $dbr->tableName( 'page' ); $imagelinks = $dbr->tableName( 'imagelinks' ); - $sql = "SELECT cur_namespace,cur_title FROM $imagelinks,$cur WHERE il_to=" . - $dbr->addQuotes( $this->mTitle->getDBkey() ) . " AND il_from=cur_id"; + $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, DB_SLAVE, "Article::imageLinks" ); if ( 0 == $dbr->numRows( $res ) ) { - $wgOut->addHtml( "

" . wfMsg( "nolinkstoimage" ) . "

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

' . wfMsg( "nolinkstoimage" ) . "

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

" . wfMsg( "linkstoimage" ) . "

\n