Index: trunk/phase3/includes/AjaxDispatcher.php |
— | — | @@ -18,25 +18,53 @@ |
19 | 19 | * @ingroup Ajax |
20 | 20 | */ |
21 | 21 | class AjaxDispatcher { |
| 22 | + /** The way the request was made, either a 'get' or a 'post' */ |
| 23 | + private $mode; |
| 24 | + |
22 | 25 | /** Name of the requested handler */ |
23 | | - private $func_name = null; |
| 26 | + private $func_name; |
24 | 27 | |
25 | 28 | /** Arguments passed */ |
26 | | - private $args = array(); |
| 29 | + private $args; |
27 | 30 | |
28 | 31 | /** Load up our object with user supplied data */ |
29 | | - public function __construct( WebRequest $req ) { |
| 32 | + function __construct() { |
30 | 33 | wfProfileIn( __METHOD__ ); |
31 | 34 | |
32 | | - $rs = $req->getVal( 'rs' ); |
33 | | - if( $rs !== null ) { |
34 | | - $this->func_name = $rs; |
| 35 | + $this->mode = ""; |
| 36 | + |
| 37 | + if ( ! empty( $_GET["rs"] ) ) { |
| 38 | + $this->mode = "get"; |
35 | 39 | } |
36 | | - $rsargs = $req->getVal( 'rsargs' ); |
37 | | - if( $rsargs !== null ) { |
38 | | - $this->args = $rsargs; |
| 40 | + |
| 41 | + if ( !empty( $_POST["rs"] ) ) { |
| 42 | + $this->mode = "post"; |
39 | 43 | } |
40 | 44 | |
| 45 | + switch( $this->mode ) { |
| 46 | + case 'get': |
| 47 | + $this->func_name = isset( $_GET["rs"] ) ? $_GET["rs"] : ''; |
| 48 | + if ( ! empty( $_GET["rsargs"] ) ) { |
| 49 | + $this->args = $_GET["rsargs"]; |
| 50 | + } else { |
| 51 | + $this->args = array(); |
| 52 | + } |
| 53 | + break; |
| 54 | + case 'post': |
| 55 | + $this->func_name = isset( $_POST["rs"] ) ? $_POST["rs"] : ''; |
| 56 | + if ( ! empty( $_POST["rsargs"] ) ) { |
| 57 | + $this->args = $_POST["rsargs"]; |
| 58 | + } else { |
| 59 | + $this->args = array(); |
| 60 | + } |
| 61 | + break; |
| 62 | + default: |
| 63 | + wfProfileOut( __METHOD__ ); |
| 64 | + return; |
| 65 | + # Or we could throw an exception: |
| 66 | + # throw new MWException( __METHOD__ . ' called without any data (mode empty).' ); |
| 67 | + } |
| 68 | + |
41 | 69 | wfProfileOut( __METHOD__ ); |
42 | 70 | } |
43 | 71 | |
— | — | @@ -48,7 +76,7 @@ |
49 | 77 | function performAction() { |
50 | 78 | global $wgAjaxExportList, $wgOut; |
51 | 79 | |
52 | | - if ( is_null( $this->func_name ) ) { |
| 80 | + if ( empty( $this->mode ) ) { |
53 | 81 | return; |
54 | 82 | } |
55 | 83 | |
Index: trunk/phase3/index.php |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | # |
70 | 70 | if( $wgUseAjax && $action == 'ajax' ) { |
71 | 71 | require_once( $IP . '/includes/AjaxDispatcher.php' ); |
72 | | - $dispatcher = new AjaxDispatcher( $wgRequest ); |
| 72 | + $dispatcher = new AjaxDispatcher(); |
73 | 73 | $dispatcher->performAction(); |
74 | 74 | $mediaWiki->restInPeace(); |
75 | 75 | exit; |