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);
549 $this->buttons = array();
559 include_once(
"./Services/YUI/classes/class.ilYuiUtil.php");
564 $tpl->addJavaScript(
"./Services/JavaScript/js/Basic.js");
565 $tpl->addJavaScript(
"Services/Form/js/Form.js");
567 $this->tpl =
new ilTemplate(
"tpl.property_form.html",
true,
true,
"Services/Form");
572 $fi = $this->items[0];
573 if ($this->
getMode() ==
"std" &&
575 is_object($fi) && $fi->getType() ==
"section_header" 579 unset($this->items[0]);
586 $this->tpl->setCurrentBlock(
"title_icon");
587 $this->tpl->setVariable(
"IMG_ICON", $this->
getTitleIcon());
588 $this->tpl->parseCurrentBlock();
595 if (count($this->buttons) > 0 && $this->
getShowTopButtons() && count($this->items) > 2)
598 foreach($this->buttons as $button)
600 $this->tpl->setCurrentBlock(
"cmd2");
601 $this->tpl->setVariable(
"CMD", $button[
"cmd"]);
602 $this->tpl->setVariable(
"CMD_TXT", $button[
"text"]);
603 $this->tpl->parseCurrentBlock();
605 $this->tpl->setCurrentBlock(
"commands2");
606 $this->tpl->parseCurrentBlock();
609 if (is_object($ilSetting))
611 if ($ilSetting->get(
'char_selector_availability') > 0)
613 require_once
'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
619 $char_selector->addToPage();
620 $this->tpl->TouchBlock(
'char_selector');
626 $this->tpl->setCurrentBlock(
"header");
627 $this->tpl->setVariable(
"TXT_TITLE", $this->
getTitle());
628 $this->tpl->setVariable(
"LABEL", $this->
getTopAnchor());
629 $this->tpl->setVariable(
"TXT_DESCRIPTION", $this->
getDescription());
630 $this->tpl->parseCurrentBlock();
632 $this->tpl->touchBlock(
"item");
635 $this->required_text =
false;
636 foreach($this->items as $item)
638 if ($item->getType() !=
"hidden")
645 if ($this->required_text && $this->
getMode() ==
"std")
647 $this->tpl->setCurrentBlock(
"required_text");
648 $this->tpl->setVariable(
"TXT_REQUIRED", $lng->txt(
"required_field"));
649 $this->tpl->parseCurrentBlock();
653 foreach($this->buttons as $button)
655 $this->tpl->setCurrentBlock(
"cmd");
656 $this->tpl->setVariable(
"CMD", $button[
"cmd"]);
657 $this->tpl->setVariable(
"CMD_TXT", $button[
"text"]);
658 $this->tpl->parseCurrentBlock();
664 $hash =
$_POST[
"ilfilehash"];
667 $hash = md5(uniqid(mt_rand(),
true));
670 $fhash->setValue($hash);
675 $hidden_fields =
false;
676 foreach($this->items as $item)
678 if ($item->getType() ==
"hidden")
680 $item->insert($this->tpl);
681 $hidden_fields =
true;
685 if ($this->required_text || count($this->buttons) > 0 || $hidden_fields)
687 $this->tpl->setCurrentBlock(
"commands");
688 $this->tpl->parseCurrentBlock();
692 if ($this->
getMode() ==
"subform")
694 $this->tpl->touchBlock(
"sub_table");
698 $this->tpl->touchBlock(
"std_table");
699 $this->tpl->setVariable(
'STD_TABLE_WIDTH',$this->
getTableWidth());
702 return $this->tpl->get();
715 $tpl->addJavascript(
"./Services/Form/js/ServiceFormMulti.js");
717 $this->tpl->setCurrentBlock(
"multi_in");
718 $this->tpl->setVariable(
"ID", $item->getFieldId());
719 $this->tpl->parseCurrentBlock();
721 $this->tpl->touchBlock(
"multi_out");
726 $multi_values = $item->getMultiValues();
727 if(is_array($multi_values) &&
sizeof($multi_values) > 1)
730 $multi_value->
setValue(implode(
"~", $multi_values));
733 $cfg[
"multi_values"] = $multi_values;
736 $item->insert($this->tpl);
738 if ($item->getType() ==
"file" || $item->getType() ==
"image_file")
743 if ($item->getType() !=
"section_header")
745 $cfg[
"id"] = $item->getFieldId();
748 if ($item->getInfo() !=
"")
750 $this->tpl->setCurrentBlock(
"description");
751 $this->tpl->setVariable(
"PROPERTY_DESCRIPTION",
753 $this->tpl->parseCurrentBlock();
756 if ($this->
getMode() ==
"subform")
759 if ($item->getType() !=
"non_editable_value")
761 if ($item->getRequired())
763 $this->tpl->touchBlock(
"sub_required");
764 $this->required_text =
true;
769 if ($item->getHiddenTitle() !=
"")
771 $this->tpl->setCurrentBlock(
"sub_hid_title");
772 $this->tpl->setVariable(
"SPHID_TITLE",
773 $item->getHiddenTitle());
774 $this->tpl->parseCurrentBlock();
777 $this->tpl->setCurrentBlock(
"sub_prop_start");
778 $this->tpl->setVariable(
"PROPERTY_TITLE", $item->getTitle());
779 $this->tpl->setVariable(
"PROPERTY_CLASS",
"il_".$item->getType());
780 if ($item->getType() !=
"non_editable_value")
782 $this->tpl->setVariable(
"LAB_ID", $item->getFieldId());
784 $this->tpl->parseCurrentBlock();
789 if ($item->getType() !=
"non_editable_value")
791 if ($item->getRequired())
793 $this->tpl->touchBlock(
"required");
794 $this->required_text =
true;
799 if ($item->getHiddenTitle() !=
"")
801 $this->tpl->setCurrentBlock(
"std_hid_title");
802 $this->tpl->setVariable(
"PHID_TITLE",
803 $item->getHiddenTitle());
804 $this->tpl->parseCurrentBlock();
807 $this->tpl->setCurrentBlock(
"std_prop_start");
808 $this->tpl->setVariable(
"PROPERTY_TITLE", $item->getTitle());
809 if ($item->getType() !=
"non_editable_value")
811 $this->tpl->setVariable(
"LAB_ID", $item->getFieldId());
815 $this->tpl->setVariable(
"HIDE_LABELS_STYLE",
" ilFormOptionHidden");
817 $this->tpl->parseCurrentBlock();
821 if ($item->getType() !=
"non_editable_value" && $item->getAlert() !=
"")
823 $this->tpl->setCurrentBlock(
"alert");
824 $this->tpl->setVariable(
"IMG_ALERT",
826 $this->tpl->setVariable(
"ALT_ALERT",
828 $this->tpl->setVariable(
"TXT_ALERT",
830 $this->tpl->parseCurrentBlock();
835 if ($item->getType() !=
"non_editable_value" or 1)
837 $sf = $item->getSubForm();
838 if ($item->hideSubForm() && is_object($sf))
840 $this->tpl->setCurrentBlock(
"sub_form_hide");
841 $this->tpl->setVariable(
"DSFID", $item->getFieldId());
842 $this->tpl->parseCurrentBlock();
850 $sf_content = $sf->getContent();
851 if ($sf->getMultipart())
855 $this->tpl->setCurrentBlock(
"sub_form");
856 $this->tpl->setVariable(
"PROP_SUB_FORM", $sf_content);
857 $this->tpl->setVariable(
"SFID", $item->getFieldId());
858 $this->tpl->parseCurrentBlock();
861 $this->tpl->setCurrentBlock(
"prop");
866 $this->tpl->parseCurrentBlock();
870 $this->tpl->touchBlock(
"item");
875 $html = parent::getHTML();
878 foreach($this->items as $item)
881 if(method_exists($item,
"getContentOutsideFormTag"))
883 $outside = $item->getContentOutsideFormTag();
911 protected function keepFileUpload($a_hash, $a_field, $a_tmp_name, $a_name, $a_type, $a_index = null, $a_sub_index = null)
915 $user_id = $ilUser->getId();
916 if(!$user_id || $user_id == ANONYMOUS_USER_ID)
921 $a_name = ilUtil::getAsciiFileName($a_name);
923 $tmp_file_name = implode(
"~~", array($user_id,
928 str_replace(
"/",
"~~", $a_type),
929 str_replace(
"~~",
"_", $a_name)));
933 if (!is_dir($temp_path))
938 move_uploaded_file($a_tmp_name, $temp_path.
"/".$tmp_file_name);
954 if($_FILES[$a_field][
"tmp_name"][$a_index][$a_sub_index])
957 "tmp_name" => $_FILES[$a_field][
"tmp_name"][$a_index][$a_sub_index],
958 "name" => $_FILES[$a_field][
"name"][$a_index][$a_sub_index],
959 "type" => $_FILES[$a_field][
"type"][$a_index][$a_sub_index],
960 "error" => $_FILES[$a_field][
"error"][$a_index][$a_sub_index],
961 "size" => $_FILES[$a_field][
"size"][$a_index][$a_sub_index],
965 else if($this->reloaded_files[$a_field][
"tmp_name"][$a_index][$a_sub_index])
968 "tmp_name" => $this->reloaded_files[
"tmp_name"][$a_index][$a_sub_index],
969 "name" => $this->reloaded_files[
"name"][$a_index][$a_sub_index],
970 "type" => $this->reloaded_files[
"type"][$a_index][$a_sub_index],
971 "error" => $this->reloaded_files[
"error"][$a_index][$a_sub_index],
972 "size" => $this->reloaded_files[
"size"][$a_index][$a_sub_index],
977 else if($a_sub_index)
979 if($_FILES[$a_field][
"tmp_name"][$a_index])
982 "tmp_name" => $_FILES[$a_field][
"tmp_name"][$a_index],
983 "name" => $_FILES[$a_field][
"name"][$a_index],
984 "type" => $_FILES[$a_field][
"type"][$a_index],
985 "error" => $_FILES[$a_field][
"error"][$a_index],
986 "size" => $_FILES[$a_field][
"size"][$a_index],
990 else if($this->reloaded_files[$a_field][
"tmp_name"][$a_index])
993 "tmp_name" => $this->reloaded_files[$a_field][
"tmp_name"][$a_index],
994 "name" => $this->reloaded_files[$a_field][
"name"][$a_index],
995 "type" => $this->reloaded_files[$a_field][
"type"][$a_index],
996 "error" => $this->reloaded_files[$a_field][
"error"][$a_index],
997 "size" => $this->reloaded_files[$a_field][
"size"][$a_index],
1004 if($_FILES[$a_field][
"tmp_name"])
1007 "tmp_name" => $_FILES[$a_field][
"tmp_name"],
1008 "name" => $_FILES[$a_field][
"name"],
1009 "type" => $_FILES[$a_field][
"type"],
1010 "error" => $_FILES[$a_field][
"error"],
1011 "size" => $_FILES[$a_field][
"size"],
1015 else if($this->reloaded_files[$a_field][
"tmp_name"])
1018 "tmp_name" => $this->reloaded_files[$a_field][
"tmp_name"],
1019 "name" => $this->reloaded_files[$a_field][
"name"],
1020 "type" => $this->reloaded_files[$a_field][
"type"],
1021 "error" => $this->reloaded_files[$a_field][
"error"],
1022 "size" => $this->reloaded_files[$a_field][
"size"],
1023 "is_upload" =>
false 1041 return (
bool)
$data[
"tmp_name"];
1054 function moveFileUpload($a_target_directory, $a_field, $a_target_name = null, $a_index = null, $a_sub_index = null)
1056 if(!is_dir($a_target_directory))
1062 if(
$data[
"tmp_name"] && file_exists(
$data[
"tmp_name"]))
1066 $data[
"name"] = $a_target_name;
1069 $target_file = $a_target_directory.
"/".
$data[
"name"];
1070 $target_file = str_replace(
"//",
"/", $target_file);
1072 if(
$data[
"is_upload"])
1074 if (!move_uploaded_file(
$data[
"tmp_name"], $target_file))
1081 if (!rename(
$data[
"tmp_name"], $target_file))
1087 return $target_file;
1100 $user_id = $ilUser->getId();
1102 if(is_dir($temp_path) && $user_id && $user_id != ANONYMOUS_USER_ID)
1106 $temp_files = glob($temp_path.
"/".$ilUser->getId().
"~~".
$_POST[
"ilfilehash"].
"~~*");
1107 if(is_array($temp_files))
1109 foreach($temp_files as $full_file)
1111 $file = explode(
"~~", basename($full_file));
1120 if(!$_FILES[$field][
"tmp_name"][$idx][$idx2])
1122 $reload[$field][
"tmp_name"][$idx][$idx2] = $full_file;
1123 $reload[$field][
"name"][$idx][$idx2] =
$name;
1124 $reload[$field][
"type"][$idx][$idx2] = $type;
1125 $reload[$field][
"error"][$idx][$idx2] = 0;
1126 $reload[$field][
"size"][$idx][$idx2] = filesize($full_file);
1131 if(!$_FILES[$field][
"tmp_name"][$idx])
1133 $reload[$field][
"tmp_name"][$idx] = $full_file;
1134 $reload[$field][
"name"][$idx] =
$name;
1135 $reload[$field][
"type"][$idx] = $type;
1136 $reload[$field][
"error"][$idx] = 0;
1137 $reload[$field][
"size"][$idx] = filesize($full_file);
1142 if(!$_FILES[$field][
"tmp_name"])
1144 $reload[$field][
"tmp_name"] = $full_file;
1145 $reload[$field][
"name"] =
$name;
1146 $reload[$field][
"type"] = $type;
1147 $reload[$field][
"error"] = 0;
1148 $reload[$field][
"size"] = filesize($full_file);
1154 $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)
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']