/[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.6 - (hide annotations)
Mon Mar 10 23:30:34 2003 UTC (21 years, 6 months ago) by joko
Branch: MAIN
Changes since 1.5: +8 -3 lines
+ fixed metadata for phpDocumentor

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

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