| 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.4 2003/03/11 01:22:22 joko |
| 20 |
|
* + fixed metadata for phpDocumentor |
| 21 |
|
* |
| 22 |
|
* Revision 1.3 2003/03/05 18:54:42 joko |
| 23 |
|
* updated docu - phpDocumentor is very strict about its 'blocks'... |
| 24 |
|
* |
| 25 |
|
* Revision 1.2 2003/03/03 21:13:59 joko |
| 26 |
|
* + request translation |
| 27 |
|
* mungled namespaces |
| 28 |
|
* - purged old code |
| 29 |
|
* |
| 30 |
* Revision 1.1 2003/03/01 21:11:18 joko |
* Revision 1.1 2003/03/01 21:11:18 joko |
| 31 |
* + initial commit |
* + initial commit |
| 32 |
* |
* </pre> |
| 33 |
* |
* |
| 34 |
*/ |
*/ |
| 35 |
|
|
| 36 |
|
|
| 37 |
/** |
/** |
| 38 |
* --- |
* This requires the Application::Request::BaseController base class |
| 39 |
|
* |
| 40 |
|
*/ |
| 41 |
|
loadModule('Application::Request::BaseController'); |
| 42 |
|
|
| 43 |
|
/** |
| 44 |
|
* --- Application::Request::HttpController |
| 45 |
* |
* |
| 46 |
|
* Responsible for GET and POST argument handling. |
| 47 |
|
* Does an array_join_merge for now. |
| 48 |
* |
* |
| 49 |
* @author Andreas Motl <andreas.motl@ilo.de> |
* @author Andreas Motl <andreas.motl@ilo.de> |
| 50 |
* @copyright (c) 2003 - All Rights reserved. |
* @copyright (c) 2003 - All Rights reserved. |
| 51 |
* @license GNU LGPL (GNU Lesser General Public License) |
* @license GNU LGPL (GNU Lesser General Public License) |
| 52 |
* |
* |
| 53 |
* @author-url http://www.netfrag.org/~joko/ |
* @link http://www.netfrag.org/~joko/ |
| 54 |
* @license-url http://www.gnu.org/licenses/lgpl.txt |
* @link http://www.gnu.org/licenses/lgpl.txt |
| 55 |
* |
* |
| 56 |
* @package org.netfrag.glib |
* @package org.netfrag.glib |
| 57 |
* @module Application::Request::HttpController |
* @subpackage Application |
| 58 |
* |
* @name Application::Request::HttpController |
|
*/ |
|
|
|
|
|
/** |
|
|
* Todo: |
|
|
* |
|
|
* o xyz |
|
|
* o bla, bli, blub |
|
|
* |
|
| 59 |
* |
* |
| 60 |
*/ |
*/ |
|
|
|
|
|
|
|
loadModule('Application::Request::BaseController'); |
|
| 61 |
class Application_Request_HttpController extends Application_Request_BaseController { |
class Application_Request_HttpController extends Application_Request_BaseController { |
| 62 |
|
|
| 63 |
/** |
/** |
| 74 |
} |
} |
| 75 |
|
|
| 76 |
function get_request() { |
function get_request() { |
| 77 |
return array_join_merge($_GET, $_POST); |
return php::array_join_merge($_GET, $_POST); |
| 78 |
|
} |
| 79 |
|
|
| 80 |
|
function get_request_translated() { |
| 81 |
|
return $this->translate_request($this->get_request()); |
| 82 |
} |
} |
| 83 |
|
|
| 84 |
function perform(&$metadata) { |
function perform(&$metadata) { |
| 85 |
|
|
| 86 |
|
$this->metadata = &$metadata; |
| 87 |
|
|
| 88 |
//print "model: " . Dumper($metadata); |
//print "model: " . Dumper($metadata); |
| 89 |
//print "request: " . Dumper($this->get_request()); |
//print "request: " . Dumper($this->get_request()); |
| 90 |
$request_raw = $this->get_request(); |
$request_translated = $this->get_request_translated(); |
| 91 |
|
|
|
// 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]; |
|
|
} |
|
|
} |
|
|
|
|
| 92 |
// trace |
// trace |
| 93 |
//print Dumper($request_mapped); |
//print Dumper($request_mapped); |
| 94 |
//exit; |
//exit; |
| 95 |
|
|
|
/* |
|
|
|
|
|
// 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>"; |
|
|
|
|
|
*/ |
|
|
|
|
| 96 |
// 2. rule it! mungle request through dispatching rules - lambda-style callbacks |
// 2. rule it! mungle request through dispatching rules - lambda-style callbacks |
| 97 |
$results = array(); |
$results = array(); |
| 98 |
foreach ($this->_rules as $rule) { |
foreach ($this->_rules as $rule) { |
| 99 |
//$in = array(); |
//$in = array(); |
| 100 |
$in = $request_mapped; |
$in = $request_translated; |
| 101 |
$out = array(); |
$out = array(); |
| 102 |
call_user_func($rule, &$in, &$out); |
call_user_func($rule, &$in, &$out); |
| 103 |
array_push($results, array( in => $in, out => $out)); |
array_push($results, array( in => $in, out => $out)); |
| 111 |
$final = array(); |
$final = array(); |
| 112 |
foreach ($results as $result) { |
foreach ($results as $result) { |
| 113 |
//print Dumper($result[out]); |
//print Dumper($result[out]); |
| 114 |
$final = array_join_merge($final, $result[out]); |
$final = php::array_join_merge($final, $result[out]); |
| 115 |
} |
} |
| 116 |
|
|
| 117 |
// trace |
// trace |
| 118 |
//print Dumper($final); |
//print "final: " . Dumper($final); |
| 119 |
//exit; |
//exit; |
| 120 |
|
|
| 121 |
return $final; |
return $final; |