$rt = Title::newFromText( $m[1] );
# Disallow redirects to Special:Userlogout
- if ( !is_null($rt) && $rt->getNamespace() == NS_SPECIAL && preg_match( '/^Userlogout/i', $rt->getText() ) ) {
+ if ( !is_null($rt) && $rt->isSpecial( 'Userlogout' ) ) {
$rt = NULL;
}
}
$lc = SearchEngine::legalSearchChars() . '&#;';
$t = $wgContLang->stripForSearch( $title );
$t = preg_replace( "/[^{$lc}]+/", ' ', $t );
- $t = strtolower( $t );
+ $t = $wgContLang->lc( $t );
# Handle 's, s'
$t = preg_replace( "/([{$lc}]+)'s( |$)/", "\\1 \\1's ", $t );
*/
function getInterwikiLink( $key ) {
global $wgMemc, $wgInterwikiExpiry;
- global $wgInterwikiCache;
+ global $wgInterwikiCache, $wgContLang;
$fname = 'Title::getInterwikiLink';
- $key = strtolower( $key );
+ $key = $wgContLang->lc( $key );
$k = wfMemcKey( 'interwiki', $key );
if( array_key_exists( $k, Title::$interwikiCache ) ) {
else
$variantArticlePath = $wgVariantArticlePath;
- $url = str_replace( '$1', $dbkey, $variantArticlePath );
- $url = str_replace( '$2', urlencode( $variant ), $url );
+ $url = str_replace( '$2', urlencode( $variant ), $variantArticlePath );
+ $url = str_replace( '$1', $dbkey, $url );
+
}
else
$url = str_replace( '$1', $dbkey, $wgArticlePath );
} else {
global $wgWhitelistRead;
- /** If anon users can create an account,
- they need to reach the login page first! */
- if( $wgUser->isAllowed( 'createaccount' )
- && $this->getNamespace() == NS_SPECIAL
+ /**
+ * Always grant access to the login page.
+ * Even anons need to be able to log in.
+ */
+ if( $this->getNamespace() == NS_SPECIAL
&& $this->getText() == 'Userlogin' ) {
return true;
}
do {
if ( preg_match( "/^(.+?)_*:_*(.*)$/S", $t, $m ) ) {
$p = $m[1];
- $lowerNs = strtolower( $p );
+ $lowerNs = $wgContLang->lc( $p );
if ( $ns = Namespace::getCanonicalIndex( $lowerNs ) ) {
# Canonical namespace
$t = $m[2];
# Interwiki link
$t = $m[2];
- $this->mInterwiki = strtolower( $p );
+ $this->mInterwiki = $wgContLang->lc( $p );
# Redundant interwiki prefix to the local wiki
if ( 0 == strcasecmp( $this->mInterwiki, $wgLocalInterwiki ) ) {
* Get a cached value from a global cache that is invalidated when this page changes
* @param string $key the key
* @param callback $callback A callback function which generates the value on cache miss
+ *
+ * @deprecated use DependencyWrapper
*/
function getRelatedCache( $memc, $key, $expiry, $callback, $params = array() ) {
- $touched = $this->getTouched();
- $cacheEntry = $memc->get( $key );
- if ( $cacheEntry ) {
- if ( $cacheEntry['touched'] >= $touched ) {
- return $cacheEntry['value'];
- } else {
- wfDebug( __METHOD__.": $key expired\n" );
- }
- } else {
- wfDebug( __METHOD__.": $key not found\n" );
- }
- $value = call_user_func_array( $callback, $params );
- $cacheEntry = array(
- 'value' => $value,
- 'touched' => $touched
- );
- $memc->set( $key, $cacheEntry, $expiry );
- return $value;
+ return DependencyWrapper::getValueFromCache( $memc, $key, $expiry, $callback,
+ $params, new TitleDependency( $this ) );
}
function trackbackURL() {
* @return string
*/
function getNamespaceKey() {
+ global $wgContLang;
switch ($this->getNamespace()) {
case NS_MAIN:
case NS_TALK:
case NS_CATEGORY_TALK:
return 'nstab-category';
default:
- return 'nstab-' . strtolower( $this->getSubjectNsText() );
+ return 'nstab-' . $wgContLang->lc( $this->getSubjectNsText() );
+ }
+ }
+
+ /**
+ * Returns true if this title resolves to the named special page
+ * @param string $name The special page name
+ * @access public
+ */
+ function isSpecial( $name ) {
+ if ( $this->getNamespace() == NS_SPECIAL ) {
+ list( $thisName, $subpage ) = SpecialPage::resolveAliasWithSubpage( $this->getDBkey() );
+ if ( $name == $thisName ) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * If the Title refers to a special page alias which is not the local default,
+ * returns a new Title which points to the local default. Otherwise, returns $this.
+ */
+ function fixSpecialName() {
+ if ( $this->getNamespace() == NS_SPECIAL ) {
+ $canonicalName = SpecialPage::resolveAlias( $this->mDbkeyform );
+ if ( $canonicalName ) {
+ $localName = SpecialPage::getLocalNameFor( $canonicalName );
+ if ( $localName != $this->mDbkeyform ) {
+ return Title::makeTitle( NS_SPECIAL, $localName );
+ }
+ }
}
+ return $this;
}
}
?>