4 |
## $Id$ |
## $Id$ |
5 |
## ----------------------------------------------------------------------------- |
## ----------------------------------------------------------------------------- |
6 |
## $Log$ |
## $Log$ |
7 |
|
## Revision 1.4 2003/04/06 01:41:07 jonen |
8 |
|
## - removed duplicated decode functions |
9 |
|
## |
10 |
|
## Revision 1.3 2003/04/04 21:26:06 joko |
11 |
|
## added comments regarding possible (future) refactoring using the Data::Lift-infrastructure |
12 |
|
## |
13 |
|
## Revision 1.2 2003/04/04 00:45:40 jonen |
14 |
|
## + reworked decode functions |
15 |
|
## |
16 |
## Revision 1.1 2003/03/27 01:17:31 jonen |
## Revision 1.1 2003/03/27 01:17:31 jonen |
17 |
## + inital commit (was orginal 'ObjectList.inc) |
## + inital commit (was orginal 'ObjectList.inc) |
18 |
## |
## |
48 |
*/ |
*/ |
49 |
var $_options = NULL; |
var $_options = NULL; |
50 |
|
|
51 |
|
/** |
52 |
|
* Holds a list of hidden elements |
53 |
|
* |
54 |
|
*/ |
55 |
|
var $_hidden_elements = array(); |
56 |
|
|
57 |
/** |
/** |
58 |
* The constructor is used to pass in some additional |
* The constructor is used to pass in some additional |
59 |
* metadata informations as "options". |
* metadata informations as "options". |
185 |
|
|
186 |
//make sure its set to something. |
//make sure its set to something. |
187 |
if ($obj == '') { |
if ($obj == '') { |
188 |
$obj = " "; |
$obj = " "; |
189 |
} |
} |
190 |
// if item is match by expression we will replace it with an link object |
|
191 |
elseif($this->_options['decode']) { |
// decode item / mungle item data? |
192 |
if($this->decode_item_expr($obj)) { |
// TODO: use Data::Lift here!!! (like already done in YAA::JobList and YAA::JobDetails) |
193 |
$obj = $this->decode_item_expr($obj); |
elseif ($this->_options['decode']) { |
194 |
} |
|
195 |
// if item is an Array we will replace it with an selection form object |
// Proposal using Data::Lift: (see YAA::JobList and YAA::JobDetails) |
196 |
elseif($this->decode_item_array($obj) ) { |
// This class will get shorter and better to maintain! |
197 |
$obj = $this->decode_item_array($obj); |
|
198 |
|
// Picture Data::Lift as a container component handling |
199 |
|
// *specific* en-/decoding stuff for your very core components. |
200 |
|
// This way we will have almost all "specific mungling code" at one place. nice thing! |
201 |
|
|
202 |
|
/* |
203 |
|
|
204 |
|
// 1. expr: string -> object (phpHtmlLib-object: 'html_a'-tag) |
205 |
|
// returns a phpHtmlLib object of class 'Xyz' containing a http-/html-link |
206 |
|
// pointing to a View of a different - linked/referenced - object (reference-interpolation) |
207 |
|
$this->lift1 = php::mkComponent('Data::Lift', $obj, array( metatype => 'expression' ) ); |
208 |
|
$obj = $this->lift1->to('phpHtmlLib::html_a'); |
209 |
|
|
210 |
|
// 2. data: hash -> object (phpHtmlLib-object: 'container'-object containing form) |
211 |
|
// returns a phpHtmlLib object of class 'Container' containing a html-form made up of |
212 |
|
// phpHtmlLib form-tags wrapping all attribute-value pairs of the data hash (object-edit) |
213 |
|
$this->lift2 = php::mkComponent('Data::Lift', $obj, array( metatype => 'item' ) ); |
214 |
|
$obj = $this->lift2->to('phpHtmlLib::form'); |
215 |
|
|
216 |
|
*/ |
217 |
|
|
218 |
|
$utils = php::mkComponent('WebExplorer::utils'); |
219 |
|
$hidden = $this->_hidden_elements; |
220 |
|
$options = $this->_options['decode_args']; |
221 |
|
|
222 |
|
// 1. if item is match by expression we will replace it with an link object |
223 |
|
if ($utils->decode_item_expr($obj, $hidden, $options)) { |
224 |
|
$obj = $utils->decode_item_expr($obj, $hidden, $options); |
225 |
} |
} |
226 |
|
|
227 |
|
// 2. if item is an Array we will replace it with an selection form object |
228 |
|
elseif ( $utils->decode_item_array($obj, $hidden, $options) ) { |
229 |
|
$obj = $utils->decode_item_array($obj, $hidden, $options); |
230 |
|
} |
231 |
|
|
232 |
} |
} |
233 |
|
|
234 |
//make sure we don't put a right border on the last |
//make sure we don't put a right border on the last |
235 |
//column we are working on. |
//column we are working on. |
236 |
//$style = "padding-left: 3px;padding-right:3px;border-top: 1px solid #dddddd;"; |
//$style = "padding-left: 3px;padding-right:3px;border-top: 1px solid #dddddd;"; |
255 |
return $td; |
return $td; |
256 |
} |
} |
257 |
|
|
258 |
function decode_item_array($item) { |
function add_hidden_element($label, $value) { |
259 |
$options = $this->_options['decode_args']; |
$this->_hidden_elements[$label] = $value; |
|
if( is_array($item) ) { |
|
|
//$cur_row_index = $this->_datasource->get_cur_data_index(); |
|
|
//$parent_guid = $this->_datasource->_data[$cur_row_index]['guid']; |
|
|
// build list for selection form |
|
|
if($options['form']) { |
|
|
foreach($item as $key => $value) { |
|
|
$tmp = split($options['seperator'], $value); |
|
|
$ident = $tmp['1']; |
|
|
$meta = $tmp['2']; |
|
|
$list[$key] = $ident; |
|
|
} |
|
|
if(is_array($list) ) { |
|
|
$container = container( |
|
|
form_open( $item[0], $_SERVER["PHP_SELF"], "POST" ), |
|
|
form_open("ecdm", $meta), |
|
|
form_select("ecdid", $list), |
|
|
form_submit("submit","view" ) |
|
|
); |
|
|
foreach($this->_hidden_items as $label => $value) { |
|
|
$container->add(form_hidden($label, $value)); |
|
|
} |
|
|
$container->add(form_close() ); |
|
|
$item = $container; |
|
|
} |
|
|
} else { |
|
|
$container = container(); |
|
|
foreach($item as $key => $value) { |
|
|
$tmp = split($options['seperator'], $value); |
|
|
$ident = $tmp['1']; |
|
|
$meta = $tmp['2']; |
|
|
foreach($this->_hidden_items as $label => $value) { |
|
|
$tmp_array[] = $label . "=" . $value; |
|
|
} |
|
|
$str_hidden = join("&", $tmp_array); |
|
|
$container->add("->", html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . $str_hidden, $key . " view"), html_br()); |
|
|
} |
|
|
$item = $container; |
|
|
} |
|
|
return $item; |
|
260 |
} |
} |
|
} |
|
261 |
|
|
262 |
function decode_item_expr($item) { |
|
263 |
$options = $this->_options['decode_args']; |
|
|
if(substr($item, 0, 2) == "o_") { |
|
|
$tmp = split($options['seperator'], $item); |
|
|
$ident = $tmp['1']; |
|
|
$meta = $tmp['2']; |
|
|
foreach($this->_hidden_items as $label => $value) { |
|
|
$tmp_array[] = $label . "=" . $value; |
|
|
} |
|
|
$str_hidden = join("&", $tmp_array); |
|
|
$item = html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $guid . "&ecdm=" . $meta . $str_hidden, "view"); |
|
|
return $item; |
|
|
} |
|
|
} |
|
264 |
|
|
265 |
} |
} |
266 |
?> |
?> |