function isTrans() {
global $wgTitleInterwikiCache, $wgDBname;
- if ($this->mInterwiki == '' || !$this->isLocal())
+ if ($this->mInterwiki == '')
return false;
# Make sure key is loaded into cache
$this->getInterwikiLink( $this->mInterwiki );
return $text;
}
+ /**
+ * Get the lowest-level subpage name, i.e. the rightmost part after /
+ * @return string Subpage name
+ */
+ function getSubpageText() {
+ global $wgNamespacesWithSubpages;
+ if( $wgNamespacesWithSubpages[ $this->mNamespace ] ) {
+ $parts = explode( '/', $this->mTextform );
+ return( $parts[ count( $parts ) - 1 ] );
+ } else {
+ return( $this->mTextform );
+ }
+ }
+
/**
* Get a URL-encoded title (not an actual URL) including interwiki
* @return string the URL-encoded form
if ( $this->isExternal() ) {
$url = $this->getFullURL();
+ if ( $query ) {
+ // This is currently only used for edit section links in the
+ // context of interwiki transclusion. In theory we should
+ // append the query to the end of any existing query string,
+ // but interwiki transclusion is already broken in that case.
+ $url .= "?$query";
+ }
} else {
$dbkey = wfUrlencode( $this->getPrefixedDBkey() );
if ( $query == '' ) {
*/
function isExternal() { return ( '' != $this->mInterwiki ); }
+ /**
+ * Is this page "semi-protected" - the *only* protection is autoconfirm?
+ *
+ * @param string Action to check (default: edit)
+ * @return bool
+ */
+ function isSemiProtected( $action = 'edit' ) {
+ $restrictions = $this->getRestrictions( $action );
+ # We do a full compare because this could be an array
+ foreach( $restrictions as $restriction ) {
+ if( strtolower( $restriction ) != 'autoconfirmed' ) {
+ return( false );
+ }
+ }
+ return( true );
+ }
+
/**
* Does the title correspond to a protected article?
* @param string $what the action the page is protected from,
wfProfileIn( $fname );
global $wgUser;
+
+ $result = true;
+ if ( !wfRunHooks( 'userCan', array( &$this, &$wgUser, $action, &$result ) ) ) {
+ wfProfileOut( $fname );
+ return $result;
+ }
+
if( NS_SPECIAL == $this->mNamespace ) {
wfProfileOut( $fname );
return false;
function userCanRead() {
global $wgUser;
+ $result = true;
+ if ( !wfRunHooks( 'userCan', array( &$this, &$wgUser, "read", &$result ) ) ) {
+ return $result;
+ }
+
if( $wgUser->isAllowed('read') ) {
return true;
} else {
function isCssJsSubpage() {
return ( NS_USER == $this->mNamespace and preg_match("/\\.(css|js)$/", $this->mTextform ) );
}
+ /**
+ * Is this a *valid* .css or .js subpage of a user page?
+ * Check that the corresponding skin exists
+ */
+ function isValidCssJsSubpage() {
+ global $wgValidSkinNames;
+ return( $this->isCssJsSubpage() && array_key_exists( $this->getSkinFromCssJsSubpage(), $wgValidSkinNames ) );
+ }
+ /**
+ * Trim down a .css or .js subpage title to get the corresponding skin name
+ */
+ function getSkinFromCssJsSubpage() {
+ $subpage = explode( '/', $this->mTextform );
+ $subpage = $subpage[ count( $subpage ) - 1 ];
+ return( str_replace( array( '.css', '.js' ), array( '', '' ), $subpage ) );
+ }
/**
* Is this a .css subpage of a user page?
* @return bool
# Do another namespace split...
continue;
}
+
+ # If there's an initial colon after the interwiki, that also
+ # resets the default namespace
+ if ( $t !== '' && $t[0] == ':' ) {
+ $this->mNamespace = NS_MAIN;
+ $t = substr( $t, 1 );
+ }
}
# If there's no recognized interwiki or namespace,
# then let the colon expression be part of the title.
* @return bool
*/
function equals( $title ) {
- return $this->getInterwiki() == $title->getInterwiki()
+ // Note: === is necessary for proper matching of number-like titles.
+ return $this->getInterwiki() === $title->getInterwiki()
&& $this->getNamespace() == $title->getNamespace()
- && $this->getDbkey() == $title->getDbkey();
+ && $this->getDbkey() === $title->getDbkey();
}
/**