protected $skinname = 'standard';
// @todo Fixme: should be protected :-\
var $mTitle = null;
+ protected $mRelevantTitle = null;
+ protected $mRelevantUser = null;
/** Constructor, call parent constructor */
function __construct() {
return $this->mTitle;
}
+ /**
+ * Set the "relevant" title
+ * @see self::getRelevantTitle()
+ * @param $t Title object to use
+ */
+ public function setRelevantTitle( $t ) {
+ $this->mRelevantTitle = $t;
+ }
+
+ /**
+ * Return the "relevant" title.
+ * A "relevant" title is not necessarily the actual title of the page.
+ * Special pages like Special:MovePage use set the page they are acting on
+ * as their "relevant" title, this allows the skin system to display things
+ * such as content tabs which belong to to that page instead of displaying
+ * a basic special page tab which has almost no meaning.
+ */
+ public function getRelevantTitle() {
+ if ( isset($this->mRelevantTitle) ) {
+ return $this->mRelevantTitle;
+ }
+ return $this->mTitle;
+ }
+
+ /**
+ * Set the "relevant" user
+ * @see self::getRelevantUser()
+ * @param $u User object to use
+ */
+ public function setRelevantUser( $u ) {
+ $this->mRelevantUser = $u;
+ }
+
+ /**
+ * Return the "relevant" user.
+ * A "relevant" user is similar to a relevant title. Special pages like
+ * Special:Contributions mark the user which they are relevant to so that
+ * things like the toolbox can display the information they usually are only
+ * able to display on a user's userpage and talkpage.
+ */
+ public function getRelevantUser() {
+ if ( isset($this->mRelevantUser) ) {
+ return $this->mRelevantUser;
+ }
+ $title = $this->getRelevantTitle();
+ if( $title->getNamespace() == NS_USER || $title->getNamespace() == NS_USER_TALK ) {
+ $rootUser = strtok( $title->getText(), '/' );
+ if ( User::isIP( $rootUser ) ) {
+ $this->mRelevantUser = User::newFromName( $rootUser, false );
+ } else {
+ $user = User::newFromName( $rootUser );
+ if ( $user->isLoggedIn() ) {
+ $this->mRelevantUser = $user;
+ }
+ }
+ return $this->mRelevantUser;
+ }
+ return null;
+ }
+
/**
* Outputs the HTML generated by other functions.
* @param $out Object: instance of OutputPage
wfProfileIn( __METHOD__ );
+ $title = $this->getRelevantTitle(); // Display tabs for the relevant title rather than always the title itself
+ $onPage = $title->equals($this->mTitle);
+
$content_navigation = array(
'namespaces' => array(),
'views' => array(),
$action = $wgRequest->getVal( 'action', 'view' );
$section = $wgRequest->getVal( 'section' );
- $userCanRead = $this->mTitle->userCanRead();
+ $userCanRead = $title->userCanRead();
$skname = $this->skinname;
$preventActiveTabs = false;
wfRunHooks( 'SkinTemplatePreventOtherActiveTabs', array( &$this, &$preventActiveTabs ) );
// Checks if page is some kind of content
- if( $this->iscontent ) {
+ if( $this->mTitle->getNamespace() != NS_SPECIAL ) {
// Gets page objects for the related namespaces
- $subjectPage = $this->mTitle->getSubjectPage();
- $talkPage = $this->mTitle->getTalkPage();
+ $subjectPage = $title->getSubjectPage();
+ $talkPage = $title->getTalkPage();
// Determines if this is a talk page
- $isTalk = $this->mTitle->isTalkPage();
+ $isTalk = $title->isTalkPage();
// Generates XML IDs from namespace names
- $subjectId = $this->mTitle->getNamespaceKey( '' );
+ $subjectId = $title->getNamespaceKey( '' );
if ( $subjectId == 'main' ) {
$talkId = 'talk';
$content_navigation['namespaces'][$talkId]['context'] = 'talk';
// Adds view view link
- if ( $this->mTitle->exists() && $userCanRead ) {
+ if ( $title->exists() && $userCanRead ) {
$content_navigation['views']['view'] = $this->tabAction(
$isTalk ? $talkPage : $subjectPage,
!wfEmptyMsg( "$skname-view-view" ) ? "$skname-view-view" : 'view',
- ( $action == 'view' ), '', true
+ ( $onPage && $action == 'view' ), '', true
);
$content_navigation['views']['view']['redundant'] = true; // signal to hide this from simple content_actions
}
// Checks if user can...
if (
// read and edit the current page
- $userCanRead && $this->mTitle->quickUserCan( 'edit' ) &&
+ $userCanRead && $title->quickUserCan( 'edit' ) &&
(
// if it exists
- $this->mTitle->exists() ||
+ $title->exists() ||
// or they can create one here
- $this->mTitle->quickUserCan( 'create' )
+ $title->quickUserCan( 'create' )
)
) {
// Builds CSS class for talk page links
// Determines if we're in edit mode
$selected = (
+ $onPage &&
( $action == 'edit' || $action == 'submit' ) &&
( $section != 'new' )
);
- $msgKey = $this->mTitle->exists() || ( $this->mTitle->getNamespace() == NS_MEDIAWIKI && !wfEmptyMsg( $this->mTitle->getText() ) ) ?
+ $msgKey = $title->exists() || ( $title->getNamespace() == NS_MEDIAWIKI && !wfEmptyMsg( $title->getText() ) ) ?
"edit" : "create";
$content_navigation['views']['edit'] = array(
'class' => ( $selected ? 'selected' : '' ) . $isTalkClass,
'text' => wfMessageFallback( "$skname-view-$msgKey", $msgKey )->plain(),
- 'href' => $this->mTitle->getLocalURL( $this->editUrlOptions() ),
+ 'href' => $title->getLocalURL( $this->editUrlOptions() ),
'primary' => true, // don't collapse this in vector
);
// Checks if this is a current rev of talk page and we should show a new
$content_navigation['views']['addsection'] = array(
'class' => $section == 'new' ? 'selected' : false,
'text' => wfMessageFallback( "$skname-action-addsection", 'addsection' )->plain(),
- 'href' => $this->mTitle->getLocalURL( 'action=edit§ion=new' )
+ 'href' => $title->getLocalURL( 'action=edit§ion=new' )
);
}
}
// Checks if the page has some kind of viewable content
- } elseif ( $this->mTitle->hasSourceText() && $userCanRead ) {
+ } elseif ( $title->hasSourceText() && $userCanRead ) {
// Adds view source view link
$content_navigation['views']['viewsource'] = array(
- 'class' => ( $action == 'edit' ) ? 'selected' : false,
+ 'class' => ( $onPage && $action == 'edit' ) ? 'selected' : false,
'text' => wfMessageFallback( "$skname-action-viewsource", 'viewsource' )->plain(),
- 'href' => $this->mTitle->getLocalURL( $this->editUrlOptions() ),
+ 'href' => $title->getLocalURL( $this->editUrlOptions() ),
'primary' => true, // don't collapse this in vector
);
}
wfProfileIn( __METHOD__ . '-live' );
// Checks if the page exists
- if ( $this->mTitle->exists() && $userCanRead ) {
+ if ( $title->exists() && $userCanRead ) {
// Adds history view link
$content_navigation['views']['history'] = array(
- 'class' => ( $action == 'history' ) ? 'selected' : false,
+ 'class' => ( $onPage && $action == 'history' ) ? 'selected' : false,
'text' => wfMessageFallback( "$skname-view-history", 'history_short' )->plain(),
- 'href' => $this->mTitle->getLocalURL( 'action=history' ),
+ 'href' => $title->getLocalURL( 'action=history' ),
'rel' => 'archives',
);
if( $wgUser->isAllowed( 'delete' ) ) {
$content_navigation['actions']['delete'] = array(
- 'class' => ( $action == 'delete' ) ? 'selected' : false,
+ 'class' => ( $onPage && $action == 'delete' ) ? 'selected' : false,
'text' => wfMessageFallback( "$skname-action-delete", 'delete' )->plain(),
- 'href' => $this->mTitle->getLocalURL( 'action=delete' )
+ 'href' => $title->getLocalURL( 'action=delete' )
);
}
- if ( $this->mTitle->quickUserCan( 'move' ) ) {
- $moveTitle = SpecialPage::getTitleFor( 'Movepage', $this->thispage );
+ if ( $title->quickUserCan( 'move' ) ) {
+ $moveTitle = SpecialPage::getTitleFor( 'Movepage', $title->getPrefixedDBkey() );
$content_navigation['actions']['move'] = array(
'class' => $this->mTitle->isSpecial( 'Movepage' ) ? 'selected' : false,
'text' => wfMessageFallback( "$skname-action-move", 'move' )->plain(),
);
}
- if ( $this->mTitle->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed( 'protect' ) ) {
- $mode = !$this->mTitle->isProtected() ? 'protect' : 'unprotect';
+ if ( $title->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed( 'protect' ) ) {
+ $mode = !$title->isProtected() ? 'protect' : 'unprotect';
$content_navigation['actions'][$mode] = array(
- 'class' => ( $action == $mode ) ? 'selected' : false,
+ 'class' => ( $onPage && $action == $mode ) ? 'selected' : false,
'text' => wfMessageFallback( "$skname-action-$mode", $mode )->plain(),
- 'href' => $this->mTitle->getLocalURL( "action=$mode" )
+ 'href' => $title->getLocalURL( "action=$mode" )
);
}
} else {
// article doesn't exist or is deleted
if ( $wgUser->isAllowed( 'deletedhistory' ) ) {
- $n = $this->mTitle->isDeleted();
+ $n = $title->isDeleted();
if( $n ) {
$undelTitle = SpecialPage::getTitleFor( 'Undelete' );
// If the user can't undelete but can view deleted history show them a "View .. deleted" tab instead
$msgKey = $wgUser->isAllowed( 'undelete' ) ? 'undelete' : 'viewdeleted';
$content_navigation['actions']['undelete'] = array(
- 'class' => false,
+ 'class' => $this->mTitle->isSpecial( 'Undelete' ) ? 'selected' : false,
'text' => wfMessageFallback( "$skname-action-$msgKey", "{$msgKey}_short" )
->params( $wgLang->formatNum( $n ) )->text(),
- 'href' => $undelTitle->getLocalURL( array( 'target' => $this->thispage ) )
+ 'href' => $undelTitle->getLocalURL( array( 'target' => $title->getPrefixedDBkey() ) )
);
}
}
- if ( $this->mTitle->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed( 'protect' ) ) {
- $mode = !$this->mTitle->getRestrictions( 'create' ) ? 'protect' : 'unprotect';
+ if ( $title->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed( 'protect' ) ) {
+ $mode = !$title->getRestrictions( 'create' ) ? 'protect' : 'unprotect';
$content_navigation['actions'][$mode] = array(
- 'class' => ( $action == $mode ) ? 'selected' : false,
+ 'class' => ( $onPage && $action == $mode ) ? 'selected' : false,
'text' => wfMessageFallback( "$skname-action-$mode", $mode )->plain(),
- 'href' => $this->mTitle->getLocalURL( "action=$mode" )
+ 'href' => $title->getLocalURL( "action=$mode" )
);
}
}
* a change to that procedure these messages will have to remain as
* the global versions.
*/
- $mode = $this->mTitle->userIsWatching() ? 'unwatch' : 'watch';
+ $mode = $title->userIsWatching() ? 'unwatch' : 'watch';
$content_navigation['actions'][$mode] = array(
- 'class' => ( $action == 'watch' || $action == 'unwatch' ) ? 'selected' : false,
+ 'class' => $onPage && ( $action == 'watch' || $action == 'unwatch' ) ? 'selected' : false,
'text' => wfMsg( $mode ), // uses 'watch' or 'unwatch' message
- 'href' => $this->mTitle->getLocalURL( 'action=' . $mode )
+ 'href' => $title->getLocalURL( 'action=' . $mode )
);
}
$content_navigation['variants'][] = array(
'class' => ( $code == $preferred ) ? 'selected' : false,
'text' => $varname,
- 'href' => $this->mTitle->getLocalURL( '', $code )
+ 'href' => $title->getLocalURL( '', $code )
);
}
}
);
}
- if( $this->mTitle->getNamespace() == NS_USER || $this->mTitle->getNamespace() == NS_USER_TALK ) {
- $rootUser = strtok( $this->mTitle->getText(), '/' );
- $id = User::idFromName( $rootUser );
- $ip = User::isIP( $rootUser );
+ if ( $user = $this->getRelevantUser() ) {
+ $id = $user->getID();
+ $ip = $user->isAnon();
+ $rootUser = $user->getName();
} else {
$id = 0;
$ip = false;