4include_once(
"./Services/Form/classes/class.ilFormGUI.php");
 
    8include_once(
"./Services/Form/classes/class.ilFormPropertyGUI.php");
 
    9include_once(
"./Services/Form/classes/class.ilSubEnabledFormPropertyGUI.php");
 
   10include_once(
"./Services/Form/classes/class.ilCheckboxInputGUI.php");
 
   11include_once(
"./Services/Form/classes/class.ilCustomInputGUI.php");
 
   12include_once(
"./Services/Form/classes/class.ilDateTimeInputGUI.php");
 
   13include_once(
"./Services/Form/classes/class.ilFileInputGUI.php");
 
   14include_once(
"./Services/Form/classes/class.ilImageFileInputGUI.php");
 
   15include_once(
'./Services/Form/classes/class.ilFlashFileInputGUI.php');
 
   16include_once(
"./Services/Form/classes/class.ilLocationInputGUI.php");
 
   17include_once(
"./Services/Form/classes/class.ilRadioGroupInputGUI.php");
 
   18include_once(
"./Services/Form/classes/class.ilCheckboxGroupInputGUI.php");
 
   19include_once(
"./Services/Form/classes/class.ilFormSectionHeaderGUI.php");
 
   20include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
 
   21include_once(
"./Services/Form/classes/class.ilTextAreaInputGUI.php");
 
   22include_once(
"./Services/Form/classes/class.ilTextInputGUI.php");
 
   23include_once(
"./Services/Form/classes/class.ilDurationInputGUI.php");
 
   24include_once(
"./Services/Form/classes/class.ilFeedUrlInputGUI.php");
 
   25include_once(
"./Services/Form/classes/class.ilNonEditableValueGUI.php");
 
   26include_once(
"./Services/Form/classes/class.ilRegExpInputGUI.php");
 
   27include_once(
'./Services/Form/classes/class.ilColorPickerInputGUI.php');
 
   28include_once(
'./Services/Form/classes/class.ilPasswordInputGUI.php');
 
   29include_once(
'./Services/Form/classes/class.ilUserLoginInputGUI.php');
 
   30include_once(
'./Services/Form/classes/class.ilEMailInputGUI.php');
 
   31include_once(
'./Services/Form/classes/class.ilHiddenInputGUI.php');
 
   32include_once(
'./Services/Form/classes/class.ilNumberInputGUI.php');
 
   33include_once(
'./Services/Form/classes/class.ilCSSRectInputGUI.php');
 
   34include_once(
'./Services/Form/classes/class.ilTextWizardInputGUI.php');
 
   35include_once 
'./Services/Form/classes/class.ilFileWizardInputGUI.php';
 
   36include_once 
'./Services/Form/classes/class.ilFormulaInputGUI.php';
 
   37include_once 
'./Services/Form/classes/class.ilBirthdayInputGUI.php';
 
   97        $this->lng = 
$DIC->language();
 
   98        $this->ctrl = 
$DIC->ctrl();
 
  101        if (isset(
$DIC[
"ilUser"])) {
 
  102            $this->
user = $DIC[
"ilUser"];
 
  106        if (isset(
$DIC[
"ilSetting"])) {
 
  107            $this->
settings = $DIC[
"ilSetting"];
 
  112        $lng->loadLanguageModule(
"form");
 
  128        $next_class = $ilCtrl->getNextClass($this);
 
  129        $cmd = $ilCtrl->getCmd();
 
  131        switch ($next_class) {
 
  132            case 'ilformpropertydispatchgui':
 
  133                $ilCtrl->saveParameter($this, 
'postvar');
 
  134                include_once 
'./Services/Form/classes/class.ilFormPropertyDispatchGUI.php';
 
  137                $form_prop_dispatch->setItem($item);
 
  138                return $ilCtrl->forwardCommand($form_prop_dispatch);
 
  154        $this->tbl_width = $a_width;
 
  175        $this->mode = $a_mode;
 
  195        $this->title = $a_title;
 
  215        $this->titleicon = $a_titleicon;
 
  235        $this->description = $a_val;
 
  256        $this->top_anchor = $a_val;
 
  274        $this->show_top_buttons = $a_val;
 
  292        $this->force_top_buttons = $a_val;
 
  313        $a_item->setParentForm($this);
 
  314        return $this->items[] = $a_item;
 
  324        foreach ($this->items as $key => $item) {
 
  325            if (method_exists($item, 
"getPostVar") && $item->getPostVar() == $a_post_var) {
 
  326                unset($this->items[$key]);
 
  331        if ($a_remove_unused_headers) {
 
  332            $unset_keys = array();
 
  335            foreach ($this->items as $key => $item) {
 
  337                    $unset_keys[] = $last_key;
 
  343                $unset_keys[] = $last_key;
 
  345            foreach ($unset_keys as $key) {
 
  346                unset($this->items[$key]);
 
  358        foreach ($this->items as $key => $item) {
 
  359            if ($item->getType() != 
"section_header") {
 
  361                $ret = $item->getItemByPostVar($a_post_var);
 
  362                if (is_object(
$ret)) {
 
  378        $this->items = $a_items;
 
  399        $inputItems = array();
 
  401        foreach ($this->items as $item) {
 
  402            if ($item->getType() == 
'section_header') {
 
  406            $inputItems[] = $item;
 
  409                $inputItems = array_merge($inputItems, $item->getSubInputItemsRecursive());
 
  423        $this->disable_standard_message = $a_val;
 
  453        $this->hide_labels = $a_value;
 
  463        foreach ($this->items as $item) {
 
  464            if (!($a_restrict_to_value_keys) ||
 
  465                in_array($item->getPostVar(), array_keys($a_values))) {
 
  466                $item->setValueByArray($a_values);
 
  477        foreach ($this->items as $item) {
 
  478            $item->setValueByArray(
$_POST);
 
  492        if ($this->check_input_called) {
 
  493            die(
"Error: ilPropertyFormGUI->checkInput() called twice.");
 
  497        foreach ($this->items as $item) {
 
  498            $item_ok = $item->checkInput();
 
  505        if (count($this->items) > 0 && !is_array(
$_POST)) {
 
  509        $this->check_input_called = 
true;
 
  514        if (!
$ok && 
$_POST[
"ilfilehash"] && 
sizeof($_FILES)) {
 
  515            $hash = 
$_POST[
"ilfilehash"];
 
  517            foreach ($_FILES as $field => 
$data) {
 
  521                if (is_bool($item) || !$item->checkInput()) {
 
  525                if (is_array(
$data[
"tmp_name"])) {
 
  526                    foreach (
$data[
"tmp_name"] as $idx => $upload) {
 
  527                        if (is_array($upload)) {
 
  528                            foreach ($upload as $idx2 => $file) {
 
  529                                if ($file && is_uploaded_file($file)) {
 
  530                                    $file_name = 
$data[
"name"][$idx][$idx2];
 
  531                                    $file_type = 
$data[
"type"][$idx][$idx2];
 
  532                                    $this->keepFileUpload($hash, $field, $file, $file_name, $file_type, $idx, $idx2);
 
  535                        } elseif ($upload && is_uploaded_file($upload)) {
 
  536                            $file_name = 
$data[
"name"][$idx];
 
  537                            $file_type = 
$data[
"type"][$idx];
 
  538                            $this->keepFileUpload($hash, $field, $upload, $file_name, $file_type, $idx);
 
  542                    $this->keepFileUpload($hash, $field, 
$data[
"tmp_name"], 
$data[
"name"], 
$data[
"type"]);
 
  547        $txt = 
$DIC->language()->txt(
"form_input_not_valid");
 
  548        switch (
$http->request()->getHeaderLine(
'Accept')) {
 
  550            case 'application/json':
 
  555                $http->saveResponse(
$http->response()->withBody($stream));
 
  580    public function getInput($a_post_var, $ensureValidation = 
true)
 
  583        if (!$this->check_input_called && $ensureValidation) {
 
  584            die(
"Error: ilPropertyFormGUI->getInput() called without calling checkInput() first.");
 
  587        return $_POST[$a_post_var];
 
  606        $this->properties[] = array(
"type" => 
"custom",
 
  620        $this->buttons[] = array(
"cmd" => $a_cmd, 
"text" => $a_text, 
"id" => $a_id);
 
  639        $this->buttons = array();
 
  652        include_once(
"./Services/YUI/classes/class.ilYuiUtil.php");
 
  657        $tpl->addJavaScript(
"./Services/JavaScript/js/Basic.js");
 
  658        $tpl->addJavaScript(
"Services/Form/js/Form.js");
 
  660        $this->tpl = 
new ilTemplate(
"tpl.property_form.html", 
true, 
true, 
"Services/Form");
 
  665        $fi = $this->items[0];
 
  666        if ($this->
getMode() == 
"std" &&
 
  668            is_object($fi) && $fi->getType() == 
"section_header" 
  671            unset($this->items[0]);
 
  677            $this->tpl->setCurrentBlock(
"title_icon");
 
  678            $this->tpl->setVariable(
"IMG_ICON", $this->
getTitleIcon());
 
  679            $this->tpl->parseCurrentBlock();
 
  685            if (count($this->buttons) > 0 && $this->
getShowTopButtons() && (count($this->items) > 2 || $this->force_top_buttons)) {
 
  687                foreach ($this->buttons as $button) {
 
  688                    $this->tpl->setCurrentBlock(
"cmd2");
 
  689                    $this->tpl->setVariable(
"CMD", $button[
"cmd"]);
 
  690                    $this->tpl->setVariable(
"CMD_TXT", $button[
"text"]);
 
  691                    if ($button[
"id"] != 
"") {
 
  692                        $this->tpl->setVariable(
"CMD2_ID", 
" id='" . $button[
"id"] . 
"_top'");
 
  694                    $this->tpl->parseCurrentBlock();
 
  696                $this->tpl->setCurrentBlock(
"commands2");
 
  697                $this->tpl->parseCurrentBlock();
 
  701                if (
$ilSetting->get(
'char_selector_availability') > 0) {
 
  702                    require_once 
'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
 
  706                            $char_selector->addToPage();
 
  707                            $this->tpl->TouchBlock(
'char_selector');
 
  713            $this->tpl->setCurrentBlock(
"header");
 
  714            $this->tpl->setVariable(
"TXT_TITLE", $this->
getTitle());
 
  716            $this->tpl->setVariable(
"TXT_DESCRIPTION", $this->
getDescription());
 
  717            $this->tpl->parseCurrentBlock();
 
  719        $this->tpl->touchBlock(
"item");
 
  722        $this->required_text = 
false;
 
  723        foreach ($this->items as $item) {
 
  724            if ($item->getType() != 
"hidden") {
 
  730        if ($this->required_text && $this->
getMode() == 
"std") {
 
  731            $this->tpl->setCurrentBlock(
"required_text");
 
  732            $this->tpl->setVariable(
"TXT_REQUIRED", 
$lng->txt(
"required_field"));
 
  733            $this->tpl->parseCurrentBlock();
 
  737        foreach ($this->buttons as $button) {
 
  738            $this->tpl->setCurrentBlock(
"cmd");
 
  739            $this->tpl->setVariable(
"CMD", $button[
"cmd"]);
 
  740            $this->tpl->setVariable(
"CMD_TXT", $button[
"text"]);
 
  742            if ($button[
"id"] != 
"") {
 
  743                $this->tpl->setVariable(
"CMD_ID", 
" id='" . $button[
"id"] . 
"'");
 
  746            $this->tpl->parseCurrentBlock();
 
  750        if ($this->
getMode() != 
"subform") {
 
  753                $hash = 
$_POST[
"ilfilehash"];
 
  755                    $hash = md5(uniqid(mt_rand(), 
true));
 
  758                $fhash->setValue($hash);
 
  764        $hidden_fields = 
false;
 
  765        foreach ($this->items as $item) {
 
  766            if ($item->getType() == 
"hidden") {
 
  767                $item->insert($this->tpl);
 
  768                $hidden_fields = 
true;
 
  772        if ($this->required_text || count($this->buttons) > 0 || $hidden_fields) {
 
  773            $this->tpl->setCurrentBlock(
"commands");
 
  774            $this->tpl->parseCurrentBlock();
 
  778        if ($this->
getMode() == 
"subform") {
 
  779            $this->tpl->touchBlock(
"sub_table");
 
  781            $this->tpl->touchBlock(
"std_table");
 
  782            $this->tpl->setVariable(
'STD_TABLE_WIDTH', $this->
getTableWidth());
 
  785        return $this->tpl->get();
 
  791        return in_array($a_type, array(
"non_editable_value"));
 
  806            $tpl->addJavascript(
"./Services/Form/js/ServiceFormMulti.js");
 
  808            $this->tpl->setCurrentBlock(
"multi_in");
 
  809            $this->tpl->setVariable(
"ID", $item->getFieldId());
 
  810            $this->tpl->parseCurrentBlock();
 
  812            $this->tpl->touchBlock(
"multi_out");
 
  817            $multi_values = $item->getMultiValues();
 
  818            if (is_array($multi_values) && 
sizeof($multi_values) > 1) {
 
  819                $multi_value = 
new ilHiddenInputGUI(
"ilMultiValues~" . $item->getPostVar());
 
  820                $multi_value->setValue(implode(
"~", $multi_values));
 
  823            $cfg[
"multi_values"] = $multi_values;
 
  826        $item->insert($this->tpl);
 
  828        if ($item->getType() == 
"file" || $item->getType() == 
"image_file") {
 
  832        if ($item->getType() != 
"section_header") {
 
  833            $cfg[
"id"] = $item->getFieldId();
 
  836            if ($item->getInfo() != 
"") {
 
  837                $this->tpl->setCurrentBlock(
"description");
 
  838                $this->tpl->setVariable(
 
  839                    "PROPERTY_DESCRIPTION",
 
  842                $this->tpl->parseCurrentBlock();
 
  845            if ($this->
getMode() == 
"subform") {
 
  848                    if ($item->getRequired()) {
 
  849                        $this->tpl->touchBlock(
"sub_required");
 
  850                        $this->required_text = 
true;
 
  855                if ($item->getHiddenTitle() != 
"") {
 
  856                    $this->tpl->setCurrentBlock(
"sub_hid_title");
 
  857                    $this->tpl->setVariable(
 
  859                        $item->getHiddenTitle()
 
  861                    $this->tpl->parseCurrentBlock();
 
  864                $this->tpl->setCurrentBlock(
"sub_prop_start");
 
  865                $this->tpl->setVariable(
"PROPERTY_TITLE", $item->getTitle());
 
  866                $this->tpl->setVariable(
"PROPERTY_CLASS", 
"il_" . $item->getType());
 
  867                if ($item->getType() != 
"non_editable_value" && $item->getFormLabelFor() != 
"") {
 
  868                    $this->tpl->setVariable(
"FOR_ID", 
' for="' . $item->getFormLabelFor() . 
'" ');
 
  870                $this->tpl->setVariable(
"LAB_ID", $item->getFieldId());
 
  871                $this->tpl->parseCurrentBlock();
 
  875                    if ($item->getRequired()) {
 
  876                        $this->tpl->touchBlock(
"required");
 
  877                        $this->required_text = 
true;
 
  882                if ($item->getHiddenTitle() != 
"") {
 
  883                    $this->tpl->setCurrentBlock(
"std_hid_title");
 
  884                    $this->tpl->setVariable(
 
  886                        $item->getHiddenTitle()
 
  888                    $this->tpl->parseCurrentBlock();
 
  891                $this->tpl->setCurrentBlock(
"std_prop_start");
 
  892                $this->tpl->setVariable(
"PROPERTY_TITLE", $item->getTitle());
 
  893                if ($item->getType() != 
"non_editable_value" && $item->getFormLabelFor() != 
"") {
 
  894                    $this->tpl->setVariable(
"FOR_ID", 
' for="' . $item->getFormLabelFor() . 
'" ');
 
  896                $this->tpl->setVariable(
"LAB_ID", $item->getFieldId());
 
  898                    $this->tpl->setVariable(
"HIDE_LABELS_STYLE", 
" ilFormOptionHidden");
 
  900                $this->tpl->parseCurrentBlock();
 
  904            if ($item->getType() != 
"non_editable_value" && $item->getAlert() != 
"") {
 
  905                $this->tpl->setCurrentBlock(
"alert");
 
  906                $this->tpl->setVariable(
 
  910                $this->tpl->setVariable(
 
  914                $this->tpl->setVariable(
 
  918                $this->tpl->parseCurrentBlock();
 
  923            if ($item->getType() != 
"non_editable_value" or 1) {
 
  924                $sf = $item->getSubForm();
 
  925                if ($item->hideSubForm() && is_object($sf)) {
 
  926                    $this->tpl->setCurrentBlock(
"sub_form_hide");
 
  927                    $this->tpl->setVariable(
"DSFID", $item->getFieldId());
 
  928                    $this->tpl->parseCurrentBlock();
 
  934            if (is_object($sf)) {
 
  935                $sf_content = $sf->getContent();
 
  936                if ($sf->getMultipart()) {
 
  939                $this->tpl->setCurrentBlock(
"sub_form");
 
  940                $this->tpl->setVariable(
"PROP_SUB_FORM", $sf_content);
 
  941                $this->tpl->setVariable(
"SFID", $item->getFieldId());
 
  942                $this->tpl->parseCurrentBlock();
 
  945            $this->tpl->setCurrentBlock(
"prop");
 
  949            $this->tpl->parseCurrentBlock();
 
  953        $this->tpl->touchBlock(
"item");
 
  958        $html = parent::getHTML();
 
  961        foreach ($this->items as $item) {
 
  963            if (method_exists($item, 
"getContentOutsideFormTag")) {
 
  964                $outside = $item->getContentOutsideFormTag();
 
  991    protected function keepFileUpload($a_hash, $a_field, $a_tmp_name, $a_name, $a_type, $a_index = 
null, $a_sub_index = 
null)
 
  993        if (trim($a_tmp_name) == 
"") {
 
  997        $a_name = ilUtil::getAsciiFileName($a_name);
 
  999        $tmp_file_name = implode(
"~~", array(session_id(),
 
 1004            str_replace(
"/", 
"~~", $a_type),
 
 1005            str_replace(
"~~", 
"_", $a_name)));
 
 1009        if (!is_dir($temp_path)) {
 
 1017        $file_input->setPending($a_name);
 
 1032            if ($_FILES[$a_field][
"tmp_name"][$a_index][$a_sub_index]) {
 
 1034                    "tmp_name" => $_FILES[$a_field][
"tmp_name"][$a_index][$a_sub_index],
 
 1035                    "name" => $_FILES[$a_field][
"name"][$a_index][$a_sub_index],
 
 1036                    "type" => $_FILES[$a_field][
"type"][$a_index][$a_sub_index],
 
 1037                    "error" => $_FILES[$a_field][
"error"][$a_index][$a_sub_index],
 
 1038                    "size" => $_FILES[$a_field][
"size"][$a_index][$a_sub_index],
 
 1039                    "is_upload" => $_FILES[$a_field][
"is_upload"][$a_index][$a_sub_index] ?? 
true 
 1042        } elseif ($a_sub_index) {
 
 1043            if ($_FILES[$a_field][
"tmp_name"][$a_index]) {
 
 1045                    "tmp_name" => $_FILES[$a_field][
"tmp_name"][$a_index],
 
 1046                    "name" => $_FILES[$a_field][
"name"][$a_index],
 
 1047                    "type" => $_FILES[$a_field][
"type"][$a_index],
 
 1048                    "error" => $_FILES[$a_field][
"error"][$a_index],
 
 1049                    "size" => $_FILES[$a_field][
"size"][$a_index],
 
 1050                    "is_upload" => $_FILES[$a_field][
"is_upload"][$a_index] ?? 
true 
 1054            if ($_FILES[$a_field][
"tmp_name"]) {
 
 1056                    "tmp_name" => $_FILES[$a_field][
"tmp_name"],
 
 1057                    "name" => $_FILES[$a_field][
"name"],
 
 1058                    "type" => $_FILES[$a_field][
"type"],
 
 1059                    "error" => $_FILES[$a_field][
"error"],
 
 1060                    "size" => $_FILES[$a_field][
"size"],
 
 1061                    "is_upload" => $_FILES[$a_field][
"is_upload"] ?? 
true 
 1079        return (
bool) 
$data[
"tmp_name"];
 
 1092    public function moveFileUpload($a_target_directory, $a_field, $a_target_name = 
null, $a_index = 
null, $a_sub_index = 
null)
 
 1094        if (!is_dir($a_target_directory)) {
 
 1099        if (
$data[
"tmp_name"] && file_exists(
$data[
"tmp_name"])) {
 
 1100            if ($a_target_name) {
 
 1101                $data[
"name"] = $a_target_name;
 
 1104            $target_file = $a_target_directory . 
"/" . 
$data[
"name"];
 
 1105            $target_file = str_replace(
"//", 
"/", $target_file);
 
 1107            if (
$data[
"is_upload"]) {
 
 1112                if (!rename(
$data[
"tmp_name"], $target_file)) {
 
 1117            return $target_file;
 
 1126        if (isset(
$_POST[
"ilfilehash"]) && 
$_POST[
"ilfilehash"]) {
 
 1128            if (is_dir($temp_path)) {
 
 1131                $temp_files = glob($temp_path . 
"/" . session_id() . 
"~~" . 
$_POST[
"ilfilehash"] . 
"~~*");
 
 1132                if (is_array($temp_files)) {
 
 1133                    foreach ($temp_files as $full_file) {
 
 1134                        $file = explode(
"~~", basename($full_file));
 
 1138                        $type = $file[5] . 
"/" . $file[6];
 
 1142                            if (!$_FILES[$field][
"tmp_name"][$idx][$idx2]) {
 
 1143                                $_FILES[$field][
"tmp_name"][$idx][$idx2] = $full_file;
 
 1144                                $_FILES[$field][
"name"][$idx][$idx2] = 
$name;
 
 1145                                $_FILES[$field][
"type"][$idx][$idx2] = 
$type;
 
 1146                                $_FILES[$field][
"error"][$idx][$idx2] = 0;
 
 1147                                $_FILES[$field][
"size"][$idx][$idx2] = filesize($full_file);
 
 1148                                $_FILES[$field][
"is_upload"][$idx][$idx2] = 
false;
 
 1150                        } elseif ($idx != 
"") {
 
 1151                            if (!$_FILES[$field][
"tmp_name"][$idx]) {
 
 1152                                $_FILES[$field][
"tmp_name"][$idx] = $full_file;
 
 1153                                $_FILES[$field][
"name"][$idx] = 
$name;
 
 1154                                $_FILES[$field][
"type"][$idx] = 
$type;
 
 1155                                $_FILES[$field][
"error"][$idx] = 0;
 
 1156                                $_FILES[$field][
"size"][$idx] = filesize($full_file);
 
 1157                                $_FILES[$field][
"is_upload"][$idx] = 
false;
 
 1160                            if (!$_FILES[$field][
"tmp_name"]) {
 
 1161                                $_FILES[$field][
"tmp_name"] = $full_file;
 
 1162                                $_FILES[$field][
"name"] = 
$name;
 
 1163                                $_FILES[$field][
"type"] = 
$type;
 
 1164                                $_FILES[$field][
"error"] = 0;
 
 1165                                $_FILES[$field][
"size"] = filesize($full_file);
 
 1166                                $_FILES[$field][
"is_upload"] = 
false;
 
An exception for terminatinating execution or to throw for unit testing.
static ofString($string)
Creates a new stream with an initial value.
static _isAllowed()
Check if the CharSelector is allowed for the current GUI.
static _getCurrentGUI(ilObjTest $a_test_obj=null)
Get the GUI that is used for the currently available selector (other GUI instances may exist for conf...
special template class to simplify handling of ITX/PEAR
static getDataDir()
get data directory (outside webspace)
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static createDirectory($a_dir, $a_mod=0755)
create directory
static initDom(ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Dom.
static initEvent(ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Event.
static initAnimation(ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Animation.
Interface for multi values support.
foreach($_POST as $key=> $value) $res