1 |
joko |
1.1 |
<?php |
2 |
|
|
|
3 |
|
|
/** |
4 |
|
|
* This file contains the concrete Application::Request::Http Controller class. |
5 |
|
|
* |
6 |
|
|
* @author Andreas Motl <andreas.motl@ilo.de> |
7 |
|
|
* @package org.netfrag.glib |
8 |
joko |
1.3 |
* @name Application::Request::HttpController |
9 |
joko |
1.1 |
* |
10 |
|
|
*/ |
11 |
|
|
|
12 |
|
|
/** |
13 |
joko |
1.4 |
* <b>Cvs-Log:</b> |
14 |
|
|
* |
15 |
|
|
* <pre> |
16 |
jonen |
1.5 |
* $Id: HttpController.php,v 1.4 2003/03/11 01:22:22 joko Exp $ |
17 |
joko |
1.2 |
* |
18 |
|
|
* $Log: HttpController.php,v $ |
19 |
jonen |
1.5 |
* Revision 1.4 2003/03/11 01:22:22 joko |
20 |
|
|
* + fixed metadata for phpDocumentor |
21 |
|
|
* |
22 |
joko |
1.4 |
* Revision 1.3 2003/03/05 18:54:42 joko |
23 |
|
|
* updated docu - phpDocumentor is very strict about its 'blocks'... |
24 |
|
|
* |
25 |
joko |
1.3 |
* Revision 1.2 2003/03/03 21:13:59 joko |
26 |
|
|
* + request translation |
27 |
|
|
* mungled namespaces |
28 |
|
|
* - purged old code |
29 |
|
|
* |
30 |
joko |
1.2 |
* Revision 1.1 2003/03/01 21:11:18 joko |
31 |
|
|
* + initial commit |
32 |
joko |
1.4 |
* </pre> |
33 |
joko |
1.1 |
* |
34 |
|
|
*/ |
35 |
|
|
|
36 |
|
|
|
37 |
|
|
/** |
38 |
joko |
1.3 |
* This requires the Application::Request::BaseController base class |
39 |
|
|
* |
40 |
|
|
*/ |
41 |
|
|
loadModule('Application::Request::BaseController'); |
42 |
|
|
|
43 |
|
|
/** |
44 |
|
|
* --- Application::Request::HttpController |
45 |
joko |
1.1 |
* |
46 |
joko |
1.3 |
* Responsible for GET and POST argument handling. |
47 |
|
|
* Does an array_join_merge for now. |
48 |
joko |
1.1 |
* |
49 |
|
|
* @author Andreas Motl <andreas.motl@ilo.de> |
50 |
|
|
* @copyright (c) 2003 - All Rights reserved. |
51 |
|
|
* @license GNU LGPL (GNU Lesser General Public License) |
52 |
|
|
* |
53 |
joko |
1.3 |
* @link http://www.netfrag.org/~joko/ |
54 |
|
|
* @link http://www.gnu.org/licenses/lgpl.txt |
55 |
joko |
1.1 |
* |
56 |
|
|
* @package org.netfrag.glib |
57 |
joko |
1.3 |
* @subpackage Application |
58 |
|
|
* @name Application::Request::HttpController |
59 |
joko |
1.1 |
* |
60 |
|
|
*/ |
61 |
|
|
class Application_Request_HttpController extends Application_Request_BaseController { |
62 |
|
|
|
63 |
|
|
/** |
64 |
|
|
* The constructor ... |
65 |
|
|
* ... just does nothing. |
66 |
|
|
* |
67 |
|
|
* @param registry |
68 |
|
|
*/ |
69 |
|
|
function Application_Request_HttpController(&$request) { |
70 |
|
|
//print Dumper($request); |
71 |
|
|
//exit; |
72 |
|
|
// propagate request data |
73 |
|
|
$this->set_request($request); |
74 |
|
|
} |
75 |
|
|
|
76 |
|
|
function get_request() { |
77 |
jonen |
1.5 |
// FIXME!? |
78 |
|
|
if ($lbid = $_GET[lbid]) { |
79 |
|
|
// talk to LinkBuilder... |
80 |
|
|
$linkbuilder = new LinkBuilder(); |
81 |
|
|
return $linkbuilder->load($lbid); |
82 |
|
|
} else { |
83 |
|
|
return php::array_join_merge($_GET, $_POST); |
84 |
|
|
} |
85 |
joko |
1.2 |
} |
86 |
|
|
|
87 |
|
|
function get_request_translated() { |
88 |
|
|
return $this->translate_request($this->get_request()); |
89 |
joko |
1.1 |
} |
90 |
|
|
|
91 |
|
|
function perform(&$metadata) { |
92 |
|
|
|
93 |
joko |
1.2 |
$this->metadata = &$metadata; |
94 |
|
|
|
95 |
joko |
1.1 |
//print "model: " . Dumper($metadata); |
96 |
|
|
//print "request: " . Dumper($this->get_request()); |
97 |
joko |
1.2 |
$request_translated = $this->get_request_translated(); |
98 |
joko |
1.1 |
|
99 |
|
|
// trace |
100 |
|
|
//print Dumper($request_mapped); |
101 |
|
|
//exit; |
102 |
|
|
|
103 |
|
|
// 2. rule it! mungle request through dispatching rules - lambda-style callbacks |
104 |
|
|
$results = array(); |
105 |
|
|
foreach ($this->_rules as $rule) { |
106 |
|
|
//$in = array(); |
107 |
joko |
1.2 |
$in = $request_translated; |
108 |
joko |
1.1 |
$out = array(); |
109 |
|
|
call_user_func($rule, &$in, &$out); |
110 |
|
|
array_push($results, array( in => $in, out => $out)); |
111 |
|
|
} |
112 |
|
|
|
113 |
|
|
// trace |
114 |
|
|
//print Dumper($results); |
115 |
|
|
//exit; |
116 |
|
|
|
117 |
|
|
// 3. merge it! merge dispatching output ($_out!) |
118 |
|
|
$final = array(); |
119 |
|
|
foreach ($results as $result) { |
120 |
|
|
//print Dumper($result[out]); |
121 |
joko |
1.2 |
$final = php::array_join_merge($final, $result[out]); |
122 |
joko |
1.1 |
} |
123 |
|
|
|
124 |
|
|
// trace |
125 |
joko |
1.2 |
//print "final: " . Dumper($final); |
126 |
joko |
1.1 |
//exit; |
127 |
|
|
|
128 |
|
|
return $final; |
129 |
|
|
|
130 |
|
|
} |
131 |
|
|
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
} |
135 |
|
|
|
136 |
|
|
?> |