24 include_once 
"./Modules/TestQuestionPool/classes/class.ilSingleChoiceWizardInputGUI.php";
 
   54                 $this->
setSuffixes(array(
"jpg", 
"jpeg", 
"png", 
"gif"));
 
   56                 $this->text_name = $lng->txt(
'answer_text');
 
   57                 $this->image_name = $lng->txt(
'answer_image');
 
   67                 $this->suffixes = $a_suffixes;
 
   87                 $this->hideImages = $a_hide;
 
   97                 $this->values = $a_values;
 
  112                 $this->text_name = $a_value;
 
  117                 $this->image_name = $a_value;
 
  127                 $this->qstObject =& $a_value;
 
  147                 $this->allowMove = $a_allow_move;
 
  167                 $this->values = array();
 
  168                 if (is_array($a_value))
 
  170                         if (is_array($a_value[
'answer']))
 
  172                                 foreach ($a_value[
'answer'] as $index => 
$value)
 
  174                                         include_once 
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
 
  176                                         array_push($this->values, $answer);
 
  190                 include_once 
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
 
  193                 if (is_array($foundvalues))
 
  196                         if (is_array($foundvalues[
'answer']))
 
  198                                 foreach ($foundvalues[
'answer'] as $aidx => $answervalue)
 
  200                                         if (((strlen($answervalue)) == 0) && (strlen($foundvalues[
'imagename'][$aidx]) == 0))
 
  202                                                 $this->
setAlert($lng->txt(
"msg_input_is_required"));
 
  210                                 if (is_array($_FILES[$this->
getPostVar()][
'error'][
'image']))
 
  212                                         foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as $index => $error)
 
  219                                                                 case UPLOAD_ERR_INI_SIZE:
 
  220                                                                         $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
 
  224                                                                 case UPLOAD_ERR_FORM_SIZE:
 
  225                                                                         $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
 
  229                                                                 case UPLOAD_ERR_PARTIAL:
 
  230                                                                         $this->
setAlert($lng->txt(
"form_msg_file_partially_uploaded"));
 
  234                                                                 case UPLOAD_ERR_NO_FILE:
 
  237                                                                                 if ((!strlen($foundvalues[
'imagename'][$index])) && (!strlen($foundvalues[
'answer'][$index])))
 
  239                                                                                         $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
 
  245                                                                 case UPLOAD_ERR_NO_TMP_DIR:
 
  246                                                                         $this->
setAlert($lng->txt(
"form_msg_file_missing_tmp_dir"));
 
  250                                                                 case UPLOAD_ERR_CANT_WRITE:
 
  251                                                                         $this->
setAlert($lng->txt(
"form_msg_file_cannot_write_to_disk"));
 
  255                                                                 case UPLOAD_ERR_EXTENSION:
 
  256                                                                         $this->
setAlert($lng->txt(
"form_msg_file_upload_stopped_ext"));
 
  267                                                 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
 
  272                                 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image']))
 
  274                                         foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname)
 
  278                                                 $suffix = $filename_arr[
"extension"];
 
  279                                                 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
 
  280                                                 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
 
  282                                                 if (strlen($tmpname) && is_array($this->
getSuffixes()))
 
  286                                                                 $this->
setAlert($lng->txt(
"form_msg_file_wrong_file_type"));
 
  293                                 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image']))
 
  295                                         foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname)
 
  299                                                 $suffix = $filename_arr[
"extension"];
 
  300                                                 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
 
  301                                                 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
 
  303                                                 if (strlen($tmpname))
 
  306                                                         if ($vir[0] == 
false)
 
  308                                                                 $this->
setAlert($lng->txt(
"form_msg_file_virus_found").
"<br />".$vir[1]);
 
  328                 $tpl = 
new ilTemplate(
"tpl.prop_matchingwizardinput.html", 
true, 
true, 
"Modules/TestQuestionPool");
 
  330                 foreach ($this->values as 
$value)
 
  332                         if (!$this->hideImages)
 
  334                                 if (strlen($value->picture))
 
  336                                         $imagename = $this->qstObject->getImagePathWeb() . $value->picture;
 
  337                                         if ($this->qstObject->getThumbSize())
 
  339                                                 if (@file_exists($this->qstObject->getImagePath() . $this->qstObject->getThumbPrefix() . $value->picture))
 
  341                                                         $imagename = $this->qstObject->getImagePathWeb() . $this->qstObject->getThumbPrefix() . $value->picture;
 
  344                                         $tpl->setCurrentBlock(
'image');
 
  345                                         $tpl->setVariable(
'SRC_IMAGE', $imagename);
 
  346                                         $tpl->setVariable(
'IMAGE_NAME', $value->picture);
 
  348                                         $tpl->setVariable(
"TXT_DELETE_EXISTING", $lng->txt(
"delete_existing_file"));
 
  349                                         $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
 
  351                                         $tpl->parseCurrentBlock();
 
  353                                 $tpl->setCurrentBlock(
'addimage');
 
  354                                 $tpl->setVariable(
"IMAGE_ID", $this->
getPostVar() . 
"[image][$i]");
 
  355                                 $tpl->setVariable(
"IMAGE_SUBMIT", $lng->txt(
"upload"));
 
  356                                 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
 
  358                                 $tpl->parseCurrentBlock();
 
  361                         if (is_object($value))
 
  363                                 $tpl->setCurrentBlock(
"prop_text_propval");
 
  365                                 $tpl->parseCurrentBlock();
 
  370                         $tpl->setVariable(
"SINGLELINE_ID", $this->
getPostVar() . 
"[answer][$i]");
 
  371                         $tpl->setVariable(
"SINGLELINE_ROW_NUMBER", $i);
 
  376                                 $tpl->setVariable(
"DISABLED_SINGLELINE", 
" disabled=\"disabled\"");
 
  378                         $tpl->parseCurrentBlock();
 
  381                                 $tpl->setCurrentBlock(
"move");
 
  382                                 $tpl->setVariable(
"CMD_UP", 
"cmd[up" . $this->
getFieldId() . 
"][$i]");
 
  383                                 $tpl->setVariable(
"CMD_DOWN", 
"cmd[down" . $this->
getFieldId() . 
"][$i]");
 
  387                                 $tpl->parseCurrentBlock();
 
  389                         $tpl->setCurrentBlock(
"row");
 
  390                         $class = ($i % 2 == 0) ? 
"even" : 
"odd";
 
  391                         if ($i == 0) $class .= 
" first";
 
  392                         if ($i == count($this->values)-1) $class .= 
" last";
 
  393                         $tpl->setVariable(
"ROW_CLASS", $class);
 
  395                         $tpl->setVariable(
"ROW_NUMBER", $i+1);
 
  396                         $tpl->setVariable(
"ROW_IDENTIFIER", $value->identifier);
 
  398                         $tpl->setVariable(
"CMD_ADD", 
"cmd[add" . $this->
getFieldId() . 
"][$i]");
 
  399                         $tpl->setVariable(
"CMD_REMOVE", 
"cmd[remove" . $this->
getFieldId() . 
"][$i]");
 
  402                         $tpl->parseCurrentBlock();
 
  406                 if (!$this->hideImages)
 
  410                                 $suff_str = $delim = 
"";
 
  413                                         $suff_str.= $delim.
".".
$suffix;
 
  416                                 $tpl->setCurrentBlock(
'allowed_image_suffixes');
 
  417                                 $tpl->setVariable(
"TXT_ALLOWED_SUFFIXES", $lng->txt(
"file_allowed_suffixes").
" ".$suff_str);
 
  418                                 $tpl->parseCurrentBlock();
 
  420                         $tpl->setCurrentBlock(
"image_heading");
 
  421                         $tpl->setVariable(
"ANSWER_IMAGE", $this->image_name);
 
  423                         $tpl->parseCurrentBlock();
 
  427                 $tpl->setVariable(
"TEXT_YES", $lng->txt(
'yes'));
 
  428                 $tpl->setVariable(
"TEXT_NO", $lng->txt(
'no'));
 
  429                 $tpl->setVariable(
"DELETE_IMAGE_HEADER", $lng->txt(
'delete_image_header'));
 
  430                 $tpl->setVariable(
"DELETE_IMAGE_QUESTION", $lng->txt(
'delete_image_question'));
 
  431                 $tpl->setVariable(
"ANSWER_TEXT", $this->text_name);
 
  432                 $tpl->setVariable(
"NUMBER_TEXT", $lng->txt(
'row'));
 
  433                 $tpl->setVariable(
"COMMANDS_TEXT", $lng->txt(
'actions'));
 
  435                 $a_tpl->setCurrentBlock(
"prop_generic");
 
  436                 $a_tpl->setVariable(
"PROP_GENERIC", 
$tpl->get());
 
  437                 $a_tpl->parseCurrentBlock();