| 1 |
<? |
| 2 |
/* |
| 3 |
## ----------------------------------------------------------------------------- |
| 4 |
## $Id: AbstractGUIModule.php,v 1.7 2003/04/16 16:15:27 joko Exp $ |
| 5 |
## ----------------------------------------------------------------------------- |
| 6 |
## $Log: AbstractGUIModule.php,v $ |
| 7 |
## 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 |
## Revision 1.6 2003/04/10 06:19:33 joko |
| 11 |
## minor fix: prevent use of undefined instance |
| 12 |
## |
| 13 |
## Revision 1.5 2003/04/07 22:29:27 jonen |
| 14 |
## + minor changes |
| 15 |
## |
| 16 |
## 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 |
## Revision 1.3 2003/04/04 00:56:08 jonen |
| 20 |
## + add 'mungle_adapter' function |
| 21 |
## |
| 22 |
## Revision 1.2 2003/03/20 07:56:18 jonen |
| 23 |
## + added docu |
| 24 |
## |
| 25 |
## Revision 1.1 2003/03/20 03:49:22 jonen |
| 26 |
## + initial commit |
| 27 |
## |
| 28 |
## Revision 1.1 2003/03/01 22:57:23 cvsmax |
| 29 |
## + inital commit |
| 30 |
## |
| 31 |
## |
| 32 |
## ----------------------------------------------------------------------------- |
| 33 |
*/ |
| 34 |
|
| 35 |
|
| 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 |
/** |
| 46 |
* AbstractGUIModule class provides an simple way to create new modules |
| 47 |
* for the Explorer, eg navigation or data browsing elements. |
| 48 |
* |
| 49 |
* @author Sebastian Utz <seut@tunemedia.de> |
| 50 |
* @package org.netfrag.app |
| 51 |
* @name WebExplorer::Module::AbstractModule |
| 52 |
*/ |
| 53 |
class WebExplorer_Module_AbstractGUIModule extends Class_Abstract { |
| 54 |
|
| 55 |
|
| 56 |
/** |
| 57 |
* most modules needs arguments e.g. data_locator_key, caption etc. |
| 58 |
*/ |
| 59 |
var $_args = array(); |
| 60 |
|
| 61 |
/** |
| 62 |
* variable thats holds the reference to phphtmllib GUI object |
| 63 |
*/ |
| 64 |
var $_gui_object; |
| 65 |
|
| 66 |
/** |
| 67 |
* the contructor |
| 68 |
* 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 |
* |
| 72 |
* @params struct - the arguments |
| 73 |
*/ |
| 74 |
function WebExplorer_Module_AbstractGUIModule($args = array()) { |
| 75 |
$this->_args = $args; |
| 76 |
|
| 77 |
//print Dumper($this->_gui_object); |
| 78 |
$this->set_gui_object(); |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
function set_gui_object() { |
| 83 |
$msg = "AbstractGUIModule::get_gui_object() - Child must override"; |
| 84 |
user_error($msg); |
| 85 |
return $msg; |
| 86 |
} |
| 87 |
|
| 88 |
/** |
| 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 |
} |
| 98 |
|
| 99 |
|
| 100 |
function _add_hidden_element($label, $value) { |
| 101 |
// TODO: review this! |
| 102 |
if (!$this->_gui_object) { return; } |
| 103 |
//print "Label: $label => $value<br>"; |
| 104 |
|
| 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 |
} |
| 110 |
|
| 111 |
|
| 112 |
function &get() { |
| 113 |
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 |
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 |
} |
| 129 |
|
| 130 |
|
| 131 |
} |
| 132 |
|
| 133 |
?> |