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