4 |
## $Id$ |
## $Id$ |
5 |
## ----------------------------------------------------------------------------- |
## ----------------------------------------------------------------------------- |
6 |
## $Log$ |
## $Log$ |
7 |
|
## Revision 1.4 2003/04/06 01:41:33 jonen |
8 |
|
## - removed duplicated decode functions |
9 |
|
## |
10 |
|
## Revision 1.3 2003/04/04 23:58:02 jonen |
11 |
|
## + saving of items sould now work with new 'GenericSource' structure |
12 |
|
## |
13 |
## Revision 1.2 2003/04/04 00:43:22 jonen |
## Revision 1.2 2003/04/04 00:43:22 jonen |
14 |
## + complete rework |
## + complete rework |
15 |
## |
## |
101 |
//we want an confirmation page for this form. |
//we want an confirmation page for this form. |
102 |
$this->set_confirm(); |
$this->set_confirm(); |
103 |
|
|
104 |
|
$utils = php::mkComponent('WebExplorer::utils'); |
105 |
|
$hidden = $this->get_hidden_elements(); |
106 |
|
$options = $this->_options['decode_args']; |
107 |
|
|
108 |
foreach($this->_datasource->_result as $key => $value) { |
foreach($this->_datasource->_result as $key => $value) { |
109 |
if($value) { |
if($value) { |
110 |
$validation = TRUE; |
$validation = TRUE; |
111 |
} else { |
} else { |
112 |
$validation = FALSE; |
$validation = FALSE; |
113 |
} |
} |
114 |
if(!$this->decode_item_expr($value, $this->_options) && !$this->decode_item_array($value, $this->_options)) { |
if(!$utils->decode_item_expr($value, $hidden, $options) && !$utils->decode_item_array($value, $hidden, $options)) { |
115 |
$this->add_element( new FEText($key, $validation, "350px") ); |
$this->add_element( new FEText($key, $validation, "350px") ); |
116 |
} |
} |
117 |
} |
} |
129 |
//and set the initial values of some of the |
//and set the initial values of some of the |
130 |
//form fields. |
//form fields. |
131 |
|
|
132 |
|
$utils = php::mkComponent('WebExplorer::utils'); |
133 |
|
$hidden = $this->get_hidden_elements(); |
134 |
|
$options = $this->_options['decode_args']; |
135 |
|
|
136 |
foreach($this->_datasource->_result as $key => $value) { |
foreach($this->_datasource->_result as $key => $value) { |
137 |
if(!$this->decode_item_expr($value, $this->_options) && !$this->decode_item_array($value, $this->_options)) { |
if(!$utils->decode_item_expr($value, $hidden, $options) && !$utils->decode_item_array($value, $hidden, $options)) { |
138 |
$this->set_element_value($key, $value); |
$this->set_element_value($key, $value); |
139 |
} |
} |
140 |
} |
} |
159 |
foreach($this->_datasource->_result as $key => $value) { |
foreach($this->_datasource->_result as $key => $value) { |
160 |
// if item is match by expression we will replace it with an link object |
// if item is match by expression we will replace it with an link object |
161 |
if($this->_options['decode']) { |
if($this->_options['decode']) { |
162 |
if($this->decode_item_expr($value)) { |
$utils = php::mkComponent('WebExplorer::utils'); |
163 |
$table->add_row($key, $this->decode_item_expr($value)); |
$hidden = $this->get_hidden_elements(); |
164 |
|
$options = $this->_options['decode_args']; |
165 |
|
if($utils->decode_item_expr($value, $hidden, $options)) { |
166 |
|
$table->add_row($key, $utils->decode_item_expr($value, $hidden, $options)); |
167 |
} |
} |
168 |
// if item is an Array we will replace it with an selection form object |
// if item is an Array we will replace it with an selection form object |
169 |
elseif($this->decode_item_array($value) ) { |
elseif($utils->decode_item_array($value, $hidden, $options) ) { |
170 |
$table->add_row($key, $this->decode_item_array($value)); |
$table->add_row($key, $utils->decode_item_array($value, $hidden, $options)); |
171 |
} else { |
} else { |
172 |
$table->add_row($this->element_label($key), $this->element_form($key)); |
$table->add_row($this->element_label($key), $this->element_form($key)); |
173 |
} |
} |
227 |
$td = new TDtag(array("colspan" => 2, |
$td = new TDtag(array("colspan" => 2, |
228 |
"class" => "contentnovertical", |
"class" => "contentnovertical", |
229 |
"align" => "center"), |
"align" => "center"), |
230 |
form_submit('ecfedit', "Confirm"), |
form_submit('ecdfe', "Confirm"), |
231 |
_HTML_SPACE, |
_HTML_SPACE, |
232 |
$this->add_action("Edit")); |
$this->add_action("Edit")); |
233 |
|
|
251 |
*/ |
*/ |
252 |
function confirm_action() { |
function confirm_action() { |
253 |
|
|
254 |
|
$utils = php::mkComponent('WebExplorer::utils'); |
255 |
|
$hidden = $this->get_hidden_elements(); |
256 |
|
$options = $this->_options['decode_args']; |
257 |
|
|
258 |
foreach($this->_datasource->_result as $label => $value_old) { |
foreach($this->_datasource->_result as $label => $value_old) { |
259 |
print $label . "<br>"; |
if(!$utils->decode_item_expr($value_old, $hidden, $options) && !$utils->decode_item_array($value_old, $hidden, $options)) { |
|
if(!$this->decode_item_expr($value_old) && !$this->decode_item_array($value_old)) { |
|
260 |
$value_new = $this->_elements[$label]->get_value(); |
$value_new = $this->_elements[$label]->get_value(); |
261 |
$data[$label] = $value_new; |
$data[$label] = $value_new; |
262 |
} |
} |
263 |
} |
} |
264 |
|
// write new data to datasource |
265 |
$this->_options['data_locator_meta']['action'] = "write"; |
$this->_options['data_locator_meta']['action'] = "write"; |
266 |
$this->_options['data_locator_meta']['data'] = $data; |
$this->_options['data_locator_meta']['data'] = $data; |
267 |
|
// TODO: 'data_prefetch()' will never return ANYTHING! |
268 |
|
// Implement some error-handling there or somewhere. |
269 |
$error = $this->data_prefetch(); |
$error = $this->data_prefetch(); |
270 |
|
|
271 |
//$error = $this->_datasource->set($item); |
//$error = $this->_datasource->set($item); |
272 |
if(!$error) { |
if(!$error) { |
273 |
|
// fetch fresh data |
274 |
|
$this->_options['data_locator_meta']['action'] = "read"; |
275 |
|
// unset previous initialed 'data' var |
276 |
|
$this->_options['data_locator_meta']['data'] = NULL; |
277 |
|
$this->data_prefetch(); |
278 |
|
|
279 |
$this->set_action_message($this->_confirm_msg); |
$this->set_action_message($this->_confirm_msg); |
280 |
return TRUE; |
return TRUE; |
281 |
} else { |
} else { |
293 |
$div = new DIVtag( array("style" => "background-color: #eeeeee;". |
$div = new DIVtag( array("style" => "background-color: #eeeeee;". |
294 |
"padding-top:5px;padding-bottom:5px", |
"padding-top:5px;padding-bottom:5px", |
295 |
"align"=>"center", "nowrap"), |
"align"=>"center", "nowrap"), |
296 |
form_submit('ecfedit', "Save"), |
form_submit('ecdfe', "Save"), |
297 |
_HTML_SPACE, |
_HTML_SPACE, |
298 |
$this->add_cancel() ); |
//$this->add_cancel() |
299 |
|
form_submit('ecdfc', "Cancel") |
300 |
|
); |
301 |
return $div; |
return $div; |
302 |
} |
} |
303 |
|
|
304 |
|
|
305 |
|
function get_hidden_elements() { |
306 |
|
foreach($this->_hidden_elements as $label => $object) { |
307 |
function decode_item_array($item) { |
$value = $this->_hidden_elements[$label]->get_value(); |
308 |
$options = $this->_options['decode_args']; |
$tmp_array[$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_hidden("ecdm", $meta), |
|
|
form_select("ecdid", $list), |
|
|
form_submit("submit","view" ) |
|
|
); |
|
|
foreach($this->_hidden_elements 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_elements as $label => $object) { |
|
|
$value = $this->_hidden_elements[$label]->get_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; |
|
309 |
} |
} |
310 |
|
return $tmp_array; |
311 |
} |
} |
312 |
|
|
|
|
|
|
function decode_item_expr($item) { |
|
|
$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_elements as $label => $object) { |
|
|
$value = $this->_hidden_elements[$label]->get_value(); |
|
|
$tmp_array[] = $label . "=" . $value; |
|
|
} |
|
|
$str_hidden = join("&", $tmp_array); |
|
|
$item = html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . "&" . $str_hidden, "view"); |
|
|
return $item; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
313 |
} |
} |
314 |
|
|
315 |
|
|