r22674 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22673‎ | r22674 | r22675 >
Date:10:44, 3 June 2007
Author:tstarling
Status:old
Tags:
Comment:
Partial implementation of $wgCapitalLinks differences between local wiki and file repository. Description pages don't work when $wgCapitalLinks=true and initialCapital=false, but it should work well enough in the converse situation.
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/includes/filerepo/FSRepo.php (modified) (history)
  • /trunk/phase3/includes/filerepo/File.php (modified) (history)
  • /trunk/phase3/includes/filerepo/UnregisteredLocalFile.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/UnregisteredLocalFile.php
@@ -27,7 +27,7 @@
2828 }
2929 if ( $title ) {
3030 $this->title = $title;
31 - $this->name = $title->getDBkey();
 31+ $this->name = $repo->getNameFromTitle( $title );
3232 } else {
3333 $this->name = basename( $path );
3434 $this->title = Title::makeTitleSafe( NS_IMAGE, $this->name );
Index: trunk/phase3/includes/filerepo/FSRepo.php
@@ -11,7 +11,7 @@
1212 const DELETE_SOURCE = 1;
1313
1414 var $directory, $url, $hashLevels, $thumbScriptUrl, $transformVia404;
15 - var $descBaseUrl, $scriptDirUrl, $articleUrl, $fetchDescription;
 15+ var $descBaseUrl, $scriptDirUrl, $articleUrl, $fetchDescription, $initialCapital;
1616 var $fileFactory = array( 'UnregisteredLocalFile', 'newFromTitle' );
1717 var $oldFileFactory = false;
1818
@@ -24,8 +24,9 @@
2525 $this->transformVia404 = !empty( $info['transformVia404'] );
2626
2727 // Optional settings
 28+ $this->initialCapital = true; // by default
2829 foreach ( array( 'descBaseUrl', 'scriptDirUrl', 'articleUrl', 'fetchDescription',
29 - 'thumbScriptUrl' ) as $var )
 30+ 'thumbScriptUrl', 'initialCapital' ) as $var )
3031 {
3132 if ( isset( $info[$var] ) ) {
3233 $this->$var = $info[$var];
@@ -298,7 +299,7 @@
299300
300301 /**
301302 * 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
303304 */
304305 function getHashPath( $name ) {
305306 if ( $this->isHashed() ) {
@@ -309,7 +310,7 @@
310311 }
311312 return $path;
312313 } else {
313 - return '';
 314+ return '/';
314315 }
315316 }
316317
@@ -407,6 +408,23 @@
408409 function enumFiles( $callback ) {
409410 $this->enumFilesInFS( $callback );
410411 }
 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+ }
411429 }
412430
413431 ?>
Index: trunk/phase3/includes/filerepo/File.php
@@ -119,7 +119,7 @@
120120 */
121121 function getName() {
122122 if ( !isset( $this->name ) ) {
123 - $this->name = $this->title->getDBkey();
 123+ $this->name = $this->repo->getNameFromTitle( $this->title );
124124 }
125125 return $this->name;
126126 }
Index: trunk/phase3/includes/Title.php
@@ -47,6 +47,7 @@
4848 var $mTextform; # Text form (spaces not underscores) of the main part
4949 var $mUrlform; # URL-encoded form of the main part
5050 var $mDbkeyform; # Main part with underscores
 51+ var $mUserCaseDBKey; # DB key with the initial letter in the case specified by the user
5152 var $mNamespace; # Namespace index, i.e. one of the NS_xxxx constants
5253 var $mInterwiki; # Interwiki prefix (or null string)
5354 var $mFragment; # Title fragment (i.e. the bit after the #)
@@ -556,6 +557,12 @@
557558 return $wgContLang->getNsText( $this->mNamespace );
558559 }
559560 /**
 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+ /**
560567 * Get the namespace text of the subject (rather than talk) page
561568 * @return string
562569 */
@@ -1749,6 +1756,7 @@
17501757 * Don't force it for interwikis, since the other
17511758 * site might be case-sensitive.
17521759 */
 1760+ $this->mUserCaseDBKey = $dbkey;
17531761 if( $wgCapitalLinks && $this->mInterwiki == '') {
17541762 $dbkey = $wgContLang->ucfirst( $dbkey );
17551763 }
Index: trunk/phase3/includes/DefaultSettings.php
@@ -203,6 +203,10 @@
204204 * thumbScriptUrl The URL for thumb.php (optional, not recommended)
205205 * transformVia404 Whether to skip media file transformation on parse and rely on a 404
206206 * 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.
207211 *
208212 * These settings describe a foreign MediaWiki installation. They are optional, and will be ignored
209213 * for local repositories:

Follow-up revisions

RevisionCommit summaryAuthorDate
r22717Merged revisions 22667-22715 via svnmerge from...david20:00, 4 June 2007

Status & tagging log