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.ilRadioMatrixInputGUI.php');
35 include_once(
'./Services/Form/classes/class.ilTextWizardInputGUI.php');
36 include_once
'./Services/Form/classes/class.ilFileWizardInputGUI.php';
37 include_once
'./Services/Form/classes/class.ilFormulaInputGUI.php';
38 include_once
'./Services/Form/classes/class.ilBirthdayInputGUI.php';
71 $lng->loadLanguageModule(
"form");
85 $next_class = $ilCtrl->getNextClass($this);
86 $cmd = $ilCtrl->getCmd();
90 case 'ilformpropertydispatchgui':
91 $ilCtrl->saveParameter($this,
'postvar');
92 include_once
'./Services/Form/classes/class.ilFormPropertyDispatchGUI.php';
95 $form_prop_dispatch->setItem($item);
96 return $ilCtrl->forwardCommand($form_prop_dispatch);
112 $this->tbl_width = $a_width;
133 $this->mode = $a_mode;
153 $this->title = $a_title;
173 $this->titleicon = $a_titleicon;
193 $this->description = $a_val;
213 $this->top_anchor = $a_val;
231 $this->show_top_buttons = $a_val;
249 $a_item->setParentForm($this);
250 return $this->items[] = $a_item;
260 foreach ($this->items as $key => $item)
262 if (method_exists($item,
"getPostVar") && $item->getPostVar() == $a_post_var)
264 unset($this->items[$key]);
276 foreach ($this->items as $key => $item)
278 if ($item->getType() !=
"section_header")
281 $ret = $item->getItemByPostVar($a_post_var);
299 $this->items = $a_items;
319 $this->disable_standard_message = $a_val;
339 foreach($this->items as $item)
341 $item->setValueByArray($a_values);
351 foreach($this->items as $item)
353 $item->setValueByArray(
$_POST);
367 if ($this->check_input_called)
369 die (
"Error: ilPropertyFormGUI->checkInput() called twice.");
373 foreach($this->items as $item)
375 $item_ok = $item->checkInput();
383 if (count($this->items) > 0 && !is_array(
$_POST))
388 $this->check_input_called =
true;
393 if(!
$ok &&
$_POST[
"ilfilehash"] &&
sizeof($_FILES))
395 $hash =
$_POST[
"ilfilehash"];
397 foreach($_FILES as $field =>
$data)
400 if(is_array(
$data[
"tmp_name"]))
402 foreach(
$data[
"tmp_name"] as $idx => $upload)
404 if(is_array($upload))
406 foreach($upload as $idx2 =>
$file)
410 $file_name =
$data[
"name"][$idx][$idx2];
411 $file_type =
$data[
"type"][$idx][$idx2];
416 else if($upload && is_uploaded_file($upload))
418 $file_name =
$data[
"name"][$idx];
419 $file_type =
$data[
"type"][$idx];
420 $this->
keepFileUpload($hash, $field, $upload, $file_name, $file_type, $idx);
449 public function getInput($a_post_var, $ensureValidation =
true)
452 if (!$this->check_input_called && $ensureValidation)
454 die (
"Error: ilPropertyFormGUI->getInput() called without calling checkInput() first.");
457 return $_POST[$a_post_var];
470 $a_alert =
"", $a_required =
false)
472 $this->properties[] = array (
"type" =>
"custom",
486 $this->buttons[] = array(
"cmd" => $a_cmd,
"text" => $a_text);
494 $this->buttons = array();
504 include_once(
"./Services/YUI/classes/class.ilYuiUtil.php");
509 $tpl->addJavaScript(
"./Services/JavaScript/js/Basic.js");
510 $tpl->addJavaScript(
"Services/Form/js/Form.js");
512 $this->tpl =
new ilTemplate(
"tpl.property_form.html",
true,
true,
"Services/Form");
517 $fi = $this->items[0];
518 if ($this->
getMode() ==
"std" &&
520 is_object($fi) && $fi->getType() ==
"section_header"
524 unset($this->items[0]);
531 $this->tpl->setCurrentBlock(
"title_icon");
532 $this->tpl->setVariable(
"IMG_ICON", $this->
getTitleIcon());
533 $this->tpl->parseCurrentBlock();
543 foreach($this->buttons as $button)
545 $this->tpl->setCurrentBlock(
"cmd2");
546 $this->tpl->setVariable(
"CMD", $button[
"cmd"]);
547 $this->tpl->setVariable(
"CMD_TXT", $button[
"text"]);
548 $this->tpl->parseCurrentBlock();
550 $this->tpl->setCurrentBlock(
"commands2");
551 $this->tpl->parseCurrentBlock();
554 $this->tpl->setCurrentBlock(
"header");
555 $this->tpl->setVariable(
"TXT_TITLE", $this->
getTitle());
556 $this->tpl->setVariable(
"LABEL", $this->
getTopAnchor());
557 $this->tpl->setVariable(
"TXT_DESCRIPTION", $this->
getDescription());
558 $this->tpl->parseCurrentBlock();
560 $this->tpl->touchBlock(
"item");
563 $this->required_text =
false;
564 foreach($this->items as $item)
566 if ($item->getType() !=
"hidden")
573 if ($this->required_text && $this->
getMode() ==
"std")
575 $this->tpl->setCurrentBlock(
"required_text");
576 $this->tpl->setVariable(
"TXT_REQUIRED", $lng->txt(
"required_field"));
577 $this->tpl->parseCurrentBlock();
581 foreach($this->buttons as $button)
583 $this->tpl->setCurrentBlock(
"cmd");
584 $this->tpl->setVariable(
"CMD", $button[
"cmd"]);
585 $this->tpl->setVariable(
"CMD_TXT", $button[
"text"]);
586 $this->tpl->parseCurrentBlock();
592 $hash =
$_POST[
"ilfilehash"];
595 $hash = md5(uniqid(mt_rand(),
true));
598 $fhash->setValue($hash);
603 $hidden_fields =
false;
604 foreach($this->items as $item)
606 if ($item->getType() ==
"hidden")
608 $item->insert($this->tpl);
609 $hidden_fields =
true;
613 if ($this->required_text || count($this->buttons) > 0 || $hidden_fields)
615 $this->tpl->setCurrentBlock(
"commands");
616 $this->tpl->parseCurrentBlock();
620 if ($this->
getMode() ==
"subform")
622 $this->tpl->touchBlock(
"sub_table");
626 $this->tpl->touchBlock(
"std_table");
627 $this->tpl->setVariable(
'STD_TABLE_WIDTH',$this->
getTableWidth());
630 return $this->tpl->get();
637 if(method_exists($item,
"getMulti") && $item->getMulti())
639 $tpl->addJavascript(
"./Services/Form/js/ServiceFormMulti.js");
641 $this->tpl->setCurrentBlock(
"multi_in");
642 $this->tpl->setVariable(
"ID", $item->getFieldId());
643 $this->tpl->parseCurrentBlock();
645 $this->tpl->touchBlock(
"multi_out");
649 $multi_values = $item->getMultiValues();
650 if(is_array($multi_values) &&
sizeof($multi_values) > 1)
653 $multi_value->
setValue(implode(
"~", $multi_values));
658 $item->insert($this->tpl);
660 if ($item->getType() ==
"file" || $item->getType() ==
"image_file")
665 if ($item->getType() !=
"section_header")
668 if ($item->getInfo() !=
"")
670 $this->tpl->setCurrentBlock(
"description");
671 $this->tpl->setVariable(
"PROPERTY_DESCRIPTION",
673 $this->tpl->parseCurrentBlock();
676 if ($this->
getMode() ==
"subform")
679 if ($item->getType() !=
"non_editable_value")
681 if ($item->getRequired())
683 $this->tpl->touchBlock(
"sub_required");
684 $this->required_text =
true;
689 if ($item->getHiddenTitle() !=
"")
691 $this->tpl->setCurrentBlock(
"sub_hid_title");
692 $this->tpl->setVariable(
"SPHID_TITLE",
693 $item->getHiddenTitle());
694 $this->tpl->parseCurrentBlock();
697 $this->tpl->setCurrentBlock(
"sub_prop_start");
698 $this->tpl->setVariable(
"PROPERTY_TITLE", $item->getTitle());
699 if ($item->getType() !=
"non_editable_value")
701 $this->tpl->setVariable(
"LAB_ID", $item->getFieldId());
703 $this->tpl->parseCurrentBlock();
708 if ($item->getType() !=
"non_editable_value")
710 if ($item->getRequired())
712 $this->tpl->touchBlock(
"required");
713 $this->required_text =
true;
718 if ($item->getHiddenTitle() !=
"")
720 $this->tpl->setCurrentBlock(
"std_hid_title");
721 $this->tpl->setVariable(
"PHID_TITLE",
722 $item->getHiddenTitle());
723 $this->tpl->parseCurrentBlock();
726 $this->tpl->setCurrentBlock(
"std_prop_start");
727 $this->tpl->setVariable(
"PROPERTY_TITLE", $item->getTitle());
728 if ($item->getType() !=
"non_editable_value")
730 $this->tpl->setVariable(
"LAB_ID", $item->getFieldId());
732 $this->tpl->parseCurrentBlock();
736 if ($item->getType() !=
"non_editable_value" && $item->getAlert() !=
"")
738 $this->tpl->setCurrentBlock(
"alert");
739 $this->tpl->setVariable(
"IMG_ALERT",
741 $this->tpl->setVariable(
"ALT_ALERT",
743 $this->tpl->setVariable(
"TXT_ALERT",
745 $this->tpl->parseCurrentBlock();
750 if ($item->getType() !=
"non_editable_value" or 1)
752 $sf = $item->getSubForm();
753 if ($item->hideSubForm() && is_object($sf))
755 $this->tpl->setCurrentBlock(
"sub_form_hide");
756 $this->tpl->setVariable(
"DSFID", $item->getFieldId());
757 $this->tpl->parseCurrentBlock();
765 $sf_content = $sf->getContent();
766 if ($sf->getMultipart())
770 $this->tpl->setCurrentBlock(
"sub_form");
771 $this->tpl->setVariable(
"PROP_SUB_FORM", $sf_content);
772 $this->tpl->setVariable(
"SFID", $item->getFieldId());
773 $this->tpl->parseCurrentBlock();
776 $this->tpl->setCurrentBlock(
"prop");
778 $this->tpl->parseCurrentBlock();
781 $this->tpl->touchBlock(
"item");
801 protected function keepFileUpload($a_hash, $a_field, $a_tmp_name, $a_name, $a_type, $a_index = null, $a_sub_index = null)
805 $user_id = $ilUser->getId();
806 if(!$user_id || $user_id == ANONYMOUS_USER_ID)
811 $a_name = ilUtil::getAsciiFileName($a_name);
813 $tmp_file_name = implode(
"~~", array($user_id,
818 str_replace(
"/",
"~~", $a_type),
819 str_replace(
"~~",
"_", $a_name)));
823 if (!is_dir($temp_path))
828 move_uploaded_file($a_tmp_name, $temp_path.
"/".$tmp_file_name);
844 if($_FILES[$a_field][
"tmp_name"][$a_index][$a_sub_index])
847 "tmp_name" => $_FILES[$a_field][
"tmp_name"][$a_index][$a_sub_index],
848 "name" => $_FILES[$a_field][
"name"][$a_index][$a_sub_index],
849 "type" => $_FILES[$a_field][
"type"][$a_index][$a_sub_index],
850 "error" => $_FILES[$a_field][
"error"][$a_index][$a_sub_index],
851 "size" => $_FILES[$a_field][
"size"][$a_index][$a_sub_index],
855 else if($this->reloaded_files[$a_field][
"tmp_name"][$a_index][$a_sub_index])
858 "tmp_name" => $this->reloaded_files[
"tmp_name"][$a_index][$a_sub_index],
859 "name" => $this->reloaded_files[
"name"][$a_index][$a_sub_index],
860 "type" => $this->reloaded_files[
"type"][$a_index][$a_sub_index],
861 "error" => $this->reloaded_files[
"error"][$a_index][$a_sub_index],
862 "size" => $this->reloaded_files[
"size"][$a_index][$a_sub_index],
867 else if($a_sub_index)
869 if($_FILES[$a_field][
"tmp_name"][$a_index])
872 "tmp_name" => $_FILES[$a_field][
"tmp_name"][$a_index],
873 "name" => $_FILES[$a_field][
"name"][$a_index],
874 "type" => $_FILES[$a_field][
"type"][$a_index],
875 "error" => $_FILES[$a_field][
"error"][$a_index],
876 "size" => $_FILES[$a_field][
"size"][$a_index],
880 else if($this->reloaded_files[$a_field][
"tmp_name"][$a_index])
883 "tmp_name" => $this->reloaded_files[$a_field][
"tmp_name"][$a_index],
884 "name" => $this->reloaded_files[$a_field][
"name"][$a_index],
885 "type" => $this->reloaded_files[$a_field][
"type"][$a_index],
886 "error" => $this->reloaded_files[$a_field][
"error"][$a_index],
887 "size" => $this->reloaded_files[$a_field][
"size"][$a_index],
894 if($_FILES[$a_field][
"tmp_name"])
897 "tmp_name" => $_FILES[$a_field][
"tmp_name"],
898 "name" => $_FILES[$a_field][
"name"],
899 "type" => $_FILES[$a_field][
"type"],
900 "error" => $_FILES[$a_field][
"error"],
901 "size" => $_FILES[$a_field][
"size"],
905 else if($this->reloaded_files[$a_field][
"tmp_name"])
908 "tmp_name" => $this->reloaded_files[$a_field][
"tmp_name"],
909 "name" => $this->reloaded_files[$a_field][
"name"],
910 "type" => $this->reloaded_files[$a_field][
"type"],
911 "error" => $this->reloaded_files[$a_field][
"error"],
912 "size" => $this->reloaded_files[$a_field][
"size"],
931 return (
bool)
$data[
"tmp_name"];
944 function moveFileUpload($a_target_directory, $a_field, $a_target_name = null, $a_index = null, $a_sub_index = null)
946 if(!is_dir($a_target_directory))
952 if(
$data[
"tmp_name"] && file_exists(
$data[
"tmp_name"]))
956 $data[
"name"] = $a_target_name;
959 $target_file = $a_target_directory.
"/".
$data[
"name"];
960 $target_file = str_replace(
"//",
"/", $target_file);
962 if(
$data[
"is_upload"])
964 if (!move_uploaded_file(
$data[
"tmp_name"], $target_file))
971 if (!rename(
$data[
"tmp_name"], $target_file))
990 $user_id = $ilUser->getId();
992 if(is_dir($temp_path) && $user_id && $user_id != ANONYMOUS_USER_ID)
996 $temp_files = glob($temp_path.
"/".$ilUser->getId().
"~~".
$_POST[
"ilfilehash"].
"~~*");
997 if(is_array($temp_files))
999 foreach($temp_files as $full_file)
1001 $file = explode(
"~~", basename($full_file));
1010 if(!$_FILES[$field][
"tmp_name"][$idx][$idx2])
1012 $reload[$field][
"tmp_name"][$idx][$idx2] = $full_file;
1013 $reload[$field][
"name"][$idx][$idx2] =
$name;
1014 $reload[$field][
"type"][$idx][$idx2] = $type;
1015 $reload[$field][
"error"][$idx][$idx2] = 0;
1016 $reload[$field][
"size"][$idx][$idx2] = filesize($full_file);
1021 if(!$_FILES[$field][
"tmp_name"][$idx])
1023 $reload[$field][
"tmp_name"][$idx] = $full_file;
1024 $reload[$field][
"name"][$idx] =
$name;
1025 $reload[$field][
"type"][$idx] = $type;
1026 $reload[$field][
"error"][$idx] = 0;
1027 $reload[$field][
"size"][$idx] = filesize($full_file);
1032 if(!$_FILES[$field][
"tmp_name"])
1034 $reload[$field][
"tmp_name"] = $full_file;
1035 $reload[$field][
"name"] =
$name;
1036 $reload[$field][
"type"] = $type;
1037 $reload[$field][
"error"] = 0;
1038 $reload[$field][
"size"] = filesize($full_file);
1044 $this->reloaded_files = $reload;