var $mDbkeyform = ''; // /< Main part with underscores
var $mUserCaseDBKey; // /< DB key with the initial letter in the case specified by the user
var $mNamespace = NS_MAIN; // /< Namespace index, i.e. one of the NS_xxxx constants
- var $mInterwiki = ''; // /< Interwiki prefix (or null string)
+ var $mInterwiki = ''; // /< Interwiki prefix
var $mFragment; // /< Title fragment (i.e. the bit after the #)
var $mArticleID = -1; // /< Article ID, fetched from the link cache on demand
var $mLatestID = false; // /< ID of most recent revision
var $mHasCascadingRestrictions; ///< Are cascading restrictions in effect on this page?
var $mCascadeSources; ///< Where are the cascading restrictions coming from on this page?
var $mRestrictionsLoaded = false; ///< Boolean for initialisation on demand
- var $mPrefixedText; ///< Text form including namespace/interwiki, initialised on demand
+ var $mPrefixedText = null; ///< Text form including namespace/interwiki, initialised on demand
var $mTitleProtection; ///< Cached value for getTitleProtection (create protection)
# Don't change the following default, NS_MAIN is hardcoded in several
# places. See bug 696.
* @return Bool TRUE if this is an in-project interwiki link or a wikilink, FALSE otherwise
*/
public function isLocal() {
- if ( $this->mInterwiki != '' ) {
+ if ( $this->isExternal() ) {
$iw = Interwiki::fetch( $this->mInterwiki );
if ( $iw ) {
return $iw->isLocal();
* @return Bool
*/
public function isExternal() {
- return ( $this->mInterwiki != '' );
+ return $this->mInterwiki !== '';
}
/**
- * Get the interwiki prefix (or null string)
+ * Get the interwiki prefix
*
* @return String Interwiki prefix
*/
* @return Bool TRUE if this is transcludable
*/
public function isTrans() {
- if ( $this->mInterwiki == '' ) {
+ if ( !$this->isExternal() ) {
return false;
}
* @return String the DB name
*/
public function getTransWikiID() {
- if ( $this->mInterwiki == '' ) {
+ if ( !$this->isExternal() ) {
return false;
}
public function getNsText() {
global $wgContLang;
- if ( $this->mInterwiki != '' ) {
+ if ( $this->isExternal() ) {
// This probably shouldn't even happen. ohh man, oh yuck.
// But for interwiki transclusion it sometimes does.
// Shit. Shit shit shit.
* @return Bool TRUE or FALSE
*/
public function isMovable() {
- if ( !MWNamespace::isMovable( $this->getNamespace() ) || $this->getInterwiki() != '' ) {
+ if ( !MWNamespace::isMovable( $this->getNamespace() ) || $this->isExternal() ) {
// Interwiki title or immovable namespace. Hooks don't get to override here
return false;
}
*/
private function prefix( $name ) {
$p = '';
- if ( $this->mInterwiki != '' ) {
+ if ( $this->isExternal() ) {
$p = $this->mInterwiki . ':';
}
* @return String the prefixed title, with spaces
*/
public function getPrefixedText() {
- // @todo FIXME: Bad usage of empty() ?
- if ( empty( $this->mPrefixedText ) ) {
+ if ( $this->mPrefixedText === null ) {
$s = $this->prefix( $this->mTextform );
$s = str_replace( '_', ' ', $s );
$this->mPrefixedText = $s;
* interwiki link
*/
public function getEditURL() {
- if ( $this->mInterwiki != '' ) {
+ if ( $this->isExternal() ) {
return '';
}
$s = $this->getLocalURL( 'action=edit' );
return ( $sources > 0 );
}
+ /**
+ * Determines whether cascading protection sources have already been loaded from
+ * the database.
+ *
+ * @param bool $getPages True to check if the pages are loaded, or false to check
+ * if the status is loaded.
+ * @return bool Whether or not the specified information has been loaded
+ * @since 1.23
+ */
+ public function areCascadeProtectionSourcesLoaded( $getPages = true ) {
+ return $getPages ? isset( $this->mCascadeSources ) : isset( $this->mHasCascadingRestrictions );
+ }
+
/**
* Cascading protection: Get the source of any cascading restrictions on this page.
*
return array( $sources, $pagerestrictions );
}
+ /**
+ * Accessor for mRestrictionsLoaded
+ *
+ * @return bool Whether or not the page's restrictions have already been
+ * loaded from the database
+ * @since 1.23
+ */
+ public function areRestrictionsLoaded() {
+ return $this->mRestrictionsLoaded;
+ }
+
/**
* Accessor/initialisation for mRestrictions
*
: array();
}
+ /**
+ * Accessor/initialisation for mRestrictions
+ *
+ * @return Array of Arrays of Strings the first level indexed by
+ * action, the second level containing the names of the groups
+ * allowed to perform each action
+ * @since 1.23
+ */
+ public function getAllRestrictions() {
+ if ( !$this->mRestrictionsLoaded ) {
+ $this->loadRestrictions();
+ }
+ return $this->mRestrictions;
+ }
+
/**
* Get the expiry time for the restriction against a given action
*
} while ( true );
# We already know that some pages won't be in the database!
- if ( $this->mInterwiki != '' || NS_SPECIAL == $this->mNamespace ) {
+ if ( $this->isExternal() || NS_SPECIAL == $this->mNamespace ) {
$this->mArticleID = 0;
}
$fragment = strstr( $dbkey, '#' );
# and [[Foo]] point to the same place. Don't force it for interwikis, since the
# other site might be case-sensitive.
$this->mUserCaseDBKey = $dbkey;
- if ( $this->mInterwiki == '' ) {
+ if ( !$this->isExternal() ) {
$dbkey = self::capitalize( $dbkey, $this->mNamespace );
}
# Can't make a link to a namespace alone... "empty" local links can only be
# self-links with a fragment identifier.
- if ( $dbkey == '' && $this->mInterwiki == '' && $this->mNamespace != NS_MAIN ) {
+ if ( $dbkey == '' && !$this->isExternal() && $this->mNamespace != NS_MAIN ) {
return false;
}
}
}
+ // If we are looking at a css/js user subpage, purge the action=raw.
+ if ( $this->isJsSubpage() ) {
+ $urls[] = $this->getInternalUrl( 'action=raw&ctype=text/javascript' );
+ } elseif ( $this->isCssSubpage() ) {
+ $urls[] = $this->getInternalUrl( 'action=raw&ctype=text/css' );
+ }
+
wfRunHooks( 'TitleSquidURLs', array( $this, &$urls ) );
return $urls;
}
if ( !$this->isMovable() ) {
$errors[] = array( 'immobile-source-namespace', $this->getNsText() );
}
- if ( $nt->getInterwiki() != '' ) {
+ if ( $nt->isExternal() ) {
$errors[] = array( 'immobile-target-namespace-iw' );
}
if ( !$nt->isMovable() ) {
if ( $moveOverRedirect ) {
$newid = $nt->getArticleID();
+ $newcontent = $newpage->getContent();
# Delete the old redirect. We don't save it to history since
# by definition if we've got here it's rather uninteresting.
# a conflict on the unique namespace+title index...
$dbw->delete( 'page', array( 'page_id' => $newid ), __METHOD__ );
- $newpage->doDeleteUpdates( $newid );
+ $newpage->doDeleteUpdates( $newid, $newcontent );
}
# Save a null revision in the page's history notifying of the move
return $isKnown;
}
- if ( $this->mInterwiki != '' ) {
+ if ( $this->isExternal() ) {
return true; // any interwiki link might be viewable, for all we know
}