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 |
## Revision 1.2 2003/04/04 00:45:40 jonen |
11 |
## + reworked decode functions |
## + reworked decode functions |
12 |
## |
## |
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;"; |
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']; |
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); |
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']; |