From db835165c2b795cd327034bb24606e0a841d044f Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sat, 5 May 2007 00:06:20 +0000 Subject: [PATCH] * AjaxDispatcher : use a switch() * Add doxygen comments. --- includes/AjaxDispatcher.php | 42 ++++++++++++++++++++++++++++--------- includes/AjaxResponse.php | 30 +++++++++++++++++++------- 2 files changed, 55 insertions(+), 17 deletions(-) diff --git a/includes/AjaxDispatcher.php b/includes/AjaxDispatcher.php index ca12902919..0d4e830a58 100644 --- a/includes/AjaxDispatcher.php +++ b/includes/AjaxDispatcher.php @@ -1,10 +1,9 @@ mode = "post"; } - if ($this->mode == "get") { + switch( $this->mode ) { + + case 'get': $this->func_name = isset( $_GET["rs"] ) ? $_GET["rs"] : ''; if (! empty($_GET["rsargs"])) { $this->args = $_GET["rsargs"]; } else { $this->args = array(); } - } else { + break; + + case 'post': $this->func_name = isset( $_POST["rs"] ) ? $_POST["rs"] : ''; if (! empty($_POST["rsargs"])) { $this->args = $_POST["rsargs"]; } else { $this->args = array(); } + break; + + default: + return; + # Or we could throw an exception: + #throw new MWException( __METHOD__ . ' called without any data (mode empty).' ); + } + wfProfileOut( __METHOD__ ); } + /** Pass the request to our internal function. + * BEWARE! Data are passed as they have been supplied by the user, + * they should be carefully handled in the function processing the + * request. + */ function performAction() { global $wgAjaxExportList, $wgOut; diff --git a/includes/AjaxResponse.php b/includes/AjaxResponse.php index cb4af1b57f..e910a523fa 100644 --- a/includes/AjaxResponse.php +++ b/includes/AjaxResponse.php @@ -8,14 +8,27 @@ if( !defined( 'MEDIAWIKI' ) ) { * @addtogroup Ajax */ class AjaxResponse { - var $mCacheDuration; - var $mVary; - var $mDisabled; - var $mText; - var $mResponseCode; - var $mLastModified; - var $mContentType; + /** Number of seconds to get the response cached by a proxy */ + private $mCacheDuration; + + /** HTTP header Content-Type */ + private $mContentType; + + /** @todo document */ + private $mDisabled; + + /** Date for the HTTP header Last-modified */ + private $mLastModified; + + /** HTTP response code */ + private $mResponseCode; + + /** HTTP Vary header */ + private $mVary; + + /** Content of our HTTP response */ + private $mText; function __construct( $text = NULL ) { $this->mCacheDuration = NULL; @@ -52,18 +65,21 @@ class AjaxResponse { $this->mDisabled = true; } + /** Add content to the response */ function addText( $text ) { if ( ! $this->mDisabled && $text ) { $this->mText .= $text; } } + /** Output text */ function printText() { if ( ! $this->mDisabled ) { print $this->mText; } } + /** Construct the header and output it */ function sendHeaders() { global $wgUseSquid, $wgUseESI; -- 2.20.1