Index: trunk/phase3/includes/AjaxDispatcher.php |
— | — | @@ -18,53 +18,25 @@ |
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 | | - |
25 | 22 | /** Name of the requested handler */ |
26 | | - private $func_name; |
| 23 | + private $func_name = null; |
27 | 24 | |
28 | 25 | /** Arguments passed */ |
29 | | - private $args; |
| 26 | + private $args = array(); |
30 | 27 | |
31 | 28 | /** Load up our object with user supplied data */ |
32 | | - function __construct() { |
| 29 | + public function __construct( WebRequest $req ) { |
33 | 30 | wfProfileIn( __METHOD__ ); |
34 | 31 | |
35 | | - $this->mode = ""; |
36 | | - |
37 | | - if ( ! empty( $_GET["rs"] ) ) { |
38 | | - $this->mode = "get"; |
| 32 | + $rs = $req->getVal( 'rs' ); |
| 33 | + if( $rs !== null ) { |
| 34 | + $this->func_name = $rs; |
39 | 35 | } |
40 | | - |
41 | | - if ( !empty( $_POST["rs"] ) ) { |
42 | | - $this->mode = "post"; |
| 36 | + $rsargs = $req->getVal( 'rsargs' ); |
| 37 | + if( $rsargs !== null ) { |
| 38 | + $this->args = $rsargs; |
43 | 39 | } |
44 | 40 | |
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 | | - |
69 | 41 | wfProfileOut( __METHOD__ ); |
70 | 42 | } |
71 | 43 | |
— | — | @@ -76,7 +48,7 @@ |
77 | 49 | function performAction() { |
78 | 50 | global $wgAjaxExportList, $wgOut; |
79 | 51 | |
80 | | - if ( empty( $this->mode ) ) { |
| 52 | + if ( is_null( $this->func_name ) ) { |
81 | 53 | return; |
82 | 54 | } |
83 | 55 | |
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(); |
| 72 | + $dispatcher = new AjaxDispatcher( $wgRequest ); |
73 | 73 | $dispatcher->performAction(); |
74 | 74 | $mediaWiki->restInPeace(); |
75 | 75 | exit; |