1 |
joko |
1.1 |
<? |
2 |
|
|
/** |
3 |
joko |
1.2 |
* This file contains an adapter class called |
4 |
|
|
* Site::Adapter::phpHtmlLib::PageWidget. |
5 |
joko |
1.1 |
* It inherits from phpHtmlLib's abstract PageWidget |
6 |
|
|
* class to seamlessly integrate into its render queue. |
7 |
|
|
* |
8 |
|
|
* @author Andreas Motl <andreas.motl@ilo.de> |
9 |
joko |
1.2 |
* @package org.netfrag.glib |
10 |
joko |
1.3 |
* @name Site::Adapter::phpHtmlLib::PageWidget |
11 |
joko |
1.1 |
* |
12 |
joko |
1.3 |
* |
13 |
|
|
* |
14 |
|
|
* |
15 |
|
|
* <b>Cvs-Log:</b> |
16 |
|
|
* |
17 |
|
|
* <pre> |
18 |
joko |
1.5 |
* $Id: PageWidget.php,v 1.4 2003/03/10 00:34:56 joko Exp $ |
19 |
joko |
1.2 |
* |
20 |
|
|
* $Log: PageWidget.php,v $ |
21 |
joko |
1.5 |
* Revision 1.4 2003/03/10 00:34:56 joko |
22 |
|
|
* + additional metadata for Autodia |
23 |
|
|
* |
24 |
joko |
1.4 |
* Revision 1.3 2003/03/05 17:13:18 joko |
25 |
|
|
* updated docu (phpDocumentor testing....) |
26 |
|
|
* |
27 |
joko |
1.3 |
* Revision 1.2 2003/03/05 12:50:44 joko |
28 |
|
|
* added first implementation using this as an Adapter to phpHtmlLib |
29 |
|
|
* |
30 |
joko |
1.2 |
* Revision 1.1 2003/03/03 22:11:32 joko |
31 |
|
|
* + initial commit |
32 |
joko |
1.3 |
* </pre> |
33 |
joko |
1.1 |
* |
34 |
|
|
* |
35 |
|
|
*/ |
36 |
|
|
|
37 |
|
|
|
38 |
|
|
/** |
39 |
joko |
1.3 |
* Make sure we have the required parent class |
40 |
|
|
*/ |
41 |
|
|
//loadModule('DesignPattern::MVC'); |
42 |
|
|
//require_once($phphtmllib."/widgets/PageWidget.inc"); |
43 |
|
|
|
44 |
|
|
|
45 |
|
|
/** |
46 |
|
|
* forget about the MVC stuff at this level by now --- |
47 |
joko |
1.2 |
* |
48 |
joko |
1.3 |
* <pre> |
49 |
joko |
1.2 |
* --- The way to MVC.... |
50 |
|
|
* o refactor this making calls to components only!!! |
51 |
|
|
* o refactor this using a MVC dispatcher dispatching any n arguments ... |
52 |
|
|
* to any n pageblocks having n widgets connected to n datasources. |
53 |
|
|
* this scope is: arguments from parent mvc -> pageblock |
54 |
joko |
1.3 |
* </pre> |
55 |
joko |
1.2 |
* |
56 |
joko |
1.1 |
* This class is used to build content |
57 |
joko |
1.2 |
* for an (MVC) controlled page. It instantiates |
58 |
joko |
1.1 |
* an concrete helper MVC object which does the |
59 |
|
|
* dispatching stuff. (phpHtmlLib::controller::WebMVC, |
60 |
|
|
* inherited from the abstract DesignPattern::MVC) |
61 |
|
|
* |
62 |
|
|
* This class is established here to act as a wrapper |
63 |
|
|
* bringing MVC and phpHtmlLib together. |
64 |
|
|
* |
65 |
|
|
* By now we inherit from the PageWidget, but this has |
66 |
|
|
* to be broken using the ProxyPattern or s.th.l.th. |
67 |
|
|
* I guess we'll have to dispatch to arbitrary concrete |
68 |
|
|
* Page-implementations here in future... |
69 |
|
|
* |
70 |
|
|
* @author Andreas Motl <andreas.motl@ilo.de> |
71 |
joko |
1.2 |
* @package org.netfrag.glib |
72 |
joko |
1.3 |
* @subpackage Site |
73 |
|
|
* @name Site::Adapter::phpHtmlLib::PageWidget |
74 |
joko |
1.1 |
* |
75 |
|
|
*/ |
76 |
|
|
//class Site_WebPageMVC extends PageWidget { |
77 |
|
|
class Site_Adapter_phpHtmlLib_PageWidget extends PageWidget { |
78 |
|
|
|
79 |
joko |
1.2 |
var $_arguments; |
80 |
|
|
|
81 |
joko |
1.1 |
function Site_Adapter_phpHtmlLib_PageWidget($args = array()) { |
82 |
|
|
|
83 |
joko |
1.2 |
$this->_arguments = $args; |
84 |
|
|
|
85 |
joko |
1.1 |
// trace |
86 |
|
|
//print Dumper($args); |
87 |
|
|
//exit; |
88 |
|
|
|
89 |
|
|
//$this->PageWidget( $title, $render_type ); |
90 |
|
|
//$this->PageWidget( 'Hello World!', HTML ); |
91 |
|
|
$this->PageWidget( $args[title], HTML ); |
92 |
|
|
|
93 |
joko |
1.2 |
|
94 |
|
|
// --- branding --- |
95 |
|
|
//add some css links |
96 |
|
|
//assuming that phphtmllib is installed in the doc root |
97 |
|
|
$this->add_css_link("inc/css/main.css"); |
98 |
|
|
$this->add_css_link("inc/css/fonts.css"); |
99 |
|
|
$this->add_css_link("inc/css/colors.css"); |
100 |
|
|
//add the phphtmllib widget css |
101 |
|
|
$this->add_css_link( "inc/css/redtheme.php" ); |
102 |
|
|
// --- branding --- |
103 |
|
|
|
104 |
joko |
1.1 |
} |
105 |
|
|
|
106 |
|
|
function body_content() { |
107 |
|
|
|
108 |
|
|
$master_div = html_div(); |
109 |
|
|
$master_div->set_style('border:1px solid black;'); |
110 |
|
|
|
111 |
|
|
//add the header area |
112 |
|
|
$master_div->add( html_comment( "HEADER BLOCK BEGIN") ); |
113 |
|
|
$master_div->add( $this->header_block() ); |
114 |
|
|
$master_div->add( html_comment( "HEADER BLOCK END") ); |
115 |
|
|
|
116 |
|
|
//add it to the page |
117 |
|
|
//build the outer wrapper div |
118 |
|
|
//that everything will live under |
119 |
|
|
$wrapper_div = html_div(); |
120 |
|
|
$wrapper_div->set_id( "phphtmllib" ); |
121 |
|
|
$wrapper_div->set_style('border:1px solid blue;'); |
122 |
|
|
|
123 |
|
|
//add the main body |
124 |
|
|
$wrapper_div->add( html_comment( "MAIN BLOCK BEGIN") ); |
125 |
|
|
$wrapper_div->add( $this->main_block() ); |
126 |
|
|
$wrapper_div->add( html_comment( "MAIN BLOCK END") ); |
127 |
|
|
|
128 |
|
|
$master_div->add( $wrapper_div ); |
129 |
|
|
|
130 |
|
|
//add the footer area. |
131 |
|
|
$master_div->add( html_comment( "FOOTER BLOCK BEGIN") ); |
132 |
|
|
$master_div->add( $this->footer_block() ); |
133 |
|
|
$master_div->add( html_comment( "FOOTER BLOCK END") ); |
134 |
|
|
|
135 |
|
|
$this->add($master_div); |
136 |
|
|
|
137 |
|
|
} |
138 |
|
|
|
139 |
|
|
/** |
140 |
|
|
* We override this method to automatically |
141 |
|
|
* break up the main block into a |
142 |
|
|
* left block and a right block |
143 |
|
|
* |
144 |
|
|
* @param TABLEtag object. |
145 |
|
|
*/ |
146 |
|
|
function main_block() { |
147 |
|
|
|
148 |
|
|
$main = html_div(); |
149 |
|
|
$main->set_id("maincontent"); |
150 |
|
|
|
151 |
|
|
$table = html_table("100%",0); |
152 |
|
|
$left_div = html_div("leftblock", $this->left_block() ); |
153 |
|
|
|
154 |
|
|
$table->add_row( html_td("leftblock", "", $left_div ), |
155 |
|
|
html_td("divider", "", " "), |
156 |
|
|
html_td("rightblock", "", $this->content_block() )); |
157 |
|
|
$main->add( $table ); |
158 |
|
|
|
159 |
|
|
return $main; |
160 |
|
|
} |
161 |
|
|
|
162 |
|
|
|
163 |
|
|
function header_block() { |
164 |
joko |
1.2 |
|
165 |
|
|
// Site::WebBlock is a TransparentProxy which resolves |
166 |
|
|
// the argument 'adapter' as a key identifying a |
167 |
|
|
// further component, an Adapter. |
168 |
|
|
// Adapters "adapt" foreign frameworks by sitting in their |
169 |
|
|
// respective inheritance trees adding bridging infrastructure |
170 |
|
|
// to have a consistent interface to them. |
171 |
|
|
// -> compare: Yakka's StorageAdapters |
172 |
|
|
|
173 |
|
|
// php_class gets resolved to an Adapter "Site::Adapter::php::Class", |
174 |
|
|
// which itself is a TransparentProxy again. |
175 |
|
|
// This way, it can re-dispatch you the payload as a phpHtmlLib Widget |
176 |
|
|
// object (AbstractGuiModule|GenericDataWidget) |
177 |
|
|
// This is part of the second layer and should become part of the |
178 |
|
|
// XyzExplorer. |
179 |
|
|
|
180 |
joko |
1.4 |
/** |
181 |
|
|
* <!-- Autodia --> |
182 |
|
|
* can do: (this is metadata supplied for Autodia, don't delete!) |
183 |
|
|
* $comp = new Site_WebBlock() |
184 |
|
|
* |
185 |
|
|
*/ |
186 |
|
|
|
187 |
joko |
1.2 |
$comp = php::mkComponent('Site::WebBlock', |
188 |
|
|
array( adapter => 'php_class', block => array( |
189 |
|
|
_module => 'TsPage', |
190 |
|
|
_function => 'header_block', |
191 |
|
|
//_arguments => array( 'Site::WebBlock - TsPage - header_block' ), |
192 |
|
|
_arguments => $this->_arguments['title'], |
193 |
|
|
_metadata => array( |
194 |
|
|
_component_address => 'Site::WebBlock > TsPage > header_block', |
195 |
|
|
), |
196 |
|
|
) ) |
197 |
|
|
); |
198 |
|
|
|
199 |
|
|
// trace |
200 |
|
|
//print Dumper($comp); |
201 |
|
|
//exit; |
202 |
|
|
|
203 |
|
|
// this makes the component transparent |
204 |
|
|
// here: will be casted to a phpHtmlLib-object to |
205 |
|
|
// seamlessly integrate into its rendering queue |
206 |
|
|
//$comp = $comp->make_transparent(); |
207 |
|
|
$comp->make_transparent(); |
208 |
|
|
|
209 |
|
|
return container( $comp ); |
210 |
|
|
//return container( "HEADER BLOCK" ); |
211 |
joko |
1.1 |
} |
212 |
|
|
|
213 |
|
|
function footer_block() { |
214 |
joko |
1.4 |
|
215 |
|
|
/** |
216 |
|
|
* <!-- Autodia --> |
217 |
|
|
* can do: (this is metadata supplied for Autodia, don't delete!) |
218 |
|
|
* $comp = new Site_WebBlock() |
219 |
|
|
* |
220 |
|
|
*/ |
221 |
|
|
|
222 |
joko |
1.2 |
$comp = php::mkComponent('Site::WebBlock', |
223 |
|
|
array( adapter => 'php_object', block => array( |
224 |
|
|
_module => 'TsPage', |
225 |
|
|
_function => 'footer_block', |
226 |
|
|
//_arguments => array( 'Site::WebBlock - TsPage - header_block' ), |
227 |
|
|
_arguments => $this->_arguments['title'], |
228 |
|
|
_metadata => array( |
229 |
|
|
_component_address => 'Site::WebBlock > TsPage > footer_block', |
230 |
|
|
), |
231 |
|
|
) ) |
232 |
|
|
); |
233 |
|
|
$comp->make_transparent(); |
234 |
|
|
return container( $comp ); |
235 |
joko |
1.1 |
} |
236 |
|
|
|
237 |
|
|
function left_block() { |
238 |
joko |
1.2 |
$comp = php::mkComponent('Site::WebBlock', |
239 |
|
|
array( adapter => 'php_file', block => array(name => 'olist', part => 'left') ) |
240 |
|
|
); |
241 |
|
|
$comp->make_transparent(); |
242 |
|
|
return container( $comp ); |
243 |
joko |
1.1 |
} |
244 |
|
|
|
245 |
|
|
function content_block() { |
246 |
|
|
//$this->add( "CONTENT BLOCK" ); |
247 |
joko |
1.2 |
//return container( "CONTENT BLOCK" ); |
248 |
|
|
|
249 |
|
|
// FIXME: dispatch to olist or oedit here! (what about o(item)view or olist*edit*?) |
250 |
|
|
// new proposal: (two fold) |
251 |
|
|
// entity-mode: List, Item (rename/correlate "entity-mode" to "widget-type"?) |
252 |
|
|
// action-mode: view, edit, new |
253 |
|
|
|
254 |
|
|
// => each generic data widget component (MVC-View) has to get: |
255 |
|
|
// - a locator: describing or embedding a DataSourceXyz) |
256 |
|
|
// - a query: actually a select-query leading to a result should be required for display - insert or update-actions are in a different scope) |
257 |
|
|
// - an entity-mode: which AbstractGuiModule|GenericDataWidget to choose for this Block |
258 |
|
|
// -> could this be wrapped into some processing rules...? (MVC!) |
259 |
|
|
// -> switch ($entity_mode) { 'Item|List|Tree' } |
260 |
|
|
// - an action-mode: in which mode is this module/widget/block? |
261 |
|
|
// - a "view" requires a DataSource::Data::Fetch *before* |
262 |
|
|
// - an "edit" requires a DataSource::Data::Fetch *before* and a DataSource::Data::Store *afterwards* |
263 |
|
|
// - a "new" requires a DataSource::Schema::Fetch *before* and a DataSource::Data::Store *afterwards* |
264 |
|
|
// -> could this be wrapped into some processing rules...? (MVC!) |
265 |
|
|
// -> switch ($action_mode) { 'view|edit|new' } |
266 |
|
|
|
267 |
|
|
// first proposal implementation using... |
268 |
|
|
// a) lots of stuff from the php:: - namespace under the hood |
269 |
|
|
// b) some attempts to implement some abstract |
270 |
|
|
// software design patterns into some concrete |
271 |
|
|
// software components living in the "DesignPattern" namespace |
272 |
|
|
// at org.netfrag.glib (http://cvs.netfrag.org/nfo/php/libs/org.netfrag.glib) |
273 |
|
|
|
274 |
|
|
$comp = php::mkComponent('Site::WebBlock', |
275 |
|
|
array( adapter => 'php_file', block => array(name => 'olist', part => 'content') ) |
276 |
|
|
); |
277 |
|
|
|
278 |
|
|
// this actually triggers loading the block from the file |
279 |
|
|
// following certain rules hidden elsewhere (hmmm...., where?) |
280 |
|
|
// TODO: document this here! |
281 |
|
|
// TODO: refactor this to the php::Class - Adapter!!! |
282 |
|
|
$comp->make_transparent(); |
283 |
|
|
return container( $comp ); |
284 |
|
|
|
285 |
joko |
1.1 |
} |
286 |
|
|
|
287 |
|
|
|
288 |
|
|
} |
289 |
|
|
|
290 |
|
|
?> |