269712aa527872ba66f471493be12e6e86d68363
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
18 * @author Trevor Parscal
19 * @author Roan Kattouw
23 * Object passed around to modules which contains information about the state of a specific loader request
25 class ResourceLoaderContext
{
26 /* Protected Members */
41 public function __construct( WebRequest
$request ) {
42 global $wgLang, $wgDefaultSkin;
44 $this->request
= $request;
46 $this->modules
= explode( '|', $request->getVal( 'modules' ) );
47 $this->language
= $request->getVal( 'lang' );
48 $this->direction
= $request->getVal( 'dir' );
49 $this->skin
= $request->getVal( 'skin' );
50 $this->user
= $request->getVal( 'user' );
51 $this->debug
= $request->getBool( 'debug' ) && $request->getVal( 'debug' ) === 'true';
52 $this->only
= $request->getVal( 'only' );
53 $this->version
= $request->getVal( 'version' );
55 // Fallback on system defaults
56 if ( !$this->language
) {
57 $this->language
= $wgLang->getCode();
60 if ( !$this->direction
) {
61 $this->direction
= Language
::factory( $this->language
)->getDir();
65 $this->skin
= $wgDefaultSkin;
69 public function getRequest() {
70 return $this->request
;
73 public function getModules() {
74 return $this->modules
;
77 public function getLanguage() {
78 return $this->language
;
81 public function getDirection() {
82 return $this->direction
;
85 public function getSkin() {
89 public function getUser() {
93 public function getDebug() {
97 public function getOnly() {
101 public function getVersion() {
102 return $this->version
;
105 public function shouldIncludeScripts() {
106 return is_null( $this->only
) ||
$this->only
=== 'scripts';
109 public function shouldIncludeStyles() {
110 return is_null( $this->only
) ||
$this->only
=== 'styles';
113 public function shouldIncludeMessages() {
114 return is_null( $this->only
) ||
$this->only
=== 'messages';
117 public function getHash() {
118 return isset( $this->hash
) ?
119 $this->hash
: $this->hash
= implode( '|', array(
120 $this->language
, $this->direction
, $this->skin
, $this->user
, $this->debug
, $this->only
, $this->version