X-Git-Url: http://git.cyclocoop.org/%22.%20generer_url_ecrire%28%22sites_tous%22%2C%22%22%29.%20%22?a=blobdiff_plain;f=includes%2Fcontext%2FDerivativeContext.php;h=1e3fbf27b870d2b9be5bd2c572df96cd83ec280b;hb=57d3f41876599497fcb9c672b88ebad7239353dc;hp=eda56a7d55d67b72fa0412f442ae81eb6c581133;hpb=5c5fb511c70346a660cb6aa388cc677e11d3bdab;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/context/DerivativeContext.php b/includes/context/DerivativeContext.php index eda56a7d55..1e3fbf27b8 100644 --- a/includes/context/DerivativeContext.php +++ b/includes/context/DerivativeContext.php @@ -65,6 +65,11 @@ class DerivativeContext extends ContextSource { */ private $skin; + /** + * @var SiteConfiguration + */ + private $config; + /** * Constructor * @param IContextSource $context Context to inherit from @@ -73,6 +78,28 @@ class DerivativeContext extends ContextSource { $this->setContext( $context ); } + /** + * Set the SiteConfiguration object + * + * @param SiteConfiguration $c + */ + public function setConfig( SiteConfiguration $s ) { + $this->config = $s; + } + + /** + * Get the SiteConfiguration object + * + * @return SiteConfiguration + */ + public function getConfig() { + if ( !is_null( $this->config ) ) { + return $this->config; + } else { + return $this->getContext()->getConfig(); + } + } + /** * Set the WebRequest object * @@ -99,8 +126,12 @@ class DerivativeContext extends ContextSource { * Set the Title object * * @param Title $t + * @throws MWException */ - public function setTitle( Title $t ) { + public function setTitle( $t ) { + if ( $t !== null && !$t instanceof Title ) { + throw new MWException( __METHOD__ . " expects an instance of Title" ); + } $this->title = $t; } @@ -281,4 +312,21 @@ class DerivativeContext extends ContextSource { return $this->getContext()->getSkin(); } } + + /** + * Get a message using the current context. + * + * This can't just inherit from ContextSource, since then + * it would set only the original context, and not take + * into account any changes. + * + * @param String Message name + * @param Variable number of message arguments + * @return Message + */ + public function msg() { + $args = func_get_args(); + + return call_user_func_array( 'wfMessage', $args )->setContext( $this ); + } }