12 |
* Cvs-Log |
* Cvs-Log |
13 |
* |
* |
14 |
* $Id$ |
* $Id$ |
15 |
|
* |
16 |
|
* $Log$ |
17 |
|
* Revision 1.7 2004/12/14 21:15:25 jonen |
18 |
|
* + log-layout modifications |
19 |
|
* |
20 |
|
* Revision 1.6 2004/12/14 21:10:10 jonen |
21 |
|
* + inserted Log-Tag |
22 |
|
* |
23 |
*/ |
*/ |
24 |
|
|
25 |
|
|
26 |
// this is an abstract form-class to edit LangText - content. |
// this is an abstract form-class to edit LangText - content. |
27 |
class EditPageForm extends EditDataItem { |
class EditPageForm extends EditDataItem { |
28 |
|
|
48 |
$this->_undone = $undone; |
$this->_undone = $undone; |
49 |
$parent = get_parent_class($this); |
$parent = get_parent_class($this); |
50 |
|
|
51 |
|
|
52 |
|
//$this->$parent($title, $_SERVER['PHP_SELF'], $options); |
53 |
$this->$parent($title, $options); |
$this->$parent($title, $options); |
54 |
} |
} |
55 |
|
|
|
|
|
56 |
// this function is needed, because _set_items and _show_items may contain a |
// this function is needed, because _set_items and _show_items may contain a |
57 |
// different amount of entries. in that case we have ensure, that there will |
// different amount of entries. in that case we have ensure, that there will |
58 |
// be input-fields at the mising places and that the data will be recieved |
// be input-fields at the mising places and that the data will be recieved |
59 |
// with the correct lkey |
// with the correct lkey |
60 |
function get_nested_array_by_lkey($whichArray, $whichKey) { |
function get_nested_array_by_lkey($whichArray, $whichKey) { |
61 |
$myArray = array(); |
$myArray = array(); |
62 |
$myArray = &$whichArray; |
$myArray = &$whichArray; |
63 |
foreach ($myArray as $key=>$value) { |
foreach ($myArray as $key=>$value) { |
64 |
if ($value['lkey'] == $whichKey) { |
if ($value['lkey'] == $whichKey) {return $value;} |
|
return $value;} |
|
65 |
} |
} |
66 |
} |
} |
67 |
|
|
84 |
if (empty($this->_undone)) { |
if (empty($this->_undone)) { |
85 |
$this->_undone = $_REQUEST['_undone']; |
$this->_undone = $_REQUEST['_undone']; |
86 |
} |
} |
87 |
|
|
|
|
|
88 |
// used_keys are all lkeys, that contain the _sql_key |
// used_keys are all lkeys, that contain the _sql_key |
89 |
$used_keys = array(); |
$used_keys = array(); |
90 |
|
|
91 |
$this->set_confirm(); |
$this->set_confirm(); |
92 |
|
|
93 |
// the _datasource->result - object is parsed and the matching items are |
// the _datasource->result - object is parsed and the matching items are |
94 |
// written into the arrays |
// written into the arrays |
95 |
foreach($this->_datasource->_result as $key => $value) { |
foreach($this->_datasource->_result as $key => $value) { |
96 |
if (strstr ( $value['lkey'], $this->_sql_key)) { |
if (strstr ( $value['lkey'], $this->_sql_key)) { |
97 |
if (!in_array($value['lkey'], $used_keys)) {array_push($used_keys, $value['lkey']);} |
if (!in_array($value['lkey'], $used_keys)) {array_push($used_keys, $value['lkey']);} |
98 |
if ($value['lcountrykey'] == $this->_show_lang) {array_push($this->_show_items, $value);} |
//if ($value['lcountrykey'] == $this->_show_lang) {array_push($this->_show_items, $value);} |
99 |
if ($value['lcountrykey'] == $this->_set_lang) {array_push($this->_set_items, $value);} |
if ($value['lcountrykey'] == $this->_show_lang) {$this->_show_items[$value['lkey']] = $value;} |
100 |
|
//if ($value['lcountrykey'] == $this->_set_lang) {array_push($this->_set_items, $value);} |
101 |
|
if ($value['lcountrykey'] == $this->_set_lang) {$this->_set_items[$value['lkey']] = $value;} |
102 |
} |
} |
103 |
} |
} |
104 |
|
|
105 |
|
|
106 |
// this is needed for sorting |
// this is needed for sorting |
107 |
$tmp_array = array(); |
$tmp_array = array(); |
141 |
// are not yet translated, every entry, that has lvalues in both arrays, is marked. |
// are not yet translated, every entry, that has lvalues in both arrays, is marked. |
142 |
if ($this->_undone == "yes") { |
if ($this->_undone == "yes") { |
143 |
foreach ($used_keys as $key => $value) { |
foreach ($used_keys as $key => $value) { |
144 |
if ((strlen($larger[$key]['lvalue']) > 0) && (strlen($smaller[$key]['lvalue']) > 0)) { |
if ((strlen($larger[$value]['lvalue']) > 0) && (strlen($smaller[$value]['lvalue']) > 0)) { |
145 |
$this->_set_items[$key] = "kickedMarkerXXX"; |
$this->_set_items[$value] = "kickedMarkerXXX"; |
146 |
$this->_show_items[$key] = "kickedMarkerXXX"; |
$this->_show_items[$value] = "kickedMarkerXXX"; |
147 |
} |
} |
148 |
} |
} |
149 |
} |
} |
166 |
|
|
167 |
$set_el = str_replace("/", "x_x", $value) . $this->_set_lang . "u"; |
$set_el = str_replace("/", "x_x", $value) . $this->_set_lang . "u"; |
168 |
|
|
169 |
if ((strlen($this->_set_items[$key]['lvalue']) < 40) && (strlen($this->_show_items[$key]['lvalue']) < 40)) { |
if ((strlen($this->_set_items[$value]['lvalue']) < 40) && (strlen($this->_show_items[$value]['lvalue']) < 40)) { |
170 |
$this->add_element( new FEText($show_el, false, 40, 200)); |
$this->add_element( new FEText($show_el, false, 40)); |
171 |
$this->add_element( new FEText($set_el, false, 40, 200)); |
$this->add_element( new FEText($set_el, false, 40)); |
172 |
} else{ |
} else{ |
173 |
$this->add_element( new FETextArea($show_el, false, 10, 40)); |
$this->add_element( new FETextArea($show_el, false, 10, 40)); |
174 |
$this->add_element( new FETextArea($set_el, false, 10, 40)); |
$this->add_element( new FETextArea($set_el, false, 10, 40)); |
222 |
* @param InfoTable object |
* @param InfoTable object |
223 |
*/ |
*/ |
224 |
function build_confirm_table( &$table ) { |
function build_confirm_table( &$table ) { |
225 |
|
foreach( $this->_elements as $label => $element) { |
226 |
$useless_keys = array ('0' => "ecdfe", |
if ((substr($label, strlen($label) - 3, 2) == $_REQUEST['_set_lang']) && (substr($label, strlen($label) - 1, 1) == "u") && $element->get_value()){ |
227 |
'1' => "_form_action", |
$correct_key = substr($label, 0, strlen($label) - 3); |
228 |
'2' => "_form_visited", |
$correct_key = str_replace("x_x", "/", $correct_key); |
229 |
'3' => "_form_confirm", |
$table->add_row( $correct_key, $element->get_value()); |
|
); |
|
|
|
|
|
// the actually updated data has to be parsed out of the post data. |
|
|
// there is a lot data in the post that is useless for this, like for page-control usw. |
|
|
// if the selected show- and set-language is the same, we will only confirm the set-items |
|
|
if ($_REQUEST['_set_lang'] <> $_REQUEST['_show_lang']) { |
|
|
foreach( $_POST as $label => $element) { |
|
|
|
|
|
// the wanted data is not part of the hidden elements, not part of the useless page-control-post (useless_keys) |
|
|
// and its key contains the selected set-language |
|
|
if (!array_key_exists( $label, $this->get_hidden_elements()) && !in_array( $label, $useless_keys) && stristr(substr($label, strlen($label)-3, 2) , $_REQUEST['_set_lang']) ){ |
|
|
$correct_key = substr($label, 0, strlen($label) - 3); |
|
|
$correct_key = str_replace("x_x", "/", $correct_key); |
|
|
$table->add_row( $correct_key, $element); |
|
|
} |
|
230 |
} |
} |
|
} else { |
|
|
foreach( $_POST as $label => $element) { |
|
|
if (!array_key_exists( $label, $this->get_hidden_elements()) && !in_array( $label, $useless_keys) && (substr($label, strlen($label)-1, 1) == "u") ){ |
|
|
$correct_key = substr($label, 0, strlen($label) - 3); |
|
|
$correct_key = str_replace("x_x", "/", $correct_key); |
|
|
$table->add_row( $correct_key, $element); |
|
|
} |
|
|
} |
|
231 |
} |
} |
232 |
} |
} |
233 |
|
|
247 |
form_submit('ecdfc',"Edit")); |
form_submit('ecdfc',"Edit")); |
248 |
|
|
249 |
$table->add_row( $td ); |
$table->add_row( $td ); |
|
|
|
250 |
return $table; |
return $table; |
251 |
} |
} |
252 |
|
|
307 |
} |
} |
308 |
|
|
309 |
|
|
|
// for the final form action the post-variables have to be parsed again and merged together with the datasource-result |
|
|
// in a way that keeps the guid from the datasource-result and replaces the old lvalues with the new ones. |
|
310 |
function form_action() { |
function form_action() { |
311 |
|
|
312 |
$useless_keys = array ('0' => "ecdfe", |
$data = array(); |
|
'1' => "_form_action", |
|
|
'2' => "_form_visited", |
|
|
'3' => "_form_confirm", |
|
|
); |
|
|
|
|
313 |
$new_data = array(); |
$new_data = array(); |
314 |
$used_keys = array(); |
foreach( $this->_elements as $label => $element) { |
315 |
|
if ((substr($label, strlen($label) - 3, 2) == $_REQUEST['_set_lang']) && (substr($label, strlen($label) - 1, 1) == "u") && $element->get_value()){ |
|
// the keys that will be needed for update are parsed from the post |
|
|
foreach( $_POST as $label => $element) { |
|
|
if (!array_key_exists( $label, $this->get_hidden_elements()) && !in_array( $label, $useless_keys) && stristr(substr($label, strlen($label)-3, 2) , $_REQUEST['_set_lang']) ){ |
|
316 |
$correct_key = substr($label, 0, strlen($label) - 3); |
$correct_key = substr($label, 0, strlen($label) - 3); |
317 |
$correct_key = str_replace("x_x", "/", $correct_key); |
$correct_key = str_replace("x_x", "/", $correct_key); |
318 |
$used_keys[$correct_key] = $element; |
$new_data[$correct_key]=$element->get_value(); |
319 |
} |
} |
320 |
} |
} |
321 |
|
|
322 |
// the guid of the updated elements is received out of the datasource-result and |
foreach ($this->_set_items as $item_key => $item_value) { |
323 |
// the old items are replaced by the new ones. |
foreach($new_data as $data_key => $data_value) { |
324 |
foreach ($this->_datasource->_result as $key=>$value) { |
if ($data_key == $item_value['lkey']) { |
325 |
if (array_key_exists($value['lkey'], $used_keys) && ($value['lcountrykey'] == $_REQUEST['_set_lang'])) { |
$tmp_array = $item_value; |
326 |
$new_data[$key] = $value; |
$tmp_array['lvalue'] = $data_value; |
327 |
$new_data[$key]['lvalue'] = $used_keys[$value['lkey']]; |
array_push($data, $tmp_array); |
|
} |
|
|
} |
|
|
|
|
|
// if there are completely new items without a guid, they are pushed to the new data-array in |
|
|
// the correct form, as an array containing a lkey, a lcountrykey and, of course, a lvalue |
|
|
if (array_count_values($new_data)<array_count_values($used_keys)) { |
|
|
foreach ($used_keys as $key=>$value) { |
|
|
$wanted_array = $this->get_nested_array_by_lkey($new_data, $key); |
|
|
if (!is_array($wanted_array)) { |
|
|
$tmp_array = array(); |
|
|
$tmp_array['lcountrykey'] = $_REQUEST['_set_lang']; |
|
|
$tmp_array['lvalue'] = $value; |
|
|
$tmp_array['lkey'] = $key; |
|
|
$tmp_array['GIUD'] = ""; |
|
|
array_push($new_data, $tmp_array); |
|
|
} |
|
328 |
} |
} |
329 |
} |
} |
330 |
|
} |
331 |
|
|
332 |
|
|
333 |
|
// print " data: " .Dumper($data). "<br>"; |
334 |
|
|
335 |
// write new data to datasource in $data as array (keep old indices, set new values) |
// write new data to datasource in $data as array (keep old indices, set new values) |
336 |
$this->_options['data_locator_meta']['action'] = "write"; |
$this->_options['data_locator_meta']['action'] = "write"; |
337 |
$this->_options['data_locator_meta']['data'] = $new_data; |
$this->_options['data_locator_meta']['data'] = $data; |
338 |
// TODO: 'data_prefetch()' will never return ANYTHING! |
// TODO: 'data_prefetch()' will never return ANYTHING! |
339 |
// Implement some error-handling there or somewhere. |
// Implement some error-handling there or somewhere. |
340 |
$error = $this->data_prefetch(); |
$error = $this->data_prefetch(); |
341 |
} |
} |
342 |
function form_backend_validation() { |
function form_backend_validation() { |
343 |
$this->set_action("Confirm"); |
$this->set_action("Confirm"); |
344 |
return TRUE; |
return TRUE; |
345 |
} |
} |
346 |
function confirm_action() { |
function confirm_action() { |
347 |
|
$this->set_action_message("yip, alles klar!"); |
348 |
return TRUE; |
return TRUE; |
349 |
} |
} |
350 |
} |
} |