* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
+ * @file
* @author Trevor Parscal
* @author Roan Kattouw
*/
+defined( 'MEDIAWIKI' ) || die( 1 );
+
/**
- * Object passed around to modules which contains information about the state of a specific loader request
+ * Object passed around to modules which contains information about the state
+ * of a specific loader request
*/
class ResourceLoaderContext {
+
/* Protected Members */
+ protected $resourceLoader;
protected $request;
protected $modules;
protected $language;
/* Methods */
- public function __construct( WebRequest $request ) {
- global $wgLang, $wgDefaultSkin;
+ public function __construct( ResourceLoader $resourceLoader, WebRequest $request ) {
+ global $wgLang, $wgDefaultSkin, $wgResourceLoaderDebug;
+ $this->resourceLoader = $resourceLoader;
$this->request = $request;
- // Interperet request
- $this->modules = explode( '|', $request->getVal( 'modules' ) );
+ // Interpret request
+ $modules = $request->getVal( 'modules' );
+ $this->modules = $modules ? explode( '|', $modules ) : array();
$this->language = $request->getVal( 'lang' );
$this->direction = $request->getVal( 'dir' );
$this->skin = $request->getVal( 'skin' );
$this->user = $request->getVal( 'user' );
- $this->debug = $request->getBool( 'debug' ) && $request->getVal( 'debug' ) === 'true';
+ $this->debug = $request->getFuzzyBool( 'debug', $wgResourceLoaderDebug );
$this->only = $request->getVal( 'only' );
$this->version = $request->getVal( 'version' );
}
}
+ public function getResourceLoader() {
+ return $this->resourceLoader;
+ }
+
public function getRequest() {
return $this->request;
}
}
public function getHash() {
- return isset( $this->hash ) ?
- $this->hash : $this->hash = implode( '|', array(
- $this->language, $this->direction, $this->skin, $this->user, $this->debug, $this->only, $this->version
+ if ( isset( $this->hash ) ) {
+ $this->hash = implode( '|', array(
+ $this->language, $this->direction, $this->skin, $this->user,
+ $this->debug, $this->only, $this->version
) );
+ }
+ return $this->hash;
}
-}
\ No newline at end of file
+}