47 $this->
setSuffixes(array(
"jpg",
"jpeg",
"png",
"gif"));
49 $this->validationRegexp =
"";
59 $this->values = array();
60 if (is_array($a_value))
62 if (is_array($a_value[
'count']))
64 foreach ($a_value[
'count'] as $index =>
$value)
66 array_push($this->values, $a_value[
'imagename'][$index]);
79 $this->suffixes = $a_suffixes;
99 $this->values = $a_values;
119 $this->qstObject =& $a_value;
139 $this->allowMove = $a_allow_move;
162 if (is_array($_FILES[$this->
getPostVar()][
'error'][
'image']))
164 foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as $index =>
$error)
171 case UPLOAD_ERR_INI_SIZE:
172 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
176 case UPLOAD_ERR_FORM_SIZE:
177 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
181 case UPLOAD_ERR_PARTIAL:
182 $this->
setAlert($lng->txt(
"form_msg_file_partially_uploaded"));
186 case UPLOAD_ERR_NO_FILE:
191 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
197 case UPLOAD_ERR_NO_TMP_DIR:
198 $this->
setAlert($lng->txt(
"form_msg_file_missing_tmp_dir"));
202 case UPLOAD_ERR_CANT_WRITE:
203 $this->
setAlert($lng->txt(
"form_msg_file_cannot_write_to_disk"));
207 case UPLOAD_ERR_EXTENSION:
208 $this->
setAlert($lng->txt(
"form_msg_file_upload_stopped_ext"));
219 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
224 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image']))
226 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname)
230 $suffix = $filename_arr[
"extension"];
231 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
232 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
234 if (strlen($tmpname) && is_array($this->
getSuffixes()))
238 $this->
setAlert($lng->txt(
"form_msg_file_wrong_file_type"));
245 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image']))
247 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname)
251 $suffix = $filename_arr[
"extension"];
252 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
253 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
255 if (strlen($tmpname))
258 if ($vir[0] ==
false)
260 $this->
setAlert($lng->txt(
"form_msg_file_virus_found").
"<br />".$vir[1]);
279 $tpl =
new ilTemplate(
"tpl.prop_imagewizardinput.html",
true,
true,
"Modules/TestQuestionPool");
281 foreach ($this->values as
$value)
285 $imagename = $this->qstObject->getImagePathWeb() .
$value;
286 if ($this->qstObject->getThumbSize())
288 if (@file_exists($this->qstObject->getImagePath() . $this->qstObject->getThumbPrefix() .
$value))
290 $imagename = $this->qstObject->getImagePathWeb() . $this->qstObject->getThumbPrefix() .
$value;
293 $tpl->setCurrentBlock(
'image');
294 $tpl->setVariable(
'SRC_IMAGE', $imagename);
295 $tpl->setVariable(
'IMAGE_NAME', $value);
297 $tpl->setVariable(
"TXT_DELETE_EXISTING", $lng->txt(
"delete_existing_file"));
298 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
300 $tpl->parseCurrentBlock();
302 $tpl->setCurrentBlock(
'addimage');
303 $tpl->setVariable(
"IMAGE_ID", $this->
getPostVar() .
"[image][$i]");
304 $tpl->setVariable(
"IMAGE_SUBMIT", $lng->txt(
"upload"));
305 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
307 $tpl->parseCurrentBlock();
311 $tpl->setCurrentBlock(
"move");
312 $tpl->setVariable(
"CMD_UP",
"cmd[up" . $this->
getFieldId() .
"][$i]");
313 $tpl->setVariable(
"CMD_DOWN",
"cmd[down" . $this->
getFieldId() .
"][$i]");
317 $tpl->parseCurrentBlock();
319 $tpl->setCurrentBlock(
"row");
320 $class = ($i % 2 == 0) ?
"even" :
"odd";
321 if ($i == 0) $class .=
" first";
322 if ($i == count($this->values)-1) $class .=
" last";
323 $tpl->setVariable(
"ROW_CLASS", $class);
325 $tpl->setVariable(
"ROW_NUMBER", $i);
327 $tpl->setVariable(
"CMD_ADD",
"cmd[add" . $this->
getFieldId() .
"][$i]");
328 $tpl->setVariable(
"CMD_REMOVE",
"cmd[remove" . $this->
getFieldId() .
"][$i]");
331 $tpl->parseCurrentBlock();
337 $suff_str = $delim =
"";
340 $suff_str.= $delim.
".".
$suffix;
343 $tpl->setCurrentBlock(
'allowed_image_suffixes');
344 $tpl->setVariable(
"TXT_ALLOWED_SUFFIXES", $lng->txt(
"file_allowed_suffixes").
" ".$suff_str);
345 $tpl->parseCurrentBlock();
347 $tpl->setCurrentBlock(
"image_heading");
348 $tpl->setVariable(
"ANSWER_IMAGE", $lng->txt(
'answer_image'));
350 $tpl->parseCurrentBlock();
353 $tpl->setVariable(
"TEXT_YES", $lng->txt(
'yes'));
354 $tpl->setVariable(
"TEXT_NO", $lng->txt(
'no'));
355 $tpl->setVariable(
"DELETE_IMAGE_HEADER", $lng->txt(
'delete_image_header'));
356 $tpl->setVariable(
"DELETE_IMAGE_QUESTION", $lng->txt(
'delete_image_question'));
357 $tpl->setVariable(
"ANSWER_TEXT", $lng->txt(
'answer_text'));
358 $tpl->setVariable(
"COMMANDS_TEXT", $lng->txt(
'actions'));
360 $a_tpl->setCurrentBlock(
"prop_generic");
361 $a_tpl->setVariable(
"PROP_GENERIC",
$tpl->get());
362 $a_tpl->parseCurrentBlock();
365 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
367 $tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/imagewizard.js");