58 $this->glyph_factory =
$DIC->ui()->factory()->symbol()->glyph();
59 $this->button_factory =
$DIC->ui()->factory()->button();
60 $this->
renderer = $DIC->ui()->renderer();
61 $this->upload_limit =
$DIC[
'ui.upload_limit_resolver'];
68 $this->text_name =
$lng->
txt(
'answer_text');
69 $this->image_name =
$lng->
txt(
'answer_image');
79 $this->suffixes = $a_suffixes;
99 $this->hideImages = $a_hide;
109 $this->values = $a_values;
124 $this->text_name = $a_value;
129 $this->image_name = $a_value;
139 $this->qstObject = &$a_value;
156 $answers = $this->forms_helper->transformArray($a_value,
'answer', $this->
refinery->kindlyTo()->string());
157 $imagename = $this->forms_helper->transformArray($a_value,
'imagename', $this->
refinery->kindlyTo()->string());
158 $identifier = $this->forms_helper->transformArray($a_value,
'identifier', $this->
refinery->kindlyTo()->int());
160 foreach ($answers as $index =>
$value) {
163 $imagename[$index] ??
'',
164 $identifier[$index] ?? 0
177 if (!is_array(
$data)) {
178 $this->
setAlert($this->
lng->txt(
'msg_input_is_required'));
183 $answers = $this->forms_helper->transformArray(
$data,
'answer', $this->
refinery->kindlyTo()->string());
184 $images = $this->forms_helper->transformArray(
$data,
'imagename', $this->
refinery->kindlyTo()->string());
185 foreach ($answers as $index =>
$value) {
188 && !$this->forms_helper->inArray($images, $index)
189 && !isset($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'][$index])
191 $this->
setAlert($this->
lng->txt(
'msg_input_is_required'));
196 if (!$this->hideImages) {
197 if (is_array($_FILES[$this->
getPostVar()][
'error'][
'image'])) {
198 foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as $index => $error) {
202 case UPLOAD_ERR_FORM_SIZE:
203 case UPLOAD_ERR_INI_SIZE:
204 $this->
setAlert($this->
lng->txt(
'form_msg_file_size_exceeds'));
208 case UPLOAD_ERR_PARTIAL:
209 $this->
setAlert($this->
lng->txt(
'form_msg_file_partially_uploaded'));
213 case UPLOAD_ERR_NO_FILE:
215 !$this->forms_helper->inArray($images, $index)
216 && !$this->forms_helper->inArray($answers, $index)
217 && $this->getRequired()
219 $this->
setAlert($this->
lng->txt(
'form_msg_file_no_upload'));
224 case UPLOAD_ERR_NO_TMP_DIR:
225 $this->
setAlert($this->
lng->txt(
'form_msg_file_missing_tmp_dir'));
229 case UPLOAD_ERR_CANT_WRITE:
230 $this->
setAlert($this->
lng->txt(
'form_msg_file_cannot_write_to_disk'));
234 case UPLOAD_ERR_EXTENSION:
235 $this->
setAlert($this->
lng->txt(
'form_msg_file_upload_stopped_ext'));
243 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'])) {
244 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname) {
247 $suffix = $filename_arr[
'extension'] ??
'';
250 if ($tmpname !==
'' && is_array($this->
getSuffixes())) {
252 if ($vir[0] ==
false) {
253 $this->
setAlert($this->
lng->txt(
'form_msg_file_virus_found') .
'<br />' . $vir[1]);
258 $this->
setAlert($this->
lng->txt(
'form_msg_file_wrong_file_type'));
278 $global_tpl->addJavascript(
'assets/js/matchinginput.js');
281 $tpl =
new ilTemplate(
"tpl.prop_matchingwizardinput.html",
true,
true,
"components/ILIAS/TestQuestionPool");
283 foreach ($this->values as
$value) {
284 if (!$this->hideImages) {
285 if (
$value->getPicture() &&
286 file_exists($this->qstObject->getImagePath() .
$value->getPicture())
288 $imagename = $this->qstObject->getImagePathWeb() .
$value->getPicture();
289 if ($this->qstObject->getThumbSize()) {
290 if (file_exists($this->qstObject->getImagePath() . $this->qstObject->getThumbPrefix() .
$value->getPicture())) {
291 $imagename = $this->qstObject->getImagePathWeb() . $this->qstObject->getThumbPrefix() .
$value->getPicture();
295 $tpl->setCurrentBlock(
'image');
296 $tpl->setVariable(
'SRC_IMAGE', $imagename);
297 $tpl->setVariable(
'IMAGE_NAME',
$value->getPicture());
299 $tpl->setVariable(
"TXT_DELETE_EXISTING",
$lng->
txt(
"delete_existing_file"));
300 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
301 $tpl->setVariable(
"IMAGE_POST_VAR", $this->
getPostVar());
302 $tpl->parseCurrentBlock();
304 $tpl->setCurrentBlock(
'addimage');
305 $tpl->setVariable(
"IMAGE_BROWSE",
$lng->
txt(
'select_file'));
306 $tpl->setVariable(
"IMAGE_ID", $this->
getPostVar() .
"[image][$i]");
307 $tpl->setVariable(
'MAX_SIZE_WARNING', $this->
lng->txt(
'form_msg_file_size_exceeds'));
308 $tpl->setVariable(
'MAX_SIZE', $this->upload_limit->getPhpUploadLimitInBytes());
309 $tpl->setVariable(
"IMAGE_SUBMIT",
$lng->
txt(
"upload"));
310 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
311 $tpl->setVariable(
"IMAGE_POST_VAR", $this->
getPostVar());
312 $tpl->parseCurrentBlock();
316 $tpl->setCurrentBlock(
"prop_text_propval");
318 $tpl->parseCurrentBlock();
322 $tpl->setVariable(
"SIZE", $this->
getSize());
323 $tpl->setVariable(
"SINGLELINE_ID", $this->
getPostVar() .
"[answer][$i]");
324 $tpl->setVariable(
"SINGLELINE_ROW_NUMBER", $i);
325 $tpl->setVariable(
"SINGLELINE_POST_VAR", $this->
getPostVar());
328 $tpl->setVariable(
"DISABLED_SINGLELINE",
" disabled=\"disabled\"");
330 $tpl->parseCurrentBlock();
331 $tpl->setCurrentBlock(
"row");
332 $tpl->setVariable(
"POST_VAR", $this->
getPostVar());
333 $tpl->setVariable(
"ROW_NUMBER", $i + 1);
334 $tpl->setVariable(
"ROW_IDENTIFIER",
$value->getIdentifier());
335 $tpl->setVariable(
"ID", $this->
getPostVar() .
"[answer][$i]");
336 $tpl->setVariable(
"ADD_BUTTON", $this->
renderer->render(
337 $this->button_factory->shy(
'',
'')->withSymbol($this->glyph_factory->add())
339 $tpl->setVariable(
"REMOVE_BUTTON", $this->
renderer->render(
340 $this->button_factory->shy(
'',
'')->withSymbol($this->glyph_factory->remove())
342 $tpl->parseCurrentBlock();
346 if (!$this->hideImages) {
348 $suff_str = $delim =
"";
350 $suff_str .= $delim .
"." .
$suffix;
353 $tpl->setCurrentBlock(
'allowed_image_suffixes');
354 $tpl->setVariable(
"TXT_ALLOWED_SUFFIXES",
$lng->
txt(
"file_allowed_suffixes") .
" " . $suff_str);
355 $tpl->parseCurrentBlock();
357 $tpl->setCurrentBlock(
"image_heading");
358 $tpl->setVariable(
"ANSWER_IMAGE", $this->image_name);
360 $tpl->parseCurrentBlock();
363 $tpl->setVariable(
"ELEMENT_ID", $this->
getPostVar());
364 $tpl->setVariable(
"TEXT_YES",
$lng->
txt(
'yes'));
365 $tpl->setVariable(
"TEXT_NO",
$lng->
txt(
'no'));
366 $tpl->setVariable(
"DELETE_IMAGE_HEADER",
$lng->
txt(
'delete_image_header'));
367 $tpl->setVariable(
"DELETE_IMAGE_QUESTION",
$lng->
txt(
'delete_image_question'));
368 $tpl->setVariable(
"ANSWER_TEXT", $this->text_name);
369 $tpl->setVariable(
"NUMBER_TEXT",
$lng->
txt(
'row'));
370 $tpl->setVariable(
"COMMANDS_TEXT",
$lng->
txt(
'actions'));
379 $this->pending = $a_val;
setVariable($variable, $value='')
Sets a variable value.
Builds a Color from either hex- or rgb values.
Class for matching question terms.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
This class represents a text property in a property form.
setMaxLength(?int $a_maxlength)
static virusHandling(string $a_file, string $a_orig_name='', bool $a_clean=true)
addOnLoadCode(string $a_code, int $a_batch=2)
Add on load code.
This is how a factory for glyphs looks like.
An entity that renders components to a string output.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc