* Based on UploadWizard/resources/mw.Title.js
* Refactored to use local scope and prototypes instead of per-instance private scope (less references, faster instantiation)
* Fix potential ReferenceError in the check for wgArticlePath (inline if statements will fail to evaluate for undeclared variables). Using mw.config instead
* The following were not ported because they are or were already redundant and/or merged with another method:
-- setNameText (redundant with the improved setName)
-- setPrefix (redundant wit the improved setNamespace)
* Ported all jasmine tests to QUnit. Left them exactly the same to make sure it's compatible with UploadWizard. Perhaps I'll expand or adjust the suite later to be less file-specific, but for now make sure it's compatible and the same.
@todo FIXME
* Removed assumption that every title has a namespace prefix in it by creating a separate RegExp when there is a namespace given
** Fixes strip-bug in cases where a namespace appears to be part of a title when the namespace is also given: "Project:User:Foobar"
new mw.Title( 'User:Foobar', 4 ).toString()
> 'Project:Foobar'
** Fixes a thrown exception in case a colon is part of the title (colons are valid in MediaWiki pagenames!)
new mw.Title( 'Just some:Random page')
> Error: mw.Title> Unrecognized canonical namespace: just_some
* Added check for capitalLinks et (wasn't possible before due to bug X)
** Prevents breakages on wiktionary and other wikis with case sensitivity.
);
$mainPage = Title::newMainPage();
);
$mainPage = Title::newMainPage();
- // Build wgNamespaceIds
- // A complete key-value pair object mapping localized, canonical and aliases for namespaces
- // to their numerical ids (case insensitive and with underscores)
+ /**
+ * Namespace related preparation
+ * - wgNamespaceIds: Key-value pairs of all localized, canonical and aliases for namespaces.
+ * - wgCaseSensitiveNamespaces: Array of namespaces that are case-sensitive.
+ */
$namespaceIds = $wgContLang->getNamespaceIds();
$namespaceIds = $wgContLang->getNamespaceIds();
+ $caseSensitiveNamespaces = array();
foreach( MWNamespace::getCanonicalNamespaces() as $index => $name ) {
$namespaceIds[$wgContLang->lc( $name )] = $index;
foreach( MWNamespace::getCanonicalNamespaces() as $index => $name ) {
$namespaceIds[$wgContLang->lc( $name )] = $index;
+ if ( !MWNamespace::isCapitalized( $index ) ) {
+ $caseSensitiveNamespaces[] = $index;
+ }
$serverBits = wfParseUrl( $wgServer );
$protocol = $serverBits ? $serverBits['scheme'] : 'http';
$serverBits = wfParseUrl( $wgServer );
$protocol = $serverBits ? $serverBits['scheme'] : 'http';
'wgCookiePrefix' => $wgCookiePrefix,
'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength,
'wgLegacyJavaScriptGlobals' => $wgLegacyJavaScriptGlobals,
'wgCookiePrefix' => $wgCookiePrefix,
'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength,
'wgLegacyJavaScriptGlobals' => $wgLegacyJavaScriptGlobals,
+ 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces,
);
if ( $wgUseAjax && $wgEnableMWSuggest ) {
$vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
);
if ( $wgUseAjax && $wgEnableMWSuggest ) {
$vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();