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