r40385 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40384‎ | r40385 | r40386 >
Date:15:47, 3 September 2008
Author:demon
Status:old
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/filerepo/File.php (modified) (history)
  • /trunk/phase3/includes/filerepo/FileRepo.php (modified) (history)
  • /trunk/phase3/includes/filerepo/ForeignAPIFile.php (modified) (history)
  • /trunk/phase3/includes/filerepo/ForeignAPIRepo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/FileRepo.php
@@ -15,7 +15,7 @@
1616 var $thumbScriptUrl, $transformVia404;
1717 var $descBaseUrl, $scriptDirUrl, $articleUrl, $fetchDescription, $initialCapital;
1818 var $pathDisclosureProtection = 'paranoid';
19 - var $descriptionCacheExpiry, $apiThumbCacheExpiry, $apiThumbCacheDir;
 19+ var $descriptionCacheExpiry, $apiThumbCacheExpiry, $thumbDir;
2020
2121 /**
2222 * Factory functions for creating new files
@@ -30,9 +30,10 @@
3131
3232 // Optional settings
3333 $this->initialCapital = true; // by default
 34+ $this->thumbDir = 'thumb/'; // sane default
3435 foreach ( array( 'descBaseUrl', 'scriptDirUrl', 'articleUrl', 'fetchDescription',
3536 'thumbScriptUrl', 'initialCapital', 'pathDisclosureProtection',
36 - 'descriptionCacheExpiry', 'apiThumbCacheExpiry', 'apiThumbCacheDir' ) as $var )
 37+ 'descriptionCacheExpiry', 'apiThumbCacheExpiry', 'thumbDir') as $var )
3738 {
3839 if ( isset( $info[$var] ) ) {
3940 $this->$var = $info[$var];
Index: trunk/phase3/includes/filerepo/ForeignAPIRepo.php
@@ -121,7 +121,7 @@
122122 }
123123 else {
124124 $foreignUrl = $this->getThumbUrl( $name, $width, $height );
125 - $path = $this->apiThumbCacheDir . '/' . $this->name . '/' .
 125+ $path = $this->thumbDir . '/' . $this->name . '/' .
126126 $name . '/';
127127 if ( !is_dir($wgUploadDirectory . '/' . $path) ) {
128128 wfMkdirParents($wgUploadDirectory . '/' . $path);
Index: trunk/phase3/includes/filerepo/File.php
@@ -749,7 +749,7 @@
750750
751751 /** Get relative path for a thumbnail file */
752752 function getThumbRel( $suffix = false ) {
753 - $path = 'thumb/' . $this->getRel();
 753+ $path = $this->repo->thumbDir . $this->getRel();
754754 if ( $suffix !== false ) {
755755 $path .= '/' . $suffix;
756756 }
@@ -779,7 +779,7 @@
780780
781781 /** Get the URL of the thumbnail directory, or a particular file if $suffix is specified */
782782 function getThumbUrl( $suffix = false ) {
783 - $path = $this->repo->getZoneUrl('public') . '/thumb/' . $this->getUrlRel();
 783+ $path = $this->repo->getZoneUrl('public') . '/'. $this->repo->thumbDir . $this->getUrlRel();
784784 if ( $suffix !== false ) {
785785 $path .= '/' . rawurlencode( $suffix );
786786 }
@@ -799,7 +799,7 @@
800800
801801 /** Get the virtual URL for a thumbnail file or directory */
802802 function getThumbVirtualUrl( $suffix = false ) {
803 - $path = $this->repo->getVirtualUrl() . '/public/thumb/' . $this->getUrlRel();
 803+ $path = $this->repo->getVirtualUrl() . '/public/' . $this->repo->thumbDir . $this->getUrlRel();
804804 if ( $suffix !== false ) {
805805 $path .= '/' . rawurlencode( $suffix );
806806 }
Index: trunk/phase3/includes/filerepo/ForeignAPIFile.php
@@ -31,7 +31,7 @@
3232 }
3333
3434 function transform( $params, $flags = 0 ) {
35 - if ( $this->repo->apiThumbCacheExpiry > 0 && $this->repo->apiThumbCacheDir ) {
 35+ if ( $this->repo->apiThumbCacheExpiry > 0 && $this->repo->thumbDir ) {
3636 $thumbUrl = $this->repo->getThumbUrlFromCache(
3737 $this->getName(),
3838 isset( $params['width'] ) ? $params['width'] : -1,
@@ -110,9 +110,9 @@
111111 */
112112 function getThumbPath( $suffix = '' ) {
113113 $ret = null;
114 - if ( $this->repo->apiThumbCacheExpiry > 0 && $this->repo->apiThumbCacheDir ) {
 114+ if ( $this->repo->apiThumbCacheExpiry > 0 && $this->repo->thumbDir ) {
115115 global $wgUploadDirectory;
116 - $path = $wgUploadDirectory . '/' . $this->repo->apiThumbCacheDir . '/' . $this->repo->name . '/';
 116+ $path = $wgUploadDirectory . '/' . $this->repo->thumbDir . '/' . $this->repo->name . '/';
117117 if ( $suffix ) {
118118 $path = $path . $suffix . '/';
119119 }
Index: trunk/phase3/includes/DefaultSettings.php
@@ -206,6 +206,9 @@
207207 * May be 'paranoid' to remove all parameters from error messages, 'none' to
208208 * leave the paths in unchanged, or 'simple' to replace paths with
209209 * placeholders. Default for LocalRepo is 'simple'.
 210+ * thumbDir
 211+ * Sub-directory of $wgUploadPath in which to place thumbnails. Defaults to
 212+ * 'thumb/'.
210213 *
211214 * These settings describe a foreign MediaWiki installation. They are optional, and will be ignored
212215 * for local repositories:

Follow-up revisions

RevisionCommit summaryAuthorDate
r40504Revert r40385. Half-assed attempt at making something configurable that doesn...demon18:29, 5 September 2008

Status & tagging log