'ConfEditor' => 'includes/ConfEditor.php',
'ConfEditorParseError' => 'includes/ConfEditor.php',
'ConfEditorToken' => 'includes/ConfEditor.php',
+ 'ContextSource' => 'includes/RequestContext.php',
'Cookie' => 'includes/Cookie.php',
'CookieJar' => 'includes/Cookie.php',
'DiffHistoryBlob' => 'includes/HistoryBlob.php',
'HTMLTextField' => 'includes/HTMLForm.php',
'Http' => 'includes/HttpFunctions.php',
'HttpRequest' => 'includes/HttpFunctions.old.php',
+ 'IContextSource' => 'includes/RequestContext.php',
'IcuCollation' => 'includes/Collation.php',
'ImageGallery' => 'includes/ImageGallery.php',
'ImageHistoryList' => 'includes/ImagePage.php',
}
}
+/**
+ * Interface for objects which can provide a context on request.
+ */
+interface IContextSource {
+
+ /**
+ * Get the WebRequest object
+ *
+ * @return WebRequest
+ */
+ public function getRequest();
+
+ /**
+ * Get the Title object
+ *
+ * @return Title
+ */
+ public function getTitle();
+
+ /**
+ * Get the OutputPage object
+ *
+ * @return OutputPage object
+ */
+ public function getOutput();
+
+ /**
+ * Get the User object
+ *
+ * @return User
+ */
+ public function getUser();
+
+ /**
+ * Get the Language object
+ *
+ * @return Language
+ */
+ public function getLang();
+
+ /**
+ * Get the Skin object
+ *
+ * @return Skin
+ */
+ public function getSkin();
+}
+
+/**
+ * The simplest way of implementing IContextSource is to hold a RequestContext as a
+ * member variable and provide accessors to it.
+ */
+abstract class ContextSource implements IContextSource {
+
+ /**
+ * @var RequestContext
+ */
+ private $context;
+
+ /**
+ * Get the RequestContext object
+ *
+ * @return RequestContext
+ */
+ public function getContext() {
+ return $this->context;
+ }
+
+ /**
+ * Set the RequestContext object
+ *
+ * @param $context RequestContext
+ */
+ public function setContext( RequestContext $context ) {
+ $this->context = $context;
+ }
+
+ /**
+ * Get the WebRequest object
+ *
+ * @return WebRequest
+ */
+ public function getRequest() {
+ return $this->context->getRequest();
+ }
+
+ /**
+ * Get the Title object
+ *
+ * @return Title
+ */
+ public function getTitle() {
+ return $this->context->getTitle();
+ }
+
+ /**
+ * Get the OutputPage object
+ *
+ * @return OutputPage object
+ */
+ public function getOutput() {
+ return $this->context->getOutput();
+ }
+
+ /**
+ * Get the User object
+ *
+ * @return User
+ */
+ public function getUser() {
+ return $this->context->getUser();
+ }
+
+ /**
+ * Get the Language object
+ *
+ * @return Language
+ */
+ public function getLang() {
+ return $this->context->getLang();
+ }
+
+ /**
+ * Get the Skin object
+ *
+ * @return Skin
+ */
+ public function getSkin() {
+ return $this->context->getSkin();
+ }
+}
\ No newline at end of file