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(
"assets/js/Basic.js");
   496         $tpl->addJavaScript(
"assets/js/Form.js");
   498         $this->tpl = 
new ilTemplate(
"tpl.property_form.html", 
true, 
true, 
"components/ILIAS/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();
   546             $this->tpl->setVariable(
"TXT_TITLE", $this->
getTitle());
   548             $this->tpl->setVariable(
"TXT_DESCRIPTION", $this->
getDescription());
   549             $this->tpl->parseCurrentBlock();
   550         } elseif (!$this->required_text && $this->
getMode() == 
"std") {
   551             $this->tpl->setCurrentBlock(
"header");
   553             $this->tpl->setCurrentBlock(
"required_text_top");
   554             $this->tpl->setVariable(
"TXT_REQUIRED_TOP", $lng->
txt(
"required_field"));
   555             $this->tpl->parseCurrentBlock();
   557         $this->tpl->touchBlock(
"item");
   560         $this->required_text = 
false;
   561         foreach ($this->items as $item) {
   562             if ($item->getType() != 
"hidden") {
   568         if ($this->required_text && $this->
getMode() == 
"std") {
   569             $this->tpl->setCurrentBlock(
"required_text");
   570             $this->tpl->setVariable(
"TXT_REQUIRED", $lng->
txt(
"required_field"));
   571             $this->tpl->parseCurrentBlock();
   575         foreach ($this->buttons as $button) {
   576             $this->tpl->setCurrentBlock(
"cmd");
   577             $this->tpl->setVariable(
"CMD", $button[
"cmd"]);
   578             $this->tpl->setVariable(
"CMD_TXT", $button[
"text"]);
   580             if ($button[
"id"] != 
"") {
   581                 $this->tpl->setVariable(
"CMD_ID", 
" id='" . $button[
"id"] . 
"'");
   584             $this->tpl->parseCurrentBlock();
   588         if ($this->
getMode() != 
"subform") {
   593                     $hash = md5(uniqid((
string) mt_rand(), 
true));
   596                 $fhash->setValue($hash);
   602         $hidden_fields = 
false;
   603         foreach ($this->items as $item) {
   604             if ($item->getType() == 
"hidden") {
   605                 $item->insert($this->tpl);
   606                 $hidden_fields = 
true;
   610         if ($this->required_text || count($this->buttons) > 0 || $hidden_fields) {
   611             $this->tpl->setCurrentBlock(
"commands");
   612             $this->tpl->parseCurrentBlock();
   616         if ($this->
getMode() == 
"subform") {
   617             $this->tpl->touchBlock(
"sub_table");
   619             $this->tpl->touchBlock(
"std_table");
   620             $this->tpl->setVariable(
'STD_TABLE_WIDTH', $this->
getTableWidth());
   623         return $this->tpl->get();
   629         return $a_type == 
"non_editable_value";
   637         bool $a_sub_item = 
false   648             $tpl->addJavascript(
"assets/js/ServiceFormMulti.js");
   651             $this->tpl->setVariable(
"ID", $item->getFieldId());
   652             $this->tpl->parseCurrentBlock();
   654             $this->tpl->touchBlock(
"multi_out");
   659             $multi_values = $item->getMultiValues();
   660             if (is_array($multi_values) && 
sizeof($multi_values) > 1) {
   661                 $multi_value = 
new ilHiddenInputGUI(
"ilMultiValues~" . $item->getPostVar());
   662                 $multi_value->
setValue(base64_encode(json_encode($multi_values)));
   668         $item->insert($this->tpl);
   670         if ($item->getType() == 
"file" || $item->getType() == 
"image_file") {
   674         if ($item->getType() != 
"section_header") {
   678             if ($item->getInfo() != 
"") {
   679                 $this->tpl->setCurrentBlock(
"description");
   680                 $this->tpl->setVariable(
   681                     "PROPERTY_DESCRIPTION",
   684                 $this->tpl->setVariable(
   685                     "DESCRIPTION_FOR_ID",
   688                 $this->tpl->parseCurrentBlock();
   691             if ($this->
getMode() == 
"subform") {
   694                     if ($item->getRequired()) {
   695                         $this->tpl->touchBlock(
"sub_required");
   696                         $this->required_text = 
true;
   701                 if ($item->getHiddenTitle() != 
"") {
   702                     $this->tpl->setCurrentBlock(
"sub_hid_title");
   703                     $this->tpl->setVariable(
   705                         $item->getHiddenTitle()
   707                     $this->tpl->parseCurrentBlock();
   710                 $this->tpl->setCurrentBlock(
"sub_prop_start");
   711                 $this->tpl->setVariable(
"PROPERTY_TITLE", $item->getTitle());
   712                 $this->tpl->setVariable(
"PROPERTY_CLASS", 
"il_" . $item->getType());
   713                 if ($item->getType() != 
"non_editable_value" && $item->getFormLabelFor() != 
"") {
   714                     $this->tpl->setVariable(
"FOR_ID", 
' for="' . $item->getFormLabelFor() . 
'" ');
   716                 $this->tpl->setVariable(
"LAB_ID", $item->getFieldId());
   720                     if ($item->getRequired()) {
   721                         $this->tpl->touchBlock(
"required");
   722                         $this->required_text = 
true;
   727                 if ($item->getHiddenTitle() != 
"") {
   728                     $this->tpl->setCurrentBlock(
"std_hid_title");
   729                     $this->tpl->setVariable(
   731                         $item->getHiddenTitle()
   733                     $this->tpl->parseCurrentBlock();
   736                 $this->tpl->setCurrentBlock(
"std_prop_start");
   737                 $this->tpl->setVariable(
"PROPERTY_TITLE", $item->getTitle());
   738                 if ($item->getType() != 
"non_editable_value" && $item->getFormLabelFor() != 
"") {
   739                     $this->tpl->setVariable(
"FOR_ID", 
' for="' . $item->getFormLabelFor() . 
'" ');
   741                 $this->tpl->setVariable(
"LAB_ID", $item->getFieldId());
   743                     $this->tpl->setVariable(
"HIDE_LABELS_STYLE", 
" ilFormOptionHidden");
   746             $this->tpl->parseCurrentBlock();
   749             if ($item->getType() != 
"non_editable_value" && $item->getAlert() != 
"") {
   750                 $this->tpl->setCurrentBlock(
"alert");
   751                 $this->tpl->setVariable(
   755                 $this->tpl->setVariable(
   759                 $this->tpl->setVariable(
   763                 $this->tpl->setVariable(
   767                 $this->tpl->parseCurrentBlock();
   772             if ($item->getType() != 
"non_editable_value" or 1) {
   773                 $sf = $item->getSubForm();
   774                 if ($item->hideSubForm() && is_object($sf)) {
   775                     if ($this->global_tpl) {
   776                         $dsfid = $item->getFieldId();
   777                         $this->global_tpl->addOnloadCode(
   778                             "il.Form.hideSubForm('subform_$dsfid');"   786             if (is_object($sf)) {
   787                 $sf_content = $sf->getContent();
   788                 if ($sf->getMultipart()) {
   791                 $this->tpl->setCurrentBlock(
"sub_form");
   792                 $this->tpl->setVariable(
"PROP_SUB_FORM", $sf_content);
   793                 $this->tpl->setVariable(
"SFID", $item->getFieldId());
   794                 $this->tpl->parseCurrentBlock();
   797             $this->tpl->setCurrentBlock(
"prop");
   801             $this->tpl->parseCurrentBlock();
   805         $this->tpl->touchBlock(
"item");
   810         $this->onload_code[] = $code;
   815         $html = parent::getHTML();
   818         foreach ($this->items as $item) {
   820             if (method_exists($item, 
"getContentOutsideFormTag")) {
   821                 $outside = $item->getContentOutsideFormTag();
   827         if ($this->
ctrl->isAsynch()) {
   836         if (!$this->
ctrl->isAsynch()) {
   844         if (count($this->onload_code) > 0) {
   846             foreach ($this->onload_code as $code) {
   847                 $html .= $code . 
"\n";
   849             $html .= 
"</script>";
   870     protected function keepFileUpload(
   876         ?
string $a_index = null,
   877         ?
string $a_sub_index = null
   879         if (in_array($a_tmp_name, $this->kept_uploads)) {
   883         if (trim($a_tmp_name) == 
"") {
   889         $tmp_file_name = implode(
"~~", array(session_id(),
   894             str_replace(
"/", 
"~~", $a_type),
   895             str_replace(
"~~", 
"_", $a_name)));
   899         if (!is_dir($temp_path)) {
   907         $file_input->setPending($a_name);
   908         $this->kept_uploads[] = $a_tmp_name;
   921         ?
string $a_index = null,
   922         ?
string $a_sub_index = null
   926             if ($_FILES[$a_field][
"tmp_name"][$a_index][$a_sub_index] ?? 
false) {
   928                     "tmp_name" => $_FILES[$a_field][
"tmp_name"][$a_index][$a_sub_index],
   929                     "name" => $_FILES[$a_field][
"name"][$a_index][$a_sub_index],
   930                     "type" => $_FILES[$a_field][
"type"][$a_index][$a_sub_index],
   931                     "error" => $_FILES[$a_field][
"error"][$a_index][$a_sub_index],
   932                     "size" => $_FILES[$a_field][
"size"][$a_index][$a_sub_index],
   933                     "is_upload" => $_FILES[$a_field][
"is_upload"][$a_index][$a_sub_index] ?? 
true   936         } elseif ($a_sub_index) {
   937             if ($_FILES[$a_field][
"tmp_name"][$a_index] ?? 
false) {
   939                     "tmp_name" => $_FILES[$a_field][
"tmp_name"][$a_index],
   940                     "name" => $_FILES[$a_field][
"name"][$a_index],
   941                     "type" => $_FILES[$a_field][
"type"][$a_index],
   942                     "error" => $_FILES[$a_field][
"error"][$a_index],
   943                     "size" => $_FILES[$a_field][
"size"][$a_index],
   944                     "is_upload" => $_FILES[$a_field][
"is_upload"][$a_index] ?? 
true   948             if ($_FILES[$a_field][
"tmp_name"] ?? 
false) {
   950                     "tmp_name" => $_FILES[$a_field][
"tmp_name"],
   951                     "name" => $_FILES[$a_field][
"name"],
   952                     "type" => $_FILES[$a_field][
"type"],
   953                     "error" => $_FILES[$a_field][
"error"],
   954                     "size" => $_FILES[$a_field][
"size"],
   955                     "is_upload" => $_FILES[$a_field][
"is_upload"] ?? 
true   964         ?
string $a_index = null,
   965         ?
string $a_sub_index = null
   968         return (
bool) (
$data[
"tmp_name"] ?? 
false);
   983         string $a_target_directory,
   985         ?
string $a_target_name = null,
   986         ?
string $a_index = null,
   987         ?
string $a_sub_index = null
   989         if (!is_dir($a_target_directory)) {
   994         if (
$data[
"tmp_name"] && file_exists(
$data[
"tmp_name"])) {
   995             if ($a_target_name) {
   996                 $data[
"name"] = $a_target_name;
   999             $target_file = $a_target_directory . 
"/" . 
$data[
"name"];
  1000             $target_file = str_replace(
"//", 
"/", $target_file);
  1002             if (
$data[
"is_upload"]) {
  1012             return $target_file;
  1020         if ($file_hash != 
"") {
  1022             if (is_dir($temp_path)) {
  1023                 $temp_files = glob($temp_path . 
"/" . session_id() . 
"~~" . $file_hash . 
"~~*");
  1024                 if (is_array($temp_files)) {
  1025                     foreach ($temp_files as $full_file) {
  1026                         $file = explode(
"~~", basename($full_file));
  1030                         $type = $file[5] . 
"/" . $file[6];
  1034                             if (!isset($_FILES[$field][
"tmp_name"][$idx][$idx2])) {
  1035                                 $_FILES[$field][
"tmp_name"][$idx][$idx2] = $full_file;
  1036                                 $_FILES[$field][
"name"][$idx][$idx2] = 
$name;
  1037                                 $_FILES[$field][
"type"][$idx][$idx2] = $type;
  1038                                 $_FILES[$field][
"error"][$idx][$idx2] = 0;
  1039                                 $_FILES[$field][
"size"][$idx][$idx2] = filesize($full_file);
  1040                                 $_FILES[$field][
"is_upload"][$idx][$idx2] = 
false;
  1042                         } elseif ($idx != 
"") {
  1043                             if (!isset($_FILES[$field][
"tmp_name"][$idx])) {
  1044                                 $_FILES[$field][
"tmp_name"][$idx] = $full_file;
  1045                                 $_FILES[$field][
"name"][$idx] = 
$name;
  1046                                 $_FILES[$field][
"type"][$idx] = $type;
  1047                                 $_FILES[$field][
"error"][$idx] = 0;
  1048                                 $_FILES[$field][
"size"][$idx] = filesize($full_file);
  1049                                 $_FILES[$field][
"is_upload"][$idx] = 
false;
  1052                             if (!isset($_FILES[$field][
"tmp_name"])) {
  1053                                 $_FILES[$field][
"tmp_name"] = $full_file;
  1054                                 $_FILES[$field][
"name"] = 
$name;
  1055                                 $_FILES[$field][
"type"] = $type;
  1056                                 $_FILES[$field][
"error"] = 0;
  1057                                 $_FILES[$field][
"size"] = filesize($full_file);
  1058                                 $_FILES[$field][
"is_upload"] = 
false;
  1069         foreach ($this->items as $item) {
  1072             } elseif ($item->getType() != 
"hidden") {
  1073                 if ($this->
getMode() == 
"subform") {
  1075                         if ($item->getRequired()) {
  1080                     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...
 
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 getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template 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.