4 |
## $Id$ |
## $Id$ |
5 |
## ----------------------------------------------------------------------------- |
## ----------------------------------------------------------------------------- |
6 |
## $Log$ |
## $Log$ |
7 |
|
## Revision 1.8 2003/12/15 21:05:19 udo |
8 |
|
## bugfix: $PHP_SELF -> $_SERVER['PHP_SELF'] |
9 |
|
## |
10 |
|
## Revision 1.7 2003/05/10 18:04:45 jonen |
11 |
|
## + added values needed for 'create/add new' links |
12 |
|
## |
13 |
|
## Revision 1.6 2003/04/11 00:48:03 joko |
14 |
|
## minor fix: calling parent constructor explicitely by name now, transparency seems not be automagically compatible with inheritance in php ,-) (non-orthogonal) |
15 |
|
## |
16 |
|
## Revision 1.5 2003/04/09 09:59:30 joko |
17 |
|
## fixes regarding modification of decode-function-behavior |
18 |
|
## |
19 |
|
## Revision 1.4 2003/04/06 01:41:33 jonen |
20 |
|
## - removed duplicated decode functions |
21 |
|
## |
22 |
|
## Revision 1.3 2003/04/04 23:58:02 jonen |
23 |
|
## + saving of items sould now work with new 'GenericSource' structure |
24 |
|
## |
25 |
## Revision 1.2 2003/04/04 00:43:22 jonen |
## Revision 1.2 2003/04/04 00:43:22 jonen |
26 |
## + complete rework |
## + complete rework |
27 |
## |
## |
74 |
// prefetch data |
// prefetch data |
75 |
$this->data_prefetch(); |
$this->data_prefetch(); |
76 |
|
|
77 |
$parent = get_parent_class($this); |
// doesn't work if EditDataItem gets inherited |
78 |
$this->$parent($title, $PHP_SELF, 600); |
//$parent = get_parent_class($this); |
79 |
|
//$this->$parent($title, $PHP_SELF, 600); |
80 |
|
|
81 |
|
// $this->StandardFormContent($title, $PHP_SELF, 600); |
82 |
|
$this->StandardFormContent($title, $_SERVER['PHP_SELF'], 600); |
83 |
|
|
84 |
} |
} |
85 |
|
|
86 |
function set_data_source(&$source) { |
function set_data_source(&$source) { |
118 |
//we want an confirmation page for this form. |
//we want an confirmation page for this form. |
119 |
$this->set_confirm(); |
$this->set_confirm(); |
120 |
|
|
121 |
|
$utils = php::mkComponent('WebExplorer::utils'); |
122 |
|
$hidden = $this->get_hidden_elements(); |
123 |
|
$options = $this->_options['decode_args']; |
124 |
|
|
125 |
foreach($this->_datasource->_result as $key => $value) { |
foreach($this->_datasource->_result as $key => $value) { |
126 |
if($value) { |
if($value) { |
127 |
$validation = TRUE; |
$validation = TRUE; |
128 |
} else { |
} else { |
129 |
$validation = FALSE; |
$validation = FALSE; |
130 |
} |
} |
131 |
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)) { |
132 |
$this->add_element( new FEText($key, $validation, "350px") ); |
$this->add_element( new FEText($key, $validation, "350px") ); |
133 |
} |
} |
134 |
} |
} |
146 |
//and set the initial values of some of the |
//and set the initial values of some of the |
147 |
//form fields. |
//form fields. |
148 |
|
|
149 |
|
$utils = php::mkComponent('WebExplorer::utils'); |
150 |
|
$hidden = $this->get_hidden_elements(); |
151 |
|
$options = $this->_options['decode_args']; |
152 |
|
|
153 |
foreach($this->_datasource->_result as $key => $value) { |
foreach($this->_datasource->_result as $key => $value) { |
154 |
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)) { |
155 |
$this->set_element_value($key, $value); |
$this->set_element_value($key, $value); |
156 |
} |
} |
157 |
} |
} |
176 |
foreach($this->_datasource->_result as $key => $value) { |
foreach($this->_datasource->_result as $key => $value) { |
177 |
// 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 |
178 |
if($this->_options['decode']) { |
if($this->_options['decode']) { |
179 |
if($this->decode_item_expr($value)) { |
$utils = php::mkComponent('WebExplorer::utils'); |
180 |
$table->add_row($key, $this->decode_item_expr($value)); |
$hidden = $this->get_hidden_elements(); |
181 |
|
$options = $this->_options['decode_args']; |
182 |
|
$options[label] = $key; |
183 |
|
$options[parent_guid] = $this->_options['parent']['guid']; |
184 |
|
$options[parent_class] = $this->_options['parent']['class']; |
185 |
|
if($utils->decode_item_expr($value, $hidden, $options)) { |
186 |
|
$table->add_row($key, $value); |
187 |
} |
} |
188 |
// 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 |
189 |
elseif($this->decode_item_array($value) ) { |
elseif($utils->decode_item_array($value, $hidden, $options) ) { |
190 |
$table->add_row($key, $this->decode_item_array($value)); |
$table->add_row($key, $value); |
191 |
} else { |
} else { |
192 |
$table->add_row($this->element_label($key), $this->element_form($key)); |
$table->add_row($this->element_label($key), $this->element_form($key)); |
193 |
} |
} |
247 |
$td = new TDtag(array("colspan" => 2, |
$td = new TDtag(array("colspan" => 2, |
248 |
"class" => "contentnovertical", |
"class" => "contentnovertical", |
249 |
"align" => "center"), |
"align" => "center"), |
250 |
form_submit('ecfedit', "Confirm"), |
form_submit('ecdfe', "Confirm"), |
251 |
_HTML_SPACE, |
_HTML_SPACE, |
252 |
$this->add_action("Edit")); |
$this->add_action("Edit")); |
253 |
|
|
271 |
*/ |
*/ |
272 |
function confirm_action() { |
function confirm_action() { |
273 |
|
|
274 |
|
$utils = php::mkComponent('WebExplorer::utils'); |
275 |
|
$hidden = $this->get_hidden_elements(); |
276 |
|
$options = $this->_options['decode_args']; |
277 |
|
|
278 |
foreach($this->_datasource->_result as $label => $value_old) { |
foreach($this->_datasource->_result as $label => $value_old) { |
279 |
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)) { |
|
280 |
$value_new = $this->_elements[$label]->get_value(); |
$value_new = $this->_elements[$label]->get_value(); |
281 |
$data[$label] = $value_new; |
$data[$label] = $value_new; |
282 |
} |
} |
283 |
} |
} |
284 |
|
// write new data to datasource |
285 |
$this->_options['data_locator_meta']['action'] = "write"; |
$this->_options['data_locator_meta']['action'] = "write"; |
286 |
$this->_options['data_locator_meta']['data'] = $data; |
$this->_options['data_locator_meta']['data'] = $data; |
287 |
|
// TODO: 'data_prefetch()' will never return ANYTHING! |
288 |
|
// Implement some error-handling there or somewhere. |
289 |
$error = $this->data_prefetch(); |
$error = $this->data_prefetch(); |
290 |
|
|
291 |
//$error = $this->_datasource->set($item); |
//$error = $this->_datasource->set($item); |
292 |
if(!$error) { |
if(!$error) { |
293 |
|
// fetch fresh data |
294 |
|
$this->_options['data_locator_meta']['action'] = "read"; |
295 |
|
// unset previous initialed 'data' var |
296 |
|
$this->_options['data_locator_meta']['data'] = NULL; |
297 |
|
$this->data_prefetch(); |
298 |
|
|
299 |
$this->set_action_message($this->_confirm_msg); |
$this->set_action_message($this->_confirm_msg); |
300 |
return TRUE; |
return TRUE; |
301 |
} else { |
} else { |
313 |
$div = new DIVtag( array("style" => "background-color: #eeeeee;". |
$div = new DIVtag( array("style" => "background-color: #eeeeee;". |
314 |
"padding-top:5px;padding-bottom:5px", |
"padding-top:5px;padding-bottom:5px", |
315 |
"align"=>"center", "nowrap"), |
"align"=>"center", "nowrap"), |
316 |
form_submit('ecfedit', "Save"), |
form_submit('ecdfe', "Save"), |
317 |
_HTML_SPACE, |
_HTML_SPACE, |
318 |
$this->add_cancel() ); |
//$this->add_cancel() |
319 |
|
form_submit('ecdfc', "Cancel") |
320 |
|
); |
321 |
return $div; |
return $div; |
322 |
} |
} |
323 |
|
|
324 |
|
|
325 |
|
function get_hidden_elements() { |
326 |
|
foreach($this->_hidden_elements as $label => $object) { |
327 |
function decode_item_array($item) { |
$value = $this->_hidden_elements[$label]->get_value(); |
328 |
$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; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
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; |
|
329 |
} |
} |
330 |
|
return $tmp_array; |
331 |
} |
} |
332 |
|
|
|
|
|
333 |
} |
} |
334 |
|
|
335 |
|
|
|
?> |
|
336 |
|
?> |