* @ingroup Skins
*/
abstract class Skin {
- /**#@+
- * @private
- */
- var $mWatchLinkNum = 0; // Appended to end of watch link id's
- /**#@-*/
- protected $mRevisionId; // The revision ID we're looking at, null if not applicable.
protected $skinname = 'standard';
protected $mRelevantTitle = null;
protected $mRelevantUser = null;
$className = "Skin{$skinName}";
# Grab the skin class and initialise it.
- if ( !class_exists( $className ) ) {
- // Preload base classes to work around APC/PHP5 bug
- $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
+ if ( !MWInit::classExists( $className ) ) {
- if ( file_exists( $deps ) ) {
- include_once( $deps );
+ if ( !defined( 'MW_COMPILED' ) ) {
+ // Preload base classes to work around APC/PHP5 bug
+ $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
+ if ( file_exists( $deps ) ) {
+ include_once( $deps );
+ }
+ require_once( "{$wgStyleDirectory}/{$skinName}.php" );
}
- require_once( "{$wgStyleDirectory}/{$skinName}.php" );
# Check if we got if not failback to default skin
- if ( !class_exists( $className ) ) {
+ if ( !MWInit::classExists( $className ) ) {
# DO NOT die if the class isn't found. This breaks maintenance
# scripts and can cause a user account to be unrecoverable
# except by SQL manipulation if a previously valid skin name
# is no longer valid.
wfDebug( "Skin class does not exist: $className\n" );
$className = 'SkinVector';
- require_once( "{$wgStyleDirectory}/Vector.php" );
+ if ( !defined( 'MW_COMPILED' ) ) {
+ require_once( "{$wgStyleDirectory}/Vector.php" );
+ }
}
}
$skin = new $className;
function initPage( OutputPage $out ) {
wfProfileIn( __METHOD__ );
- $this->mRevisionId = $out->mRevisionId;
$this->preloadExistence();
$this->setMembers();
*/
protected function setMembers() {
$this->userpage = $this->getContext()->getUser()->getUserPage()->getPrefixedText();
- $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->getTitle()->getLatestRevID();
}
/**
return $this->getContext()->getUser();
}
+ /**
+ * Get the current revision ID
+ *
+ * @return Integer
+ */
+ public function getRevisionId() {
+ return $this->getContext()->getOutput()->getRevisionId();
+ }
+
+ /**
+ * Whether the revision displayed is the latest revision of the page
+ *
+ * @return Boolean
+ */
+ public function isRevisionCurrent() {
+ $revID = $this->getRevisionId();
+ return $revID == 0 || $revID == $this->getTitle()->getLatestRevID();
+ }
+
/**
* Set the "relevant" title
* @see self::getRelevantTitle()
* 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.
+ * @return User
*/
public function getRelevantUser() {
if ( isset($this->mRelevantUser) ) {
/**
* Generated JavaScript action=raw&gen=js
- * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
- * nated together. For some bizarre reason, it does *not* return any
- * custom user JS from subpages. Huh?
- *
- * There's absolutely no reason to have separate Monobook/Common JSes.
- * Any JS that cares can just check the skin variable generated at the
- * top. For now Monobook.js will be maintained, but it should be consi-
- * dered deprecated.
+ * This used to load MediaWiki:Common.js and the skin-specific style
+ * before the ResourceLoader.
*
+ * @deprecated since 1.18 Use the ResourceLoader instead. This may be removed at some
+ * point.
* @param $skinName String: If set, overrides the skin name
- * @return string
+ * @return String
*/
public function generateUserJs( $skinName = null ) {
-
- // Stub - see ResourceLoaderSiteModule, CologneBlue, Simple and Standard skins override this
-
return '';
}
/**
* Generate user stylesheet for action=raw&gen=css
+ *
+ * @deprecated since 1.18 Use the ResourceLoader instead. This may be removed at some
+ * point.
+ * @return String
*/
public function generateUserStylesheet() {
-
- // Stub - see ResourceLoaderUserModule, CologneBlue, Simple and Standard skins override this
-
- return '';
- }
-
- /**
- * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
- * Anything in here won't be generated if $wgAllowUserCssPrefs is false.
- */
- protected function reallyGenerateUserStylesheet() {
-
- // Stub - see ResourceLoaderUserModule, CologneBlue, Simple and Standard skins override this
-
return '';
}
// Per-user custom styles
if ( $wgAllowUserCss ) {
if ( $this->getTitle()->isCssSubpage() && $this->userCanPreview( $this->getContext()->getRequest()->getVal( 'action' ) ) ) {
- // @FIXME: properly escape the cdata!
+ // @todo FIXME: Properly escape the cdata!
$out->addInlineStyle( $this->getContext()->getRequest()->getText( 'wpTextbox1' ) );
} else {
$out->addModuleStyles( 'user' );
/**
* Add skin specific stylesheets
+ * Calling this method with an $out of anything but the same OutputPage
+ * inside ->getContext()->getOutput() is deprecated. The $out arg is kept
+ * for compatibility purposes with skins.
* @param $out OutputPage
* @delete
*/
abstract function setupSkinUserCss( OutputPage $out );
+ /**
+ * TODO: document
+ * @param $title Title
+ * @return String
+ */
function getPageClasses( $title ) {
$numeric = 'ns-' . $title->getNamespace();
if ( $title->getNamespace() == NS_SPECIAL ) {
$type = 'ns-special';
// bug 23315: provide a class based on the canonical special page name without subpages
- list( $canonicalName ) = SpecialPage::resolveAliasWithSubpage( $title->getDBkey() );
+ list( $canonicalName ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
if ( $canonicalName ) {
$type .= ' ' . Sanitizer::escapeClass( "mw-special-$canonicalName" );
} else {
return $wgLogo;
}
- /**
- * The format without an explicit $out argument is deprecated
- */
- function getCategoryLinks( OutputPage $out=null ) {
+ function getCategoryLinks() {
global $wgUseCategoryBrowser, $wgContLang;
+ $out = $this->getContext()->output;
+
if ( count( $out->mCategoryLinks ) == 0 ) {
return '';
}
$msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
$s .= '<div id="mw-normal-catlinks">' .
- $this->link( Title::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
+ Linker::link( Title::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
. $colon . $t . '</div>';
}
/**
* Render the array as a serie of links.
* @param $tree Array: categories tree returned by Title::getParentCategoryTree
- * @param &skin Object: skin passed by reference
* @return String separated by >, terminate with "\n"
*/
- function drawCategoryBrowser( $tree, &$skin ) {
+ function drawCategoryBrowser( $tree ) {
$return = '';
foreach ( $tree as $element => $parent ) {
$return .= "\n";
} else {
# grab the others elements
- $return .= $this->drawCategoryBrowser( $parent, $skin ) . ' > ';
+ $return .= $this->drawCategoryBrowser( $parent ) . ' > ';
}
# add our current element to the list
$eltitle = Title::newFromText( $element );
- $return .= $skin->link( $eltitle, $eltitle->getText() );
+ $return .= Linker::link( $eltitle, $eltitle->getText() );
}
return $return;
}
- /**
- * The ->getCategories() form is deprecated, please instead use
- * the ->getCategories( $out ) form with whatout OutputPage is on hand
- */
- function getCategories( OutputPage $out=null ) {
+ function getCategories() {
+ $out = $this->getContext()->output;
- $catlinks = $this->getCategoryLinks( $out );
+ $catlinks = $this->getCategoryLinks();
$classes = 'catlinks';
* area.
* @return String HTML containing debug data, if enabled (otherwise empty).
*/
- protected function generateDebugHTML( OutputPage $out ) {
+ protected function generateDebugHTML() {
global $wgShowDebug;
if ( $wgShowDebug ) {
- $listInternals = $this->formatDebugHTML( $out->mDebugtext );
+ $listInternals = $this->formatDebugHTML( $this->getContext()->getOutput()->mDebugtext );
return "\n<hr />\n<strong>Debug data:</strong><ul id=\"mw-debug-html\">" .
$listInternals . "</ul>\n";
}
* @return String HTML-wrapped JS code to be put before </body>
*/
function bottomScripts( $out ) {
- $bottomScriptText = "\n" . $out->getHeadScripts( $this );
+ // TODO and the suckage continues. This function is really just a wrapper around
+ // OutputPage::getBottomScripts() which takes a Skin param. This should be cleaned
+ // up at some point
+ $bottomScriptText = $out->getBottomScripts( $this );
wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
return $bottomScriptText;
return wfMsg(
$msg,
- $this->link(
+ Linker::link(
SpecialPage::getTitleFor( 'Undelete', $this->getTitle()->getPrefixedDBkey() ),
wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $this->getContext()->getLang()->formatNum( $n ) ),
array(),
return '';
}
- /**
- * The format without an explicit $out argument is deprecated
- */
- function subPageSubtitle( OutputPage $out=null ) {
+ function subPageSubtitle() {
$out = $this->getContext()->getOutput();
$subpages = '';
if ( $wgRightsPage ) {
$title = Title::newFromText( $wgRightsPage );
- $link = $this->linkKnown( $title, $wgRightsText );
+ $link = Linker::linkKnown( $title, $wgRightsText );
} elseif ( $wgRightsUrl ) {
- $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
+ $link = Linker::makeExternalLink( $wgRightsUrl, $wgRightsText );
} elseif ( $wgRightsText ) {
$link = $wgRightsText;
} else {
*/
protected function lastModified( $article ) {
if ( !$this->isRevisionCurrent() ) {
- $timestamp = Revision::getTimestampFromId( $this->getTitle(), $this->mRevisionId );
+ $timestamp = Revision::getTimestampFromId( $this->getTitle(), $this->getRevisionId() );
} else {
$timestamp = $article->getTimestamp();
}
* @return string
*/
function mainPageLink() {
- $s = $this->link(
+ $s = Linker::link(
Title::newMainPage(),
wfMsg( 'mainpage' ),
array(),
// but we make the link target be the one site-wide page.
$title = Title::newFromText( wfMsgForContent( $page ) );
- return $this->linkKnown(
+ return Linker::linkKnown(
$title,
wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) )
);
$options = array( 'action' => 'edit' );
if ( !$this->isRevisionCurrent() ) {
- $options['oldid'] = intval( $this->mRevisionId );
+ $options['oldid'] = intval( $this->getRevisionId() );
}
return $options;
}
static function makeSpecialUrl( $name, $urlaction = '' ) {
- $title = SpecialPage::getTitleFor( $name );
+ $title = SpecialPage::getSafeTitleFor( $name );
return $title->getLocalURL( $urlaction );
}
if ( strpos( $line, '|' ) !== false ) { // sanity check
$line = MessageCache::singleton()->transform( $line, false, null, $this->getTitle() );
$line = array_map( 'trim', explode( '|', $line, 2 ) );
- $link = wfMsgForContent( $line[0] );
- if ( $link == '-' ) {
- continue;
+ $msgLink = wfMessage( $line[0] )->inContentLanguage();
+ if ( $msgLink->exists() ) {
+ $link = $msgLink->text();
+ if ( $link == '-' ) {
+ continue;
+ }
+ } else {
+ $link = $line[0];
}
- $text = wfMsgExt( $line[1], 'parsemag' );
-
- if ( wfEmptyMsg( $line[1] ) ) {
+ $msgText = wfMessage( $line[1] );
+ if ( $msgText->exists() ) {
+ $text = $msgText->text();
+ } else {
$text = $line[1];
}
- if ( wfEmptyMsg( $line[0] ) ) {
- $link = $line[0];
- }
-
if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
$href = $link;
} else {
if ( !is_null( $tooltip ) ) {
# Bug 25462: undo double-escaping.
$tooltip = Sanitizer::decodeCharReferences( $tooltip );
- $attribs['title'] = wfMsgReal( 'editsectionhint', array( $tooltip ), true, $lang );
+ $attribs['title'] = wfMsgExt( 'editsectionhint', array( 'language' => $lang, 'parsemag' ), $tooltip );
}
$link = Linker::link( $nt, wfMsgExt( 'editsection', array( 'language' => $lang ) ),
$attribs,
# we can rid of it someday.
$attribs = '';
if ( $tooltip ) {
- $attribs = htmlspecialchars( wfMsgReal( 'editsectionhint', array( $tooltip ), true, $lang ) );
+ $attribs = wfMsgExt( 'editsectionhint', array( 'language' => $lang, 'parsemag', 'escape' ), $tooltip );
$attribs = " title=\"$attribs\"";
}
$result = null;