{
global $wgUploadDirectory,$wgHashedUploadDirectory,
$wgUseSharedUploads, $wgSharedUploadDirectory,
- $wgHashedSharedUploadDirectory;
+ $wgHashedSharedUploadDirectory,$wgUseLatin1,
+ $wgSharedLatin1;
$this->name = $name;
$this->title = Title::makeTitleSafe( NS_IMAGE, $this->name );
- $this->fromSharedDirectory = false;
-
+ $this->fromSharedDirectory = false;
if ($wgHashedUploadDirectory) {
$hash = md5( $this->title->getDBkey() );
$this->imagePath = $wgUploadDirectory . '/' . $hash{0} . '/' .
if (!$this->fileExists && $wgUseSharedUploads) {
# in case we're running a capitallinks=false wiki
$sharedname=ucfirst($name);
+ $sharedtitle=$this->title->getDBkey();
+ if($wgUseLatin1 && !$wgSharedLatin1) {
+ $sharedname=utf8_encode($sharedname);
+ $sharedtitle=utf8_encode($sharedtitle);
+ }
if($wgHashedSharedUploadDirectory) {
- $hash = md5( $this->title->getDBkey() );
+ $hash = md5( $sharedtitle );
$this->imagePath = $wgSharedUploadDirectory . '/' . $hash{0} . '/' .
substr( $hash, 0, 2 ) . "/".$sharedname;
} else {
}
$this->fileExists = file_exists( $this->imagePath);
$this->fromSharedDirectory = true;
- #wfDebug ("File from shared directory: ".$this->imagePath."\n");
+ #wfDebug ("File from shared directory: ".$this->imagePath."\n");
}
if($this->fileExists) {
$this->url = $this->wfImageUrl( $name, $this->fromSharedDirectory );
function wfImageUrl( $name, $fromSharedDirectory = false )
{
global $wgUploadPath,$wgUploadBaseUrl,$wgHashedUploadDirectory,
- $wgHashedSharedUploadDirectory,$wgSharedUploadPath;
+ $wgHashedSharedUploadDirectory,$wgSharedUploadPath,
+ $wgUseLatin1, $wgSharedLatin1;
if($fromSharedDirectory) {
$hash = $wgHashedSharedUploadDirectory;
$base = '';
$path = $wgSharedUploadPath;
+ if($wgUseLatin1 && !$wgSharedLatin1) {
+ $name=utf8_encode($name);
+ }
} else {
$hash = $wgHashedUploadDirectory;
$base = $wgUploadBaseUrl;
function thumbUrl( $width, $subdir='thumb') {
global $wgUploadPath,$wgHashedUploadDirectory, $wgUploadBaseUrl,
$wgSharedUploadPath,$wgSharedUploadDirectory,
- $wgHashedSharedUploadDirectory;
- $name = $this->thumbName( $width );
+ $wgHashedSharedUploadDirectory,$wgUseLatin1,$wgSharedLatin1;
+ $name = $this->thumbName( $width );
if($this->fromSharedDirectory) {
$hashdir = $wgHashedSharedUploadDirectory;
$base = '';
$path = $wgSharedUploadPath;
+ if($wgUseLatin1 && !$wgSharedLatin1) {
+ $name=utf8_encode($name);
+ }
} else {
$hashdir = $wgHashedUploadDirectory;
$base = $wgUploadBaseUrl;
* Return the file name of a thumbnail of the specified width
*
* @param integer $width Width of the thumbnail image
+ * @param boolean $shared Does the thumbnail come from the shared repository?
* @access private
*/
- function thumbName( $width ) {
+ function thumbName( $width, $shared=false ) {
+ global $wgUseLatin1,$wgSharedLatin1;
$thumb = $width."px-".$this->name;
if( $this->extension == 'svg' ) {
# Rasterize SVG vector images to PNG
$thumb .= '.png';
}
+ if( $shared && $wgUseLatin1 && !$wgSharedLatin1) {
+ $thumb=utf8_encode($thumb);
+ }
return $thumb;
}
$width = IntVal( $width );
- $thumbName = $this->thumbName( $width );
+ $thumbName = $this->thumbName( $width, $this->fromSharedDirectory );
$thumbPath = wfImageThumbDir( $thumbName, 'thumb', $this->fromSharedDirectory ).'/'.$thumbName;
$thumbUrl = $this->thumbUrl( $width );
#wfDebug ( "Render name: $thumbName path: $thumbPath url: $thumbUrl\n");
global $wgUploadDirectory, $wgHashedUploadDirectory,
$wgSharedUploadDirectory, $wgHashedSharedUploadDirectory;
$dir = $shared ? $wgSharedUploadDirectory : $wgUploadDirectory;
- $hashdir = $shared ? $wgHashedSharedUploadDirectory : $wgHashedUploadDirectory;
+ $hashdir = $shared ? $wgHashedSharedUploadDirectory : $wgHashedUploadDirectory;
if (!$hashdir) { return $dir.'/'.$subdir; }
-
$hash = md5( $fname );
$oldumask = umask(0);
# Suppress warning messages here; if the file itself can't