From: Chad Horohoe Date: Wed, 3 Sep 2008 15:47:42 +0000 (+0000) Subject: Implement 'thumbDir' configuration parameter for local and foreign repos. Replaces... X-Git-Tag: 1.31.0-rc.0~45506 X-Git-Url: http://git.cyclocoop.org///%22%40url%40//%22?a=commitdiff_plain;h=4c03073817005038c969d5fa30290b0be27f359f;p=lhc%2Fweb%2Fwiklou.git Implement 'thumbDir' configuration parameter for local and foreign repos. Replaces apiThumbCacheDir as it's redundant. Also allows for customization of the default '/thumb/' path on local repos. --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index ef02aae090..d0ecb3bb53 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -206,6 +206,9 @@ $wgFileStore['deleted']['hash'] = 3; ///< 3-level subdirectory split * May be 'paranoid' to remove all parameters from error messages, 'none' to * leave the paths in unchanged, or 'simple' to replace paths with * placeholders. Default for LocalRepo is 'simple'. + * thumbDir + * Sub-directory of $wgUploadPath in which to place thumbnails. Defaults to + * 'thumb/'. * * These settings describe a foreign MediaWiki installation. They are optional, and will be ignored * for local repositories: diff --git a/includes/filerepo/File.php b/includes/filerepo/File.php index b82f1c4101..8ae51f0deb 100644 --- a/includes/filerepo/File.php +++ b/includes/filerepo/File.php @@ -749,7 +749,7 @@ abstract class File { /** Get relative path for a thumbnail file */ function getThumbRel( $suffix = false ) { - $path = 'thumb/' . $this->getRel(); + $path = $this->repo->thumbDir . $this->getRel(); if ( $suffix !== false ) { $path .= '/' . $suffix; } @@ -779,7 +779,7 @@ abstract class File { /** Get the URL of the thumbnail directory, or a particular file if $suffix is specified */ function getThumbUrl( $suffix = false ) { - $path = $this->repo->getZoneUrl('public') . '/thumb/' . $this->getUrlRel(); + $path = $this->repo->getZoneUrl('public') . '/'. $this->repo->thumbDir . $this->getUrlRel(); if ( $suffix !== false ) { $path .= '/' . rawurlencode( $suffix ); } @@ -799,7 +799,7 @@ abstract class File { /** Get the virtual URL for a thumbnail file or directory */ function getThumbVirtualUrl( $suffix = false ) { - $path = $this->repo->getVirtualUrl() . '/public/thumb/' . $this->getUrlRel(); + $path = $this->repo->getVirtualUrl() . '/public/' . $this->repo->thumbDir . $this->getUrlRel(); if ( $suffix !== false ) { $path .= '/' . rawurlencode( $suffix ); } diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index 23a132eae5..88504aef51 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -15,7 +15,7 @@ abstract class FileRepo { var $thumbScriptUrl, $transformVia404; var $descBaseUrl, $scriptDirUrl, $articleUrl, $fetchDescription, $initialCapital; var $pathDisclosureProtection = 'paranoid'; - var $descriptionCacheExpiry, $apiThumbCacheExpiry, $apiThumbCacheDir; + var $descriptionCacheExpiry, $apiThumbCacheExpiry, $thumbDir; /** * Factory functions for creating new files @@ -30,9 +30,10 @@ abstract class FileRepo { // Optional settings $this->initialCapital = true; // by default + $this->thumbDir = 'thumb/'; // sane default foreach ( array( 'descBaseUrl', 'scriptDirUrl', 'articleUrl', 'fetchDescription', 'thumbScriptUrl', 'initialCapital', 'pathDisclosureProtection', - 'descriptionCacheExpiry', 'apiThumbCacheExpiry', 'apiThumbCacheDir' ) as $var ) + 'descriptionCacheExpiry', 'apiThumbCacheExpiry', 'thumbDir') as $var ) { if ( isset( $info[$var] ) ) { $this->$var = $info[$var]; diff --git a/includes/filerepo/ForeignAPIFile.php b/includes/filerepo/ForeignAPIFile.php index 42bd7e10b8..c97d225c8b 100644 --- a/includes/filerepo/ForeignAPIFile.php +++ b/includes/filerepo/ForeignAPIFile.php @@ -31,7 +31,7 @@ class ForeignAPIFile extends File { } function transform( $params, $flags = 0 ) { - if ( $this->repo->apiThumbCacheExpiry > 0 && $this->repo->apiThumbCacheDir ) { + if ( $this->repo->apiThumbCacheExpiry > 0 && $this->repo->thumbDir ) { $thumbUrl = $this->repo->getThumbUrlFromCache( $this->getName(), isset( $params['width'] ) ? $params['width'] : -1, @@ -110,9 +110,9 @@ class ForeignAPIFile extends File { */ function getThumbPath( $suffix = '' ) { $ret = null; - if ( $this->repo->apiThumbCacheExpiry > 0 && $this->repo->apiThumbCacheDir ) { + if ( $this->repo->apiThumbCacheExpiry > 0 && $this->repo->thumbDir ) { global $wgUploadDirectory; - $path = $wgUploadDirectory . '/' . $this->repo->apiThumbCacheDir . '/' . $this->repo->name . '/'; + $path = $wgUploadDirectory . '/' . $this->repo->thumbDir . '/' . $this->repo->name . '/'; if ( $suffix ) { $path = $path . $suffix . '/'; } diff --git a/includes/filerepo/ForeignAPIRepo.php b/includes/filerepo/ForeignAPIRepo.php index bd53686d12..3334e9ad21 100644 --- a/includes/filerepo/ForeignAPIRepo.php +++ b/includes/filerepo/ForeignAPIRepo.php @@ -121,7 +121,7 @@ class ForeignAPIRepo extends FileRepo { } else { $foreignUrl = $this->getThumbUrl( $name, $width, $height ); - $path = $this->apiThumbCacheDir . '/' . $this->name . '/' . + $path = $this->thumbDir . '/' . $this->name . '/' . $name . '/'; if ( !is_dir($wgUploadDirectory . '/' . $path) ) { wfMkdirParents($wgUploadDirectory . '/' . $path);