Index: trunk/phase3/includes/filerepo/UnregisteredLocalFile.php |
— | — | @@ -27,7 +27,7 @@ |
28 | 28 | } |
29 | 29 | if ( $title ) { |
30 | 30 | $this->title = $title; |
31 | | - $this->name = $title->getDBkey(); |
| 31 | + $this->name = $repo->getNameFromTitle( $title ); |
32 | 32 | } else { |
33 | 33 | $this->name = basename( $path ); |
34 | 34 | $this->title = Title::makeTitleSafe( NS_IMAGE, $this->name ); |
Index: trunk/phase3/includes/filerepo/FSRepo.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | const DELETE_SOURCE = 1; |
13 | 13 | |
14 | 14 | var $directory, $url, $hashLevels, $thumbScriptUrl, $transformVia404; |
15 | | - var $descBaseUrl, $scriptDirUrl, $articleUrl, $fetchDescription; |
| 15 | + var $descBaseUrl, $scriptDirUrl, $articleUrl, $fetchDescription, $initialCapital; |
16 | 16 | var $fileFactory = array( 'UnregisteredLocalFile', 'newFromTitle' ); |
17 | 17 | var $oldFileFactory = false; |
18 | 18 | |
— | — | @@ -24,8 +24,9 @@ |
25 | 25 | $this->transformVia404 = !empty( $info['transformVia404'] ); |
26 | 26 | |
27 | 27 | // Optional settings |
| 28 | + $this->initialCapital = true; // by default |
28 | 29 | foreach ( array( 'descBaseUrl', 'scriptDirUrl', 'articleUrl', 'fetchDescription', |
29 | | - 'thumbScriptUrl' ) as $var ) |
| 30 | + 'thumbScriptUrl', 'initialCapital' ) as $var ) |
30 | 31 | { |
31 | 32 | if ( isset( $info[$var] ) ) { |
32 | 33 | $this->$var = $info[$var]; |
— | — | @@ -298,7 +299,7 @@ |
299 | 300 | |
300 | 301 | /** |
301 | 302 | * Get a relative path including trailing slash, e.g. f/fa/ |
302 | | - * If the repo is not hashed, returns an empty string |
| 303 | + * If the repo is not hashed, returns a slash |
303 | 304 | */ |
304 | 305 | function getHashPath( $name ) { |
305 | 306 | if ( $this->isHashed() ) { |
— | — | @@ -309,7 +310,7 @@ |
310 | 311 | } |
311 | 312 | return $path; |
312 | 313 | } else { |
313 | | - return ''; |
| 314 | + return '/'; |
314 | 315 | } |
315 | 316 | } |
316 | 317 | |
— | — | @@ -407,6 +408,23 @@ |
408 | 409 | function enumFiles( $callback ) { |
409 | 410 | $this->enumFilesInFS( $callback ); |
410 | 411 | } |
| 412 | + |
| 413 | + /** |
| 414 | + * Get the name of an image from its title object |
| 415 | + */ |
| 416 | + function getNameFromTitle( $title ) { |
| 417 | + global $wgCapitalLinks; |
| 418 | + if ( $this->initialCapital != $wgCapitalLinks ) { |
| 419 | + global $wgContLang; |
| 420 | + $name = $title->getUserCaseDBKey(); |
| 421 | + if ( $this->initialCapital ) { |
| 422 | + $name = $wgContLang->ucfirst( $name ); |
| 423 | + } |
| 424 | + } else { |
| 425 | + $name = $title->getDBkey(); |
| 426 | + } |
| 427 | + return $name; |
| 428 | + } |
411 | 429 | } |
412 | 430 | |
413 | 431 | ?> |
Index: trunk/phase3/includes/filerepo/File.php |
— | — | @@ -119,7 +119,7 @@ |
120 | 120 | */ |
121 | 121 | function getName() { |
122 | 122 | if ( !isset( $this->name ) ) { |
123 | | - $this->name = $this->title->getDBkey(); |
| 123 | + $this->name = $this->repo->getNameFromTitle( $this->title ); |
124 | 124 | } |
125 | 125 | return $this->name; |
126 | 126 | } |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -47,6 +47,7 @@ |
48 | 48 | var $mTextform; # Text form (spaces not underscores) of the main part |
49 | 49 | var $mUrlform; # URL-encoded form of the main part |
50 | 50 | var $mDbkeyform; # Main part with underscores |
| 51 | + var $mUserCaseDBKey; # DB key with the initial letter in the case specified by the user |
51 | 52 | var $mNamespace; # Namespace index, i.e. one of the NS_xxxx constants |
52 | 53 | var $mInterwiki; # Interwiki prefix (or null string) |
53 | 54 | var $mFragment; # Title fragment (i.e. the bit after the #) |
— | — | @@ -556,6 +557,12 @@ |
557 | 558 | return $wgContLang->getNsText( $this->mNamespace ); |
558 | 559 | } |
559 | 560 | /** |
| 561 | + * Get the DB key with the initial letter case as specified by the user |
| 562 | + */ |
| 563 | + function getUserCaseDBKey() { |
| 564 | + return $this->mUserCaseDBKey; |
| 565 | + } |
| 566 | + /** |
560 | 567 | * Get the namespace text of the subject (rather than talk) page |
561 | 568 | * @return string |
562 | 569 | */ |
— | — | @@ -1749,6 +1756,7 @@ |
1750 | 1757 | * Don't force it for interwikis, since the other |
1751 | 1758 | * site might be case-sensitive. |
1752 | 1759 | */ |
| 1760 | + $this->mUserCaseDBKey = $dbkey; |
1753 | 1761 | if( $wgCapitalLinks && $this->mInterwiki == '') { |
1754 | 1762 | $dbkey = $wgContLang->ucfirst( $dbkey ); |
1755 | 1763 | } |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -203,6 +203,10 @@ |
204 | 204 | * thumbScriptUrl The URL for thumb.php (optional, not recommended) |
205 | 205 | * transformVia404 Whether to skip media file transformation on parse and rely on a 404 |
206 | 206 | * handler instead. |
| 207 | + * initialCapital Equivalent to $wgCapitalLinks, determines whether filenames implicitly |
| 208 | + * start with a capital letter. The current implementation may give incorrect |
| 209 | + * description page links when the local $wgCapitalLinks and initialCapital |
| 210 | + * are mismatched. |
207 | 211 | * |
208 | 212 | * These settings describe a foreign MediaWiki installation. They are optional, and will be ignored |
209 | 213 | * for local repositories: |