4 |
## $Id$ |
## $Id$ |
5 |
## ----------------------------------------------------------------------------- |
## ----------------------------------------------------------------------------- |
6 |
## $Log$ |
## $Log$ |
7 |
|
## Revision 1.3 2003/04/04 21:26:06 joko |
8 |
|
## added comments regarding possible (future) refactoring using the Data::Lift-infrastructure |
9 |
|
## |
10 |
|
## Revision 1.2 2003/04/04 00:45:40 jonen |
11 |
|
## + reworked decode functions |
12 |
|
## |
13 |
## Revision 1.1 2003/03/27 01:17:31 jonen |
## Revision 1.1 2003/03/27 01:17:31 jonen |
14 |
## + inital commit (was orginal 'ObjectList.inc) |
## + inital commit (was orginal 'ObjectList.inc) |
15 |
## |
## |
45 |
*/ |
*/ |
46 |
var $_options = NULL; |
var $_options = NULL; |
47 |
|
|
48 |
|
/** |
49 |
|
* Holds a list of hidden elements |
50 |
|
* |
51 |
|
*/ |
52 |
|
var $_hidden_elements = array(); |
53 |
|
|
54 |
/** |
/** |
55 |
* The constructor is used to pass in some additional |
* The constructor is used to pass in some additional |
56 |
* metadata informations as "options". |
* metadata informations as "options". |
182 |
|
|
183 |
//make sure its set to something. |
//make sure its set to something. |
184 |
if ($obj == '') { |
if ($obj == '') { |
185 |
$obj = " "; |
$obj = " "; |
186 |
} |
} |
187 |
// if item is match by expression we will replace it with an link object |
|
188 |
elseif($this->_options['decode']) { |
// decode item / mungle item data? |
189 |
if($this->decode_item_expr($obj)) { |
// TODO: use Data::Lift here!!! (like already done in YAA::JobList and YAA::JobDetails) |
190 |
$obj = $this->decode_item_expr($obj); |
elseif ($this->_options['decode']) { |
191 |
} |
|
192 |
// if item is an Array we will replace it with an selection form object |
// Proposal using Data::Lift: (see YAA::JobList and YAA::JobDetails) |
193 |
elseif($this->decode_item_array($obj) ) { |
// This class will get shorter and better to maintain! |
194 |
|
|
195 |
|
// Picture Data::Lift as a container component handling |
196 |
|
// *specific* en-/decoding stuff for your very core components. |
197 |
|
// This way we will have almost all "specific mungling code" at one place. nice thing! |
198 |
|
|
199 |
|
/* |
200 |
|
|
201 |
|
// 1. expr: string -> object (phpHtmlLib-object: 'html_a'-tag) |
202 |
|
// returns a phpHtmlLib object of class 'Xyz' containing a http-/html-link |
203 |
|
// pointing to a View of a different - linked/referenced - object (reference-interpolation) |
204 |
|
$this->lift1 = php::mkComponent('Data::Lift', $obj, array( metatype => 'expression' ) ); |
205 |
|
$obj = $this->lift1->to('phpHtmlLib::html_a'); |
206 |
|
|
207 |
|
// 2. data: hash -> object (phpHtmlLib-object: 'container'-object containing form) |
208 |
|
// returns a phpHtmlLib object of class 'Container' containing a html-form made up of |
209 |
|
// phpHtmlLib form-tags wrapping all attribute-value pairs of the data hash (object-edit) |
210 |
|
$this->lift2 = php::mkComponent('Data::Lift', $obj, array( metatype => 'item' ) ); |
211 |
|
$obj = $this->lift2->to('phpHtmlLib::form'); |
212 |
|
|
213 |
|
*/ |
214 |
|
|
215 |
|
|
216 |
|
// 1. if item is match by expression we will replace it with an link object |
217 |
|
if ($this->decode_item_expr($obj)) { |
218 |
|
$obj = $this->decode_item_expr($obj); |
219 |
|
} |
220 |
|
|
221 |
|
// 2. if item is an Array we will replace it with an selection form object |
222 |
|
elseif ( $this->decode_item_array($obj) ) { |
223 |
$obj = $this->decode_item_array($obj); |
$obj = $this->decode_item_array($obj); |
224 |
} |
} |
225 |
|
|
226 |
} |
} |
227 |
|
|
228 |
//make sure we don't put a right border on the last |
//make sure we don't put a right border on the last |
229 |
//column we are working on. |
//column we are working on. |
230 |
//$style = "padding-left: 3px;padding-right:3px;border-top: 1px solid #dddddd;"; |
//$style = "padding-left: 3px;padding-right:3px;border-top: 1px solid #dddddd;"; |
249 |
return $td; |
return $td; |
250 |
} |
} |
251 |
|
|
252 |
|
function add_hidden_element($label, $value) { |
253 |
|
$this->_hidden_elements[$label] = $value; |
254 |
|
} |
255 |
|
|
256 |
|
|
257 |
|
// TODO: refactor to Data::Lift - subcomponent: handling will get way more easy! |
258 |
function decode_item_array($item) { |
function decode_item_array($item) { |
259 |
$options = $this->_options['decode_args']; |
$options = $this->_options['decode_args']; |
260 |
|
//print "item: " . Dumper($item); |
261 |
|
//print "options: " . Dumper($options); |
262 |
if( is_array($item) ) { |
if( is_array($item) ) { |
263 |
//$cur_row_index = $this->_datasource->get_cur_data_index(); |
//$cur_row_index = $this->_datasource->get_cur_data_index(); |
264 |
//$parent_guid = $this->_datasource->_data[$cur_row_index]['guid']; |
//$parent_guid = $this->_datasource->_data[$cur_row_index]['guid']; |
273 |
if(is_array($list) ) { |
if(is_array($list) ) { |
274 |
$container = container( |
$container = container( |
275 |
form_open( $item[0], $_SERVER["PHP_SELF"], "POST" ), |
form_open( $item[0], $_SERVER["PHP_SELF"], "POST" ), |
276 |
form_open("ecdm", $meta), |
form_hidden("ecdm", $meta), |
277 |
form_select("ecdid", $list), |
form_select("ecdid", $list), |
278 |
form_submit("submit","view" ) |
form_submit("submit","view" ) |
279 |
); |
); |
280 |
foreach($this->_hidden_items as $label => $value) { |
foreach($this->_hidden_elements as $label => $value) { |
281 |
$container->add(form_hidden($label, $value)); |
$container->add(form_hidden($label, $value)); |
282 |
} |
} |
283 |
$container->add(form_close() ); |
$container->add(form_close() ); |
284 |
$item = $container; |
$item = $container; |
285 |
} |
} |
286 |
} else { |
} else { |
287 |
|
//print "<b>2</b><br/>"; |
288 |
$container = container(); |
$container = container(); |
289 |
foreach($item as $key => $value) { |
foreach($item as $key => $value) { |
290 |
$tmp = split($options['seperator'], $value); |
$tmp = split($options['seperator'], $value); |
291 |
$ident = $tmp['1']; |
$ident = $tmp['1']; |
292 |
$meta = $tmp['2']; |
$meta = $tmp['2']; |
293 |
foreach($this->_hidden_items as $label => $value) { |
foreach($this->_hidden_elements as $label => $value) { |
294 |
$tmp_array[] = $label . "=" . $value; |
$tmp_array[] = $label . "=" . $value; |
295 |
} |
} |
296 |
$str_hidden = join("&", $tmp_array); |
$str_hidden = join("&", $tmp_array); |
297 |
$container->add("->", html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . $str_hidden, $key . " view"), html_br()); |
$container->add("->", html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . "&" . $str_hidden, $key . " view"), html_br()); |
298 |
} |
} |
299 |
$item = $container; |
$item = $container; |
300 |
} |
} |
302 |
} |
} |
303 |
} |
} |
304 |
|
|
305 |
|
// decodes serialized string representations of object-references |
306 |
|
// TODO: refactor to Data::Lift - subcomponent: handling will get way more easy! |
307 |
function decode_item_expr($item) { |
function decode_item_expr($item) { |
308 |
$options = $this->_options['decode_args']; |
$options = $this->_options['decode_args']; |
309 |
|
//print "item: $item<br/>"; |
310 |
if(substr($item, 0, 2) == "o_") { |
if(substr($item, 0, 2) == "o_") { |
311 |
$tmp = split($options['seperator'], $item); |
$tmp = split($options['seperator'], $item); |
312 |
$ident = $tmp['1']; |
$ident = $tmp['1']; |
313 |
$meta = $tmp['2']; |
$meta = $tmp['2']; |
314 |
foreach($this->_hidden_items as $label => $value) { |
foreach($this->_hidden_elements as $label => $value) { |
315 |
$tmp_array[] = $label . "=" . $value; |
$tmp_array[] = $label . "=" . $value; |
316 |
} |
} |
317 |
$str_hidden = join("&", $tmp_array); |
$str_hidden = join("&", $tmp_array); |
318 |
$item = html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $guid . "&ecdm=" . $meta . $str_hidden, "view"); |
$item = html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . "&" . $str_hidden, "view"); |
319 |
return $item; |
return $item; |
320 |
} |
} |
321 |
} |
} |