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