/[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.2 - (hide annotations)
Wed Mar 5 12:50:44 2003 UTC (21 years, 6 months ago) by joko
Branch: MAIN
Changes since 1.1: +131 -12 lines
added first implementation using this as an Adapter to phpHtmlLib

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

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