24 require_once
'Services/Form/classes/class.ilTextInputGUI.php';
49 $this->
setSuffixes(array(
"jpg",
"jpeg",
"png",
"gif"));
51 $this->validationRegexp =
"";
61 $this->values = array();
62 if (is_array($a_value))
64 if (is_array($a_value[
'count']))
66 foreach ($a_value[
'count'] as $index =>
$value)
68 array_push($this->values, $a_value[
'imagename'][$index]);
81 $this->suffixes = $a_suffixes;
101 $this->values = $a_values;
121 $this->qstObject =& $a_value;
141 $this->allowMove = $a_allow_move;
164 if (is_array($_FILES[$this->
getPostVar()][
'error'][
'image']))
166 foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as $index => $error)
173 case UPLOAD_ERR_INI_SIZE:
174 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
178 case UPLOAD_ERR_FORM_SIZE:
179 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
183 case UPLOAD_ERR_PARTIAL:
184 $this->
setAlert($lng->txt(
"form_msg_file_partially_uploaded"));
188 case UPLOAD_ERR_NO_FILE:
193 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
199 case UPLOAD_ERR_NO_TMP_DIR:
200 $this->
setAlert($lng->txt(
"form_msg_file_missing_tmp_dir"));
204 case UPLOAD_ERR_CANT_WRITE:
205 $this->
setAlert($lng->txt(
"form_msg_file_cannot_write_to_disk"));
209 case UPLOAD_ERR_EXTENSION:
210 $this->
setAlert($lng->txt(
"form_msg_file_upload_stopped_ext"));
221 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
226 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image']))
228 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname)
232 $suffix = $filename_arr[
"extension"];
233 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
234 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
236 if (strlen($tmpname) && is_array($this->
getSuffixes()))
240 $this->
setAlert($lng->txt(
"form_msg_file_wrong_file_type"));
247 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image']))
249 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname)
253 $suffix = $filename_arr[
"extension"];
254 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
255 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
257 if (strlen($tmpname))
260 if ($vir[0] ==
false)
262 $this->
setAlert($lng->txt(
"form_msg_file_virus_found").
"<br />".$vir[1]);
281 $tpl =
new ilTemplate(
"tpl.prop_imagewizardinput.html",
true,
true,
"Modules/TestQuestionPool");
283 foreach ($this->values as
$value)
287 $imagename = $this->qstObject->getImagePathWeb() .
$value;
288 if ($this->qstObject->getThumbSize())
290 if (@file_exists($this->qstObject->getImagePath() . $this->qstObject->getThumbPrefix() .
$value))
292 $imagename = $this->qstObject->getImagePathWeb() . $this->qstObject->getThumbPrefix() .
$value;
295 $tpl->setCurrentBlock(
'image');
296 $tpl->setVariable(
'SRC_IMAGE', $imagename);
297 $tpl->setVariable(
'IMAGE_NAME', $value);
299 $tpl->setVariable(
"TXT_DELETE_EXISTING", $lng->txt(
"delete_existing_file"));
300 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
302 $tpl->parseCurrentBlock();
304 $tpl->setCurrentBlock(
'addimage');
305 $tpl->setVariable(
"IMAGE_ID", $this->
getPostVar() .
"[image][$i]");
306 $tpl->setVariable(
"IMAGE_SUBMIT", $lng->txt(
"upload"));
307 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
309 $tpl->parseCurrentBlock();
313 $tpl->setCurrentBlock(
"move");
314 $tpl->setVariable(
"CMD_UP",
"cmd[up" . $this->
getFieldId() .
"][$i]");
315 $tpl->setVariable(
"CMD_DOWN",
"cmd[down" . $this->
getFieldId() .
"][$i]");
319 $tpl->parseCurrentBlock();
321 $tpl->setCurrentBlock(
"row");
322 $class = ($i % 2 == 0) ?
"even" :
"odd";
323 if ($i == 0) $class .=
" first";
324 if ($i == count($this->values)-1) $class .=
" last";
325 $tpl->setVariable(
"ROW_CLASS", $class);
327 $tpl->setVariable(
"ROW_NUMBER", $i);
329 $tpl->setVariable(
"CMD_ADD",
"cmd[add" . $this->
getFieldId() .
"][$i]");
330 $tpl->setVariable(
"CMD_REMOVE",
"cmd[remove" . $this->
getFieldId() .
"][$i]");
333 $tpl->parseCurrentBlock();
339 $suff_str = $delim =
"";
342 $suff_str.= $delim.
".".
$suffix;
345 $tpl->setCurrentBlock(
'allowed_image_suffixes');
346 $tpl->setVariable(
"TXT_ALLOWED_SUFFIXES", $lng->txt(
"file_allowed_suffixes").
" ".$suff_str);
347 $tpl->parseCurrentBlock();
357 $tpl->setVariable(
"TEXT_YES", $lng->txt(
'yes'));
358 $tpl->setVariable(
"TEXT_NO", $lng->txt(
'no'));
359 $tpl->setVariable(
"DELETE_IMAGE_HEADER", $lng->txt(
'delete_image_header'));
360 $tpl->setVariable(
"DELETE_IMAGE_QUESTION", $lng->txt(
'delete_image_question'));
361 $tpl->setVariable(
"ANSWER_TEXT", $lng->txt(
'answer_text'));
362 $tpl->setVariable(
"COMMANDS_TEXT", $lng->txt(
'actions'));
364 $a_tpl->setCurrentBlock(
"prop_generic");
365 $a_tpl->setVariable(
"PROP_GENERIC",
$tpl->get());
366 $a_tpl->parseCurrentBlock();
369 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
371 $tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/imagewizard.js");