MediaWiki
REL1_21
|
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 00072 public function __construct( IContextSource $context ) { 00073 $this->setContext( $context ); 00074 } 00075 00081 public function setRequest( WebRequest $r ) { 00082 $this->request = $r; 00083 } 00084 00090 public function getRequest() { 00091 if ( !is_null( $this->request ) ) { 00092 return $this->request; 00093 } else { 00094 return $this->getContext()->getRequest(); 00095 } 00096 } 00097 00103 public function setTitle( Title $t ) { 00104 $this->title = $t; 00105 } 00106 00112 public function getTitle() { 00113 if ( !is_null( $this->title ) ) { 00114 return $this->title; 00115 } else { 00116 return $this->getContext()->getTitle(); 00117 } 00118 } 00119 00128 public function canUseWikiPage() { 00129 if ( $this->wikipage !== null ) { 00130 return true; 00131 } elseif ( $this->title !== null ) { 00132 return $this->title->canExist(); 00133 } else { 00134 return $this->getContext()->canUseWikiPage(); 00135 } 00136 } 00137 00144 public function setWikiPage( WikiPage $p ) { 00145 $this->wikipage = $p; 00146 } 00147 00157 public function getWikiPage() { 00158 if ( !is_null( $this->wikipage ) ) { 00159 return $this->wikipage; 00160 } else { 00161 return $this->getContext()->getWikiPage(); 00162 } 00163 } 00164 00170 public function setOutput( OutputPage $o ) { 00171 $this->output = $o; 00172 } 00173 00179 public function getOutput() { 00180 if ( !is_null( $this->output ) ) { 00181 return $this->output; 00182 } else { 00183 return $this->getContext()->getOutput(); 00184 } 00185 } 00186 00192 public function setUser( User $u ) { 00193 $this->user = $u; 00194 } 00195 00201 public function getUser() { 00202 if ( !is_null( $this->user ) ) { 00203 return $this->user; 00204 } else { 00205 return $this->getContext()->getUser(); 00206 } 00207 } 00208 00215 public function setLang( $l ) { 00216 wfDeprecated( __METHOD__, '1.19' ); 00217 $this->setLanguage( $l ); 00218 } 00219 00227 public function setLanguage( $l ) { 00228 if ( $l instanceof Language ) { 00229 $this->lang = $l; 00230 } elseif ( is_string( $l ) ) { 00231 $l = RequestContext::sanitizeLangCode( $l ); 00232 $obj = Language::factory( $l ); 00233 $this->lang = $obj; 00234 } else { 00235 throw new MWException( __METHOD__ . " was passed an invalid type of data." ); 00236 } 00237 } 00238 00243 public function getLang() { 00244 wfDeprecated( __METHOD__, '1.19' ); 00245 $this->getLanguage(); 00246 } 00247 00254 public function getLanguage() { 00255 if ( !is_null( $this->lang ) ) { 00256 return $this->lang; 00257 } else { 00258 return $this->getContext()->getLanguage(); 00259 } 00260 } 00261 00267 public function setSkin( Skin $s ) { 00268 $this->skin = clone $s; 00269 $this->skin->setContext( $this ); 00270 } 00271 00277 public function getSkin() { 00278 if ( !is_null( $this->skin ) ) { 00279 return $this->skin; 00280 } else { 00281 return $this->getContext()->getSkin(); 00282 } 00283 } 00284 }