}
}
}
- $skin = new $className;
+ $skin = new $className( $key );
return $skin;
}
- /** @return string path to the skin stylesheet */
- function getStylesheet() {
- return 'common/wikistandard.css';
- }
-
/** @return string skin name */
public function getSkinName() {
return $this->skinname;
wfProfileIn( __METHOD__ );
$this->preloadExistence();
- $this->setMembers();
wfProfileOut( __METHOD__ );
}
$lb->execute();
}
- /**
- * Set some local variables
- */
- protected function setMembers() {
- $this->userpage = $this->getUser()->getUserPage()->getPrefixedText();
- }
-
/**
* Get the current revision ID
*
* Outputs the HTML generated by other functions.
* @param $out OutputPage
*/
- abstract function outputPage( OutputPage $out );
+ abstract function outputPage( OutputPage $out = null );
static function makeVariablesScript( $data ) {
if ( $data ) {
}
}
- /**
- * To make it harder for someone to slip a user a fake
- * user-JavaScript or user-CSS preview, a random token
- * is associated with the login session. If it's not
- * passed back with the preview request, we won't render
- * the code.
- *
- * @return bool
- */
- public function userCanPreview() {
- if ( $this->getRequest()->getVal( 'action' ) != 'submit'
- || !$this->getRequest()->wasPosted()
- || !$this->getUser()->matchEditToken(
- $this->getRequest()->getVal( 'wpEditToken' ) )
- ) {
- return false;
- }
- if ( !$this->getTitle()->isJsSubpage() && !$this->getTitle()->isCssSubpage() ) {
- return false;
- }
-
- return !count( $this->getTitle()->getUserPermissionsErrors( 'edit', $this->getUser() ) );
- }
-
/**
* Generated JavaScript action=raw&gen=js
* This used to load MediaWiki:Common.js and the skin-specific style
return '';
}
- /**
- * @private
- * @todo document
- * @param $out OutputPage
- */
- function setupUserCss( OutputPage $out ) {
- global $wgUseSiteCss, $wgAllowUserCss, $wgAllowUserCssPrefs;
-
- wfProfileIn( __METHOD__ );
-
- $this->setupSkinUserCss( $out );
- // Add any extension CSS
- foreach ( $out->getExtStyle() as $url ) {
- $out->addStyle( $url );
- }
-
- // Per-site custom styles
- if ( $wgUseSiteCss ) {
- $out->addModuleStyles( array( 'site', 'noscript' ) );
- if( $this->getUser()->isLoggedIn() ){
- $out->addModuleStyles( 'user.groups' );
- }
- }
-
- // Per-user custom styles
- if ( $wgAllowUserCss ) {
- if ( $this->getTitle()->isCssSubpage() && $this->userCanPreview() ) {
- // @todo FIXME: Properly escape the cdata!
- $out->addInlineStyle( $this->getRequest()->getText( 'wpTextbox1' ) );
- } else {
- $out->addModuleStyles( 'user' );
- }
- }
-
- // Per-user preference styles
- if ( $wgAllowUserCssPrefs ) {
- $out->addModuleStyles( 'user.options' );
- }
-
- wfProfileOut( __METHOD__ );
- }
-
/**
* Get the query to generate a dynamic stylesheet
*
* @return String
*/
function getPageClasses( $title ) {
- global $wgRequest;
$numeric = 'ns-' . $title->getNamespace();
if ( $title->getNamespace() == NS_SPECIAL ) {
}
$name = Sanitizer::escapeClass( 'page-' . $title->getPrefixedText() );
-
- if ( $wgRequest->getVal('action') ) {
- $action = 'action-' . $wgRequest->getVal('action');
- } else {
- $action = 'action-view';
- }
- return "$numeric $type $name $action";
+
+ return "$numeric $type $name";
}
/**
global $wgUseCategoryBrowser;
$out = $this->getOutput();
+ $allCats = $out->getCategoryLinks();
- if ( count( $out->mCategoryLinks ) == 0 ) {
+ if ( !count( $allCats ) ) {
return '';
}
$embed = "<li>";
$pop = "</li>";
- $allCats = $out->getCategoryLinks();
$s = '';
$colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
$t = $embed . implode( "{$pop}{$embed}" , $allCats['normal'] ) . $pop;
$msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
- $s .= '<div id="mw-normal-catlinks">' .
+ $s .= '<div id="mw-normal-catlinks" class="mw-normal-catlinks">' .
Linker::link( Title::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
. $colon . '<ul>' . $t . '</ul>' . '</div>';
}
# Hidden categories
if ( isset( $allCats['hidden'] ) ) {
if ( $this->getUser()->getBoolOption( 'showhiddencats' ) ) {
- $class = 'mw-hidden-cats-user-shown';
+ $class = ' mw-hidden-cats-user-shown';
} elseif ( $this->getTitle()->getNamespace() == NS_CATEGORY ) {
- $class = 'mw-hidden-cats-ns-shown';
+ $class = ' mw-hidden-cats-ns-shown';
} else {
- $class = 'mw-hidden-cats-hidden';
+ $class = ' mw-hidden-cats-hidden';
}
- $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
+ $s .= "<div id=\"mw-hidden-catlinks\" class=\"mw-hidden-catlinks$class\">" .
wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
$colon . '<ul>' . $embed . implode( "{$pop}{$embed}" , $allCats['hidden'] ) . $pop . '</ul>' .
'</div>';
# add our current element to the list
$eltitle = Title::newFromText( $element );
- $return .= Linker::link( $eltitle, $eltitle->getText() );
+ $return .= Linker::link( $eltitle, htmlspecialchars( $eltitle->getText() ) );
}
return $return;
/**
* This gets called shortly before the </body> tag.
- * @param $out OutputPage object
+ *
* @return String HTML-wrapped JS code to be put before </body>
*/
- function bottomScripts( $out ) {
+ function bottomScripts() {
// 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 );
+ $bottomScriptText = $this->getOutput()->getBottomScripts();
wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
return $bottomScriptText;
}
- /** @return string Retrievied from HTML text */
+ /**
+ * Text with the permalink to the source page,
+ * usually shown on the footer of a printed page
+ *
+ * @return string HTML text with an URL
+ */
function printSource() {
- $url = htmlspecialchars( $this->getTitle()->getFullURL() );
+ $oldid = $this->getRevisionId();
+ if ( $oldid ) {
+ $url = htmlspecialchars( $this->getTitle()->getCanonicalURL( 'oldid=' . $oldid ) );
+ } else {
+ // oldid not available for non existing pages
+ $url = htmlspecialchars( $this->getTitle()->getCanonicalURL() );
+ }
return wfMsg( 'retrievedfrom', '<a href="' . $url . '">' . $url . '</a>' );
}
function getUndeleteLink() {
$action = $this->getRequest()->getVal( 'action', 'view' );
- if ( $this->getUser()->isAllowed( 'deletedhistory' ) &&
+ if ( $this->getUser()->isAllowed( 'deletedhistory' ) && !$this->getUser()->isBlocked() &&
( $this->getTitle()->getArticleId() == 0 || $action == 'history' ) ) {
+ $n = $this->getTitle()->isDeleted();
- $includeSuppressed = $this->getUser()->isAllowed( 'suppressrevision' );
- $n = $this->getTitle()->isDeleted( $includeSuppressed );
if ( $n ) {
if ( $this->getUser()->isAllowed( 'undelete' ) ) {
return wfMsg(
$msg,
- Linker::link(
+ Linker::linkKnown(
SpecialPage::getTitleFor( 'Undelete', $this->getTitle()->getPrefixedDBkey() ),
- wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $this->getLang()->formatNum( $n ) ),
- array(),
- array(),
- array( 'known', 'noclasses' )
+ wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $this->getLang()->formatNum( $n ) )
)
);
}
$linkObj = Title::newFromText( $growinglink );
if ( is_object( $linkObj ) && $linkObj->exists() ) {
- $getlink = $this->link(
+ $getlink = Linker::linkKnown(
$linkObj,
- htmlspecialchars( $display ),
- array(),
- array(),
- array( 'known', 'noclasses' )
+ htmlspecialchars( $display )
);
$c++;
global $wgRightsPage, $wgRightsUrl, $wgRightsText;
if ( $type == 'detect' ) {
- $diff = $this->getRequest()->getVal( 'diff' );
-
- if ( is_null( $diff ) && !$this->isRevisionCurrent() && wfMsgForContent( 'history_copyright' ) !== '-' ) {
+ if ( !$this->isRevisionCurrent() && wfMsgForContent( 'history_copyright' ) !== '-' ) {
$type = 'history';
} else {
$type = 'normal';
$msg = 'copyright';
}
- $out = '';
-
if ( $wgRightsPage ) {
$title = Title::newFromText( $wgRightsPage );
$link = Linker::linkKnown( $title, $wgRightsText );
$link = $wgRightsText;
} else {
# Give up now
- return $out;
+ return '';
}
// Allow for site and per-namespace customization of copyright notice.
wfRunHooks( 'SkinCopyrightFooter', array( $this->getTitle(), $type, &$msg, &$link, &$forContent ) );
if ( $forContent ) {
- $out .= wfMsgForContent( $msg, $link );
+ return wfMsgForContent( $msg, $link );
} else {
- $out .= wfMsg( $msg, $link );
+ return wfMsg( $msg, $link );
}
-
- return $out;
}
function getCopyrightIcon() {
$a = '';
}
- $mp = wfMsg( 'mainpage' );
+ $mp = wfMsgHtml( 'mainpage' );
$mptitle = Title::newMainPage();
$url = ( is_object( $mptitle ) ? $mptitle->escapeLocalURL() : '' );
* @return string
*/
function mainPageLink() {
- $s = Linker::link(
+ $s = Linker::linkKnown(
Title::newMainPage(),
- wfMsg( 'mainpage' ),
- array(),
- array(),
- array( 'known', 'noclasses' )
+ wfMsgHtml( 'mainpage' )
);
return $s;
*/
function addToSidebarPlain( &$bar, $text ) {
$lines = explode( "\n", $text );
- $wikiBar = array(); # We need to handle the wikitext on a different variable, to avoid trying to do an array operation on text, which would be a fatal error.
$heading = '';
if ( strpos( $line, '*' ) !== 0 ) {
continue;
}
+ $line = rtrim( $line, "\r" ); // for Windows compat
if ( strpos( $line, '**' ) !== 0 ) {
$heading = trim( $line, '* ' );
if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
$href = $link;
- //Parser::getExternalLinkAttribs won't work here because of the Namespace things
- global $wgNoFollowLinks;
- if ( $wgNoFollowLinks ) {
+
+ // Parser::getExternalLinkAttribs won't work here because of the Namespace things
+ global $wgNoFollowLinks, $wgNoFollowDomainExceptions;
+ if ( $wgNoFollowLinks && !wfMatchesDomainList( $href, $wgNoFollowDomainExceptions ) ) {
$extraAttribs['rel'] = 'nofollow';
-
- global $wgNoFollowDomainExceptions;
- if ( $wgNoFollowDomainExceptions ) {
- $bits = wfParseUrl( $url );
- if ( is_array( $bits ) && isset( $bits['host'] ) ) {
- foreach ( $wgNoFollowDomainExceptions as $domain ) {
- if ( substr( $bits['host'], -strlen( $domain ) ) == $domain ) {
- unset( $extraAttribs['rel'] );
- break;
- }
- }
- }
- }
}
+
global $wgExternalLinkTarget;
if ( $wgExternalLinkTarget) {
$extraAttribs['target'] = $wgExternalLinkTarget;
if ( $title ) {
$title = $title->fixSpecialName();
- $href = $title->getLocalURL();
+ $href = $title->getLinkURL();
} else {
$href = 'INVALID-TITLE';
}
'id' => 'n-' . Sanitizer::escapeId( strtr( $line[1], ' ', '-' ), 'noninitial' ),
'active' => false
), $extraAttribs );
- } elseif ( ( substr( $line, 0, 2 ) == '{{' ) && ( substr( $line, -2 ) == '}}' ) ) {
- global $wgParser;
-
- $line = substr( $line, 2, strlen( $line ) - 4 );
-
- $options = new ParserOptions();
- $options->setEditSection( false );
- $options->setInterfaceMessage( true );
- $wikiBar[$heading] = $wgParser->parse( wfMsgForContentNoTrans( $line ) , $this->getTitle(), $options )->getText();
} else {
continue;
}
}
}
- if ( count( $wikiBar ) > 0 ) {
- $bar = array_merge( $bar, $wikiBar );
- }
-
return $bar;
}
$userTalkTitle = $userTitle->getTalkPage();
if ( !$userTalkTitle->equals( $out->getTitle() ) ) {
- $newMessagesLink = $this->link(
+ $newMessagesLink = Linker::linkKnown(
$userTalkTitle,
wfMsgHtml( 'newmessageslink' ),
array(),
- array( 'redirect' => 'no' ),
- array( 'known', 'noclasses' )
+ array( 'redirect' => 'no' )
);
- $newMessagesDiffLink = $this->link(
+ $newMessagesDiffLink = Linker::linkKnown(
$userTalkTitle,
wfMsgHtml( 'newmessagesdifflink' ),
array(),
- array( 'diff' => 'cur' ),
- array( 'known', 'noclasses' )
+ array( 'diff' => 'cur' )
);
$ntl = wfMsg(