/[cvs]/nfo/php/libs/org.netfrag.app/WebExplorer/Module/AbstractGUIModule.php
ViewVC logotype

Annotation of /nfo/php/libs/org.netfrag.app/WebExplorer/Module/AbstractGUIModule.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (hide annotations)
Fri Apr 18 13:31:48 2003 UTC (21 years, 4 months ago) by jonen
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +25 -9 lines
+ Now hidden elements could be given to the constructor as $args['hidden_elements'],
   which is needed special for not-real object instancation in inhiterated child objects
   (e.g. AbstractNavigationList, etc.)
+ For real object instances at inhiterated objects
   an api function 'add_hidden_element' could be used after this object is instanced
  (e.g DataList, DataItem, etc.).

1 jonen 1.1 <?
2     /*
3     ## -----------------------------------------------------------------------------
4 jonen 1.8 ## $Id: AbstractGUIModule.php,v 1.7 2003/04/16 16:15:27 joko Exp $
5 jonen 1.1 ## -----------------------------------------------------------------------------
6 jonen 1.2 ## $Log: AbstractGUIModule.php,v $
7 jonen 1.8 ## Revision 1.7 2003/04/16 16:15:27 joko
8     ## behavior fix to 'function add_hidden_element': just calling 'add_hidden_element' on core instance of it provides this method
9     ##
10 joko 1.7 ## Revision 1.6 2003/04/10 06:19:33 joko
11     ## minor fix: prevent use of undefined instance
12     ##
13 joko 1.6 ## Revision 1.5 2003/04/07 22:29:27 jonen
14     ## + minor changes
15     ##
16 jonen 1.5 ## Revision 1.4 2003/04/05 21:17:51 joko
17     ## extends Class::Abstract (for being able to call '_abstract_method' on it)
18     ##
19 joko 1.4 ## Revision 1.3 2003/04/04 00:56:08 jonen
20     ## + add 'mungle_adapter' function
21     ##
22 jonen 1.3 ## Revision 1.2 2003/03/20 07:56:18 jonen
23     ## + added docu
24     ##
25 jonen 1.2 ## Revision 1.1 2003/03/20 03:49:22 jonen
26     ## + initial commit
27     ##
28 jonen 1.1 ## Revision 1.1 2003/03/01 22:57:23 cvsmax
29     ## + inital commit
30     ##
31     ##
32     ## -----------------------------------------------------------------------------
33     */
34    
35 joko 1.4
36     /**
37     * required only for $this->_abstract_method({methodname})
38     * can later be used or not without any problems or further
39     * dependencies since this is an abstract base class at the
40     * very top of the inheritance hierarchy.
41     *
42     */
43     loadModule('Class::Abstract');
44    
45 jonen 1.1 /**
46     * AbstractGUIModule class provides an simple way to create new modules
47     * for the Explorer, eg navigation or data browsing elements.
48     *
49 jonen 1.2 * @author Sebastian Utz <seut@tunemedia.de>
50     * @package org.netfrag.app
51     * @name WebExplorer::Module::AbstractModule
52 jonen 1.1 */
53 joko 1.4 class WebExplorer_Module_AbstractGUIModule extends Class_Abstract {
54 jonen 1.1
55    
56     /**
57     * most modules needs arguments e.g. data_locator_key, caption etc.
58     */
59     var $_args = array();
60    
61     /**
62 jonen 1.2 * variable thats holds the reference to phphtmllib GUI object
63 jonen 1.1 */
64     var $_gui_object;
65 jonen 1.8
66 jonen 1.1 /**
67     * the contructor
68 jonen 1.8 * hidden elements could be given to the constructor as $args['hidden_elements'],
69     * which is needed special for not-real object instancation in inhiterated child objects
70     * (e.g. AbstractNavigationList, etc.)
71 jonen 1.1 *
72 jonen 1.2 * @params struct - the arguments
73 jonen 1.1 */
74     function WebExplorer_Module_AbstractGUIModule($args = array()) {
75     $this->_args = $args;
76 jonen 1.8
77 jonen 1.5 //print Dumper($this->_gui_object);
78 jonen 1.1 $this->set_gui_object();
79     }
80 jonen 1.2
81 jonen 1.1
82     function set_gui_object() {
83 jonen 1.5 $msg = "AbstractGUIModule::get_gui_object() - Child must override";
84     user_error($msg);
85     return $msg;
86 jonen 1.1 }
87    
88 jonen 1.8 /**
89     * Api function to add hidden elements instead or in addtion to
90     * at constructor given hidden elements.
91     * Note: All hidden elements *must* be loaded *before* $this->get()
92     * is initiated!
93     *
94     */
95     function add_hidden_element($label, $value) {
96     $this->_args['hidden_elements'][$label] = $value;
97 jonen 1.1 }
98 jonen 1.5
99 jonen 1.1
100 jonen 1.8 function _add_hidden_element($label, $value) {
101 joko 1.6 // TODO: review this!
102     if (!$this->_gui_object) { return; }
103 jonen 1.1 //print "Label: $label => $value<br>";
104 joko 1.7
105     // fixed: (alpha, maybe this doesn't work out well...)
106     if (method_exists($this->_gui_object, 'add_hidden_element')) {
107     $this->_gui_object->add_hidden_element($label, $value);
108     }
109 jonen 1.1 }
110    
111 jonen 1.5
112 jonen 1.1 function &get() {
113 jonen 1.8 if(is_array($this->_args['hidden_elements'])) {
114     foreach($this->_args['hidden_elements'] as $label => $value) {
115     $this->_add_hidden_element($label, $value);
116     }
117     }
118    
119 jonen 1.3 if($this->_args['adapter']) {
120     return $this->mungle_adapter($this->_args['adapter']);
121     } else {
122     return $this->_gui_object;
123     }
124     }
125    
126     function mungle_adapter($label) {
127     return php::mkInstance($label, array(&$this->_gui_object));
128 jonen 1.1 }
129    
130 jonen 1.5
131 jonen 1.1 }
132    
133     ?>

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