/[cvs]/nfo/php/libs/org.netfrag.glib/Site/Adapter/phpHtmlLib/PageWidget.php
ViewVC logotype

Annotation of /nfo/php/libs/org.netfrag.glib/Site/Adapter/phpHtmlLib/PageWidget.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (hide annotations)
Thu Mar 20 07:23:22 2003 UTC (21 years, 6 months ago) by jonen
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +10 -2 lines
+ added docu

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 joko 1.6 */
14    
15    
16     /**
17 joko 1.3 * <b>Cvs-Log:</b>
18     *
19     * <pre>
20 jonen 1.7 * $Id: PageWidget.php,v 1.6 2003/03/10 23:30:34 joko Exp $
21 joko 1.2 *
22     * $Log: PageWidget.php,v $
23 jonen 1.7 * Revision 1.6 2003/03/10 23:30:34 joko
24     * + fixed metadata for phpDocumentor
25     *
26 joko 1.6 * Revision 1.5 2003/03/10 22:31:59 joko
27     * + fixed metadata for phpDocumentor
28     *
29 joko 1.5 * Revision 1.4 2003/03/10 00:34:56 joko
30     * + additional metadata for Autodia
31     *
32 joko 1.4 * Revision 1.3 2003/03/05 17:13:18 joko
33     * updated docu (phpDocumentor testing....)
34     *
35 joko 1.3 * Revision 1.2 2003/03/05 12:50:44 joko
36     * added first implementation using this as an Adapter to phpHtmlLib
37     *
38 joko 1.2 * Revision 1.1 2003/03/03 22:11:32 joko
39     * + initial commit
40 joko 1.3 * </pre>
41 joko 1.1 *
42     *
43     */
44    
45    
46     /**
47 joko 1.3 * 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 joko 1.2 *
56 joko 1.3 * <pre>
57 joko 1.2 * --- 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 joko 1.3 * </pre>
63 joko 1.2 *
64 joko 1.1 * This class is used to build content
65 joko 1.2 * for an (MVC) controlled page. It instantiates
66 joko 1.1 * 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 joko 1.2 * @package org.netfrag.glib
80 joko 1.3 * @subpackage Site
81     * @name Site::Adapter::phpHtmlLib::PageWidget
82 joko 1.1 *
83     */
84     //class Site_WebPageMVC extends PageWidget {
85     class Site_Adapter_phpHtmlLib_PageWidget extends PageWidget {
86    
87 joko 1.2 var $_arguments;
88    
89 joko 1.1 function Site_Adapter_phpHtmlLib_PageWidget($args = array()) {
90    
91 joko 1.2 $this->_arguments = $args;
92    
93 joko 1.1 // 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 joko 1.2
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 joko 1.1 }
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", "", "&nbsp;"),
164     html_td("rightblock", "", $this->content_block() ));
165     $main->add( $table );
166    
167     return $main;
168     }
169    
170    
171     function header_block() {
172 joko 1.2
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 joko 1.4 /**
189     * <!-- Autodia -->
190     * can do: (this is metadata supplied for Autodia, don't delete!)
191     * $comp = new Site_WebBlock()
192     *
193     */
194    
195 joko 1.2 $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 joko 1.1 }
220    
221     function footer_block() {
222 joko 1.4
223     /**
224     * <!-- Autodia -->
225     * can do: (this is metadata supplied for Autodia, don't delete!)
226     * $comp = new Site_WebBlock()
227     *
228     */
229    
230 joko 1.2 $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 joko 1.1 }
244    
245     function left_block() {
246 joko 1.2 $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 joko 1.1 }
252    
253     function content_block() {
254     //$this->add( "CONTENT BLOCK" );
255 joko 1.2 //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 jonen 1.7 // V1 - make a component returned from a include file - "PluginProposal"
283 joko 1.2 $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 jonen 1.7
292     // V2 - make a component returned from a ....
293     // print Dumper($this);
294     // $comp = $explorer->get_ecom("content");
295    
296 joko 1.2 return container( $comp );
297    
298 joko 1.1 }
299    
300    
301     }
302    
303     ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed