1 |
<?php |
<?php |
|
|
|
2 |
/** |
/** |
3 |
* This file contains the abstract Application::Request::BaseController class. |
* This file contains the abstract Application::Request::BaseController class. |
4 |
* |
* |
5 |
* @author Andreas Motl <andreas.motl@ilo.de> |
* @author Andreas Motl <andreas.motl@ilo.de> |
6 |
* @package org.netfrag.glib |
* @package org.netfrag.glib |
7 |
* @module Application::Request::BaseController |
* @name Application::Request::BaseController |
8 |
* |
* |
9 |
*/ |
*/ |
10 |
|
|
11 |
/** |
/** |
12 |
|
* <b>Cvs-Log:</b> |
13 |
|
* |
14 |
|
* <pre> |
15 |
* $Id$ |
* $Id$ |
16 |
* |
* |
17 |
* $Log$ |
* $Log$ |
18 |
|
* Revision 1.4 2003/03/11 01:22:22 joko |
19 |
|
* + fixed metadata for phpDocumentor |
20 |
|
* |
21 |
|
* Revision 1.3 2003/03/05 18:54:42 joko |
22 |
|
* updated docu - phpDocumentor is very strict about its 'blocks'... |
23 |
|
* |
24 |
|
* Revision 1.2 2003/03/03 21:12:55 joko |
25 |
|
* split up processing into more steps |
26 |
|
* |
27 |
* Revision 1.1 2003/03/01 21:11:18 joko |
* Revision 1.1 2003/03/01 21:11:18 joko |
28 |
* + initial commit |
* + initial commit |
29 |
* |
* </pre> |
30 |
* |
* |
31 |
*/ |
*/ |
32 |
|
|
33 |
|
|
34 |
/** |
/** |
35 |
* --- |
* --- Application::Request::BaseController |
|
* |
|
36 |
* |
* |
37 |
* @author Andreas Motl <andreas.motl@ilo.de> |
* @author Andreas Motl <andreas.motl@ilo.de> |
38 |
* @copyright (c) 2003 - All Rights reserved. |
* @copyright (c) 2003 - All Rights reserved. |
39 |
* @license GNU LGPL (GNU Lesser General Public License) |
* @license GNU LGPL (GNU Lesser General Public License) |
40 |
* |
* |
41 |
* @author-url http://www.netfrag.org/~joko/ |
* @link http://www.netfrag.org/~joko/ |
42 |
* @license-url http://www.gnu.org/licenses/lgpl.txt |
* @link http://www.gnu.org/licenses/lgpl.txt |
43 |
* |
* |
44 |
* @package org.netfrag.glib |
* @package org.netfrag.glib |
45 |
* @module Application::Request::BaseController |
* @subpackage Application |
46 |
|
* @name Application::Request::BaseController |
47 |
* |
* |
48 |
*/ |
*/ |
|
|
|
|
/** |
|
|
* Todo: |
|
|
* |
|
|
* o xyz |
|
|
* o bla, bli, blub |
|
|
* |
|
|
* |
|
|
*/ |
|
|
|
|
|
|
|
|
// isn't required by now: |
|
|
//loadModule('DesignPattern::Object'); |
|
|
//class DesignPattern_MVC extends DesignPattern_Object { |
|
|
|
|
|
//loadModule('DesignPattern::Container'); |
|
49 |
class Application_Request_BaseController { |
class Application_Request_BaseController { |
50 |
|
|
51 |
var $_request = null; |
var $_request = null; |
73 |
} |
} |
74 |
*/ |
*/ |
75 |
|
|
76 |
|
function get_request() { |
77 |
|
$this->_abstract_method('get_request'); |
78 |
|
} |
79 |
|
|
80 |
|
function get_request_translated() { |
81 |
|
$this->_abstract_method('get_request_translated'); |
82 |
|
} |
83 |
|
|
84 |
|
/* |
85 |
|
function translate_request() { |
86 |
|
$this->_abstract_method('translate_request'); |
87 |
|
} |
88 |
|
*/ |
89 |
|
|
90 |
|
function translate_request($request_raw) { |
91 |
|
|
92 |
|
// 1. map it! mungle request and model together - generic processing here! |
93 |
|
// now: translate it! (done in concrete mvc controller now) |
94 |
|
|
95 |
|
$request_translated = array(); |
96 |
|
|
97 |
|
$metadata = $this->metadata; |
98 |
|
|
99 |
|
// check all areas |
100 |
|
foreach ($metadata[request_args] as $area_name) { |
101 |
|
$area_metadata = $metadata[request_arg][$area_name]; |
102 |
|
if ($http_arg_key = $area_metadata[query_arg]) { |
103 |
|
$this->translate_to($request_raw, $http_arg_key, $request_translated, $area_name); |
104 |
|
} |
105 |
|
if ($http_arg_keys = $area_metadata[query_args]) { |
106 |
|
foreach ($http_arg_keys as $key) { |
107 |
|
$this->translate_to($request_raw, $key, $request_translated, $area_name); |
108 |
|
} |
109 |
|
} |
110 |
|
} |
111 |
|
|
112 |
|
if (!sizeof($request_translated)) { |
113 |
|
user_error("MVC Error - HttpController: mapped request is empty!"); |
114 |
|
} |
115 |
|
|
116 |
|
return $request_translated; |
117 |
|
|
118 |
|
} |
119 |
|
|
120 |
|
function translate_to(&$source, $source_key, &$target, $target_key) { |
121 |
|
if (in_array($source_key, array_keys($source))) { |
122 |
|
$target[$target_key] = $source[$source_key]; |
123 |
|
} |
124 |
|
} |
125 |
|
|
126 |
// called from parent context |
// called from parent context |
127 |
function set_request(&$request) { |
function set_request(&$request) { |
128 |
$this->_request = &$request; |
$this->_request = &$request; |
133 |
$this->_rules = &$rules; |
$this->_rules = &$rules; |
134 |
} |
} |
135 |
|
|
136 |
|
/* |
137 |
function &get_request() { |
function &get_request() { |
138 |
return $this->_request; |
return $this->_request; |
139 |
} |
} |
140 |
|
*/ |
141 |
|
|
142 |
} |
} |
143 |
|
|