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.
This commit is contained in:
parent
1bf5236378
commit
52ddf77a9c
5 changed files with 36 additions and 6 deletions
|
|
@ -203,6 +203,10 @@ $wgFileStore['deleted']['hash'] = 3; // 3-level subdirectory split
|
|||
* thumbScriptUrl The URL for thumb.php (optional, not recommended)
|
||||
* transformVia404 Whether to skip media file transformation on parse and rely on a 404
|
||||
* handler instead.
|
||||
* initialCapital Equivalent to $wgCapitalLinks, determines whether filenames implicitly
|
||||
* start with a capital letter. The current implementation may give incorrect
|
||||
* description page links when the local $wgCapitalLinks and initialCapital
|
||||
* are mismatched.
|
||||
*
|
||||
* These settings describe a foreign MediaWiki installation. They are optional, and will be ignored
|
||||
* for local repositories:
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ class Title {
|
|||
var $mTextform; # Text form (spaces not underscores) of the main part
|
||||
var $mUrlform; # URL-encoded form of the main part
|
||||
var $mDbkeyform; # Main part with underscores
|
||||
var $mUserCaseDBKey; # DB key with the initial letter in the case specified by the user
|
||||
var $mNamespace; # Namespace index, i.e. one of the NS_xxxx constants
|
||||
var $mInterwiki; # Interwiki prefix (or null string)
|
||||
var $mFragment; # Title fragment (i.e. the bit after the #)
|
||||
|
|
@ -555,6 +556,12 @@ class Title {
|
|||
}
|
||||
return $wgContLang->getNsText( $this->mNamespace );
|
||||
}
|
||||
/**
|
||||
* Get the DB key with the initial letter case as specified by the user
|
||||
*/
|
||||
function getUserCaseDBKey() {
|
||||
return $this->mUserCaseDBKey;
|
||||
}
|
||||
/**
|
||||
* Get the namespace text of the subject (rather than talk) page
|
||||
* @return string
|
||||
|
|
@ -1749,6 +1756,7 @@ class Title {
|
|||
* Don't force it for interwikis, since the other
|
||||
* site might be case-sensitive.
|
||||
*/
|
||||
$this->mUserCaseDBKey = $dbkey;
|
||||
if( $wgCapitalLinks && $this->mInterwiki == '') {
|
||||
$dbkey = $wgContLang->ucfirst( $dbkey );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class FSRepo {
|
|||
const DELETE_SOURCE = 1;
|
||||
|
||||
var $directory, $url, $hashLevels, $thumbScriptUrl, $transformVia404;
|
||||
var $descBaseUrl, $scriptDirUrl, $articleUrl, $fetchDescription;
|
||||
var $descBaseUrl, $scriptDirUrl, $articleUrl, $fetchDescription, $initialCapital;
|
||||
var $fileFactory = array( 'UnregisteredLocalFile', 'newFromTitle' );
|
||||
var $oldFileFactory = false;
|
||||
|
||||
|
|
@ -24,8 +24,9 @@ class FSRepo {
|
|||
$this->transformVia404 = !empty( $info['transformVia404'] );
|
||||
|
||||
// Optional settings
|
||||
$this->initialCapital = true; // by default
|
||||
foreach ( array( 'descBaseUrl', 'scriptDirUrl', 'articleUrl', 'fetchDescription',
|
||||
'thumbScriptUrl' ) as $var )
|
||||
'thumbScriptUrl', 'initialCapital' ) as $var )
|
||||
{
|
||||
if ( isset( $info[$var] ) ) {
|
||||
$this->$var = $info[$var];
|
||||
|
|
@ -298,7 +299,7 @@ class FSRepo {
|
|||
|
||||
/**
|
||||
* Get a relative path including trailing slash, e.g. f/fa/
|
||||
* If the repo is not hashed, returns an empty string
|
||||
* If the repo is not hashed, returns a slash
|
||||
*/
|
||||
function getHashPath( $name ) {
|
||||
if ( $this->isHashed() ) {
|
||||
|
|
@ -309,7 +310,7 @@ class FSRepo {
|
|||
}
|
||||
return $path;
|
||||
} else {
|
||||
return '';
|
||||
return '/';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -407,6 +408,23 @@ class FSRepo {
|
|||
function enumFiles( $callback ) {
|
||||
$this->enumFilesInFS( $callback );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of an image from its title object
|
||||
*/
|
||||
function getNameFromTitle( $title ) {
|
||||
global $wgCapitalLinks;
|
||||
if ( $this->initialCapital != $wgCapitalLinks ) {
|
||||
global $wgContLang;
|
||||
$name = $title->getUserCaseDBKey();
|
||||
if ( $this->initialCapital ) {
|
||||
$name = $wgContLang->ucfirst( $name );
|
||||
}
|
||||
} else {
|
||||
$name = $title->getDBkey();
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ class File {
|
|||
*/
|
||||
function getName() {
|
||||
if ( !isset( $this->name ) ) {
|
||||
$this->name = $this->title->getDBkey();
|
||||
$this->name = $this->repo->getNameFromTitle( $this->title );
|
||||
}
|
||||
return $this->name;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class UnregisteredLocalFile extends File {
|
|||
}
|
||||
if ( $title ) {
|
||||
$this->title = $title;
|
||||
$this->name = $title->getDBkey();
|
||||
$this->name = $repo->getNameFromTitle( $title );
|
||||
} else {
|
||||
$this->name = basename( $path );
|
||||
$this->title = Title::makeTitleSafe( NS_IMAGE, $this->name );
|
||||
|
|
|
|||
Loading…
Reference in a new issue