12 |
* Cvs-Log |
* Cvs-Log |
13 |
* |
* |
14 |
* $Id$ |
* $Id$ |
15 |
|
* |
16 |
|
* $Log$ |
17 |
|
* Revision 1.6 2004/12/14 21:10:10 jonen |
18 |
|
* + inserted Log-Tag |
19 |
|
* |
20 |
|
* |
21 |
|
* |
22 |
*/ |
*/ |
23 |
|
|
24 |
|
|
25 |
// this is an abstract form-class to edit LangText - content. |
// this is an abstract form-class to edit LangText - content. |
26 |
class EditPageForm extends EditDataItem { |
class EditPageForm extends EditDataItem { |
27 |
|
|
47 |
$this->_undone = $undone; |
$this->_undone = $undone; |
48 |
$parent = get_parent_class($this); |
$parent = get_parent_class($this); |
49 |
|
|
50 |
|
|
51 |
|
//$this->$parent($title, $_SERVER['PHP_SELF'], $options); |
52 |
$this->$parent($title, $options); |
$this->$parent($title, $options); |
53 |
} |
} |
54 |
|
|
|
|
|
55 |
// 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 |
56 |
// 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 |
57 |
// 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 |
58 |
// with the correct lkey |
// with the correct lkey |
59 |
function get_nested_array_by_lkey($whichArray, $whichKey) { |
function get_nested_array_by_lkey($whichArray, $whichKey) { |
60 |
$myArray = array(); |
$myArray = array(); |
61 |
$myArray = &$whichArray; |
$myArray = &$whichArray; |
62 |
foreach ($myArray as $key=>$value) { |
foreach ($myArray as $key=>$value) { |
63 |
if ($value['lkey'] == $whichKey) { |
if ($value['lkey'] == $whichKey) {return $value;} |
|
return $value;} |
|
64 |
} |
} |
65 |
} |
} |
66 |
|
|
83 |
if (empty($this->_undone)) { |
if (empty($this->_undone)) { |
84 |
$this->_undone = $_REQUEST['_undone']; |
$this->_undone = $_REQUEST['_undone']; |
85 |
} |
} |
86 |
|
|
|
|
|
87 |
// used_keys are all lkeys, that contain the _sql_key |
// used_keys are all lkeys, that contain the _sql_key |
88 |
$used_keys = array(); |
$used_keys = array(); |
89 |
|
|
90 |
$this->set_confirm(); |
$this->set_confirm(); |
91 |
|
|
92 |
// the _datasource->result - object is parsed and the matching items are |
// the _datasource->result - object is parsed and the matching items are |
93 |
// written into the arrays |
// written into the arrays |
94 |
foreach($this->_datasource->_result as $key => $value) { |
foreach($this->_datasource->_result as $key => $value) { |
95 |
if (strstr ( $value['lkey'], $this->_sql_key)) { |
if (strstr ( $value['lkey'], $this->_sql_key)) { |
96 |
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']);} |
97 |
if ($value['lcountrykey'] == $this->_show_lang) {array_push($this->_show_items, $value);} |
//if ($value['lcountrykey'] == $this->_show_lang) {array_push($this->_show_items, $value);} |
98 |
if ($value['lcountrykey'] == $this->_set_lang) {array_push($this->_set_items, $value);} |
if ($value['lcountrykey'] == $this->_show_lang) {$this->_show_items[$value['lkey']] = $value;} |
99 |
|
//if ($value['lcountrykey'] == $this->_set_lang) {array_push($this->_set_items, $value);} |
100 |
|
if ($value['lcountrykey'] == $this->_set_lang) {$this->_set_items[$value['lkey']] = $value;} |
101 |
} |
} |
102 |
} |
} |
103 |
|
|
104 |
|
|
105 |
// this is needed for sorting |
// this is needed for sorting |
106 |
$tmp_array = array(); |
$tmp_array = array(); |
140 |
// 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. |
141 |
if ($this->_undone == "yes") { |
if ($this->_undone == "yes") { |
142 |
foreach ($used_keys as $key => $value) { |
foreach ($used_keys as $key => $value) { |
143 |
if ((strlen($larger[$key]['lvalue']) > 0) && (strlen($smaller[$key]['lvalue']) > 0)) { |
if ((strlen($larger[$value]['lvalue']) > 0) && (strlen($smaller[$value]['lvalue']) > 0)) { |
144 |
$this->_set_items[$key] = "kickedMarkerXXX"; |
$this->_set_items[$value] = "kickedMarkerXXX"; |
145 |
$this->_show_items[$key] = "kickedMarkerXXX"; |
$this->_show_items[$value] = "kickedMarkerXXX"; |
146 |
} |
} |
147 |
} |
} |
148 |
} |
} |
165 |
|
|
166 |
$set_el = str_replace("/", "x_x", $value) . $this->_set_lang . "u"; |
$set_el = str_replace("/", "x_x", $value) . $this->_set_lang . "u"; |
167 |
|
|
168 |
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)) { |
169 |
$this->add_element( new FEText($show_el, false, 40, 200)); |
$this->add_element( new FEText($show_el, false, 40)); |
170 |
$this->add_element( new FEText($set_el, false, 40, 200)); |
$this->add_element( new FEText($set_el, false, 40)); |
171 |
} else{ |
} else{ |
172 |
$this->add_element( new FETextArea($show_el, false, 10, 40)); |
$this->add_element( new FETextArea($show_el, false, 10, 40)); |
173 |
$this->add_element( new FETextArea($set_el, false, 10, 40)); |
$this->add_element( new FETextArea($set_el, false, 10, 40)); |
221 |
* @param InfoTable object |
* @param InfoTable object |
222 |
*/ |
*/ |
223 |
function build_confirm_table( &$table ) { |
function build_confirm_table( &$table ) { |
224 |
|
foreach( $this->_elements as $label => $element) { |
225 |
$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()){ |
226 |
'1' => "_form_action", |
$correct_key = substr($label, 0, strlen($label) - 3); |
227 |
'2' => "_form_visited", |
$correct_key = str_replace("x_x", "/", $correct_key); |
228 |
'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); |
|
|
} |
|
229 |
} |
} |
|
} 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); |
|
|
} |
|
|
} |
|
230 |
} |
} |
231 |
} |
} |
232 |
|
|
246 |
form_submit('ecdfc',"Edit")); |
form_submit('ecdfc',"Edit")); |
247 |
|
|
248 |
$table->add_row( $td ); |
$table->add_row( $td ); |
|
|
|
249 |
return $table; |
return $table; |
250 |
} |
} |
251 |
|
|
306 |
} |
} |
307 |
|
|
308 |
|
|
|
// 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. |
|
309 |
function form_action() { |
function form_action() { |
310 |
|
|
311 |
$useless_keys = array ('0' => "ecdfe", |
$data = array(); |
|
'1' => "_form_action", |
|
|
'2' => "_form_visited", |
|
|
'3' => "_form_confirm", |
|
|
); |
|
|
|
|
312 |
$new_data = array(); |
$new_data = array(); |
313 |
$used_keys = array(); |
foreach( $this->_elements as $label => $element) { |
314 |
|
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']) ){ |
|
315 |
$correct_key = substr($label, 0, strlen($label) - 3); |
$correct_key = substr($label, 0, strlen($label) - 3); |
316 |
$correct_key = str_replace("x_x", "/", $correct_key); |
$correct_key = str_replace("x_x", "/", $correct_key); |
317 |
$used_keys[$correct_key] = $element; |
$new_data[$correct_key]=$element->get_value(); |
318 |
} |
} |
319 |
} |
} |
320 |
|
|
321 |
// the guid of the updated elements is received out of the datasource-result and |
foreach ($this->_set_items as $item_key => $item_value) { |
322 |
// the old items are replaced by the new ones. |
foreach($new_data as $data_key => $data_value) { |
323 |
foreach ($this->_datasource->_result as $key=>$value) { |
if ($data_key == $item_value['lkey']) { |
324 |
if (array_key_exists($value['lkey'], $used_keys) && ($value['lcountrykey'] == $_REQUEST['_set_lang'])) { |
$tmp_array = $item_value; |
325 |
$new_data[$key] = $value; |
$tmp_array['lvalue'] = $data_value; |
326 |
$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); |
|
|
} |
|
327 |
} |
} |
328 |
} |
} |
329 |
|
} |
330 |
|
|
331 |
|
|
332 |
|
// print " data: " .Dumper($data). "<br>"; |
333 |
|
|
334 |
// 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) |
335 |
$this->_options['data_locator_meta']['action'] = "write"; |
$this->_options['data_locator_meta']['action'] = "write"; |
336 |
$this->_options['data_locator_meta']['data'] = $new_data; |
$this->_options['data_locator_meta']['data'] = $data; |
337 |
// TODO: 'data_prefetch()' will never return ANYTHING! |
// TODO: 'data_prefetch()' will never return ANYTHING! |
338 |
// Implement some error-handling there or somewhere. |
// Implement some error-handling there or somewhere. |
339 |
$error = $this->data_prefetch(); |
$error = $this->data_prefetch(); |
340 |
} |
} |
341 |
function form_backend_validation() { |
function form_backend_validation() { |
342 |
$this->set_action("Confirm"); |
$this->set_action("Confirm"); |
343 |
return TRUE; |
return TRUE; |
344 |
} |
} |
345 |
function confirm_action() { |
function confirm_action() { |
346 |
|
$this->set_action_message("yip, alles klar!"); |
347 |
return TRUE; |
return TRUE; |
348 |
} |
} |
349 |
} |
} |