protected $skinname = 'standard';
// @todo Fixme: should be protected :-\
var $mTitle = null;
+ protected $mRelevantTitle = null;
+ protected $mRelevantUser = null;
/** Constructor, call parent constructor */
function __construct() {
global $wgValidSkinNames;
static $skinsInitialised = false;
- if ( !$skinsInitialised ) {
+ if ( !$skinsInitialised || !count( $wgValidSkinNames ) ) {
# Get a list of available skins
# Build using the regular expression '^(.*).php$'
# Array keys are all lower case, array value keep the case used by filename
$skinNames = Skin::getSkinNames();
$skinName = $skinNames[$key];
- $className = 'Skin' . ucfirst( $key );
+ $className = "Skin{$skinName}";
# Grab the skin class and initialise it.
if ( !class_exists( $className ) ) {
$this->usercss = false;
}
+ /**
+ * Whether the revision displayed is the latest revision of the page
+ *
+ * @return Boolean
+ */
+ public function isRevisionCurrent() {
+ return $this->mRevisionId == 0 || $this->mRevisionId == $this->mTitle->getLatestRevID();
+ }
+
/**
* Set the title
* @param $t Title object to use
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
$out->out( $out->headElement( $this ) );
if ( $wgDebugComments ) {
- $out->out( "<!-- Wiki debugging output:\n" .
+ $out->out( "<!-- Debug output:\n" .
$out->mDebugtext . "-->\n" );
}
* You will only be adding bloat to the page and causing page caches to have to be purged on configuration changes.
*/
static function makeGlobalVariablesScript( $skinName ) {
- global $wgTitle, $wgUser, $wgRequest, $wgArticle, $wgOut, $wgRestrictionTypes, $wgUseAjax, $wgEnableMWSuggest;
+ global $wgTitle, $wgUser, $wgRequest, $wgOut, $wgUseAjax, $wgEnableMWSuggest;
$ns = $wgTitle->getNamespace();
$nsname = MWNamespace::exists( $ns ) ? MWNamespace::getCanonicalName( $ns ) : $wgTitle->getNsText();
'wgIsArticle' => $wgOut->isArticle(),
'wgUserName' => $wgUser->isAnon() ? null : $wgUser->getName(),
'wgUserGroups' => $wgUser->getEffectiveGroups(),
- 'wgCurRevisionId' => isset( $wgArticle ) ? $wgArticle->getLatest() : 0,
+ 'wgCurRevisionId' => $wgTitle->getLatestRevID(),
'wgCategories' => $wgOut->getCategories(),
+ 'wgBreakFrames' => $wgOut->getFrameOptions() == 'DENY',
);
- foreach ( $wgRestrictionTypes as $type ) {
+ foreach ( $wgTitle->getRestrictionTypes() as $type ) {
$vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
}
if ( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ) {
global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
- $oldid = $wgRequest->getVal( 'oldid' );
- $diff = $wgRequest->getVal( 'diff' );
-
- if ( !$wgOut->isArticle() ) {
+ if ( !is_null( $wgRequest->getVal( 'oldid' ) ) || !is_null( $wgRequest->getVal( 'diff' ) ) ) {
return '';
}
- if ( !$wgArticle instanceof Article ) {
- return '';
- }
-
- if ( isset( $oldid ) || isset( $diff ) ) {
- return '';
- }
-
- if ( 0 == $wgArticle->getID() ) {
+ if ( !$wgOut->isArticle() || !$this->mTitle->exists() ) {
return '';
}
}
function getCopyright( $type = 'detect' ) {
- global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest, $wgArticle;
+ global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
if ( $type == 'detect' ) {
$diff = $wgRequest->getVal( 'diff' );
- $isCur = $wgArticle && $wgArticle->isCurrent();
- if ( is_null( $diff ) && !$isCur && wfMsgForContent( 'history_copyright' ) !== '-' ) {
+ if ( is_null( $diff ) && !$this->isRevisionCurrent() && wfMsgForContent( 'history_copyright' ) !== '-' ) {
$type = 'history';
} else {
$type = 'normal';
// Allow for site and per-namespace customization of copyright notice.
$forContent = true;
- if ( isset( $wgArticle ) ) {
- wfRunHooks( 'SkinCopyrightFooter', array( $wgArticle->getTitle(), $type, &$msg, &$link, &$forContent ) );
- }
+ wfRunHooks( 'SkinCopyrightFooter', array( $this->mTitle, $type, &$msg, &$link, &$forContent ) );
if ( $forContent ) {
$out .= wfMsgForContent( $msg, $link );
function lastModified() {
global $wgLang, $wgArticle;
- if ( $this->mRevisionId && $this->mRevisionId != $wgArticle->getLatest() ) {
- $timestamp = Revision::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId );
+ if ( !$this->isRevisionCurrent() ) {
+ $timestamp = Revision::getTimestampFromId( $this->mTitle, $this->mRevisionId );
} else {
$timestamp = $wgArticle->getTimestamp();
}
return $s;
}
- private function footerLink( $desc, $page ) {
+ public function footerLink( $desc, $page ) {
// if the link description has been set to "-" in the default language,
if ( wfMsgForContent( $desc ) == '-' ) {
// then it is disabled, for all languages.
* @private
*/
function editUrlOptions() {
- global $wgArticle;
-
$options = array( 'action' => 'edit' );
- if ( $this->mRevisionId && ! $wgArticle->isCurrent() ) {
+ if ( !$this->isRevisionCurrent() ) {
$options['oldid'] = intval( $this->mRevisionId );
}
* Return a fully resolved style path url to images or styles stored in the common folder.
* This method returns a url resolved using the configured skin style path
* and includes the style version inside of the url.
- * @param $name String: The name or path of the common file to return the full path for.
+ * @param $name String: The name or path of a skin resource file
* @return String The fully resolved style path url including styleversion
*/
function getCommonStylePath( $name ) {
global $wgStylePath, $wgStyleVersion;
- return "{$wgStylePath}/common/$name?{$wgStyleVersion}";
+ return "$wgStylePath/common/$name?$wgStyleVersion";
}
/**
* Return a fully resolved style path url to images or styles stored in the curent skins's folder.
* This method returns a url resolved using the configured skin style path
* and includes the style version inside of the url.
- * @param $name String: The name or path of the skin resource file to return the full path for.
+ * @param $name String: The name or path of a skin resource file
* @return String The fully resolved style path url including styleversion
*/
function getSkinStylePath( $name ) {
global $wgStylePath, $wgStyleVersion;
- return "{$wgStylePath}/{$this->stylename}/$name?{$wgStyleVersion}";
+ return "$wgStylePath/{$this->stylename}/$name?$wgStyleVersion";
}
/* these are used extensively in SkinTemplate, but also some other places */