/[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.3 - (hide annotations)
Wed Mar 5 17:13:18 2003 UTC (21 years, 6 months ago) by joko
Branch: MAIN
Changes since 1.2: +25 -17 lines
updated docu (phpDocumentor testing....)

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

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