4 include_once(
"./Services/Form/classes/class.ilFormGUI.php");
8 include_once(
"./Services/Form/classes/class.ilFormPropertyGUI.php");
9 include_once(
"./Services/Form/classes/class.ilSubEnabledFormPropertyGUI.php");
10 include_once(
"./Services/Form/classes/class.ilCheckboxInputGUI.php");
11 include_once(
"./Services/Form/classes/class.ilCustomInputGUI.php");
12 include_once(
"./Services/Form/classes/class.ilDateTimeInputGUI.php");
13 include_once(
"./Services/Form/classes/class.ilFileInputGUI.php");
14 include_once(
"./Services/Form/classes/class.ilImageFileInputGUI.php");
15 include_once(
'./Services/Form/classes/class.ilFlashFileInputGUI.php');
16 include_once(
"./Services/Form/classes/class.ilLocationInputGUI.php");
17 include_once(
"./Services/Form/classes/class.ilRadioGroupInputGUI.php");
18 include_once(
"./Services/Form/classes/class.ilCheckboxGroupInputGUI.php");
19 include_once(
"./Services/Form/classes/class.ilFormSectionHeaderGUI.php");
20 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
21 include_once(
"./Services/Form/classes/class.ilTextAreaInputGUI.php");
22 include_once(
"./Services/Form/classes/class.ilTextInputGUI.php");
23 include_once(
"./Services/Form/classes/class.ilDurationInputGUI.php");
24 include_once(
"./Services/Form/classes/class.ilFeedUrlInputGUI.php");
25 include_once(
"./Services/Form/classes/class.ilNonEditableValueGUI.php");
26 include_once(
"./Services/Form/classes/class.ilRegExpInputGUI.php");
27 include_once(
'./Services/Form/classes/class.ilColorPickerInputGUI.php');
28 include_once(
'./Services/Form/classes/class.ilPasswordInputGUI.php');
29 include_once(
'./Services/Form/classes/class.ilUserLoginInputGUI.php');
30 include_once(
'./Services/Form/classes/class.ilEMailInputGUI.php');
31 include_once(
'./Services/Form/classes/class.ilHiddenInputGUI.php');
32 include_once(
'./Services/Form/classes/class.ilNumberInputGUI.php');
33 include_once(
'./Services/Form/classes/class.ilCSSRectInputGUI.php');
34 include_once(
'./Services/Form/classes/class.ilTextWizardInputGUI.php');
35 include_once
'./Services/Form/classes/class.ilFileWizardInputGUI.php';
36 include_once
'./Services/Form/classes/class.ilFormulaInputGUI.php';
37 include_once
'./Services/Form/classes/class.ilBirthdayInputGUI.php';
71 $lng->loadLanguageModule(
"form");
88 $next_class = $ilCtrl->getNextClass($this);
89 $cmd = $ilCtrl->getCmd();
93 case 'ilformpropertydispatchgui':
94 $ilCtrl->saveParameter($this,
'postvar');
95 include_once
'./Services/Form/classes/class.ilFormPropertyDispatchGUI.php';
98 $form_prop_dispatch->setItem($item);
99 return $ilCtrl->forwardCommand($form_prop_dispatch);
115 $this->tbl_width = $a_width;
136 $this->mode = $a_mode;
156 $this->title = $a_title;
176 $this->titleicon = $a_titleicon;
196 $this->description = $a_val;
216 $this->top_anchor = $a_val;
234 $this->show_top_buttons = $a_val;
252 $a_item->setParentForm($this);
253 return $this->items[] = $a_item;
263 foreach ($this->items as $key => $item)
265 if (method_exists($item,
"getPostVar") && $item->getPostVar() == $a_post_var)
267 unset($this->items[$key]);
279 foreach ($this->items as $key => $item)
281 if ($item->getType() !=
"section_header")
284 $ret = $item->getItemByPostVar($a_post_var);
302 $this->items = $a_items;
323 $inputItems = array();
325 foreach($this->items as $item)
327 if( $item->getType() ==
'section_header' )
332 $inputItems[] = $item;
336 $inputItems = array_merge( $inputItems, $item->getSubInputItemsRecursive() );
350 $this->disable_standard_message = $a_val;
380 $this->hide_labels = $a_value;
390 foreach($this->items as $item)
392 if(!($a_restrict_to_value_keys) ||
393 in_array($item->getPostVar(), array_keys($a_values)))
395 $item->setValueByArray($a_values);
406 foreach($this->items as $item)
408 $item->setValueByArray(
$_POST);
422 if ($this->check_input_called)
424 die (
"Error: ilPropertyFormGUI->checkInput() called twice.");
428 foreach($this->items as $item)
430 $item_ok = $item->checkInput();
438 if (count($this->items) > 0 && !is_array(
$_POST))
443 $this->check_input_called =
true;
448 if(!
$ok &&
$_POST[
"ilfilehash"] &&
sizeof($_FILES))
450 $hash =
$_POST[
"ilfilehash"];
452 foreach($_FILES as $field =>
$data)
455 if(is_array(
$data[
"tmp_name"]))
457 foreach(
$data[
"tmp_name"] as $idx => $upload)
459 if(is_array($upload))
461 foreach($upload as $idx2 =>
$file)
465 $file_name =
$data[
"name"][$idx][$idx2];
466 $file_type =
$data[
"type"][$idx][$idx2];
471 else if($upload && is_uploaded_file($upload))
473 $file_name =
$data[
"name"][$idx];
474 $file_type =
$data[
"type"][$idx];
475 $this->
keepFileUpload($hash, $field, $upload, $file_name, $file_type, $idx);
504 public function getInput($a_post_var, $ensureValidation =
true)
507 if (!$this->check_input_called && $ensureValidation)
509 die (
"Error: ilPropertyFormGUI->getInput() called without calling checkInput() first.");
512 return $_POST[$a_post_var];
525 $a_alert =
"", $a_required =
false)
527 $this->properties[] = array (
"type" =>
"custom",
541 $this->buttons[] = array(
"cmd" => $a_cmd,
"text" => $a_text);
559 $this->buttons = array();
569 include_once(
"./Services/YUI/classes/class.ilYuiUtil.php");
574 $tpl->addJavaScript(
"./Services/JavaScript/js/Basic.js");
575 $tpl->addJavaScript(
"Services/Form/js/Form.js");
577 $this->tpl =
new ilTemplate(
"tpl.property_form.html",
true,
true,
"Services/Form");
582 $fi = $this->items[0];
583 if ($this->
getMode() ==
"std" &&
585 is_object($fi) && $fi->getType() ==
"section_header" 589 unset($this->items[0]);
596 $this->tpl->setCurrentBlock(
"title_icon");
597 $this->tpl->setVariable(
"IMG_ICON", $this->
getTitleIcon());
598 $this->tpl->parseCurrentBlock();
605 if (count($this->buttons) > 0 && $this->
getShowTopButtons() && count($this->items) > 2)
608 foreach($this->buttons as $button)
610 $this->tpl->setCurrentBlock(
"cmd2");
611 $this->tpl->setVariable(
"CMD", $button[
"cmd"]);
612 $this->tpl->setVariable(
"CMD_TXT", $button[
"text"]);
613 $this->tpl->parseCurrentBlock();
615 $this->tpl->setCurrentBlock(
"commands2");
616 $this->tpl->parseCurrentBlock();
619 if (is_object($ilSetting))
621 if ($ilSetting->get(
'char_selector_availability') > 0)
623 require_once
'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
629 $char_selector->addToPage();
630 $this->tpl->TouchBlock(
'char_selector');
636 $this->tpl->setCurrentBlock(
"header");
637 $this->tpl->setVariable(
"TXT_TITLE", $this->
getTitle());
638 $this->tpl->setVariable(
"LABEL", $this->
getTopAnchor());
639 $this->tpl->setVariable(
"TXT_DESCRIPTION", $this->
getDescription());
640 $this->tpl->parseCurrentBlock();
642 $this->tpl->touchBlock(
"item");
645 $this->required_text =
false;
646 foreach($this->items as $item)
648 if ($item->getType() !=
"hidden")
655 if ($this->required_text && $this->
getMode() ==
"std")
657 $this->tpl->setCurrentBlock(
"required_text");
658 $this->tpl->setVariable(
"TXT_REQUIRED", $lng->txt(
"required_field"));
659 $this->tpl->parseCurrentBlock();
663 foreach($this->buttons as $button)
665 $this->tpl->setCurrentBlock(
"cmd");
666 $this->tpl->setVariable(
"CMD", $button[
"cmd"]);
667 $this->tpl->setVariable(
"CMD_TXT", $button[
"text"]);
668 $this->tpl->parseCurrentBlock();
672 if ($this->
getMode() !=
"subform")
677 $hash =
$_POST[
"ilfilehash"];
680 $hash = md5(uniqid(mt_rand(),
true));
683 $fhash->setValue($hash);
689 $hidden_fields =
false;
690 foreach($this->items as $item)
692 if ($item->getType() ==
"hidden")
694 $item->insert($this->tpl);
695 $hidden_fields =
true;
699 if ($this->required_text || count($this->buttons) > 0 || $hidden_fields)
701 $this->tpl->setCurrentBlock(
"commands");
702 $this->tpl->parseCurrentBlock();
706 if ($this->
getMode() ==
"subform")
708 $this->tpl->touchBlock(
"sub_table");
712 $this->tpl->touchBlock(
"std_table");
713 $this->tpl->setVariable(
'STD_TABLE_WIDTH',$this->
getTableWidth());
716 return $this->tpl->get();
722 return in_array($a_type, array(
"non_editable_value"));
735 $tpl->addJavascript(
"./Services/Form/js/ServiceFormMulti.js");
737 $this->tpl->setCurrentBlock(
"multi_in");
738 $this->tpl->setVariable(
"ID", $item->getFieldId());
739 $this->tpl->parseCurrentBlock();
741 $this->tpl->touchBlock(
"multi_out");
746 $multi_values = $item->getMultiValues();
747 if(is_array($multi_values) &&
sizeof($multi_values) > 1)
750 $multi_value->
setValue(implode(
"~", $multi_values));
753 $cfg[
"multi_values"] = $multi_values;
756 $item->insert($this->tpl);
758 if ($item->getType() ==
"file" || $item->getType() ==
"image_file")
763 if ($item->getType() !=
"section_header")
765 $cfg[
"id"] = $item->getFieldId();
768 if ($item->getInfo() !=
"")
770 $this->tpl->setCurrentBlock(
"description");
771 $this->tpl->setVariable(
"PROPERTY_DESCRIPTION",
773 $this->tpl->parseCurrentBlock();
776 if ($this->
getMode() ==
"subform")
781 if ($item->getRequired())
783 $this->tpl->touchBlock(
"sub_required");
784 $this->required_text =
true;
789 if ($item->getHiddenTitle() !=
"")
791 $this->tpl->setCurrentBlock(
"sub_hid_title");
792 $this->tpl->setVariable(
"SPHID_TITLE",
793 $item->getHiddenTitle());
794 $this->tpl->parseCurrentBlock();
797 $this->tpl->setCurrentBlock(
"sub_prop_start");
798 $this->tpl->setVariable(
"PROPERTY_TITLE", $item->getTitle());
799 $this->tpl->setVariable(
"PROPERTY_CLASS",
"il_".$item->getType());
800 if ($item->getType() !=
"non_editable_value")
802 $this->tpl->setVariable(
"LAB_ID", $item->getFieldId());
804 $this->tpl->parseCurrentBlock();
811 if ($item->getRequired())
813 $this->tpl->touchBlock(
"required");
814 $this->required_text =
true;
819 if ($item->getHiddenTitle() !=
"")
821 $this->tpl->setCurrentBlock(
"std_hid_title");
822 $this->tpl->setVariable(
"PHID_TITLE",
823 $item->getHiddenTitle());
824 $this->tpl->parseCurrentBlock();
827 $this->tpl->setCurrentBlock(
"std_prop_start");
828 $this->tpl->setVariable(
"PROPERTY_TITLE", $item->getTitle());
829 if ($item->getType() !=
"non_editable_value")
831 $this->tpl->setVariable(
"LAB_ID", $item->getFieldId());
835 $this->tpl->setVariable(
"HIDE_LABELS_STYLE",
" ilFormOptionHidden");
837 $this->tpl->parseCurrentBlock();
841 if ($item->getType() !=
"non_editable_value" && $item->getAlert() !=
"")
843 $this->tpl->setCurrentBlock(
"alert");
844 $this->tpl->setVariable(
"IMG_ALERT",
846 $this->tpl->setVariable(
"ALT_ALERT",
848 $this->tpl->setVariable(
"TXT_ALERT",
850 $this->tpl->parseCurrentBlock();
855 if ($item->getType() !=
"non_editable_value" or 1)
857 $sf = $item->getSubForm();
858 if ($item->hideSubForm() && is_object($sf))
860 $this->tpl->setCurrentBlock(
"sub_form_hide");
861 $this->tpl->setVariable(
"DSFID", $item->getFieldId());
862 $this->tpl->parseCurrentBlock();
870 $sf_content = $sf->getContent();
871 if ($sf->getMultipart())
875 $this->tpl->setCurrentBlock(
"sub_form");
876 $this->tpl->setVariable(
"PROP_SUB_FORM", $sf_content);
877 $this->tpl->setVariable(
"SFID", $item->getFieldId());
878 $this->tpl->parseCurrentBlock();
881 $this->tpl->setCurrentBlock(
"prop");
886 $this->tpl->parseCurrentBlock();
890 $this->tpl->touchBlock(
"item");
895 $html = parent::getHTML();
898 foreach($this->items as $item)
901 if(method_exists($item,
"getContentOutsideFormTag"))
903 $outside = $item->getContentOutsideFormTag();
931 protected function keepFileUpload($a_hash, $a_field, $a_tmp_name, $a_name, $a_type, $a_index = null, $a_sub_index = null)
935 if (trim($a_tmp_name) ==
"")
940 $user_id = $ilUser->getId();
941 if(!$user_id || $user_id == ANONYMOUS_USER_ID)
946 $a_name = ilUtil::getAsciiFileName($a_name);
948 $tmp_file_name = implode(
"~~", array($user_id,
953 str_replace(
"/",
"~~", $a_type),
954 str_replace(
"~~",
"_", $a_name)));
958 if (!is_dir($temp_path))
979 if($_FILES[$a_field][
"tmp_name"][$a_index][$a_sub_index])
982 "tmp_name" => $_FILES[$a_field][
"tmp_name"][$a_index][$a_sub_index],
983 "name" => $_FILES[$a_field][
"name"][$a_index][$a_sub_index],
984 "type" => $_FILES[$a_field][
"type"][$a_index][$a_sub_index],
985 "error" => $_FILES[$a_field][
"error"][$a_index][$a_sub_index],
986 "size" => $_FILES[$a_field][
"size"][$a_index][$a_sub_index],
990 else if($this->reloaded_files[$a_field][
"tmp_name"][$a_index][$a_sub_index])
993 "tmp_name" => $this->reloaded_files[
"tmp_name"][$a_index][$a_sub_index],
994 "name" => $this->reloaded_files[
"name"][$a_index][$a_sub_index],
995 "type" => $this->reloaded_files[
"type"][$a_index][$a_sub_index],
996 "error" => $this->reloaded_files[
"error"][$a_index][$a_sub_index],
997 "size" => $this->reloaded_files[
"size"][$a_index][$a_sub_index],
1002 else if($a_sub_index)
1004 if($_FILES[$a_field][
"tmp_name"][$a_index])
1007 "tmp_name" => $_FILES[$a_field][
"tmp_name"][$a_index],
1008 "name" => $_FILES[$a_field][
"name"][$a_index],
1009 "type" => $_FILES[$a_field][
"type"][$a_index],
1010 "error" => $_FILES[$a_field][
"error"][$a_index],
1011 "size" => $_FILES[$a_field][
"size"][$a_index],
1015 else if($this->reloaded_files[$a_field][
"tmp_name"][$a_index])
1018 "tmp_name" => $this->reloaded_files[$a_field][
"tmp_name"][$a_index],
1019 "name" => $this->reloaded_files[$a_field][
"name"][$a_index],
1020 "type" => $this->reloaded_files[$a_field][
"type"][$a_index],
1021 "error" => $this->reloaded_files[$a_field][
"error"][$a_index],
1022 "size" => $this->reloaded_files[$a_field][
"size"][$a_index],
1023 "is_upload" =>
false 1029 if($_FILES[$a_field][
"tmp_name"])
1032 "tmp_name" => $_FILES[$a_field][
"tmp_name"],
1033 "name" => $_FILES[$a_field][
"name"],
1034 "type" => $_FILES[$a_field][
"type"],
1035 "error" => $_FILES[$a_field][
"error"],
1036 "size" => $_FILES[$a_field][
"size"],
1040 else if($this->reloaded_files[$a_field][
"tmp_name"])
1043 "tmp_name" => $this->reloaded_files[$a_field][
"tmp_name"],
1044 "name" => $this->reloaded_files[$a_field][
"name"],
1045 "type" => $this->reloaded_files[$a_field][
"type"],
1046 "error" => $this->reloaded_files[$a_field][
"error"],
1047 "size" => $this->reloaded_files[$a_field][
"size"],
1048 "is_upload" =>
false 1066 return (
bool)
$data[
"tmp_name"];
1079 function moveFileUpload($a_target_directory, $a_field, $a_target_name = null, $a_index = null, $a_sub_index = null)
1081 if(!is_dir($a_target_directory))
1087 if(
$data[
"tmp_name"] && file_exists(
$data[
"tmp_name"]))
1091 $data[
"name"] = $a_target_name;
1094 $target_file = $a_target_directory.
"/".
$data[
"name"];
1095 $target_file = str_replace(
"//",
"/", $target_file);
1097 if(
$data[
"is_upload"])
1106 if (!rename(
$data[
"tmp_name"], $target_file))
1112 return $target_file;
1125 $user_id = $ilUser->getId();
1127 if(is_dir($temp_path) && $user_id && $user_id != ANONYMOUS_USER_ID)
1131 $temp_files = glob($temp_path.
"/".$ilUser->getId().
"~~".
$_POST[
"ilfilehash"].
"~~*");
1132 if(is_array($temp_files))
1134 foreach($temp_files as $full_file)
1136 $file = explode(
"~~", basename($full_file));
1145 if(!$_FILES[$field][
"tmp_name"][$idx][$idx2])
1147 $reload[$field][
"tmp_name"][$idx][$idx2] = $full_file;
1148 $reload[$field][
"name"][$idx][$idx2] =
$name;
1149 $reload[$field][
"type"][$idx][$idx2] = $type;
1150 $reload[$field][
"error"][$idx][$idx2] = 0;
1151 $reload[$field][
"size"][$idx][$idx2] = filesize($full_file);
1156 if(!$_FILES[$field][
"tmp_name"][$idx])
1158 $reload[$field][
"tmp_name"][$idx] = $full_file;
1159 $reload[$field][
"name"][$idx] =
$name;
1160 $reload[$field][
"type"][$idx] = $type;
1161 $reload[$field][
"error"][$idx] = 0;
1162 $reload[$field][
"size"][$idx] = filesize($full_file);
1167 if(!$_FILES[$field][
"tmp_name"])
1169 $reload[$field][
"tmp_name"] = $full_file;
1170 $reload[$field][
"name"] =
$name;
1171 $reload[$field][
"type"] = $type;
1172 $reload[$field][
"error"] = 0;
1173 $reload[$field][
"size"] = filesize($full_file);
1179 $this->reloaded_files = $reload;
static _isAllowed()
Check if the CharSelector is allowed for the current GUI.
static initAnimation()
Init YUI Animation.
static initDom()
Init YUI Dom.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
special template class to simplify handling of ITX/PEAR
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...
static createDirectory($a_dir, $a_mod=0755)
create directory
static initEvent()
Init YUI Event.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Interface for multi values support.
static getDataDir()
get data directory (outside webspace)
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']