http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90901

Revision: 90901
Author:   happy-melon
Date:     2011-06-27 19:38:30 +0000 (Mon, 27 Jun 2011)
Log Message:
-----------
Follow-up r89408, r86872: restore IContextSource and ContextSource, to be more 
carefully reimplemented.

Modified Paths:
--------------
    trunk/phase3/includes/AutoLoader.php
    trunk/phase3/includes/RequestContext.php

Modified: trunk/phase3/includes/AutoLoader.php
===================================================================
--- trunk/phase3/includes/AutoLoader.php        2011-06-27 19:26:30 UTC (rev 
90900)
+++ trunk/phase3/includes/AutoLoader.php        2011-06-27 19:38:30 UTC (rev 
90901)
@@ -47,6 +47,7 @@
        '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',
@@ -115,6 +116,7 @@
        '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',

Modified: trunk/phase3/includes/RequestContext.php
===================================================================
--- trunk/phase3/includes/RequestContext.php    2011-06-27 19:26:30 UTC (rev 
90900)
+++ trunk/phase3/includes/RequestContext.php    2011-06-27 19:38:30 UTC (rev 
90901)
@@ -217,3 +217,134 @@
        }
 }
 
+/**
+ * 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


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to