4 require_once
'Services/Form/classes/class.ilTextInputGUI.php';
33 $this->
setSuffixes(array(
"jpg",
"jpeg",
"png",
"gif"));
35 $this->validationRegexp =
"";
69 $this->values = array();
70 if (is_array($a_value))
72 if (is_array($a_value[
'count']))
74 foreach ($a_value[
'count'] as $index =>
$value)
76 array_push($this->values, $a_value[
'imagename'][$index]);
89 $this->suffixes = $a_suffixes;
109 $this->values = $a_values;
129 $this->qstObject =& $a_value;
149 $this->allowMove = $a_allow_move;
172 if (is_array($_FILES[$this->
getPostVar()][
'error'][
'image']))
174 foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as $index => $error)
181 case UPLOAD_ERR_INI_SIZE:
182 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
186 case UPLOAD_ERR_FORM_SIZE:
187 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
191 case UPLOAD_ERR_PARTIAL:
192 $this->
setAlert($lng->txt(
"form_msg_file_partially_uploaded"));
196 case UPLOAD_ERR_NO_FILE:
201 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
207 case UPLOAD_ERR_NO_TMP_DIR:
208 $this->
setAlert($lng->txt(
"form_msg_file_missing_tmp_dir"));
212 case UPLOAD_ERR_CANT_WRITE:
213 $this->
setAlert($lng->txt(
"form_msg_file_cannot_write_to_disk"));
217 case UPLOAD_ERR_EXTENSION:
218 $this->
setAlert($lng->txt(
"form_msg_file_upload_stopped_ext"));
229 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
234 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image']))
236 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname)
240 $suffix = $filename_arr[
"extension"];
241 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
242 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
244 if (strlen($tmpname) && is_array($this->
getSuffixes()))
248 $this->
setAlert($lng->txt(
"form_msg_file_wrong_file_type"));
255 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image']))
257 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname)
261 $suffix = $filename_arr[
"extension"];
262 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
263 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
265 if (strlen($tmpname))
268 if ($vir[0] ==
false)
270 $this->
setAlert($lng->txt(
"form_msg_file_virus_found").
"<br />".$vir[1]);
289 $tpl =
new ilTemplate(
"tpl.prop_imagewizardinput.html",
true,
true,
"Modules/TestQuestionPool");
291 foreach ($this->values as
$value)
295 $imagename = $this->qstObject->getImagePathWeb() .
$value;
296 if ($this->qstObject->getThumbSize())
298 if (@file_exists($this->qstObject->getImagePath() . $this->qstObject->getThumbPrefix() .
$value))
300 $imagename = $this->qstObject->getImagePathWeb() . $this->qstObject->getThumbPrefix() .
$value;
303 $tpl->setCurrentBlock(
'image');
304 $tpl->setVariable(
'SRC_IMAGE', $imagename);
305 $tpl->setVariable(
'IMAGE_NAME', $value);
307 $tpl->setVariable(
"TXT_DELETE_EXISTING", $lng->txt(
"delete_existing_file"));
308 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
310 if($this->disable_upload)
312 $tpl->setVariable(
'DISABLED_UPLOADS',
' disabled="disabled"');
314 $tpl->parseCurrentBlock();
316 $tpl->setCurrentBlock(
'addimage');
317 $tpl->setVariable(
"IMAGE_ID", $this->
getPostVar() .
"[image][$i]");
318 $tpl->setVariable(
"IMAGE_SUBMIT", $lng->txt(
"upload"));
319 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
321 if($this->disable_upload)
323 $tpl->setVariable(
'DISABLED_UPLOADS',
' disabled="disabled"');
325 $tpl->parseCurrentBlock();
329 $tpl->setCurrentBlock(
"move");
330 $tpl->setVariable(
"CMD_UP",
"cmd[up" . $this->
getFieldId() .
"][$i]");
331 $tpl->setVariable(
"CMD_DOWN",
"cmd[down" . $this->
getFieldId() .
"][$i]");
335 $tpl->parseCurrentBlock();
337 $tpl->setCurrentBlock(
"row");
338 $class = ($i % 2 == 0) ?
"even" :
"odd";
339 if ($i == 0) $class .=
" first";
340 if ($i == count($this->values)-1) $class .=
" last";
341 $tpl->setVariable(
"ROW_CLASS", $class);
343 $tpl->setVariable(
"ROW_NUMBER", $i);
345 if(!$this->disable_actions)
349 $tpl->setVariable(
"CMD_ADD",
"cmd[add" . $this->
getFieldId() .
"][$i]");
350 $tpl->setVariable(
"CMD_REMOVE",
"cmd[remove" . $this->
getFieldId() .
"][$i]");
357 $tpl->parseCurrentBlock();
363 $suff_str = $delim =
"";
366 $suff_str.= $delim.
".".
$suffix;
369 $tpl->setCurrentBlock(
'allowed_image_suffixes');
370 $tpl->setVariable(
"TXT_ALLOWED_SUFFIXES", $lng->txt(
"file_allowed_suffixes").
" ".$suff_str);
371 $tpl->parseCurrentBlock();
381 $tpl->setVariable(
"TEXT_YES", $lng->txt(
'yes'));
382 $tpl->setVariable(
"TEXT_NO", $lng->txt(
'no'));
383 $tpl->setVariable(
"DELETE_IMAGE_HEADER", $lng->txt(
'delete_image_header'));
384 $tpl->setVariable(
"DELETE_IMAGE_QUESTION", $lng->txt(
'delete_image_question'));
385 $tpl->setVariable(
"ANSWER_TEXT", $lng->txt(
'answer_text'));
386 $tpl->setVariable(
"COMMANDS_TEXT", $lng->txt(
'actions'));
388 $a_tpl->setCurrentBlock(
"prop_generic");
389 $a_tpl->setVariable(
"PROP_GENERIC",
$tpl->get());
390 $a_tpl->parseCurrentBlock();
393 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
395 $tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/imagewizard.js");