4 require_once
'Services/Form/classes/class.ilTextInputGUI.php';
5 require_once
'Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php';
30 $this->
setSuffixes(array(
"jpg",
"jpeg",
"png",
"gif"));
32 $this->validationRegexp =
"";
42 $this->values = array();
43 if (is_array($a_value))
45 if (is_array($a_value[
'count']))
47 foreach ($a_value[
'count'] as $index =>
$value)
49 array_push($this->values, $a_value[
'imagename'][$index]);
62 $this->suffixes = $a_suffixes;
82 $this->values = $a_values;
102 $this->qstObject =& $a_value;
122 $this->allowMove = $a_allow_move;
145 if (is_array($_FILES[$this->
getPostVar()][
'error'][
'image']))
147 foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as $index => $error)
154 case UPLOAD_ERR_INI_SIZE:
155 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
159 case UPLOAD_ERR_FORM_SIZE:
160 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
164 case UPLOAD_ERR_PARTIAL:
165 $this->
setAlert($lng->txt(
"form_msg_file_partially_uploaded"));
169 case UPLOAD_ERR_NO_FILE:
174 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
180 case UPLOAD_ERR_NO_TMP_DIR:
181 $this->
setAlert($lng->txt(
"form_msg_file_missing_tmp_dir"));
185 case UPLOAD_ERR_CANT_WRITE:
186 $this->
setAlert($lng->txt(
"form_msg_file_cannot_write_to_disk"));
190 case UPLOAD_ERR_EXTENSION:
191 $this->
setAlert($lng->txt(
"form_msg_file_upload_stopped_ext"));
202 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
207 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image']))
209 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname)
213 $suffix = $filename_arr[
"extension"];
214 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
215 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
217 if (strlen($tmpname) && is_array($this->
getSuffixes()))
221 $this->
setAlert($lng->txt(
"form_msg_file_wrong_file_type"));
228 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image']))
230 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname)
234 $suffix = $filename_arr[
"extension"];
235 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
236 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
238 if (strlen($tmpname))
241 if ($vir[0] ==
false)
243 $this->
setAlert($lng->txt(
"form_msg_file_virus_found").
"<br />".$vir[1]);
262 $tpl =
new ilTemplate(
"tpl.prop_imagewizardinput.html",
true,
true,
"Modules/TestQuestionPool");
264 foreach ($this->values as
$value)
268 $imagename = $this->qstObject->getImagePathWeb() .
$value;
269 if ($this->qstObject->getThumbSize())
271 if (@file_exists($this->qstObject->getImagePath() . $this->qstObject->getThumbPrefix() .
$value))
273 $imagename = $this->qstObject->getImagePathWeb() . $this->qstObject->getThumbPrefix() .
$value;
276 $tpl->setCurrentBlock(
'image');
277 $tpl->setVariable(
'SRC_IMAGE', $imagename);
278 $tpl->setVariable(
'IMAGE_NAME', $value);
280 $tpl->setVariable(
"TXT_DELETE_EXISTING", $lng->txt(
"delete_existing_file"));
281 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
283 $tpl->parseCurrentBlock();
285 $tpl->setCurrentBlock(
'addimage');
286 $tpl->setVariable(
"IMAGE_ID", $this->
getPostVar() .
"[image][$i]");
287 $tpl->setVariable(
"IMAGE_SUBMIT", $lng->txt(
"upload"));
288 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
290 $tpl->parseCurrentBlock();
294 $tpl->setCurrentBlock(
"move");
295 $tpl->setVariable(
"CMD_UP",
"cmd[up" . $this->
getFieldId() .
"][$i]");
296 $tpl->setVariable(
"CMD_DOWN",
"cmd[down" . $this->
getFieldId() .
"][$i]");
300 $tpl->parseCurrentBlock();
302 $tpl->setCurrentBlock(
"row");
304 $tpl->setVariable(
"ROW_NUMBER", $i);
306 $tpl->setVariable(
"CMD_ADD",
"cmd[add" . $this->
getFieldId() .
"][$i]");
307 $tpl->setVariable(
"CMD_REMOVE",
"cmd[remove" . $this->
getFieldId() .
"][$i]");
310 $tpl->parseCurrentBlock();
316 $suff_str = $delim =
"";
319 $suff_str.= $delim.
".".
$suffix;
322 $tpl->setCurrentBlock(
'allowed_image_suffixes');
323 $tpl->setVariable(
"TXT_ALLOWED_SUFFIXES", $lng->txt(
"file_allowed_suffixes").
" ".$suff_str);
324 $tpl->parseCurrentBlock();
334 $tpl->setVariable(
"TEXT_YES", $lng->txt(
'yes'));
335 $tpl->setVariable(
"TEXT_NO", $lng->txt(
'no'));
336 $tpl->setVariable(
"DELETE_IMAGE_HEADER", $lng->txt(
'delete_image_header'));
337 $tpl->setVariable(
"DELETE_IMAGE_QUESTION", $lng->txt(
'delete_image_question'));
338 $tpl->setVariable(
"ANSWER_TEXT", $lng->txt(
'answer_text'));
339 $tpl->setVariable(
"COMMANDS_TEXT", $lng->txt(
'actions'));
341 $a_tpl->setCurrentBlock(
"prop_generic");
342 $a_tpl->setVariable(
"PROP_GENERIC",
$tpl->get());
343 $a_tpl->parseCurrentBlock();
346 $tpl->addJavascript(
"./Services/Form/js/ServiceFormWizardInput.js");
347 $tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/imagewizard.js");