5 |
* |
* |
6 |
* @author Andreas Motl <andreas.motl@ilo.de> |
* @author Andreas Motl <andreas.motl@ilo.de> |
7 |
* @package org.netfrag.glib |
* @package org.netfrag.glib |
8 |
* @module Application::Request::HttpController |
* @name Application::Request::HttpController |
9 |
* |
* |
10 |
*/ |
*/ |
11 |
|
|
12 |
/** |
/** |
13 |
|
* <b>Cvs-Log:</b> |
14 |
|
* |
15 |
|
* <pre> |
16 |
* $Id$ |
* $Id$ |
17 |
* |
* |
18 |
* $Log$ |
* $Log$ |
19 |
|
* Revision 1.6 2003/04/06 04:27:45 joko |
20 |
|
* shortcut for LinkBuilder |
21 |
|
* |
22 |
|
* Revision 1.5 2003/04/06 01:39:32 jonen |
23 |
|
* + now, ask LinkBuilder for GET vars if linkbuilder-ID exists at GET var(s) |
24 |
|
* |
25 |
|
* Revision 1.4 2003/03/11 01:22:22 joko |
26 |
|
* + fixed metadata for phpDocumentor |
27 |
|
* |
28 |
|
* Revision 1.3 2003/03/05 18:54:42 joko |
29 |
|
* updated docu - phpDocumentor is very strict about its 'blocks'... |
30 |
|
* |
31 |
|
* Revision 1.2 2003/03/03 21:13:59 joko |
32 |
|
* + request translation |
33 |
|
* mungled namespaces |
34 |
|
* - purged old code |
35 |
|
* |
36 |
* Revision 1.1 2003/03/01 21:11:18 joko |
* Revision 1.1 2003/03/01 21:11:18 joko |
37 |
* + initial commit |
* + initial commit |
38 |
* |
* </pre> |
39 |
* |
* |
40 |
*/ |
*/ |
41 |
|
|
42 |
|
|
43 |
/** |
/** |
44 |
* --- |
* This requires the Application::Request::BaseController base class |
45 |
* |
* |
46 |
|
*/ |
47 |
|
loadModule('Application::Request::BaseController'); |
48 |
|
|
49 |
|
/** |
50 |
|
* --- Application::Request::HttpController |
51 |
|
* |
52 |
|
* Responsible for GET and POST argument handling. |
53 |
|
* Does an array_join_merge for now. |
54 |
* |
* |
55 |
* @author Andreas Motl <andreas.motl@ilo.de> |
* @author Andreas Motl <andreas.motl@ilo.de> |
56 |
* @copyright (c) 2003 - All Rights reserved. |
* @copyright (c) 2003 - All Rights reserved. |
57 |
* @license GNU LGPL (GNU Lesser General Public License) |
* @license GNU LGPL (GNU Lesser General Public License) |
58 |
* |
* |
59 |
* @author-url http://www.netfrag.org/~joko/ |
* @link http://www.netfrag.org/~joko/ |
60 |
* @license-url http://www.gnu.org/licenses/lgpl.txt |
* @link http://www.gnu.org/licenses/lgpl.txt |
61 |
* |
* |
62 |
* @package org.netfrag.glib |
* @package org.netfrag.glib |
63 |
* @module Application::Request::HttpController |
* @subpackage Application |
64 |
* |
* @name Application::Request::HttpController |
|
*/ |
|
|
|
|
|
/** |
|
|
* Todo: |
|
|
* |
|
|
* o xyz |
|
|
* o bla, bli, blub |
|
|
* |
|
65 |
* |
* |
66 |
*/ |
*/ |
|
|
|
|
|
|
|
loadModule('Application::Request::BaseController'); |
|
67 |
class Application_Request_HttpController extends Application_Request_BaseController { |
class Application_Request_HttpController extends Application_Request_BaseController { |
68 |
|
|
69 |
/** |
/** |
80 |
} |
} |
81 |
|
|
82 |
function get_request() { |
function get_request() { |
83 |
return array_join_merge($_GET, $_POST); |
// FIXME!? |
84 |
|
if ($lbid = $_GET[lbid]) { |
85 |
|
// talk to LinkBuilder... |
86 |
|
require_once('utils/links.php'); |
87 |
|
return link::restore($lbid); |
88 |
|
} else { |
89 |
|
return php::array_join_merge($_GET, $_POST); |
90 |
|
} |
91 |
|
} |
92 |
|
|
93 |
|
function get_request_translated() { |
94 |
|
return $this->translate_request($this->get_request()); |
95 |
} |
} |
96 |
|
|
97 |
function perform(&$metadata) { |
function perform(&$metadata) { |
98 |
|
|
99 |
|
$this->metadata = &$metadata; |
100 |
|
|
101 |
//print "model: " . Dumper($metadata); |
//print "model: " . Dumper($metadata); |
102 |
//print "request: " . Dumper($this->get_request()); |
//print "request: " . Dumper($this->get_request()); |
103 |
$request_raw = $this->get_request(); |
$request_translated = $this->get_request_translated(); |
104 |
|
|
|
// 1. map it! mungle request and model together - generic processing here! |
|
|
$request_mapped = array(); |
|
|
|
|
|
// check all areas |
|
|
foreach ($metadata[areas] as $area_name) { |
|
|
$area_metadata = $metadata[area][$area_name]; |
|
|
$http_arg_key = $area_metadata[query_arg]; |
|
|
if (in_array($http_arg_key, array_keys($request_raw))) { |
|
|
$request_mapped[$area_name] = $request_raw[$http_arg_key]; |
|
|
} |
|
|
} |
|
|
|
|
105 |
// trace |
// trace |
106 |
//print Dumper($request_mapped); |
//print Dumper($request_mapped); |
107 |
//exit; |
//exit; |
108 |
|
|
|
/* |
|
|
|
|
|
// set default identifier if still empty |
|
|
if ($page_ident = $this->request['ap']) { |
|
|
$this->_pageIdent = $page_ident; |
|
|
|
|
|
} elseif ($topic_ident = $this->request['t']) { |
|
|
$this->_topicIdent = $topic_ident; |
|
|
|
|
|
} else { |
|
|
$this->_pageIdent = 'overview'; |
|
|
$this->_topicIdent = ''; |
|
|
} |
|
|
|
|
|
//print "ident: " . $this->_pageIdent . "<br>"; |
|
|
|
|
|
*/ |
|
|
|
|
109 |
// 2. rule it! mungle request through dispatching rules - lambda-style callbacks |
// 2. rule it! mungle request through dispatching rules - lambda-style callbacks |
110 |
$results = array(); |
$results = array(); |
111 |
foreach ($this->_rules as $rule) { |
foreach ($this->_rules as $rule) { |
112 |
//$in = array(); |
//$in = array(); |
113 |
$in = $request_mapped; |
$in = $request_translated; |
114 |
$out = array(); |
$out = array(); |
115 |
call_user_func($rule, &$in, &$out); |
call_user_func($rule, &$in, &$out); |
116 |
array_push($results, array( in => $in, out => $out)); |
array_push($results, array( in => $in, out => $out)); |
124 |
$final = array(); |
$final = array(); |
125 |
foreach ($results as $result) { |
foreach ($results as $result) { |
126 |
//print Dumper($result[out]); |
//print Dumper($result[out]); |
127 |
$final = array_join_merge($final, $result[out]); |
$final = php::array_join_merge($final, $result[out]); |
128 |
} |
} |
129 |
|
|
130 |
// trace |
// trace |
131 |
//print Dumper($final); |
//print "final: " . Dumper($final); |
132 |
//exit; |
//exit; |
133 |
|
|
134 |
return $final; |
return $final; |