X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSkin.php;h=9ecb6150b38cf4712173b4e0a2f4a73e276f4b7c;hb=5ccc792805398296ef91184cf729c231685132bb;hp=20ba348052c3a929b82580f872c057b2f212f95d;hpb=c56bc576d694e18ed202232c6c4fbdf551b6f432;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Skin.php b/includes/Skin.php index 20ba348052..9ecb6150b3 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -15,7 +15,7 @@ if ( !defined( 'MEDIAWIKI' ) ) { * * @ingroup Skins */ -abstract class Skin { +abstract class Skin extends ContextSource { protected $skinname = 'standard'; protected $mRelevantTitle = null; protected $mRelevantUser = null; @@ -156,25 +156,22 @@ abstract class Skin { } } } - $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; } + /** + * @param $out OutputPage + */ function initPage( OutputPage $out ) { wfProfileIn( __METHOD__ ); $this->preloadExistence(); - $this->setMembers(); wfProfileOut( __METHOD__ ); } @@ -183,13 +180,13 @@ abstract class Skin { * Preload the existence of three commonly-requested pages in a single query */ function preloadExistence() { - $user = $this->getContext()->getUser(); + $user = $this->getUser(); // User/talk link $titles = array( $user->getUserPage(), $user->getTalkPage() ); // Other tab link - if ( $this->getTitle()->getNamespace() == NS_SPECIAL ) { + if ( $this->getTitle()->isSpecialPage() ) { // nothing } elseif ( $this->getTitle()->isTalkPage() ) { $titles[] = $this->getTitle()->getSubjectPage(); @@ -202,58 +199,13 @@ abstract class Skin { $lb->execute(); } - /** - * Set some local variables - */ - protected function setMembers() { - $this->userpage = $this->getContext()->getUser()->getUserPage()->getPrefixedText(); - } - - /** - * Set the RequestContext used in this instance - * - * @param RequestContext $context - */ - public function setContext( RequestContext $context ) { - $this->mContext = $context; - } - - /** - * Get the RequestContext used in this instance - * - * @return RequestContext - */ - public function getContext() { - if ( !isset($this->mContext) ) { - wfDebug( __METHOD__ . " called and \$mContext is null. Using RequestContext::getMain(); for sanity\n" ); - $this->mContext = RequestContext::getMain(); - } - return $this->mContext; - } - - /** Get the title - * - * @return Title - */ - public function getTitle() { - return $this->getContext()->getTitle(); - } - - /** Get the user - * - * @return User - */ - public function getUser() { - return $this->getContext()->getUser(); - } - /** * Get the current revision ID * * @return Integer */ public function getRevisionId() { - return $this->getContext()->getOutput()->getRevisionId(); + return $this->getOutput()->getRevisionId(); } /** @@ -319,8 +271,8 @@ abstract class Skin { if ( User::isIP( $rootUser ) ) { $this->mRelevantUser = User::newFromName( $rootUser, false ); } else { - $user = User::newFromName( $rootUser ); - if ( $user->isLoggedIn() ) { + $user = User::newFromName( $rootUser, false ); + if ( $user && $user->isLoggedIn() ) { $this->mRelevantUser = $user; } } @@ -333,8 +285,12 @@ abstract class Skin { * Outputs the HTML generated by other functions. * @param $out OutputPage */ - abstract function outputPage( OutputPage $out ); + abstract function outputPage( OutputPage $out = null ); + /** + * @param $data array + * @return string + */ static function makeVariablesScript( $data ) { if ( $data ) { return Html::inlineScript( @@ -346,98 +302,18 @@ abstract class Skin { } /** - * 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. + * Make a