Index: trunk/phase3/includes/RequestContext.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | 4 | * Group all the pieces relevant to the context of a request into one instance |
5 | | - * |
| 5 | + * |
6 | 6 | * @since 1.18 |
7 | 7 | * |
8 | 8 | * @author IAlex |
— | — | @@ -14,32 +14,32 @@ |
15 | 15 | /** |
16 | 16 | * @var WebRequest |
17 | 17 | */ |
18 | | - private $mRequest; |
| 18 | + private $request; |
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @var Title |
22 | 22 | */ |
23 | | - private $mTitle; |
| 23 | + private $title; |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @var OutputPage |
27 | 27 | */ |
28 | | - private $mOutput; |
| 28 | + private $output; |
29 | 29 | |
30 | 30 | /** |
31 | 31 | * @var User |
32 | 32 | */ |
33 | | - private $mUser; |
| 33 | + private $user; |
34 | 34 | |
35 | 35 | /** |
36 | 36 | * @var Language |
37 | 37 | */ |
38 | | - private $mLang; |
| 38 | + private $lang; |
39 | 39 | |
40 | 40 | /** |
41 | 41 | * @var Skin |
42 | 42 | */ |
43 | | - private $mSkin; |
| 43 | + private $skin; |
44 | 44 | |
45 | 45 | /** |
46 | 46 | * Set the WebRequest object |
— | — | @@ -47,7 +47,7 @@ |
48 | 48 | * @param $r WebRequest object |
49 | 49 | */ |
50 | 50 | public function setRequest( WebRequest $r ) { |
51 | | - $this->mRequest = $r; |
| 51 | + $this->request = $r; |
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
— | — | @@ -56,11 +56,11 @@ |
57 | 57 | * @return WebRequest |
58 | 58 | */ |
59 | 59 | public function getRequest() { |
60 | | - if ( !isset( $this->mRequest ) ) { |
| 60 | + if ( !isset($this->request) ) { |
61 | 61 | global $wgRequest; # fallback to $wg till we can improve this |
62 | | - $this->mRequest = $wgRequest; |
| 62 | + $this->request = $wgRequest; |
63 | 63 | } |
64 | | - return $this->mRequest; |
| 64 | + return $this->request; |
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
— | — | @@ -69,7 +69,7 @@ |
70 | 70 | * @param $t Title object |
71 | 71 | */ |
72 | 72 | public function setTitle( Title $t ) { |
73 | | - $this->mTitle = $t; |
| 73 | + $this->title = $t; |
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
— | — | @@ -78,18 +78,18 @@ |
79 | 79 | * @return Title |
80 | 80 | */ |
81 | 81 | public function getTitle() { |
82 | | - if ( !isset( $this->mTitle ) ) { |
| 82 | + if ( !isset($this->title) ) { |
83 | 83 | global $wgTitle; # fallback to $wg till we can improve this |
84 | | - $this->mTitle = $wgTitle; |
| 84 | + $this->title = $wgTitle; |
85 | 85 | } |
86 | | - return $this->mTitle; |
| 86 | + return $this->title; |
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
90 | 90 | * @param $o OutputPage |
91 | 91 | */ |
92 | 92 | public function setOutput( OutputPage $o ) { |
93 | | - $this->mOutput = $o; |
| 93 | + $this->output = $o; |
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
— | — | @@ -98,10 +98,10 @@ |
99 | 99 | * @return OutputPage object |
100 | 100 | */ |
101 | 101 | public function getOutput() { |
102 | | - if ( !isset( $this->mOutput ) ) { |
103 | | - $this->mOutput = new OutputPage( $this ); |
| 102 | + if ( !isset( $this->output ) ) { |
| 103 | + $this->output = new OutputPage( $this ); |
104 | 104 | } |
105 | | - return $this->mOutput; |
| 105 | + return $this->output; |
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
— | — | @@ -110,7 +110,7 @@ |
111 | 111 | * @param $u User |
112 | 112 | */ |
113 | 113 | public function setUser( User $u ) { |
114 | | - $this->mUser = $u; |
| 114 | + $this->user = $u; |
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
— | — | @@ -119,13 +119,13 @@ |
120 | 120 | * @return User |
121 | 121 | */ |
122 | 122 | public function getUser() { |
123 | | - if ( !isset( $this->mUser ) ) { |
| 123 | + if ( !isset($this->user) ) { |
124 | 124 | global $wgCommandLineMode; |
125 | | - $this->mUser = $wgCommandLineMode |
| 125 | + $this->user = $wgCommandLineMode |
126 | 126 | ? new User |
127 | 127 | : User::newFromSession( $this->getRequest() ); |
128 | 128 | } |
129 | | - return $this->mUser; |
| 129 | + return $this->user; |
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
— | — | @@ -134,7 +134,7 @@ |
135 | 135 | * @return Language |
136 | 136 | */ |
137 | 137 | public function getLang() { |
138 | | - if ( !isset( $this->mLang ) ) { |
| 138 | + if ( !isset($this->lang) ) { |
139 | 139 | global $wgLanguageCode, $wgContLang; |
140 | 140 | $code = $this->getRequest()->getVal( |
141 | 141 | 'uselang', |
— | — | @@ -144,21 +144,21 @@ |
145 | 145 | $code = strtolower( $code ); |
146 | 146 | |
147 | 147 | # Validate $code |
148 | | - if ( empty( $code ) || !Language::isValidCode( $code ) || ( $code === 'qqq' ) ) { |
| 148 | + if( empty( $code ) || !Language::isValidCode( $code ) || ( $code === 'qqq' ) ) { |
149 | 149 | wfDebug( "Invalid user language code\n" ); |
150 | 150 | $code = $wgLanguageCode; |
151 | 151 | } |
152 | 152 | |
153 | 153 | wfRunHooks( 'UserGetLanguageObject', array( $this->getUser(), &$code ) ); |
154 | 154 | |
155 | | - if ( $code === $wgLanguageCode ) { |
156 | | - $this->mLang = $wgContLang; |
| 155 | + if( $code === $wgLanguageCode ) { |
| 156 | + $this->lang = $wgContLang; |
157 | 157 | } else { |
158 | 158 | $obj = Language::factory( $code ); |
159 | | - $this->mLang = $obj; |
| 159 | + $this->lang = $obj; |
160 | 160 | } |
161 | 161 | } |
162 | | - return $this->mLang; |
| 162 | + return $this->lang; |
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
— | — | @@ -167,11 +167,11 @@ |
168 | 168 | * @return Skin |
169 | 169 | */ |
170 | 170 | public function getSkin() { |
171 | | - if ( !isset( $this->mSkin ) ) { |
| 171 | + if ( !isset($this->skin) ) { |
172 | 172 | wfProfileIn( __METHOD__ . '-createskin' ); |
173 | | - |
| 173 | + |
174 | 174 | global $wgHiddenPrefs; |
175 | | - if ( !in_array( 'skin', $wgHiddenPrefs ) ) { |
| 175 | + if( !in_array( 'skin', $wgHiddenPrefs ) ) { |
176 | 176 | # get the user skin |
177 | 177 | $userSkin = $this->getUser()->getOption( 'skin' ); |
178 | 178 | $userSkin = $this->getRequest()->getVal( 'useskin', $userSkin ); |
— | — | @@ -181,11 +181,11 @@ |
182 | 182 | $userSkin = $wgDefaultSkin; |
183 | 183 | } |
184 | 184 | |
185 | | - $this->mSkin = Skin::newFromKey( $userSkin ); |
186 | | - $this->mSkin->setContext( $this ); |
| 185 | + $this->skin = Skin::newFromKey( $userSkin ); |
| 186 | + $this->skin->setContext( $this ); |
187 | 187 | wfProfileOut( __METHOD__ . '-createskin' ); |
188 | 188 | } |
189 | | - return $this->mSkin; |
| 189 | + return $this->skin; |
190 | 190 | } |
191 | 191 | |
192 | 192 | /** Helpful methods **/ |
— | — | @@ -210,42 +210,10 @@ |
211 | 211 | */ |
212 | 212 | public static function getMain() { |
213 | 213 | static $instance = null; |
214 | | - if ( !isset( $instance ) ) { |
| 214 | + if ( !isset($instance) ) { |
215 | 215 | $instance = new self; |
216 | 216 | } |
217 | 217 | return $instance; |
218 | 218 | } |
219 | | - |
220 | | - /** |
221 | | - * Make these C#-style accessors, so you can do $context->user->getName() which is |
222 | | - * internally mapped to $context->__get('user')->getName() which is mapped to |
223 | | - * $context->getUser()->getName() |
224 | | - * |
225 | | - * @param $name string |
226 | | - * |
227 | | - * @return string |
228 | | - */ |
229 | | - public function __get( $name ) { |
230 | | - wfDeprecated( 'RequestContext::__get() is deprecated; use $context->getFoo() instead' ); |
231 | | - if ( in_array( $name, array( 'request', 'title', 'output', 'user', 'lang', 'skin' ) ) ) { |
232 | | - $fname = 'get' . ucfirst( $name ); |
233 | | - return $this->$fname(); |
234 | | - } |
235 | | - trigger_error( "Undefined property {$name}", E_NOTICE ); |
236 | | - } |
237 | | - |
238 | | - /** |
239 | | - * @param $name string |
240 | | - * @param $value |
241 | | - * @return string |
242 | | - */ |
243 | | - public function __set( $name, $value ) { |
244 | | - wfDeprecated( 'RequestContext::__set() is deprecated; use $context->setFoo() instead' ); |
245 | | - if ( in_array( $name, array( 'request', 'title', 'output', 'user', 'lang', 'skin' ) ) ) { |
246 | | - $fname = 'set' . ucfirst( $name ); |
247 | | - return $this->$fname( $value ); |
248 | | - } |
249 | | - trigger_error( "Undefined property {$name}", E_NOTICE ); |
250 | | - } |
251 | 219 | } |
252 | 220 | |