MediaWiki
REL1_19
|
00001 <?php 00032 class DerivativeContext extends ContextSource { 00033 00037 private $request; 00038 00042 private $title; 00043 00047 private $wikipage; 00048 00052 private $output; 00053 00057 private $user; 00058 00062 private $lang; 00063 00067 private $skin; 00068 00073 public function __construct( IContextSource $context ) { 00074 $this->setContext( $context ); 00075 } 00076 00082 public function setRequest( WebRequest $r ) { 00083 $this->request = $r; 00084 } 00085 00091 public function getRequest() { 00092 if ( !is_null( $this->request ) ) { 00093 return $this->request; 00094 } else { 00095 return $this->getContext()->getRequest(); 00096 } 00097 } 00098 00104 public function setTitle( Title $t ) { 00105 $this->title = $t; 00106 } 00107 00113 public function getTitle() { 00114 if ( !is_null( $this->title ) ) { 00115 return $this->title; 00116 } else { 00117 return $this->getContext()->getTitle(); 00118 } 00119 } 00120 00129 public function canUseWikiPage() { 00130 if ( $this->wikipage !== null ) { 00131 return true; 00132 } elseif ( $this->title !== null ) { 00133 return $this->title->canExist(); 00134 } else { 00135 return $this->getContext()->canUseWikiPage(); 00136 } 00137 } 00138 00145 public function setWikiPage( WikiPage $p ) { 00146 $this->wikipage = $p; 00147 } 00148 00158 public function getWikiPage() { 00159 if ( !is_null( $this->wikipage ) ) { 00160 return $this->wikipage; 00161 } else { 00162 return $this->getContext()->getWikiPage(); 00163 } 00164 } 00165 00171 public function setOutput( OutputPage $o ) { 00172 $this->output = $o; 00173 } 00174 00180 public function getOutput() { 00181 if ( !is_null( $this->output ) ) { 00182 return $this->output; 00183 } else { 00184 return $this->getContext()->getOutput(); 00185 } 00186 } 00187 00193 public function setUser( User $u ) { 00194 $this->user = $u; 00195 } 00196 00202 public function getUser() { 00203 if ( !is_null( $this->user ) ) { 00204 return $this->user; 00205 } else { 00206 return $this->getContext()->getUser(); 00207 } 00208 } 00209 00216 public function setLang( $l ) { 00217 wfDeprecated( __METHOD__, '1.19' ); 00218 $this->setLanguage( $l ); 00219 } 00220 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 00285 } 00286