1 |
udo |
1.1 |
<? |
2 |
|
|
/** |
3 |
|
|
* This file contains the UploadForm child class. |
4 |
|
|
* |
5 |
|
|
* |
6 |
|
|
* @package org.netfrag.patches |
7 |
|
|
* @name UploadForm |
8 |
|
|
* |
9 |
|
|
*/ |
10 |
|
|
|
11 |
|
|
/** |
12 |
|
|
* Cvs-Log |
13 |
|
|
* |
14 |
|
|
* $Id: NonValidatingFormProcessor.php,v 1.1 2003/04/11 00:37:53 joko Exp $ |
15 |
|
|
* |
16 |
|
|
* $Log: NonValidatingFormProcessor.php,v $ |
17 |
|
|
* |
18 |
|
|
* |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
// this is an abstract form-class to edit LangText - content. |
24 |
|
|
class EditPageForm extends EditDataItem { |
25 |
|
|
|
26 |
|
|
// _show_lang is the language to be shown readonly |
27 |
|
|
var $_show_lang; |
28 |
|
|
// _set_lang is the language to be entered and updated in the Langtext-table |
29 |
|
|
var $_set_lang; |
30 |
|
|
// _show_items are the items that will be shown |
31 |
|
|
var $_show_items = array(); |
32 |
|
|
// _set_items are the items, that will maybe be changed an updated |
33 |
|
|
var $_set_items = array(); |
34 |
|
|
// undone is true, if the user selected to show untranslated items only |
35 |
|
|
var $_undone; |
36 |
|
|
// all LangText - entries that contain the string _sql_key will be selected. |
37 |
|
|
// this is passed dependent on which topic is selected in the page_news - class |
38 |
|
|
var $_sql_key; |
39 |
|
|
|
40 |
|
|
function EditPageForm($title, $width, $whichKey, $show_lang, $set_lang, $undone, $options) { |
41 |
|
|
$this->_show_lang = $show_lang; |
42 |
|
|
$this->_set_lang = $set_lang; |
43 |
|
|
$this->_sql_key = $whichKey; |
44 |
|
|
$this->_undone = $undone; |
45 |
|
|
$parent = get_parent_class($this); |
46 |
|
|
$this->$parent($title, $options); |
47 |
|
|
} |
48 |
|
|
|
49 |
|
|
function form_init_elements() { |
50 |
|
|
|
51 |
|
|
// hidden element for page control |
52 |
|
|
$this->add_hidden_element( 't', 'News' ); |
53 |
|
|
|
54 |
|
|
// used_keys are all lkeys, that contain the _sql_key |
55 |
|
|
$used_keys = array(); |
56 |
|
|
|
57 |
|
|
// the _datasource->result - object is parsed and the matching items are |
58 |
|
|
// written into the arrays |
59 |
|
|
foreach($this->_datasource->_result as $key => $value) { |
60 |
|
|
if (strstr ( $value['lkey'], $this->_sql_key)) { |
61 |
|
|
if (!in_array($value['lkey'], $used_keys)) {array_push($used_keys, $value['lkey']);} |
62 |
|
|
if ($value['lcountrykey'] == $this->_show_lang) {array_push($this->_show_items, $value);} |
63 |
|
|
if ($value['lcountrykey'] == $this->_set_lang) {array_push($this->_set_items, $value);} |
64 |
|
|
} |
65 |
|
|
} |
66 |
|
|
|
67 |
|
|
// this function is needed, because _set_items and _show_items may contain a |
68 |
|
|
// different amount of entries. |
69 |
|
|
// the follogwing is all about sorting the both arrays in a way, that the same |
70 |
|
|
// entries have the same key and filling up entries, if theres an entry missing because |
71 |
|
|
// its not yet translated. |
72 |
|
|
function get_nested_array_by_lkey($whichArray=array(), $whichKey) { |
73 |
|
|
foreach ($whichArray as $key=>$value) { |
74 |
|
|
if ($value['lkey'] == $whichKey) {return $value;} |
75 |
|
|
} |
76 |
|
|
} |
77 |
|
|
|
78 |
|
|
|
79 |
|
|
// this is needed for sorting |
80 |
|
|
$tmp_array = array(); |
81 |
|
|
$larger = array(); |
82 |
|
|
// this is needed because the arrays may have to be filled with an array |
83 |
|
|
$empty_array = array("lvalue" => "", "lkey" => "", "lcountrykey" => "", "guid" => "" ); |
84 |
|
|
|
85 |
|
|
// the smaller array is backuped in tmp_array and then killed. |
86 |
|
|
// the larger array is parsed an doing this we reset the smaller array form the |
87 |
|
|
// backup in the right order. if there is an entry missing in the smaller |
88 |
|
|
// array this key will not be filled here. |
89 |
|
|
if (count($this->_set_items) > count($this->_show_items)) { |
90 |
|
|
$larger = $this->_set_items; |
91 |
|
|
$tmp_array = $this->_show_items; |
92 |
|
|
$this->_show_items = array(); |
93 |
|
|
foreach ($this->_set_items as $key=>$value) { |
94 |
|
|
$this->_show_items[$key] = get_nested_array_by_lkey($tmp_array, $value['lkey']); |
95 |
|
|
} |
96 |
|
|
} else if (count($this->_set_items) < count($this->_show_items)) { |
97 |
|
|
$larger = $this->_show_items; |
98 |
|
|
$tmp_array = $this->_set_items; |
99 |
|
|
$this->_set_items = array(); |
100 |
|
|
foreach ($this->_show_items as $key=>$value) { |
101 |
|
|
$this->_set_items[$key] = get_nested_array_by_lkey($tmp_array, $value['lkey']); |
102 |
|
|
} |
103 |
|
|
} else { |
104 |
|
|
$larger = $this->_show_items; |
105 |
|
|
} |
106 |
|
|
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
// both arrays are parsed and missing entries (without a key) are filled |
110 |
|
|
// with the empty_array. missing lkeys are filled with the lkey from used_keys, |
111 |
|
|
// so that now every key of the arrays has matching entries. this is important, |
112 |
|
|
// because otherwise the empty fields could not be named. |
113 |
|
|
|
114 |
|
|
foreach ($used_keys as $key => $value) { |
115 |
|
|
if (!is_array(get_nested_array_by_lkey($this->_set_items, $value))) { |
116 |
|
|
$this->_set_items[$key] = $empty_array; |
117 |
|
|
$this->_set_items[$key]['lkey'] = $value; |
118 |
|
|
} |
119 |
|
|
if (!is_array(get_nested_array_by_lkey($this->_show_items, $value))) { |
120 |
|
|
$this->_show_items[$key] = $empty_array; |
121 |
|
|
$this->_show_items[$key]['lkey'] = $value; |
122 |
|
|
} |
123 |
|
|
} |
124 |
|
|
|
125 |
|
|
|
126 |
|
|
// is _undone is selected, that means that the user only wants to see the items that |
127 |
|
|
// are not yet translated, every entry, that has lvalues in both arrays, is marked. |
128 |
|
|
if ($this->_undone == "yes") { |
129 |
|
|
foreach ($used_keys as $key => $value) { |
130 |
|
|
if ((strlen($this->_set_items[$key]['lvalue']) > 0) && (strlen($this->_show_items[$key]['lvalue']) > 0)) { |
131 |
|
|
$this->_set_items[$key] = "kickedMarkerXXX"; |
132 |
|
|
$this->_show_items[$key] = "kickedMarkerXXX"; |
133 |
|
|
} |
134 |
|
|
} |
135 |
|
|
} |
136 |
|
|
|
137 |
|
|
|
138 |
|
|
// the elements of the form are created |
139 |
|
|
foreach($this->_set_items as $key => $value) { |
140 |
|
|
|
141 |
|
|
|
142 |
|
|
// if the entry == kickedMarkerXXX, $value will be no array |
143 |
|
|
if (is_array($value)) { |
144 |
|
|
$show_element = $value['lkey'] . $this->_show_lang . "s"; |
145 |
|
|
$set_element = $value['lkey'] . $this->_set_lang . "u"; |
146 |
|
|
|
147 |
|
|
|
148 |
|
|
|
149 |
|
|
if (strlen($value['lvalue']) > 40) { |
150 |
|
|
$this->add_element( new FETextArea($show_element, true, 10, 40)); |
151 |
|
|
$this->add_element( new FETextArea($set_element, true, 10, 40)); |
152 |
|
|
} else{ |
153 |
|
|
$this->add_element( new FEText($show_element, true, 40, 60)); |
154 |
|
|
$this->add_element( new FEText($set_element, true, 40, 60)); |
155 |
|
|
} |
156 |
|
|
$myElement = &$this->get_element($show_element); |
157 |
|
|
$myElement->set_attribute("readonly"); |
158 |
|
|
} |
159 |
|
|
} |
160 |
|
|
} |
161 |
|
|
|
162 |
|
|
function form_init_data() { |
163 |
|
|
|
164 |
|
|
|
165 |
|
|
foreach($this->_show_items as $key => $value) { |
166 |
|
|
if (is_array($value)) { |
167 |
|
|
$show_element = $value['lkey'] . $this->_show_lang . "s"; |
168 |
|
|
$set_element = $value['lkey'] . $this->_set_lang . "u"; |
169 |
|
|
|
170 |
|
|
$this->set_element_value($show_element, $this->_show_items[$key]['lvalue']); |
171 |
|
|
$this->set_element_value($set_element, $this->_set_items[$key]['lvalue']); |
172 |
|
|
|
173 |
|
|
$myElement = &$this->get_element($show_element); |
174 |
|
|
$myElement->set_label_text(""); |
175 |
|
|
$myElement->set_required(false); |
176 |
|
|
|
177 |
|
|
$myElement = &$this->get_element($set_element); |
178 |
|
|
$myElement->set_label_text(""); |
179 |
|
|
$myElement->set_required(false); |
180 |
|
|
} |
181 |
|
|
} |
182 |
|
|
} |
183 |
|
|
|
184 |
|
|
function form_content() { |
185 |
|
|
|
186 |
|
|
$table = &html_table(600, 0, 2); |
187 |
|
|
switch ($this->_show_lang) { |
188 |
|
|
case 'de': |
189 |
|
|
$showLanguange = " german"; |
190 |
|
|
break; |
191 |
|
|
case 'en': |
192 |
|
|
$showLanguange = " english"; |
193 |
|
|
break; |
194 |
|
|
case 'tr': |
195 |
|
|
$showLanguange = " turkish"; |
196 |
|
|
break; |
197 |
|
|
} |
198 |
|
|
switch ($this->_set_lang) { |
199 |
|
|
case 'de': |
200 |
|
|
$setLanguange = " german"; |
201 |
|
|
break; |
202 |
|
|
case 'en': |
203 |
|
|
$setLanguange = " english"; |
204 |
|
|
break; |
205 |
|
|
case 'tr': |
206 |
|
|
$setLanguange = " turkish"; |
207 |
|
|
break; |
208 |
|
|
} |
209 |
|
|
$table->add_row("translate from" . $showLanguange, "translate to" . $setLanguange ); |
210 |
|
|
$all_elements_translated = 0; |
211 |
|
|
|
212 |
|
|
foreach($this->_show_items as $key => $value) { |
213 |
|
|
if (is_array($value)) { |
214 |
|
|
$all_elements_translated++; |
215 |
|
|
$show_element = $value['lkey'] . $this->_show_lang . "s"; |
216 |
|
|
$set_element = $value['lkey'] . $this->_set_lang . "u"; |
217 |
|
|
|
218 |
|
|
$inner_table_left = &html_table(); |
219 |
|
|
$inner_table_left->add_row($this->element_label($show_element)); |
220 |
|
|
$inner_table_left->add_row($this->element_form($show_element)); |
221 |
|
|
$inner_table_right = &html_table(); |
222 |
|
|
$inner_table_right->add_row($this->element_label($set_element)); |
223 |
|
|
$inner_table_right->add_row($this->element_form($set_element)); |
224 |
|
|
|
225 |
|
|
$table->add_row($inner_table_left, $inner_table_right ); |
226 |
|
|
} |
227 |
|
|
} |
228 |
|
|
if ($all_elements_translated == 0) { |
229 |
|
|
$table = &html_table(600, 0, 2); |
230 |
|
|
if (count($this->_set_items)>0) {$table->add_row("all items are translated!");} |
231 |
|
|
else {$table->add_row("no items found");} |
232 |
|
|
} |
233 |
|
|
$this->add_form_block("", $table ); |
234 |
|
|
} |
235 |
|
|
|
236 |
|
|
function form_action() { |
237 |
|
|
$data = array(); |
238 |
|
|
|
239 |
|
|
foreach ($this->_set_items as $key=>$value) { |
240 |
|
|
if (is_array($value)) { |
241 |
|
|
array_push($data, $this->_set_items[$key]); |
242 |
|
|
} |
243 |
|
|
} |
244 |
|
|
|
245 |
|
|
//$this->_options['data_locator_meta']['action'] = "write"; |
246 |
|
|
//$this->_options['data_locator_meta']['data'] = $data; |
247 |
|
|
//$error = $this->data_prefetch(); |
248 |
|
|
|
249 |
|
|
} |
250 |
|
|
function form_backend_validation() { |
251 |
|
|
$this->set_action("Confirm"); |
252 |
|
|
return TRUE; |
253 |
|
|
} |
254 |
|
|
function confirm_action() { |
255 |
|
|
return TRUE; |
256 |
|
|
} |
257 |
|
|
} |
258 |
|
|
|
259 |
|
|
|
260 |
|
|
|
261 |
|
|
//class EditTextForm extends StandardFormContent { |
262 |
|
|
class EditTextForm extends EditDataItem { |
263 |
|
|
|
264 |
|
|
var $_whichNews; |
265 |
|
|
var $_sql_key_long; |
266 |
|
|
var $_sql_key_short; |
267 |
|
|
var $_sql_key_title; |
268 |
|
|
var $_sql_key_source; |
269 |
|
|
var $_language; |
270 |
|
|
|
271 |
|
|
function EditTextForm($title, $width, $whichNews, $whichLanguage, $options=array()) { |
272 |
|
|
// something that has to be executed BEFORE parent constructor |
273 |
|
|
// |
274 |
|
|
|
275 |
|
|
$parent = get_parent_class($this); |
276 |
|
|
$this->$parent($title,$options); |
277 |
|
|
$this->_whichNews = $whichNews; |
278 |
|
|
$this->_sql_key_long = "page/news/feed/" . $whichNews . "/long"; |
279 |
|
|
$this->_sql_key_short = "page/news/feed/" . $whichNews . "/short"; |
280 |
|
|
$this->_sql_key_title = "page/news/feed/" . $whichNews . "/title"; |
281 |
|
|
$this->_sql_key_source = "page/news/feed/" . $whichNews . "/source"; |
282 |
|
|
$this->_language = $whichLanguage; |
283 |
|
|
} |
284 |
|
|
|
285 |
|
|
function form_init_elements() { |
286 |
|
|
//we want an confirmation page for this form. |
287 |
|
|
|
288 |
|
|
global $app; |
289 |
|
|
|
290 |
|
|
$this->set_confirm(); |
291 |
|
|
|
292 |
|
|
// add hidden element for page control |
293 |
|
|
$this->add_hidden_element( 't', 'News' ); |
294 |
|
|
$this->add_hidden_element( 'subtopic', $_REQUEST['subtopic'] ); |
295 |
|
|
|
296 |
|
|
$this->add_element( new FEText("Titel", true, 10, 20)); |
297 |
|
|
$this->add_element( new FETextArea("kurzer Text", true, 10, 20)); |
298 |
|
|
$this->add_element( new FETextArea("langer Text", true, 10, 20)); |
299 |
|
|
$this->add_element( new FEText("Quelle", true, 10, 20)); |
300 |
|
|
|
301 |
|
|
$handle=opendir ($app->getConfig("path.news.img.archive")); |
302 |
|
|
$myFileList= array(); |
303 |
|
|
while ($myFile = readdir ($handle)) { |
304 |
|
|
if (($myFile <> ".") && ($myFile<> "..") && (strstr($myFile, "."))){$myFileList[$myFile] = $myFile;} |
305 |
|
|
} |
306 |
|
|
closedir($handle); |
307 |
|
|
|
308 |
|
|
$this->add_element( new FEListBox("Bilderarchiv", FALSE,"200px", "80px",$myFileList)); |
309 |
|
|
|
310 |
|
|
} |
311 |
|
|
function form_init_data() { |
312 |
|
|
|
313 |
|
|
foreach($this->_datasource->_result as $key => $value) { |
314 |
|
|
if ($value['lcountrykey'] == $this->_language) { |
315 |
|
|
if ($value['lkey'] == $this->_sql_key_long) { |
316 |
|
|
$this->set_element_value("langer Text", $value['lvalue']); |
317 |
|
|
} |
318 |
|
|
if ($value['lkey'] == $this->_sql_key_short) { |
319 |
|
|
$this->set_element_value("kurzer Text", $value['lvalue']); |
320 |
|
|
} |
321 |
|
|
if ($value['lkey'] == $this->_sql_key_title) { |
322 |
|
|
$this->set_element_value("Titel", $value['lvalue']); |
323 |
|
|
} |
324 |
|
|
if ($value['lkey'] == $this->_sql_key_source) { |
325 |
|
|
$this->set_element_value("Quelle", $value['lvalue']); |
326 |
|
|
} |
327 |
|
|
} |
328 |
|
|
} |
329 |
|
|
|
330 |
|
|
$this->set_element_value("Bilderarchiv", array()); |
331 |
|
|
|
332 |
|
|
} |
333 |
|
|
|
334 |
|
|
|
335 |
|
|
function form_content() { |
336 |
|
|
$this->add_form_block("Please enter new text below " . $this->_whichNews, $this->_upload() ); |
337 |
|
|
} |
338 |
|
|
|
339 |
|
|
function &_upload() { |
340 |
|
|
|
341 |
|
|
$table = &html_table($this->_width, 0, 2); |
342 |
|
|
|
343 |
|
|
$table->add_row($this->element_label("Titel"), $this->element_form("Titel")); |
344 |
|
|
$table->add_row($this->element_label("kurzer Text"), $this->element_form("kurzer Text") ); |
345 |
|
|
$table->add_row($this->element_label("langer Text"), $this->element_form("langer Text") ); |
346 |
|
|
$table->add_row($this->element_label("Quelle"), $this->element_form("Quelle")); |
347 |
|
|
$table->add_row($this->element_label("Bilderarchiv"), $this->element_form("Bilderarchiv")); |
348 |
|
|
|
349 |
|
|
return $table; |
350 |
|
|
} |
351 |
|
|
|
352 |
|
|
|
353 |
|
|
function form_action() { |
354 |
|
|
|
355 |
|
|
$data = array(); |
356 |
|
|
|
357 |
|
|
foreach($this->_datasource->_result as $key => $value) { |
358 |
|
|
if ($value['lcountrykey'] == $this->_language) { |
359 |
|
|
if ($value['lkey'] == $this->_sql_key_long) { |
360 |
|
|
$data[$key] = $value; |
361 |
|
|
$data[$key]['lvalue'] = $this->get_element_value("langer Text"); |
362 |
|
|
} |
363 |
|
|
if ($value['lkey'] == $this->_sql_key_short) { |
364 |
|
|
$data[$key] = $value; |
365 |
|
|
$data[$key]['lvalue'] = $this->get_element_value("kurzer Text"); |
366 |
|
|
} |
367 |
|
|
if ($value['lkey'] == $this->_sql_key_title) { |
368 |
|
|
$data[$key] = $value; |
369 |
|
|
$data[$key]['lvalue'] = $this->get_element_value("Titel"); |
370 |
|
|
} |
371 |
|
|
if ($value['lkey'] == $this->_sql_key_source) { |
372 |
|
|
$data[$key] = $value; |
373 |
|
|
$data[$key]['lvalue'] = $this->get_element_value("Quelle"); |
374 |
|
|
} |
375 |
|
|
} |
376 |
|
|
} |
377 |
|
|
|
378 |
|
|
|
379 |
|
|
|
380 |
|
|
// write new data to datasource in $data as array (keep old indices, set new values) |
381 |
|
|
$this->_options['data_locator_meta']['action'] = "write"; |
382 |
|
|
$this->_options['data_locator_meta']['data'] = $data; |
383 |
|
|
// TODO: 'data_prefetch()' will never return ANYTHING! |
384 |
|
|
// Implement some error-handling there or somewhere. |
385 |
|
|
$error = $this->data_prefetch(); |
386 |
|
|
|
387 |
|
|
|
388 |
|
|
|
389 |
|
|
|
390 |
|
|
//$error = $this->_datasource->set($item); |
391 |
|
|
/* if(!$error) { |
392 |
|
|
// fetch fresh data |
393 |
|
|
$this->_options['data_locator_meta']['action'] = "read"; |
394 |
|
|
// unset previous initialed 'data' var |
395 |
|
|
$this->_options['data_locator_meta']['data'] = NULL; |
396 |
|
|
$this->data_prefetch(); |
397 |
|
|
|
398 |
|
|
$this->set_action_message($this->_confirm_msg); |
399 |
|
|
return TRUE; |
400 |
|
|
} else { |
401 |
|
|
return FALSE; |
402 |
|
|
}*/ |
403 |
|
|
|
404 |
|
|
global $app; |
405 |
|
|
|
406 |
|
|
// This contains the image-file that has to be moved from the archive-dir to the online-dir. |
407 |
|
|
// The name of the file has to be changed to the name which is hardcoded in the news-templates. |
408 |
|
|
// The online-dir will already contain a file with this name but possibly with a different suffix. |
409 |
|
|
// Make sure that this will be removed also, so that there is only one file matching in the online-dir. |
410 |
|
|
|
411 |
|
|
// prepare to copy selected file from archive-dir to online-dir |
412 |
|
|
|
413 |
|
|
|
414 |
|
|
if ($this->get_element_value("Bilderarchiv")) { |
415 |
|
|
$_dest_file_suffix = substr($this->get_element_value("Bilderarchiv"), count($this->get_element_value("Bilderarchiv")) - 4, 4); |
416 |
|
|
$_dest_file_name = $app->getConfig("path.news.img.online"). $this->_language ."/img_news_" . $this->_whichNews . "." . $_dest_file_suffix; |
417 |
|
|
$_source_file_name = $app->getConfig("path.news.img.archive") . $this->get_element_value("Bilderarchiv"); |
418 |
|
|
|
419 |
|
|
// delete all files in online-dir, which have the current news-number in the filename |
420 |
|
|
|
421 |
|
|
$handle=opendir ($app->getConfig("path.news.img.online") . $this->_language. "/"); |
422 |
|
|
|
423 |
|
|
while ($myFile = readdir ($handle)) { |
424 |
|
|
if (substr($myFile, 9, 1) == $this->_whichNews){unlink($app->getConfig("path.news.img.online") . "de/" . $myFile);} |
425 |
|
|
} |
426 |
|
|
closedir($handle); |
427 |
|
|
|
428 |
|
|
copy($_source_file_name, $_dest_file_name); |
429 |
|
|
} |
430 |
|
|
|
431 |
|
|
} |
432 |
|
|
|
433 |
|
|
function form_backend_validation() { |
434 |
|
|
$this->set_action("Confirm"); |
435 |
|
|
return TRUE; |
436 |
|
|
} |
437 |
|
|
|
438 |
|
|
/** |
439 |
|
|
* This method is called ONLY after ALL validation has |
440 |
|
|
* passed. This is the method that allows you to |
441 |
|
|
* do something with the data, say insert/update records |
442 |
|
|
* in the DB. |
443 |
|
|
*/ |
444 |
|
|
function confirm_action() { |
445 |
|
|
|
446 |
|
|
|
447 |
|
|
/* |
448 |
|
|
// all of the following is to be done later !!!!! |
449 |
|
|
|
450 |
|
|
// get data |
451 |
|
|
//print "All fetched RPC items: " . Dumper($this->_datasource->_result) . "<br>"; |
452 |
|
|
|
453 |
|
|
// write new data to datasource in $data as array (keep old indices, set new values) |
454 |
|
|
$this->_options['data_locator_meta']['action'] = "write"; |
455 |
|
|
$this->_options['data_locator_meta']['data'] = $data; |
456 |
|
|
// TODO: 'data_prefetch()' will never return ANYTHING! |
457 |
|
|
// Implement some error-handling there or somewhere. |
458 |
|
|
$error = $this->data_prefetch(); |
459 |
|
|
|
460 |
|
|
//$error = $this->_datasource->set($item); |
461 |
|
|
if(!$error) { |
462 |
|
|
// fetch fresh data |
463 |
|
|
$this->_options['data_locator_meta']['action'] = "read"; |
464 |
|
|
// unset previous initialed 'data' var |
465 |
|
|
$this->_options['data_locator_meta']['data'] = NULL; |
466 |
|
|
$this->data_prefetch(); |
467 |
|
|
|
468 |
|
|
$this->set_action_message($this->_confirm_msg); |
469 |
|
|
return TRUE; |
470 |
|
|
} else { |
471 |
|
|
return FALSE; |
472 |
|
|
}*/ |
473 |
|
|
return TRUE; |
474 |
|
|
} |
475 |
|
|
|
476 |
|
|
|
477 |
|
|
} |
478 |
|
|
|
479 |
|
|
|
480 |
|
|
////////////////////////////////////////////////////////////////////////////////////////// |
481 |
|
|
|
482 |
|
|
|
483 |
|
|
|
484 |
|
|
class UploadForm extends StandardFormContent { |
485 |
|
|
|
486 |
|
|
function UploadForm($title, $width) { |
487 |
|
|
// something that has to be executed BEFORE parent constructor |
488 |
|
|
// |
489 |
|
|
//$this->_feFile = new FEFile("testfile", TRUE, 20); |
490 |
|
|
// |
491 |
|
|
$parent = get_parent_class($this); |
492 |
|
|
$this->$parent($title, $PHP_SELF, $width=600); |
493 |
|
|
} |
494 |
|
|
|
495 |
|
|
function form_init_elements() { |
496 |
|
|
|
497 |
|
|
//print_r "scandir($this->_uploaddir)"; |
498 |
|
|
|
499 |
|
|
// add hidden element for page control |
500 |
|
|
$this->add_hidden_element( 't', 'News' ); |
501 |
|
|
$this->add_hidden_element( 'subtopic', 'upload' ); |
502 |
|
|
$this->set_confirm(false); |
503 |
|
|
$this->add_element( new FEFile("File")); |
504 |
|
|
|
505 |
|
|
} |
506 |
|
|
function form_init_data() { |
507 |
|
|
// ??? |
508 |
|
|
} |
509 |
|
|
|
510 |
|
|
|
511 |
|
|
function form_content() { |
512 |
|
|
$this->add_form_block("Waehlen Sie hier ein neues Bild aus:", $this->_upload() ); |
513 |
|
|
} |
514 |
|
|
|
515 |
|
|
function &_upload() { |
516 |
|
|
$table = &html_table($this->_width, 0, 2); |
517 |
|
|
$table->add_row($this->element_label("File"),$this->element_form("File") ); |
518 |
|
|
|
519 |
|
|
return $table; |
520 |
|
|
} |
521 |
|
|
|
522 |
|
|
|
523 |
|
|
function form_action() { |
524 |
|
|
|
525 |
|
|
global $app; |
526 |
|
|
|
527 |
|
|
$tmp = $this->get_element("File"); |
528 |
|
|
$fileInformation = $tmp->get_file_info(); |
529 |
|
|
if ($fileInformation["tmp_name"] > "") { |
530 |
|
|
|
531 |
|
|
$uploadfile = $app->getConfig("path.news.img.archive") . $fileInformation["name"]; |
532 |
|
|
|
533 |
|
|
/* the destination-name of the uploaded film is hardcoded, but not the suffix (.jpg ....) |
534 |
|
|
* so we have to ensure that there are no double files with the same filename but different suffixes |
535 |
|
|
* in the online - folder |
536 |
|
|
* |
537 |
|
|
*/ |
538 |
|
|
|
539 |
|
|
if (move_uploaded_file($fileInformation["tmp_name"], $uploadfile)) { |
540 |
|
|
print "File was successfully uploaded. "; |
541 |
|
|
//print_r($_FILES); |
542 |
|
|
} else { |
543 |
|
|
print "File not uploaded\n"; |
544 |
|
|
//print_r($_FILES); |
545 |
|
|
} |
546 |
|
|
} |
547 |
|
|
|
548 |
|
|
} |
549 |
|
|
|
550 |
|
|
function form_backend_validation() { |
551 |
|
|
//$this->set_action("Confirm"); |
552 |
|
|
return TRUE; |
553 |
|
|
} |
554 |
|
|
|
555 |
|
|
|
556 |
|
|
function &_user_info() { |
557 |
|
|
$table = &html_table(100,0,2); |
558 |
|
|
$table->add_row($this->element_label("File"), $this->element_form("File")); |
559 |
|
|
|
560 |
|
|
return $table; |
561 |
|
|
} |
562 |
|
|
|
563 |
|
|
} |
564 |
|
|
|
565 |
|
|
?> |