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';
 
   96        $this->lng = 
$DIC->language();
 
   97        $this->ctrl = 
$DIC->ctrl();
 
  100        if (isset(
$DIC[
"ilUser"])) {
 
  101            $this->
user = $DIC[
"ilUser"];
 
  105        if (isset(
$DIC[
"ilSetting"])) {
 
  106            $this->
settings = $DIC[
"ilSetting"];
 
  111        $lng->loadLanguageModule(
"form");
 
  127        $next_class = 
$ilCtrl->getNextClass($this);
 
  130        switch ($next_class) {
 
  131            case 'ilformpropertydispatchgui':
 
  132                $ilCtrl->saveParameter($this, 
'postvar');
 
  133                include_once 
'./Services/Form/classes/class.ilFormPropertyDispatchGUI.php';
 
  136                $form_prop_dispatch->setItem($item);
 
  137                return $ilCtrl->forwardCommand($form_prop_dispatch);
 
  153        $this->tbl_width = $a_width;
 
  174        $this->mode = $a_mode;
 
  194        $this->title = $a_title;
 
  214        $this->titleicon = $a_titleicon;
 
  234        $this->description = $a_val;
 
  255        $this->top_anchor = $a_val;
 
  273        $this->show_top_buttons = $a_val;
 
  291        $a_item->setParentForm($this);
 
  292        return $this->items[] = $a_item;
 
  302        foreach ($this->items as 
$key => $item) {
 
  303            if (method_exists($item, 
"getPostVar") && $item->getPostVar() == $a_post_var) {
 
  304                unset($this->items[
$key]);
 
  309        if ($a_remove_unused_headers) {
 
  310            $unset_keys = array();
 
  313            foreach ($this->items as 
$key => $item) {
 
  315                    $unset_keys[] = $last_key;
 
  321                $unset_keys[] = $last_key;
 
  323            foreach ($unset_keys as 
$key) {
 
  324                unset($this->items[
$key]);
 
  336        foreach ($this->items as 
$key => $item) {
 
  337            if ($item->getType() != 
"section_header") {
 
  339                $ret = $item->getItemByPostVar($a_post_var);
 
  340                if (is_object(
$ret)) {
 
  356        $this->items = $a_items;
 
  377        $inputItems = array();
 
  379        foreach ($this->items as $item) {
 
  380            if ($item->getType() == 
'section_header') {
 
  384            $inputItems[] = $item;
 
  387                $inputItems = array_merge($inputItems, $item->getSubInputItemsRecursive());
 
  401        $this->disable_standard_message = $a_val;
 
  431        $this->hide_labels = $a_value;
 
  441        foreach ($this->items as $item) {
 
  442            if (!($a_restrict_to_value_keys) ||
 
  443                in_array($item->getPostVar(), array_keys($a_values))) {
 
  444                $item->setValueByArray($a_values);
 
  455        foreach ($this->items as $item) {
 
  456            $item->setValueByArray(
$_POST);
 
  470        if ($this->check_input_called) {
 
  471            die(
"Error: ilPropertyFormGUI->checkInput() called twice.");
 
  475        foreach ($this->items as $item) {
 
  476            $item_ok = $item->checkInput();
 
  483        if (count($this->items) > 0 && !is_array(
$_POST)) {
 
  487        $this->check_input_called = 
true;
 
  492        if (!
$ok && 
$_POST[
"ilfilehash"] && 
sizeof($_FILES)) {
 
  493            $hash = 
$_POST[
"ilfilehash"];
 
  495            foreach ($_FILES as $field => 
$data) {
 
  499                if (!$item->checkInput()) {
 
  503                if (is_array(
$data[
"tmp_name"])) {
 
  504                    foreach (
$data[
"tmp_name"] as $idx => $upload) {
 
  505                        if (is_array($upload)) {
 
  506                            foreach ($upload as $idx2 => $file) {
 
  507                                if ($file && is_uploaded_file($file)) {
 
  508                                    $file_name = 
$data[
"name"][$idx][$idx2];
 
  509                                    $file_type = 
$data[
"type"][$idx][$idx2];
 
  510                                    $this->keepFileUpload($hash, $field, $file, $file_name, $file_type, $idx, $idx2);
 
  513                        } elseif ($upload && is_uploaded_file($upload)) {
 
  514                            $file_name = 
$data[
"name"][$idx];
 
  515                            $file_type = 
$data[
"type"][$idx];
 
  516                            $this->keepFileUpload($hash, $field, $upload, $file_name, $file_type, $idx);
 
  520                    $this->keepFileUpload($hash, $field, 
$data[
"tmp_name"], 
$data[
"name"], 
$data[
"type"]);
 
  525        $txt = 
$DIC->language()->txt(
"form_input_not_valid");
 
  526        switch (
$http->request()->getHeaderLine(
'Accept')) {
 
  528            case 'application/json':
 
  558    public function getInput($a_post_var, $ensureValidation = 
true)
 
  561        if (!$this->check_input_called && $ensureValidation) {
 
  562            die(
"Error: ilPropertyFormGUI->getInput() called without calling checkInput() first.");
 
  565        return $_POST[$a_post_var];
 
  584        $this->properties[] = array(
"type" => 
"custom",
 
  598        $this->buttons[] = array(
"cmd" => $a_cmd, 
"text" => $a_text, 
"id" => $a_id);
 
  617        $this->buttons = array();
 
  630        include_once(
"./Services/YUI/classes/class.ilYuiUtil.php");
 
  635        $tpl->addJavaScript(
"./Services/JavaScript/js/Basic.js");
 
  636        $tpl->addJavaScript(
"Services/Form/js/Form.js");
 
  638        $this->tpl = 
new ilTemplate(
"tpl.property_form.html", 
true, 
true, 
"Services/Form");
 
  643        $fi = $this->items[0];
 
  644        if ($this->
getMode() == 
"std" &&
 
  646            is_object($fi) && $fi->getType() == 
"section_header" 
  649            unset($this->items[0]);
 
  655            $this->tpl->setCurrentBlock(
"title_icon");
 
  656            $this->tpl->setVariable(
"IMG_ICON", $this->
getTitleIcon());
 
  657            $this->tpl->parseCurrentBlock();
 
  663            if (count($this->buttons) > 0 && $this->
getShowTopButtons() && count($this->items) > 2) {
 
  665                foreach ($this->buttons as $button) {
 
  666                    $this->tpl->setCurrentBlock(
"cmd2");
 
  667                    $this->tpl->setVariable(
"CMD", $button[
"cmd"]);
 
  668                    $this->tpl->setVariable(
"CMD_TXT", $button[
"text"]);
 
  669                    if ($button[
"id"] != 
"") {
 
  670                        $this->tpl->setVariable(
"CMD2_ID", 
" id='" . $button[
"id"] . 
"_top'");
 
  672                    $this->tpl->parseCurrentBlock();
 
  674                $this->tpl->setCurrentBlock(
"commands2");
 
  675                $this->tpl->parseCurrentBlock();
 
  679                if (
$ilSetting->get(
'char_selector_availability') > 0) {
 
  680                    require_once 
'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
 
  684                            $char_selector->addToPage();
 
  685                            $this->tpl->TouchBlock(
'char_selector');
 
  691            $this->tpl->setCurrentBlock(
"header");
 
  692            $this->tpl->setVariable(
"TXT_TITLE", $this->
getTitle());
 
  694            $this->tpl->setVariable(
"TXT_DESCRIPTION", $this->
getDescription());
 
  695            $this->tpl->parseCurrentBlock();
 
  697        $this->tpl->touchBlock(
"item");
 
  700        $this->required_text = 
false;
 
  701        foreach ($this->items as $item) {
 
  702            if ($item->getType() != 
"hidden") {
 
  708        if ($this->required_text && $this->
getMode() == 
"std") {
 
  709            $this->tpl->setCurrentBlock(
"required_text");
 
  710            $this->tpl->setVariable(
"TXT_REQUIRED", 
$lng->txt(
"required_field"));
 
  711            $this->tpl->parseCurrentBlock();
 
  715        foreach ($this->buttons as $button) {
 
  716            $this->tpl->setCurrentBlock(
"cmd");
 
  717            $this->tpl->setVariable(
"CMD", $button[
"cmd"]);
 
  718            $this->tpl->setVariable(
"CMD_TXT", $button[
"text"]);
 
  720            if ($button[
"id"] != 
"") {
 
  721                $this->tpl->setVariable(
"CMD_ID", 
" id='" . $button[
"id"] . 
"'");
 
  724            $this->tpl->parseCurrentBlock();
 
  728        if ($this->
getMode() != 
"subform") {
 
  731                $hash = 
$_POST[
"ilfilehash"];
 
  733                    $hash = md5(uniqid(mt_rand(), 
true));
 
  736                $fhash->setValue($hash);
 
  742        $hidden_fields = 
false;
 
  743        foreach ($this->items as $item) {
 
  744            if ($item->getType() == 
"hidden") {
 
  745                $item->insert($this->tpl);
 
  746                $hidden_fields = 
true;
 
  750        if ($this->required_text || count($this->buttons) > 0 || $hidden_fields) {
 
  751            $this->tpl->setCurrentBlock(
"commands");
 
  752            $this->tpl->parseCurrentBlock();
 
  756        if ($this->
getMode() == 
"subform") {
 
  757            $this->tpl->touchBlock(
"sub_table");
 
  759            $this->tpl->touchBlock(
"std_table");
 
  760            $this->tpl->setVariable(
'STD_TABLE_WIDTH', $this->
getTableWidth());
 
  763        return $this->tpl->get();
 
  769        return in_array(
$a_type, array(
"non_editable_value"));
 
  784            $tpl->addJavascript(
"./Services/Form/js/ServiceFormMulti.js");
 
  786            $this->tpl->setCurrentBlock(
"multi_in");
 
  787            $this->tpl->setVariable(
"ID", $item->getFieldId());
 
  788            $this->tpl->parseCurrentBlock();
 
  790            $this->tpl->touchBlock(
"multi_out");
 
  795            $multi_values = $item->getMultiValues();
 
  796            if (is_array($multi_values) && 
sizeof($multi_values) > 1) {
 
  797                $multi_value = 
new ilHiddenInputGUI(
"ilMultiValues~" . $item->getPostVar());
 
  798                $multi_value->setValue(implode(
"~", $multi_values));
 
  801            $cfg[
"multi_values"] = $multi_values;
 
  804        $item->insert($this->tpl);
 
  806        if ($item->getType() == 
"file" || $item->getType() == 
"image_file") {
 
  810        if ($item->getType() != 
"section_header") {
 
  811            $cfg[
"id"] = $item->getFieldId();
 
  814            if ($item->getInfo() != 
"") {
 
  815                $this->tpl->setCurrentBlock(
"description");
 
  816                $this->tpl->setVariable(
 
  817                    "PROPERTY_DESCRIPTION",
 
  820                $this->tpl->parseCurrentBlock();
 
  823            if ($this->
getMode() == 
"subform") {
 
  826                    if ($item->getRequired()) {
 
  827                        $this->tpl->touchBlock(
"sub_required");
 
  828                        $this->required_text = 
true;
 
  833                if ($item->getHiddenTitle() != 
"") {
 
  834                    $this->tpl->setCurrentBlock(
"sub_hid_title");
 
  835                    $this->tpl->setVariable(
 
  837                        $item->getHiddenTitle()
 
  839                    $this->tpl->parseCurrentBlock();
 
  842                $this->tpl->setCurrentBlock(
"sub_prop_start");
 
  843                $this->tpl->setVariable(
"PROPERTY_TITLE", $item->getTitle());
 
  844                $this->tpl->setVariable(
"PROPERTY_CLASS", 
"il_" . $item->getType());
 
  845                if ($item->getType() != 
"non_editable_value" && $item->getFormLabelFor() != 
"") {
 
  846                    $this->tpl->setVariable(
"FOR_ID", 
' for="'.$item->getFormLabelFor().
'" ');
 
  848                $this->tpl->setVariable(
"LAB_ID", $item->getFieldId());
 
  849                $this->tpl->parseCurrentBlock();
 
  853                    if ($item->getRequired()) {
 
  854                        $this->tpl->touchBlock(
"required");
 
  855                        $this->required_text = 
true;
 
  860                if ($item->getHiddenTitle() != 
"") {
 
  861                    $this->tpl->setCurrentBlock(
"std_hid_title");
 
  862                    $this->tpl->setVariable(
 
  864                        $item->getHiddenTitle()
 
  866                    $this->tpl->parseCurrentBlock();
 
  869                $this->tpl->setCurrentBlock(
"std_prop_start");
 
  870                $this->tpl->setVariable(
"PROPERTY_TITLE", $item->getTitle());
 
  871                if ($item->getType() != 
"non_editable_value" && $item->getFormLabelFor() != 
"") {
 
  872                    $this->tpl->setVariable(
"FOR_ID", 
' for="'.$item->getFormLabelFor().
'" ');
 
  874                $this->tpl->setVariable(
"LAB_ID", $item->getFieldId());
 
  876                    $this->tpl->setVariable(
"HIDE_LABELS_STYLE", 
" ilFormOptionHidden");
 
  878                $this->tpl->parseCurrentBlock();
 
  882            if ($item->getType() != 
"non_editable_value" && $item->getAlert() != 
"") {
 
  883                $this->tpl->setCurrentBlock(
"alert");
 
  884                $this->tpl->setVariable(
 
  888                $this->tpl->setVariable(
 
  892                $this->tpl->setVariable(
 
  896                $this->tpl->parseCurrentBlock();
 
  901            if ($item->getType() != 
"non_editable_value" or 1) {
 
  902                $sf = $item->getSubForm();
 
  903                if ($item->hideSubForm() && is_object($sf)) {
 
  904                    $this->tpl->setCurrentBlock(
"sub_form_hide");
 
  905                    $this->tpl->setVariable(
"DSFID", $item->getFieldId());
 
  906                    $this->tpl->parseCurrentBlock();
 
  912            if (is_object($sf)) {
 
  913                $sf_content = $sf->getContent();
 
  914                if ($sf->getMultipart()) {
 
  917                $this->tpl->setCurrentBlock(
"sub_form");
 
  918                $this->tpl->setVariable(
"PROP_SUB_FORM", $sf_content);
 
  919                $this->tpl->setVariable(
"SFID", $item->getFieldId());
 
  920                $this->tpl->parseCurrentBlock();
 
  923            $this->tpl->setCurrentBlock(
"prop");
 
  927            $this->tpl->parseCurrentBlock();
 
  931        $this->tpl->touchBlock(
"item");
 
  936        $html = parent::getHTML();
 
  939        foreach ($this->items as $item) {
 
  941            if (method_exists($item, 
"getContentOutsideFormTag")) {
 
  942                $outside = $item->getContentOutsideFormTag();
 
  969    protected function keepFileUpload($a_hash, $a_field, $a_tmp_name, $a_name, 
$a_type, $a_index = 
null, $a_sub_index = 
null)
 
  971        if (trim($a_tmp_name) == 
"") {
 
  975        $a_name = ilUtil::getAsciiFileName($a_name);
 
  977        $tmp_file_name = implode(
"~~", array(session_id(),
 
  982            str_replace(
"/", 
"~~", 
$a_type),
 
  983            str_replace(
"~~", 
"_", $a_name)));
 
  987        if (!is_dir($temp_path)) {
 
  991        ilUtil::moveUploadedFile($a_tmp_name, $tmp_file_name, $temp_path . 
"/" . $tmp_file_name);
 
  995        $file_input->setPending($a_name);
 
 1010            if ($_FILES[$a_field][
"tmp_name"][$a_index][$a_sub_index]) {
 
 1012                    "tmp_name" => $_FILES[$a_field][
"tmp_name"][$a_index][$a_sub_index],
 
 1013                    "name" => $_FILES[$a_field][
"name"][$a_index][$a_sub_index],
 
 1014                    "type" => $_FILES[$a_field][
"type"][$a_index][$a_sub_index],
 
 1015                    "error" => $_FILES[$a_field][
"error"][$a_index][$a_sub_index],
 
 1016                    "size" => $_FILES[$a_field][
"size"][$a_index][$a_sub_index],
 
 1020        } elseif ($a_sub_index) {
 
 1021            if ($_FILES[$a_field][
"tmp_name"][$a_index]) {
 
 1023                    "tmp_name" => $_FILES[$a_field][
"tmp_name"][$a_index],
 
 1024                    "name" => $_FILES[$a_field][
"name"][$a_index],
 
 1025                    "type" => $_FILES[$a_field][
"type"][$a_index],
 
 1026                    "error" => $_FILES[$a_field][
"error"][$a_index],
 
 1027                    "size" => $_FILES[$a_field][
"size"][$a_index],
 
 1032            if ($_FILES[$a_field][
"tmp_name"]) {
 
 1034                    "tmp_name" => $_FILES[$a_field][
"tmp_name"],
 
 1035                    "name" => $_FILES[$a_field][
"name"],
 
 1036                    "type" => $_FILES[$a_field][
"type"],
 
 1037                    "error" => $_FILES[$a_field][
"error"],
 
 1038                    "size" => $_FILES[$a_field][
"size"],
 
 1057        return (
bool) 
$data[
"tmp_name"];
 
 1070    public function moveFileUpload($a_target_directory, $a_field, $a_target_name = 
null, $a_index = 
null, $a_sub_index = 
null)
 
 1072        if (!is_dir($a_target_directory)) {
 
 1077        if (
$data[
"tmp_name"] && file_exists(
$data[
"tmp_name"])) {
 
 1078            if ($a_target_name) {
 
 1079                $data[
"name"] = $a_target_name;
 
 1082            $target_file = $a_target_directory . 
"/" . 
$data[
"name"];
 
 1083            $target_file = str_replace(
"//", 
"/", $target_file);
 
 1085            if (
$data[
"is_upload"]) {
 
 1086                if (!ilUtil::moveUploadedFile(
$data[
"tmp_name"], 
$data[
"name"], $target_file)) {
 
 1090                if (!rename(
$data[
"tmp_name"], $target_file)) {
 
 1095            return $target_file;
 
 1104        if (isset(
$_POST[
"ilfilehash"]) && 
$_POST[
"ilfilehash"]) {
 
 1106            if (is_dir($temp_path)) {
 
 1109                $temp_files = glob($temp_path . 
"/" . session_id() . 
"~~" . 
$_POST[
"ilfilehash"] . 
"~~*");
 
 1110                if (is_array($temp_files)) {
 
 1111                    foreach ($temp_files as $full_file) {
 
 1112                        $file = explode(
"~~", basename($full_file));
 
 1116                        $type = $file[5] . 
"/" . $file[6];
 
 1120                            if (!$_FILES[$field][
"tmp_name"][$idx][$idx2]) {
 
 1121                                $_FILES[$field][
"tmp_name"][$idx][$idx2] = $full_file;
 
 1122                                $_FILES[$field][
"name"][$idx][$idx2] = 
$name;
 
 1123                                $_FILES[$field][
"type"][$idx][$idx2] = 
$type;
 
 1124                                $_FILES[$field][
"error"][$idx][$idx2] = 0;
 
 1125                                $_FILES[$field][
"size"][$idx][$idx2] = filesize($full_file);
 
 1127                        } elseif ($idx != 
"") {
 
 1128                            if (!$_FILES[$field][
"tmp_name"][$idx]) {
 
 1129                                $_FILES[$field][
"tmp_name"][$idx] = $full_file;
 
 1130                                $_FILES[$field][
"name"][$idx] = 
$name;
 
 1131                                $_FILES[$field][
"type"][$idx] = 
$type;
 
 1132                                $_FILES[$field][
"error"][$idx] = 0;
 
 1133                                $_FILES[$field][
"size"][$idx] = filesize($full_file);
 
 1136                            if (!$_FILES[$field][
"tmp_name"]) {
 
 1137                                $_FILES[$field][
"tmp_name"] = $full_file;
 
 1138                                $_FILES[$field][
"name"] = 
$name;
 
 1139                                $_FILES[$field][
"type"] = 
$type;
 
 1140                                $_FILES[$field][
"error"] = 0;
 
 1141                                $_FILES[$field][
"size"] = filesize($full_file);
 
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 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()
Init YUI Dom.
static initEvent()
Init YUI Event.
static initAnimation()
Init YUI Animation.
Interface for multi values support.
$stream
PHP stream implementation.
foreach($_POST as $key=> $value) $res
catch(Exception $e) if(isset( $_POST[ 'cancel'])) if(isset($_POST['continue'])) $cfg