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;
 
  254        $this->top_anchor = $a_val;
 
  272        $this->show_top_buttons = $a_val;
 
  290        $a_item->setParentForm($this);
 
  291        return $this->items[] = $a_item;
 
  301        foreach ($this->items as 
$key => $item) {
 
  302            if (method_exists($item, 
"getPostVar") && $item->getPostVar() == $a_post_var) {
 
  303                unset($this->items[
$key]);
 
  308        if ($a_remove_unused_headers) {
 
  309            $unset_keys = array();
 
  312            foreach ($this->items as 
$key => $item) {
 
  314                    $unset_keys[] = $last_key;
 
  320                $unset_keys[] = $last_key;
 
  322            foreach ($unset_keys as 
$key) {
 
  323                unset($this->items[
$key]);
 
  335        foreach ($this->items as 
$key => $item) {
 
  336            if ($item->getType() != 
"section_header") {
 
  338                $ret = $item->getItemByPostVar($a_post_var);
 
  339                if (is_object(
$ret)) {
 
  355        $this->items = $a_items;
 
  376        $inputItems = array();
 
  378        foreach ($this->items as $item) {
 
  379            if ($item->getType() == 
'section_header') {
 
  383            $inputItems[] = $item;
 
  386                $inputItems = array_merge($inputItems, $item->getSubInputItemsRecursive());
 
  400        $this->disable_standard_message = $a_val;
 
  430        $this->hide_labels = $a_value;
 
  440        foreach ($this->items as $item) {
 
  441            if (!($a_restrict_to_value_keys) ||
 
  442                in_array($item->getPostVar(), array_keys($a_values))) {
 
  443                $item->setValueByArray($a_values);
 
  454        foreach ($this->items as $item) {
 
  455            $item->setValueByArray(
$_POST);
 
  469        if ($this->check_input_called) {
 
  470            die(
"Error: ilPropertyFormGUI->checkInput() called twice.");
 
  474        foreach ($this->items as $item) {
 
  475            $item_ok = $item->checkInput();
 
  482        if (count($this->items) > 0 && !is_array(
$_POST)) {
 
  486        $this->check_input_called = 
true;
 
  491        if (!
$ok && 
$_POST[
"ilfilehash"] && 
sizeof($_FILES)) {
 
  492            $hash = 
$_POST[
"ilfilehash"];
 
  494            foreach ($_FILES as $field => 
$data) {
 
  496                if (is_array(
$data[
"tmp_name"])) {
 
  497                    foreach (
$data[
"tmp_name"] as $idx => $upload) {
 
  498                        if (is_array($upload)) {
 
  499                            foreach ($upload as $idx2 => 
$file) {
 
  501                                    $file_name = 
$data[
"name"][$idx][$idx2];
 
  502                                    $file_type = 
$data[
"type"][$idx][$idx2];
 
  503                                    $this->keepFileUpload($hash, $field, 
$file, $file_name, $file_type, $idx, $idx2);
 
  506                        } elseif ($upload && is_uploaded_file($upload)) {
 
  507                            $file_name = 
$data[
"name"][$idx];
 
  508                            $file_type = 
$data[
"type"][$idx];
 
  509                            $this->keepFileUpload($hash, $field, $upload, $file_name, $file_type, $idx);
 
  513                    $this->keepFileUpload($hash, $field, 
$data[
"tmp_name"], 
$data[
"name"], 
$data[
"type"]);
 
  518        $txt = 
$DIC->language()->txt(
"form_input_not_valid");
 
  519        switch (
$http->request()->getHeaderLine(
'Accept')) {
 
  521            case 'application/json':
 
  551    public function getInput($a_post_var, $ensureValidation = 
true)
 
  554        if (!$this->check_input_called && $ensureValidation) {
 
  555            die(
"Error: ilPropertyFormGUI->getInput() called without calling checkInput() first.");
 
  558        return $_POST[$a_post_var];
 
  577        $this->properties[] = array(
"type" => 
"custom",
 
  591        $this->buttons[] = array(
"cmd" => $a_cmd, 
"text" => $a_text, 
"id" => $a_id);
 
  610        $this->buttons = array();
 
  623        include_once(
"./Services/YUI/classes/class.ilYuiUtil.php");
 
  628        $tpl->addJavaScript(
"./Services/JavaScript/js/Basic.js");
 
  629        $tpl->addJavaScript(
"Services/Form/js/Form.js");
 
  631        $this->tpl = 
new ilTemplate(
"tpl.property_form.html", 
true, 
true, 
"Services/Form");
 
  636        $fi = $this->items[0];
 
  637        if ($this->
getMode() == 
"std" &&
 
  639            is_object($fi) && $fi->getType() == 
"section_header" 
  642            unset($this->items[0]);
 
  648            $this->tpl->setCurrentBlock(
"title_icon");
 
  649            $this->tpl->setVariable(
"IMG_ICON", $this->
getTitleIcon());
 
  650            $this->tpl->parseCurrentBlock();
 
  656            if (count($this->buttons) > 0 && $this->
getShowTopButtons() && count($this->items) > 2) {
 
  658                foreach ($this->buttons as $button) {
 
  659                    $this->tpl->setCurrentBlock(
"cmd2");
 
  660                    $this->tpl->setVariable(
"CMD", $button[
"cmd"]);
 
  661                    $this->tpl->setVariable(
"CMD_TXT", $button[
"text"]);
 
  662                    if ($button[
"id"] != 
"") {
 
  663                        $this->tpl->setVariable(
"CMD2_ID", 
" id='" . $button[
"id"] . 
"_top'");
 
  665                    $this->tpl->parseCurrentBlock();
 
  667                $this->tpl->setCurrentBlock(
"commands2");
 
  668                $this->tpl->parseCurrentBlock();
 
  672                if (
$ilSetting->get(
'char_selector_availability') > 0) {
 
  673                    require_once 
'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
 
  677                            $char_selector->addToPage();
 
  678                            $this->tpl->TouchBlock(
'char_selector');
 
  684            $this->tpl->setCurrentBlock(
"header");
 
  685            $this->tpl->setVariable(
"TXT_TITLE", $this->
getTitle());
 
  686            $this->tpl->setVariable(
"LABEL", $this->
getTopAnchor());
 
  687            $this->tpl->setVariable(
"TXT_DESCRIPTION", $this->
getDescription());
 
  688            $this->tpl->parseCurrentBlock();
 
  690        $this->tpl->touchBlock(
"item");
 
  693        $this->required_text = 
false;
 
  694        foreach ($this->items as $item) {
 
  695            if ($item->getType() != 
"hidden") {
 
  701        if ($this->required_text && $this->
getMode() == 
"std") {
 
  702            $this->tpl->setCurrentBlock(
"required_text");
 
  703            $this->tpl->setVariable(
"TXT_REQUIRED", 
$lng->txt(
"required_field"));
 
  704            $this->tpl->parseCurrentBlock();
 
  708        foreach ($this->buttons as $button) {
 
  709            $this->tpl->setCurrentBlock(
"cmd");
 
  710            $this->tpl->setVariable(
"CMD", $button[
"cmd"]);
 
  711            $this->tpl->setVariable(
"CMD_TXT", $button[
"text"]);
 
  713            if ($button[
"id"] != 
"") {
 
  714                $this->tpl->setVariable(
"CMD_ID", 
" id='" . $button[
"id"] . 
"'");
 
  717            $this->tpl->parseCurrentBlock();
 
  721        if ($this->
getMode() != 
"subform") {
 
  724                $hash = 
$_POST[
"ilfilehash"];
 
  726                    $hash = md5(uniqid(mt_rand(), 
true));
 
  729                $fhash->setValue($hash);
 
  735        $hidden_fields = 
false;
 
  736        foreach ($this->items as $item) {
 
  737            if ($item->getType() == 
"hidden") {
 
  738                $item->insert($this->tpl);
 
  739                $hidden_fields = 
true;
 
  743        if ($this->required_text || count($this->buttons) > 0 || $hidden_fields) {
 
  744            $this->tpl->setCurrentBlock(
"commands");
 
  745            $this->tpl->parseCurrentBlock();
 
  749        if ($this->
getMode() == 
"subform") {
 
  750            $this->tpl->touchBlock(
"sub_table");
 
  752            $this->tpl->touchBlock(
"std_table");
 
  753            $this->tpl->setVariable(
'STD_TABLE_WIDTH', $this->
getTableWidth());
 
  756        return $this->tpl->get();
 
  762        return in_array(
$a_type, array(
"non_editable_value"));
 
  777            $tpl->addJavascript(
"./Services/Form/js/ServiceFormMulti.js");
 
  779            $this->tpl->setCurrentBlock(
"multi_in");
 
  780            $this->tpl->setVariable(
"ID", $item->getFieldId());
 
  781            $this->tpl->parseCurrentBlock();
 
  783            $this->tpl->touchBlock(
"multi_out");
 
  788            $multi_values = $item->getMultiValues();
 
  789            if (is_array($multi_values) && 
sizeof($multi_values) > 1) {
 
  790                $multi_value = 
new ilHiddenInputGUI(
"ilMultiValues~" . $item->getPostVar());
 
  791                $multi_value->setValue(implode(
"~", $multi_values));
 
  794            $cfg[
"multi_values"] = $multi_values;
 
  797        $item->insert($this->tpl);
 
  799        if ($item->getType() == 
"file" || $item->getType() == 
"image_file") {
 
  803        if ($item->getType() != 
"section_header") {
 
  804            $cfg[
"id"] = $item->getFieldId();
 
  807            if ($item->getInfo() != 
"") {
 
  808                $this->tpl->setCurrentBlock(
"description");
 
  809                $this->tpl->setVariable(
 
  810                    "PROPERTY_DESCRIPTION",
 
  813                $this->tpl->parseCurrentBlock();
 
  816            if ($this->
getMode() == 
"subform") {
 
  819                    if ($item->getRequired()) {
 
  820                        $this->tpl->touchBlock(
"sub_required");
 
  821                        $this->required_text = 
true;
 
  826                if ($item->getHiddenTitle() != 
"") {
 
  827                    $this->tpl->setCurrentBlock(
"sub_hid_title");
 
  828                    $this->tpl->setVariable(
 
  830                        $item->getHiddenTitle()
 
  832                    $this->tpl->parseCurrentBlock();
 
  835                $this->tpl->setCurrentBlock(
"sub_prop_start");
 
  836                $this->tpl->setVariable(
"PROPERTY_TITLE", $item->getTitle());
 
  837                $this->tpl->setVariable(
"PROPERTY_CLASS", 
"il_" . $item->getType());
 
  838                if ($item->getType() != 
"non_editable_value") {
 
  839                    $this->tpl->setVariable(
"LAB_ID", $item->getFieldId());
 
  841                $this->tpl->parseCurrentBlock();
 
  845                    if ($item->getRequired()) {
 
  846                        $this->tpl->touchBlock(
"required");
 
  847                        $this->required_text = 
true;
 
  852                if ($item->getHiddenTitle() != 
"") {
 
  853                    $this->tpl->setCurrentBlock(
"std_hid_title");
 
  854                    $this->tpl->setVariable(
 
  856                        $item->getHiddenTitle()
 
  858                    $this->tpl->parseCurrentBlock();
 
  861                $this->tpl->setCurrentBlock(
"std_prop_start");
 
  862                $this->tpl->setVariable(
"PROPERTY_TITLE", $item->getTitle());
 
  863                if ($item->getType() != 
"non_editable_value") {
 
  864                    $this->tpl->setVariable(
"LAB_ID", $item->getFieldId());
 
  867                    $this->tpl->setVariable(
"HIDE_LABELS_STYLE", 
" ilFormOptionHidden");
 
  869                $this->tpl->parseCurrentBlock();
 
  873            if ($item->getType() != 
"non_editable_value" && $item->getAlert() != 
"") {
 
  874                $this->tpl->setCurrentBlock(
"alert");
 
  875                $this->tpl->setVariable(
 
  879                $this->tpl->setVariable(
 
  883                $this->tpl->setVariable(
 
  887                $this->tpl->parseCurrentBlock();
 
  892            if ($item->getType() != 
"non_editable_value" or 1) {
 
  893                $sf = $item->getSubForm();
 
  894                if ($item->hideSubForm() && is_object($sf)) {
 
  895                    $this->tpl->setCurrentBlock(
"sub_form_hide");
 
  896                    $this->tpl->setVariable(
"DSFID", $item->getFieldId());
 
  897                    $this->tpl->parseCurrentBlock();
 
  903            if (is_object($sf)) {
 
  904                $sf_content = $sf->getContent();
 
  905                if ($sf->getMultipart()) {
 
  908                $this->tpl->setCurrentBlock(
"sub_form");
 
  909                $this->tpl->setVariable(
"PROP_SUB_FORM", $sf_content);
 
  910                $this->tpl->setVariable(
"SFID", $item->getFieldId());
 
  911                $this->tpl->parseCurrentBlock();
 
  914            $this->tpl->setCurrentBlock(
"prop");
 
  918            $this->tpl->parseCurrentBlock();
 
  922        $this->tpl->touchBlock(
"item");
 
  927        $html = parent::getHTML();
 
  930        foreach ($this->items as $item) {
 
  932            if (method_exists($item, 
"getContentOutsideFormTag")) {
 
  933                $outside = $item->getContentOutsideFormTag();
 
  960    protected function keepFileUpload($a_hash, $a_field, $a_tmp_name, $a_name, 
$a_type, $a_index = 
null, $a_sub_index = 
null)
 
  962        if (trim($a_tmp_name) == 
"") {
 
  966        $a_name = ilUtil::getAsciiFileName($a_name);
 
  968        $tmp_file_name = implode(
"~~", array(session_id(),
 
  973            str_replace(
"/", 
"~~", 
$a_type),
 
  974            str_replace(
"~~", 
"_", $a_name)));
 
  978        if (!is_dir($temp_path)) {
 
  982        ilUtil::moveUploadedFile($a_tmp_name, $tmp_file_name, $temp_path . 
"/" . $tmp_file_name);
 
  986        $file_input->setPending($a_name);
 
  997    public function getFileUpload($a_field, $a_index = 
null, $a_sub_index = 
null)
 
 1001            if ($_FILES[$a_field][
"tmp_name"][$a_index][$a_sub_index]) {
 
 1003                    "tmp_name" => $_FILES[$a_field][
"tmp_name"][$a_index][$a_sub_index],
 
 1004                    "name" => $_FILES[$a_field][
"name"][$a_index][$a_sub_index],
 
 1005                    "type" => $_FILES[$a_field][
"type"][$a_index][$a_sub_index],
 
 1006                    "error" => $_FILES[$a_field][
"error"][$a_index][$a_sub_index],
 
 1007                    "size" => $_FILES[$a_field][
"size"][$a_index][$a_sub_index],
 
 1011        } elseif ($a_sub_index) {
 
 1012            if ($_FILES[$a_field][
"tmp_name"][$a_index]) {
 
 1014                    "tmp_name" => $_FILES[$a_field][
"tmp_name"][$a_index],
 
 1015                    "name" => $_FILES[$a_field][
"name"][$a_index],
 
 1016                    "type" => $_FILES[$a_field][
"type"][$a_index],
 
 1017                    "error" => $_FILES[$a_field][
"error"][$a_index],
 
 1018                    "size" => $_FILES[$a_field][
"size"][$a_index],
 
 1023            if ($_FILES[$a_field][
"tmp_name"]) {
 
 1025                    "tmp_name" => $_FILES[$a_field][
"tmp_name"],
 
 1026                    "name" => $_FILES[$a_field][
"name"],
 
 1027                    "type" => $_FILES[$a_field][
"type"],
 
 1028                    "error" => $_FILES[$a_field][
"error"],
 
 1029                    "size" => $_FILES[$a_field][
"size"],
 
 1048        return (
bool) 
$data[
"tmp_name"];
 
 1061    public function moveFileUpload($a_target_directory, $a_field, $a_target_name = 
null, $a_index = 
null, $a_sub_index = 
null)
 
 1063        if (!is_dir($a_target_directory)) {
 
 1068        if (
$data[
"tmp_name"] && file_exists(
$data[
"tmp_name"])) {
 
 1069            if ($a_target_name) {
 
 1070                $data[
"name"] = $a_target_name;
 
 1073            $target_file = $a_target_directory . 
"/" . 
$data[
"name"];
 
 1074            $target_file = str_replace(
"//", 
"/", $target_file);
 
 1076            if (
$data[
"is_upload"]) {
 
 1077                if (!ilUtil::moveUploadedFile(
$data[
"tmp_name"], 
$data[
"name"], $target_file)) {
 
 1081                if (!rename(
$data[
"tmp_name"], $target_file)) {
 
 1086            return $target_file;
 
 1095        if (isset(
$_POST[
"ilfilehash"]) && 
$_POST[
"ilfilehash"]) {
 
 1097            if (is_dir($temp_path)) {
 
 1098                $temp_files = glob($temp_path . 
"/" . session_id() . 
"~~" . 
$_POST[
"ilfilehash"] . 
"~~*");
 
 1099                if (is_array($temp_files)) {
 
 1100                    foreach ($temp_files as $full_file) {
 
 1101                        $file = explode(
"~~", basename($full_file));
 
 1109                            if (!$_FILES[$field][
"tmp_name"][$idx][$idx2]) {
 
 1110                                $_FILES[$field][
"tmp_name"][$idx][$idx2] = $full_file;
 
 1111                                $_FILES[$field][
"name"][$idx][$idx2] = 
$name;
 
 1112                                $_FILES[$field][
"type"][$idx][$idx2] = 
$type;
 
 1113                                $_FILES[$field][
"error"][$idx][$idx2] = 0;
 
 1114                                $_FILES[$field][
"size"][$idx][$idx2] = filesize($full_file);
 
 1116                        } elseif ($idx != 
"") {
 
 1117                            if (!$_FILES[$field][
"tmp_name"][$idx]) {
 
 1118                                $_FILES[$field][
"tmp_name"][$idx] = $full_file;
 
 1119                                $_FILES[$field][
"name"][$idx] = 
$name;
 
 1120                                $_FILES[$field][
"type"][$idx] = 
$type;
 
 1121                                $_FILES[$field][
"error"][$idx] = 0;
 
 1122                                $_FILES[$field][
"size"][$idx] = filesize($full_file);
 
 1125                            if (!$_FILES[$field][
"tmp_name"]) {
 
 1126                                $_FILES[$field][
"tmp_name"] = $full_file;
 
 1127                                $_FILES[$field][
"name"] = 
$name;
 
 1128                                $_FILES[$field][
"type"] = 
$type;
 
 1129                                $_FILES[$field][
"error"] = 0;
 
 1130                                $_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.
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
foreach($_POST as $key=> $value) $res
catch(Exception $e) if(isset( $_POST[ 'cancel'])) if(isset($_POST['continue'])) $cfg