19 declare(strict_types=1);
    62         $this->
lng = $DIC->language();
    63         $this->
ctrl = $DIC->ctrl();
    66         if (isset($DIC[
"ilUser"])) {
    67             $this->
user = $DIC[
"ilUser"];
    71         if (isset($DIC[
"ilSetting"])) {
    75         $lng = $DIC->language();
    83         if (isset($DIC[
"http"])) {
    84             $this->
http = $DIC->http();
    86         if (isset($DIC[
"refinery"])) {
    90         if (isset($DIC[
"tpl"])) {      
    91             $this->global_tpl = $DIC[
'tpl'];
   105         switch ($next_class) {
   106             case 'ilformpropertydispatchgui':
   107                 $ilCtrl->saveParameter($this, 
'postvar');
   110                 $form_prop_dispatch->setItem($item);
   111                 return $ilCtrl->forwardCommand($form_prop_dispatch);
   118         $t = $this->
refinery->kindlyTo()->string();
   119         $w = $this->
http->wrapper();
   120         if ($w->post()->has(
"postvar")) {
   121             return $w->post()->retrieve(
"postvar", $t);
   123         if ($w->query()->has(
"postvar")) {
   124             return $w->query()->retrieve(
"postvar", $t);
   131         $this->tbl_width = $a_width;
   142         $this->mode = $a_mode;
   152         $this->title = $a_title;
   162         $this->titleicon = $a_titleicon;
   172         $this->description = $a_val;
   182         $this->top_anchor = $a_val;
   192         $this->show_top_buttons = $a_val;
   202         $this->force_top_buttons = $a_val;
   215         $a_item->setParentForm($this);
   216         $this->items[] = $a_item;
   221         bool $a_remove_unused_headers = 
false   223         foreach ($this->items as 
$key => $item) {
   224             if (method_exists($item, 
"getPostVar") && $item->getPostVar() == $a_post_var) {
   225                 unset($this->items[
$key]);
   230         if ($a_remove_unused_headers) {
   231             $unset_keys = array();
   234             foreach ($this->items as 
$key => $item) {
   236                     $unset_keys[] = $last_key;
   242                 $unset_keys[] = $last_key;
   244             foreach ($unset_keys as 
$key) {
   245                 unset($this->items[$key]);
   252         foreach ($this->items as $item) {
   253             if ($item->getType() != 
"section_header") {
   255                 $ret = $item->getItemByPostVar($a_post_var);
   256                 if (is_object($ret)) {
   267         $this->items = $a_items;
   281         $inputItems = array();
   283         foreach ($this->items as $item) {
   284             if ($item->getType() == 
'section_header') {
   288             $inputItems[] = $item;
   291                 $inputItems = array_merge($inputItems, $item->getSubInputItemsRecursive());
   300         $this->disable_standard_message = $a_val;
   316         $this->hide_labels = $a_value;
   321         bool $a_restrict_to_value_keys = 
false   323         foreach ($this->items as $item) {
   324             if (!($a_restrict_to_value_keys) ||
   325                 in_array($item->getPostVar(), array_keys($a_values))) {
   326                 $item->setValueByArray($a_values);
   335         if (!isset($DIC[
"http"])) {
   339         foreach ($this->items as $item) {
   340             $item->setValueByArray($DIC->http()->request()->getParsedBody());
   348         if ($this->check_input_called) {
   349             die(
"Error: ilPropertyFormGUI->checkInput() called twice.");
   353         foreach ($this->items as $item) {
   354             $item_ok = $item->checkInput();
   361         $post = $this->
http->request()->getParsedBody();
   362         if (count($this->items) > 0 && count(
$post) === 0) {
   366         $this->check_input_called = 
true;
   370         if (!$ok && !is_null($filehash) && $filehash && count($_FILES)) {
   373             foreach ($_FILES as $field => 
$data) {
   377                 if (is_null($item) || !$item->checkInput()) {
   381                 if (is_array(
$data[
"tmp_name"])) {
   382                     foreach (
$data[
"tmp_name"] as $idx => $upload) {
   383                         if (is_array($upload)) {
   384                             foreach ($upload as $idx2 => $file) {
   385                                 if ($file && is_uploaded_file($file)) {
   386                                     $file_name = 
$data[
"name"][$idx][$idx2];
   387                                     $file_type = 
$data[
"type"][$idx][$idx2];
   388                                     $this->keepFileUpload($hash, $field, $file, $file_name, $file_type, (
string) $idx, (
string) $idx2);
   391                         } elseif ($upload && is_uploaded_file($upload)) {
   392                             $file_name = 
$data[
"name"][$idx];
   393                             $file_type = 
$data[
"type"][$idx];
   394                             $this->keepFileUpload($hash, $field, $upload, $file_name, $file_type, (
string) $idx);
   398                     $this->keepFileUpload($hash, $field, 
$data[
"tmp_name"], 
$data[
"name"], 
$data[
"type"]);
   402         $http = $DIC->http();
   403         $txt = $DIC->language()->txt(
"form_input_not_valid");
   404         switch ($http->request()->getHeaderLine(
'Accept')) {
   406             case 'application/json':
   411                 $http->saveResponse($http->response()->withBody($stream));
   419                     $this->global_tpl->setOnScreenMessage(
'failure', 
$txt);
   432         $t = $this->
refinery->kindlyTo()->string();
   433         $w = $this->
http->wrapper();
   435         if ($w->post()->has(
"ilfilehash")) {
   436             $filehash = $w->post()->retrieve(
"ilfilehash", $t);
   450         bool $ensureValidation = 
true   453         if (!$this->check_input_called && $ensureValidation) {
   454             throw new LogicException(
'Error: ilPropertyFormGUI->getInput() called without calling checkInput() first.');
   458         if (is_object($item) && method_exists($item, 
"getInput")) {
   459             return $item->getInput();
   462         $post = $this->
http->request()->getParsedBody();
   463         return $post[$a_post_var] ?? 
'';
   471         $this->buttons[] = array(
"cmd" => $a_cmd, 
"text" => $a_text, 
"id" => $a_id);
   482         $this->buttons = array();
   495         $tpl->addJavaScript(
"./Services/JavaScript/js/Basic.js");
   496         $tpl->addJavaScript(
"Services/Form/js/Form.js");
   498         $this->tpl = 
new ilTemplate(
"tpl.property_form.html", 
true, 
true, 
"Services/Form");
   503         $fi = $this->items[0] ?? null;
   504         if ($this->
getMode() == 
"std" &&
   506             is_object($fi) && $fi->getType() == 
"section_header"   509             unset($this->items[0]);
   515             $this->tpl->setCurrentBlock(
"title_icon");
   516             $this->tpl->setVariable(
"IMG_ICON", $this->
getTitleIcon());
   517             $this->tpl->parseCurrentBlock();
   523             if (count($this->buttons) > 0 && $this->
getShowTopButtons() && (count($this->items) > 2 || $this->force_top_buttons)) {
   525                 foreach ($this->buttons as $button) {
   526                     $this->tpl->setCurrentBlock(
"cmd2");
   527                     $this->tpl->setVariable(
"CMD", $button[
"cmd"]);
   528                     $this->tpl->setVariable(
"CMD_TXT", $button[
"text"]);
   529                     if ($button[
"id"] != 
"") {
   530                         $this->tpl->setVariable(
"CMD2_ID", 
" id='" . $button[
"id"] . 
"_top'");
   532                     $this->tpl->parseCurrentBlock();
   534                 $this->tpl->setCurrentBlock(
"commands2");
   535                 $this->tpl->parseCurrentBlock();
   539             $this->tpl->setCurrentBlock(
"header");
   541                 $this->tpl->setCurrentBlock(
"required_text_top");
   542                 $this->tpl->setVariable(
"TXT_REQUIRED_TOP", $lng->
txt(
"required_field"));
   543                 $this->tpl->parseCurrentBlock();
   545             $this->tpl->setVariable(
"TXT_TITLE", $this->
getTitle());
   547             $this->tpl->setVariable(
"TXT_DESCRIPTION", $this->
getDescription());
   548             $this->tpl->parseCurrentBlock();
   549         } elseif (!$this->required_text && $this->
getMode() == 
"std") {
   550             $this->tpl->setCurrentBlock(
"header");
   552             $this->tpl->setCurrentBlock(
"required_text_top");
   553             $this->tpl->setVariable(
"TXT_REQUIRED_TOP", $lng->
txt(
"required_field"));
   554             $this->tpl->parseCurrentBlock();
   556         $this->tpl->touchBlock(
"item");
   559         $this->required_text = 
false;
   560         foreach ($this->items as $item) {
   561             if ($item->getType() != 
"hidden") {
   567         if ($this->required_text && $this->
getMode() == 
"std") {
   568             $this->tpl->setCurrentBlock(
"required_text");
   569             $this->tpl->setVariable(
"TXT_REQUIRED", $lng->
txt(
"required_field"));
   570             $this->tpl->parseCurrentBlock();
   574         foreach ($this->buttons as $button) {
   575             $this->tpl->setCurrentBlock(
"cmd");
   576             $this->tpl->setVariable(
"CMD", $button[
"cmd"]);
   577             $this->tpl->setVariable(
"CMD_TXT", $button[
"text"]);
   579             if ($button[
"id"] != 
"") {
   580                 $this->tpl->setVariable(
"CMD_ID", 
" id='" . $button[
"id"] . 
"'");
   583             $this->tpl->parseCurrentBlock();
   587         if ($this->
getMode() != 
"subform") {
   592                     $hash = md5(uniqid((
string) mt_rand(), 
true));
   595                 $fhash->setValue($hash);
   601         $hidden_fields = 
false;
   602         foreach ($this->items as $item) {
   603             if ($item->getType() == 
"hidden") {
   604                 $item->insert($this->tpl);
   605                 $hidden_fields = 
true;
   609         if ($this->required_text || count($this->buttons) > 0 || $hidden_fields) {
   610             $this->tpl->setCurrentBlock(
"commands");
   611             $this->tpl->parseCurrentBlock();
   615         if ($this->
getMode() == 
"subform") {
   616             $this->tpl->touchBlock(
"sub_table");
   618             $this->tpl->touchBlock(
"std_table");
   619             $this->tpl->setVariable(
'STD_TABLE_WIDTH', $this->
getTableWidth());
   622         return $this->tpl->get();
   628         return $a_type == 
"non_editable_value";
   636         bool $a_sub_item = 
false   647             $tpl->addJavascript(
"./Services/Form/js/ServiceFormMulti.js");
   650             $this->tpl->setVariable(
"ID", $item->getFieldId());
   651             $this->tpl->parseCurrentBlock();
   653             $this->tpl->touchBlock(
"multi_out");
   658             $multi_values = $item->getMultiValues();
   659             if (is_array($multi_values) && 
sizeof($multi_values) > 1) {
   660                 $multi_value = 
new ilHiddenInputGUI(
"ilMultiValues~" . $item->getPostVar());
   661                 $multi_value->
setValue(base64_encode(json_encode($multi_values)));
   667         $item->insert($this->tpl);
   669         if ($item->getType() == 
"file" || $item->getType() == 
"image_file") {
   673         if ($item->getType() != 
"section_header") {
   677             if ($item->getInfo() != 
"") {
   678                 $this->tpl->setCurrentBlock(
"description");
   679                 $this->tpl->setVariable(
   680                     "PROPERTY_DESCRIPTION",
   683                 $this->tpl->setVariable(
   684                     "DESCRIPTION_FOR_ID",
   687                 $this->tpl->parseCurrentBlock();
   690             if ($this->
getMode() == 
"subform") {
   693                     if ($item->getRequired()) {
   694                         $this->tpl->touchBlock(
"sub_required");
   695                         $this->required_text = 
true;
   700                 if ($item->getHiddenTitle() != 
"") {
   701                     $this->tpl->setCurrentBlock(
"sub_hid_title");
   702                     $this->tpl->setVariable(
   704                         $item->getHiddenTitle()
   706                     $this->tpl->parseCurrentBlock();
   709                 $this->tpl->setCurrentBlock(
"sub_prop_start");
   710                 $this->tpl->setVariable(
"PROPERTY_TITLE", $item->getTitle());
   711                 $this->tpl->setVariable(
"PROPERTY_CLASS", 
"il_" . $item->getType());
   712                 if ($item->getType() != 
"non_editable_value" && $item->getFormLabelFor() != 
"") {
   713                     $this->tpl->setVariable(
"FOR_ID", 
' for="' . $item->getFormLabelFor() . 
'" ');
   715                 $this->tpl->setVariable(
"LAB_ID", $item->getFieldId());
   719                     if ($item->getRequired()) {
   720                         $this->tpl->touchBlock(
"required");
   721                         $this->required_text = 
true;
   726                 if ($item->getHiddenTitle() != 
"") {
   727                     $this->tpl->setCurrentBlock(
"std_hid_title");
   728                     $this->tpl->setVariable(
   730                         $item->getHiddenTitle()
   732                     $this->tpl->parseCurrentBlock();
   735                 $this->tpl->setCurrentBlock(
"std_prop_start");
   736                 $this->tpl->setVariable(
"PROPERTY_TITLE", $item->getTitle());
   737                 if ($item->getType() != 
"non_editable_value" && $item->getFormLabelFor() != 
"") {
   738                     $this->tpl->setVariable(
"FOR_ID", 
' for="' . $item->getFormLabelFor() . 
'" ');
   740                 $this->tpl->setVariable(
"LAB_ID", $item->getFieldId());
   742                     $this->tpl->setVariable(
"HIDE_LABELS_STYLE", 
" ilFormOptionHidden");
   745             $this->tpl->parseCurrentBlock();
   748             if ($item->getType() != 
"non_editable_value" && $item->getAlert() != 
"") {
   749                 $this->tpl->setCurrentBlock(
"alert");
   750                 $this->tpl->setVariable(
   754                 $this->tpl->setVariable(
   758                 $this->tpl->setVariable(
   762                 $this->tpl->setVariable(
   766                 $this->tpl->parseCurrentBlock();
   771             if ($item->getType() != 
"non_editable_value" or 1) {
   772                 $sf = $item->getSubForm();
   773                 if ($item->hideSubForm() && is_object($sf)) {
   774                     if ($this->global_tpl) {
   775                         $dsfid = $item->getFieldId();
   776                         $this->global_tpl->addOnloadCode(
   777                             "il.Form.hideSubForm('subform_$dsfid');"   785             if (is_object($sf)) {
   786                 $sf_content = $sf->getContent();
   787                 if ($sf->getMultipart()) {
   790                 $this->tpl->setCurrentBlock(
"sub_form");
   791                 $this->tpl->setVariable(
"PROP_SUB_FORM", $sf_content);
   792                 $this->tpl->setVariable(
"SFID", $item->getFieldId());
   793                 $this->tpl->parseCurrentBlock();
   796             $this->tpl->setCurrentBlock(
"prop");
   800             $this->tpl->parseCurrentBlock();
   804         $this->tpl->touchBlock(
"item");
   809         $this->onload_code[] = $code;
   814         $html = parent::getHTML();
   817         foreach ($this->items as $item) {
   819             if (method_exists($item, 
"getContentOutsideFormTag")) {
   820                 $outside = $item->getContentOutsideFormTag();
   826         if ($this->
ctrl->isAsynch()) {
   835         if (!$this->
ctrl->isAsynch()) {
   843         if (count($this->onload_code) > 0) {
   845             foreach ($this->onload_code as $code) {
   846                 $html .= $code . 
"\n";
   848             $html .= 
"</script>";
   869     protected function keepFileUpload(
   875         ?
string $a_index = null,
   876         ?
string $a_sub_index = null
   878         if (in_array($a_tmp_name, $this->kept_uploads)) {
   882         if (trim($a_tmp_name) == 
"") {
   888         $tmp_file_name = implode(
"~~", array(session_id(),
   893             str_replace(
"/", 
"~~", $a_type),
   894             str_replace(
"~~", 
"_", $a_name)));
   898         if (!is_dir($temp_path)) {
   906         $file_input->setPending($a_name);
   907         $this->kept_uploads[] = $a_tmp_name;
   920         ?
string $a_index = null,
   921         ?
string $a_sub_index = null
   925             if ($_FILES[$a_field][
"tmp_name"][$a_index][$a_sub_index] ?? 
false) {
   927                     "tmp_name" => $_FILES[$a_field][
"tmp_name"][$a_index][$a_sub_index],
   928                     "name" => $_FILES[$a_field][
"name"][$a_index][$a_sub_index],
   929                     "type" => $_FILES[$a_field][
"type"][$a_index][$a_sub_index],
   930                     "error" => $_FILES[$a_field][
"error"][$a_index][$a_sub_index],
   931                     "size" => $_FILES[$a_field][
"size"][$a_index][$a_sub_index],
   932                     "is_upload" => $_FILES[$a_field][
"is_upload"][$a_index][$a_sub_index] ?? 
true   935         } elseif ($a_sub_index) {
   936             if ($_FILES[$a_field][
"tmp_name"][$a_index] ?? 
false) {
   938                     "tmp_name" => $_FILES[$a_field][
"tmp_name"][$a_index],
   939                     "name" => $_FILES[$a_field][
"name"][$a_index],
   940                     "type" => $_FILES[$a_field][
"type"][$a_index],
   941                     "error" => $_FILES[$a_field][
"error"][$a_index],
   942                     "size" => $_FILES[$a_field][
"size"][$a_index],
   943                     "is_upload" => $_FILES[$a_field][
"is_upload"][$a_index] ?? 
true   947             if ($_FILES[$a_field][
"tmp_name"] ?? 
false) {
   949                     "tmp_name" => $_FILES[$a_field][
"tmp_name"],
   950                     "name" => $_FILES[$a_field][
"name"],
   951                     "type" => $_FILES[$a_field][
"type"],
   952                     "error" => $_FILES[$a_field][
"error"],
   953                     "size" => $_FILES[$a_field][
"size"],
   954                     "is_upload" => $_FILES[$a_field][
"is_upload"] ?? 
true   963         ?
string $a_index = null,
   964         ?
string $a_sub_index = null
   967         return (
bool) (
$data[
"tmp_name"] ?? 
false);
   982         string $a_target_directory,
   984         ?
string $a_target_name = null,
   985         ?
string $a_index = null,
   986         ?
string $a_sub_index = null
   988         if (!is_dir($a_target_directory)) {
   993         if (
$data[
"tmp_name"] && file_exists(
$data[
"tmp_name"])) {
   994             if ($a_target_name) {
   995                 $data[
"name"] = $a_target_name;
   998             $target_file = $a_target_directory . 
"/" . 
$data[
"name"];
   999             $target_file = str_replace(
"//", 
"/", $target_file);
  1001             if (
$data[
"is_upload"]) {
  1011             return $target_file;
  1019         if ($file_hash != 
"") {
  1021             if (is_dir($temp_path)) {
  1022                 $temp_files = glob($temp_path . 
"/" . session_id() . 
"~~" . $file_hash . 
"~~*");
  1023                 if (is_array($temp_files)) {
  1024                     foreach ($temp_files as $full_file) {
  1025                         $file = explode(
"~~", basename($full_file));
  1029                         $type = $file[5] . 
"/" . $file[6];
  1033                             if (!isset($_FILES[$field][
"tmp_name"][$idx][$idx2])) {
  1034                                 $_FILES[$field][
"tmp_name"][$idx][$idx2] = $full_file;
  1035                                 $_FILES[$field][
"name"][$idx][$idx2] = 
$name;
  1036                                 $_FILES[$field][
"type"][$idx][$idx2] = $type;
  1037                                 $_FILES[$field][
"error"][$idx][$idx2] = 0;
  1038                                 $_FILES[$field][
"size"][$idx][$idx2] = filesize($full_file);
  1039                                 $_FILES[$field][
"is_upload"][$idx][$idx2] = 
false;
  1041                         } elseif ($idx != 
"") {
  1042                             if (!isset($_FILES[$field][
"tmp_name"][$idx])) {
  1043                                 $_FILES[$field][
"tmp_name"][$idx] = $full_file;
  1044                                 $_FILES[$field][
"name"][$idx] = 
$name;
  1045                                 $_FILES[$field][
"type"][$idx] = $type;
  1046                                 $_FILES[$field][
"error"][$idx] = 0;
  1047                                 $_FILES[$field][
"size"][$idx] = filesize($full_file);
  1048                                 $_FILES[$field][
"is_upload"][$idx] = 
false;
  1051                             if (!isset($_FILES[$field][
"tmp_name"])) {
  1052                                 $_FILES[$field][
"tmp_name"] = $full_file;
  1053                                 $_FILES[$field][
"name"] = 
$name;
  1054                                 $_FILES[$field][
"type"] = $type;
  1055                                 $_FILES[$field][
"error"] = 0;
  1056                                 $_FILES[$field][
"size"] = filesize($full_file);
  1057                                 $_FILES[$field][
"is_upload"] = 
false;
  1068         foreach ($this->items as $item) {
  1071             } elseif ($item->getType() != 
"hidden") {
  1072                 if ($this->
getMode() == 
"subform") {
  1074                         if ($item->getRequired()) {
  1079                     if ($item->getRequired()) {
 This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
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...
 
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory) 
 
loadLanguageModule(string $a_module)
Load language module. 
 
static getASCIIFilename(string $a_filename)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static initDom(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Dom. 
 
getNextClass($a_gui_class=null)
 
static http()
Fetches the global http state from ILIAS. 
 
static createDirectory(string $a_dir, int $a_mod=0755)
create directory 
 
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file 
 
static getDataDir()
get data directory (outside webspace) 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static ofString(string $string)
Creates a new stream with an initial value. 
 
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
 
static rename(string $a_source, string $a_target)
 
static initEvent(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Event.