MediaWiki
REL1_24
|
00001 <?php 00032 class DerivativeContext extends ContextSource { 00036 private $request; 00037 00041 private $title; 00042 00046 private $wikipage; 00047 00051 private $output; 00052 00056 private $user; 00057 00061 private $lang; 00062 00066 private $skin; 00067 00071 private $config; 00072 00077 public function __construct( IContextSource $context ) { 00078 $this->setContext( $context ); 00079 } 00080 00086 public function setConfig( Config $s ) { 00087 $this->config = $s; 00088 } 00089 00095 public function getConfig() { 00096 if ( !is_null( $this->config ) ) { 00097 return $this->config; 00098 } else { 00099 return $this->getContext()->getConfig(); 00100 } 00101 } 00102 00108 public function setRequest( WebRequest $r ) { 00109 $this->request = $r; 00110 } 00111 00117 public function getRequest() { 00118 if ( !is_null( $this->request ) ) { 00119 return $this->request; 00120 } else { 00121 return $this->getContext()->getRequest(); 00122 } 00123 } 00124 00130 public function setTitle( Title $t ) { 00131 $this->title = $t; 00132 } 00133 00139 public function getTitle() { 00140 if ( !is_null( $this->title ) ) { 00141 return $this->title; 00142 } else { 00143 return $this->getContext()->getTitle(); 00144 } 00145 } 00146 00155 public function canUseWikiPage() { 00156 if ( $this->wikipage !== null ) { 00157 return true; 00158 } elseif ( $this->title !== null ) { 00159 return $this->title->canExist(); 00160 } else { 00161 return $this->getContext()->canUseWikiPage(); 00162 } 00163 } 00164 00171 public function setWikiPage( WikiPage $p ) { 00172 $this->wikipage = $p; 00173 } 00174 00184 public function getWikiPage() { 00185 if ( !is_null( $this->wikipage ) ) { 00186 return $this->wikipage; 00187 } else { 00188 return $this->getContext()->getWikiPage(); 00189 } 00190 } 00191 00197 public function setOutput( OutputPage $o ) { 00198 $this->output = $o; 00199 } 00200 00206 public function getOutput() { 00207 if ( !is_null( $this->output ) ) { 00208 return $this->output; 00209 } else { 00210 return $this->getContext()->getOutput(); 00211 } 00212 } 00213 00219 public function setUser( User $u ) { 00220 $this->user = $u; 00221 } 00222 00228 public function getUser() { 00229 if ( !is_null( $this->user ) ) { 00230 return $this->user; 00231 } else { 00232 return $this->getContext()->getUser(); 00233 } 00234 } 00235 00243 public function setLanguage( $l ) { 00244 if ( $l instanceof Language ) { 00245 $this->lang = $l; 00246 } elseif ( is_string( $l ) ) { 00247 $l = RequestContext::sanitizeLangCode( $l ); 00248 $obj = Language::factory( $l ); 00249 $this->lang = $obj; 00250 } else { 00251 throw new MWException( __METHOD__ . " was passed an invalid type of data." ); 00252 } 00253 } 00254 00261 public function getLanguage() { 00262 if ( !is_null( $this->lang ) ) { 00263 return $this->lang; 00264 } else { 00265 return $this->getContext()->getLanguage(); 00266 } 00267 } 00268 00274 public function setSkin( Skin $s ) { 00275 $this->skin = clone $s; 00276 $this->skin->setContext( $this ); 00277 } 00278 00284 public function getSkin() { 00285 if ( !is_null( $this->skin ) ) { 00286 return $this->skin; 00287 } else { 00288 return $this->getContext()->getSkin(); 00289 } 00290 } 00291 00302 public function msg() { 00303 $args = func_get_args(); 00304 00305 return call_user_func_array( 'wfMessage', $args )->setContext( $this ); 00306 } 00307 }