function Image( $name )
{
- global $wgUploadDirectory;
+ global $wgUploadDirectory,$wgHashedUploadDirectory;
$this->name = $name;
$this->title = Title::makeTitleSafe( NS_IMAGE, $this->name );
//$this->imagePath = wfImagePath( $name );
- $hash = md5( $this->title->getDBkey() );
- $this->imagePath = $wgUploadDirectory . '/' . $hash{0} . '/' .substr( $hash, 0, 2 ) . "/{$name}";
+ if ($wgHashedUploadDirectory) {
+ $hash = md5( $this->title->getDBkey() );
+ $this->imagePath = $wgUploadDirectory . '/' . $hash{0} . '/' .
+ substr( $hash, 0, 2 ) . "/{$name}";
+ } else {
+ $this->imagePath = $wgUploadDirectory . '/' . $name;
+ }
$this->url = $this->wfImageUrl( $name );
function wfImageUrl( $name )
{
- global $wgUploadPath,$wgUploadBaseUrl;
- $hash = md5( $name );
-
- $url = "{$wgUploadBaseUrl}{$wgUploadPath}/" . $hash{0} . "/" .
- substr( $hash, 0, 2 ) . "/{$name}";
+ global $wgUploadPath,$wgUploadBaseUrl,$wgHashedUploadDirectory;
+ if ($wgHashedUploadDirectory) {
+ $hash = md5( $name );
+ $url = "{$wgUploadBaseUrl}{$wgUploadPath}/" . $hash{0} . "/" .
+ substr( $hash, 0, 2 ) . "/{$name}";
+ } else {
+ $url = "{$wgUploadBaseUrl}{$wgUploadPath}/{$name}";
+ }
return wfUrlencode( $url );
}
}
function thumbUrl( $width, $subdir='thumb' ) {
- global $wgUploadPath;
-
+ global $wgUploadPath,$wgHashedUploadDirectory;
$name = $this->thumbName( $width );
- $hash = md5( $name );
- $url = "{$wgUploadPath}/{$subdir}/" . $hash{0} . "/" . substr( $hash, 0, 2 ) . "/{$name}";
+ if ($wgHashedUploadDirectory) {
+ $hash = md5( $name );
+ $url = "{$wgUploadPath}/{$subdir}/" . $hash{0} . "/" .
+ substr( $hash, 0, 2 ) . "/{$name}";
+ } else {
+ $url = "{$wgUploadPath}/{$subdir}/{$name}";
+ }
return wfUrlencode($url);
}
function wfImageDir( $fname )
{
- global $wgUploadDirectory;
+ global $wgUploadDirectory, $wgHashedUploadDirectory;
+
+ if (!$wgHashedUploadDirectory) { return $wgUploadDirectory; }
$hash = md5( $fname );
$oldumask = umask(0);
function wfImageArchiveDir( $fname , $subdir='archive')
{
- global $wgUploadDirectory;
+ global $wgUploadDirectory, $wgHashedUploadDirectory;
+
+ if (!$wgHashedUploadDirectory) { return $wgUploadDirectory.'/'.$subdir; }
$hash = md5( $fname );
$oldumask = umask(0);
$log->addEntry( 'upload', $descTitle, $desc );
}
-function wfImageArchiveUrl( $name )
+function wfImageArchiveUrl( $name, $subdir='archive' )
{
- global $wgUploadPath;
+ global $wgUploadPath, $wgHashedUploadDirectory;
- $hash = md5( substr( $name, 15) );
- $url = $wgUploadPath.'/archive/' . $hash{0} . '/' .
- substr( $hash, 0, 2 ) . '/'.$name;
+ if ($wgHashedUploadDirectory) {
+ $hash = md5( substr( $name, 15) );
+ $url = $wgUploadPath.'/'.$subdir.'/' . $hash{0} . '/' .
+ substr( $hash, 0, 2 ) . '/'.$name;
+ } else {
+ $url = $wgUploadPath.'/'.$subdir.'/'.$name;
+ }
return wfUrlencode($url);
}