* Object passed around to modules which contains information about the state of a specific loader request
*/
class ResourceLoaderContext {
-
/* Protected Members */
-
+
protected $request;
- protected $server;
protected $modules;
protected $language;
protected $direction;
- protected $flip;
protected $skin;
+ protected $user;
protected $debug;
protected $only;
protected $hash;
-
+
/* Methods */
-
- public function __construct( WebRequest $request, $server ) {
- global $wgUser, $wgLang, $wgContLang, $wgDefaultSkin;
-
+
+ public function __construct( WebRequest $request ) {
+ global $wgLang, $wgDefaultSkin;
+
$this->request = $request;
- $this->server = $server;
// Interperet request
$this->modules = explode( '|', $request->getVal( 'modules' ) );
$this->language = $request->getVal( 'lang' );
$this->direction = $request->getVal( 'dir' );
$this->skin = $request->getVal( 'skin' );
- $this->debug = $request->getVal( 'debug' ) === 'true' || $request->getBool( 'debug' );
+ $this->user = $request->getVal( 'user' );
+ $this->debug = $request->getBool( 'debug' ) && $request->getVal( 'debug' ) === 'true';
$this->only = $request->getVal( 'only' );
+
// Fallback on system defaults
if ( !$this->language ) {
$this->language = $wgLang->getCode();
}
+
if ( !$this->direction ) {
$this->direction = Language::factory( $this->language )->getDir();
}
+
if ( !$this->skin ) {
$this->skin = $wgDefaultSkin;
}
- // Evaluate flip
- $this->flip = $wgContLang->getDir() !== $this->direction;
}
public function getRequest() {
return $this->request;
}
-
- public function getServer() {
- return $this->server;
- }
-
+
public function getModules() {
return $this->modules;
}
-
+
public function getLanguage() {
return $this->language;
}
public function getDirection() {
return $this->direction;
}
-
- public function getFlip() {
- return $this->flip;
- }
-
+
public function getSkin() {
return $this->skin;
}
-
+
+ public function getUser() {
+ return $this->user;
+ }
+
public function getDebug() {
return $this->debug;
}
-
+
public function getOnly() {
return $this->only;
}
-
+
public function shouldIncludeScripts() {
return is_null( $this->only ) || $this->only === 'scripts';
}
-
+
public function shouldIncludeStyles() {
return is_null( $this->only ) || $this->only === 'styles';
}
-
+
public function shouldIncludeMessages() {
return is_null( $this->only ) || $this->only === 'messages';
}
-
+
public function getHash() {
return isset( $this->hash ) ?
- $this->hash : $this->hash = implode( '|', array( $this->language, $this->skin, $this->debug ) );
+ $this->hash : $this->hash = implode( '|', array(
+ $this->language, $this->direction, $this->skin, $this->user, $this->debug, $this->only
+ ) );
}
}
\ No newline at end of file