X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FImagePage.php;h=d0285e8960aea5a8c3ff1e47eb70d412f0e4310b;hb=8da29ee8fccfd8d36ec11f597670a7dcd743449c;hp=bc993a820773b638633f5a46712d975d158f3f81;hpb=def0193f313521c499378e1e7ae294161e31f6f0;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ImagePage.php b/includes/ImagePage.php index bc993a8207..d0285e8960 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -1,59 +1,155 @@ -mTitle->getNamespace() == NS_IMAGE ) { + $this->openShowImage(); + } + 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. - if ( Namespace::getImage() == $this->mTitle->getNamespace() ) { + if( $this->mTitle->getNamespace() == NS_IMAGE ) { + $this->closeShowImage(); $this->imageHistory(); $this->imageLinks(); } } + + function openShowImage() + { + global $wgOut, $wgUser, $wgImageLimits, $wgRequest, + $wgUseImageResize, $wgRepositoryBaseUrl; + $this->img = Image::newFromTitle( $this->mTitle ); + $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() != '' ) { + # 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 ); + + 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 = ''; + } else { + $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); + } + } + } - # 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 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. + */ function imageHistory() { - global $wgUser, $wgOut, $wgLang; - $fname = "Article::imageHistory"; - - $sql = "SELECT img_size,img_description,img_user," . - "img_user_text,img_timestamp FROM image WHERE " . - "img_name='" . wfStrencode( $this->mTitle->getDBkey() ) . "'"; - $res = wfQuery( $sql, DB_READ, $fname ); - - if ( 0 == wfNumRows( $res ) ) { return; } + global $wgUser, $wgOut; $sk = $wgUser->getSkin(); - $s = $sk->beginImageHistoryList(); - $line = wfFetchObject( $res ); - $s .= $sk->imageHistoryLine( true, $line->img_timestamp, - $this->mTitle->getText(), $line->img_user, - $line->img_user_text, $line->img_size, $line->img_description ); + $line = $this->img->nextHistoryLine(); - $sql = "SELECT oi_size,oi_description,oi_user," . - "oi_user_text,oi_timestamp,oi_archive_name FROM oldimage WHERE " . - "oi_name='" . wfStrencode( $this->mTitle->getDBkey() ) . "' " . - "ORDER BY oi_timestamp DESC"; - $res = wfQuery( $sql, DB_READ, $fname ); + 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 = wfFetchObject( $res ) ) { - $s .= $sk->imageHistoryLine( false, $line->oi_timestamp, - $line->oi_archive_name, $line->oi_user, - $line->oi_user_text, $line->oi_size, $line->oi_description ); - } - $s .= $sk->endImageHistoryList(); + 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 ); } @@ -61,22 +157,27 @@ class ImagePage extends Article { { global $wgUser, $wgOut; - $wgOut->addHTML( "

" . wfMsg( "imagelinks" ) . "

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

' . wfMsg( 'imagelinks' ) . "

\n" ); - $sql = "SELECT il_from FROM imagelinks WHERE il_to='" . - wfStrencode( $this->mTitle->getDBkey() ) . "'"; - $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, DB_SLAVE, "Article::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