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';
70 $lng->loadLanguageModule(
"form");
86 $next_class = $ilCtrl->getNextClass($this);
87 $cmd = $ilCtrl->getCmd();
91 case 'ilformpropertydispatchgui':
92 $ilCtrl->saveParameter($this,
'postvar');
93 include_once
'./Services/Form/classes/class.ilFormPropertyDispatchGUI.php';
96 $form_prop_dispatch->setItem($item);
97 return $ilCtrl->forwardCommand($form_prop_dispatch);
113 $this->tbl_width = $a_width;
134 $this->mode = $a_mode;
154 $this->title = $a_title;
174 $this->titleicon = $a_titleicon;
194 $this->description = $a_val;
214 $this->top_anchor = $a_val;
232 $this->show_top_buttons = $a_val;
250 $a_item->setParentForm($this);
251 return $this->items[] = $a_item;
261 foreach ($this->items as $key => $item)
263 if (method_exists($item,
"getPostVar") && $item->getPostVar() == $a_post_var)
265 unset($this->items[$key]);
277 foreach ($this->items as $key => $item)
279 if ($item->getType() !=
"section_header")
282 $ret = $item->getItemByPostVar($a_post_var);
300 $this->items = $a_items;
321 $inputItems =
array();
323 foreach($this->items as $item)
325 if( $item->getType() ==
'section_header' )
330 $inputItems[] = $item;
334 $inputItems = array_merge( $inputItems, $item->getSubInputItemsRecursive() );
348 $this->disable_standard_message = $a_val;
378 $this->hide_labels = $a_value;
388 foreach($this->items as $item)
390 if(!($a_restrict_to_value_keys) ||
391 in_array($item->getPostVar(), array_keys($a_values)))
393 $item->setValueByArray($a_values);
404 foreach ($this->items as $item)
406 $item->setValueByArray(
$_POST);
420 if ($this->check_input_called)
422 die (
"Error: ilPropertyFormGUI->checkInput() called twice.");
426 foreach($this->items as $item)
428 $item_ok = $item->checkInput();
436 if (count($this->items) > 0 && !is_array(
$_POST))
441 $this->check_input_called =
true;
446 if(!
$ok &&
$_POST[
"ilfilehash"] &&
sizeof($_FILES))
448 $hash =
$_POST[
"ilfilehash"];
450 foreach($_FILES as $field =>
$data)
453 if(is_array(
$data[
"tmp_name"]))
455 foreach(
$data[
"tmp_name"] as $idx => $upload)
457 if(is_array($upload))
459 foreach($upload as $idx2 =>
$file)
463 $file_name =
$data[
"name"][$idx][$idx2];
464 $file_type =
$data[
"type"][$idx][$idx2];
465 $this->keepFileUpload($hash, $field,
$file, $file_name, $file_type, $idx, $idx2);
469 else if($upload && is_uploaded_file($upload))
471 $file_name =
$data[
"name"][$idx];
472 $file_type =
$data[
"type"][$idx];
473 $this->keepFileUpload($hash, $field, $upload, $file_name, $file_type, $idx);
479 $this->keepFileUpload($hash, $field,
$data[
"tmp_name"],
$data[
"name"],
$data[
"type"]);
502 public function getInput($a_post_var, $ensureValidation =
true)
505 if (!$this->check_input_called && $ensureValidation)
507 die (
"Error: ilPropertyFormGUI->getInput() called without calling checkInput() first.");
510 return $_POST[$a_post_var];
523 $a_alert =
"", $a_required =
false)
539 $this->buttons[] =
array(
"cmd" => $a_cmd,
"text" => $a_text,
"id" => $a_id);
557 $this->buttons =
array();
567 include_once(
"./Services/YUI/classes/class.ilYuiUtil.php");
572 $tpl->addJavaScript(
"./Services/JavaScript/js/Basic.js");
573 $tpl->addJavaScript(
"Services/Form/js/Form.js");
575 $this->tpl =
new ilTemplate(
"tpl.property_form.html",
true,
true,
"Services/Form");
580 $fi = $this->items[0];
581 if ($this->
getMode() ==
"std" &&
583 is_object($fi) && $fi->getType() ==
"section_header" 587 unset($this->items[0]);
594 $this->tpl->setCurrentBlock(
"title_icon");
595 $this->tpl->setVariable(
"IMG_ICON", $this->
getTitleIcon());
596 $this->tpl->parseCurrentBlock();
603 if (count($this->buttons) > 0 && $this->
getShowTopButtons() && count($this->items) > 2)
606 foreach($this->buttons as $button)
608 $this->tpl->setCurrentBlock(
"cmd2");
609 $this->tpl->setVariable(
"CMD", $button[
"cmd"]);
610 $this->tpl->setVariable(
"CMD_TXT", $button[
"text"]);
611 if ($button[
"id"] !=
"")
613 $this->tpl->setVariable(
"CMD2_ID",
" id='".$button[
"id"].
"_top'");
615 $this->tpl->parseCurrentBlock();
617 $this->tpl->setCurrentBlock(
"commands2");
618 $this->tpl->parseCurrentBlock();
621 if (is_object($ilSetting))
623 if ($ilSetting->get(
'char_selector_availability') > 0)
625 require_once
'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
631 $char_selector->addToPage();
632 $this->tpl->TouchBlock(
'char_selector');
638 $this->tpl->setCurrentBlock(
"header");
639 $this->tpl->setVariable(
"TXT_TITLE", $this->
getTitle());
640 $this->tpl->setVariable(
"LABEL", $this->
getTopAnchor());
641 $this->tpl->setVariable(
"TXT_DESCRIPTION", $this->
getDescription());
642 $this->tpl->parseCurrentBlock();
644 $this->tpl->touchBlock(
"item");
647 $this->required_text =
false;
648 foreach($this->items as $item)
650 if ($item->getType() !=
"hidden")
657 if ($this->required_text && $this->
getMode() ==
"std")
659 $this->tpl->setCurrentBlock(
"required_text");
660 $this->tpl->setVariable(
"TXT_REQUIRED", $lng->txt(
"required_field"));
661 $this->tpl->parseCurrentBlock();
665 foreach($this->buttons as $button)
667 $this->tpl->setCurrentBlock(
"cmd");
668 $this->tpl->setVariable(
"CMD", $button[
"cmd"]);
669 $this->tpl->setVariable(
"CMD_TXT", $button[
"text"]);
671 if ($button[
"id"] !=
"")
673 $this->tpl->setVariable(
"CMD_ID",
" id='".$button[
"id"].
"'");
676 $this->tpl->parseCurrentBlock();
680 if ($this->
getMode() !=
"subform")
685 $hash =
$_POST[
"ilfilehash"];
688 $hash = md5(uniqid(mt_rand(),
true));
691 $fhash->setValue($hash);
697 $hidden_fields =
false;
698 foreach($this->items as $item)
700 if ($item->getType() ==
"hidden")
702 $item->insert($this->tpl);
703 $hidden_fields =
true;
707 if ($this->required_text || count($this->buttons) > 0 || $hidden_fields)
709 $this->tpl->setCurrentBlock(
"commands");
710 $this->tpl->parseCurrentBlock();
714 if ($this->
getMode() ==
"subform")
716 $this->tpl->touchBlock(
"sub_table");
720 $this->tpl->touchBlock(
"std_table");
721 $this->tpl->setVariable(
'STD_TABLE_WIDTH',$this->
getTableWidth());
724 return $this->tpl->get();
743 $tpl->addJavascript(
"./Services/Form/js/ServiceFormMulti.js");
745 $this->tpl->setCurrentBlock(
"multi_in");
746 $this->tpl->setVariable(
"ID", $item->getFieldId());
747 $this->tpl->parseCurrentBlock();
749 $this->tpl->touchBlock(
"multi_out");
754 $multi_values = $item->getMultiValues();
755 if(is_array($multi_values) &&
sizeof($multi_values) > 1)
758 $multi_value->
setValue(implode(
"~", $multi_values));
761 $cfg[
"multi_values"] = $multi_values;
764 $item->insert($this->tpl);
766 if ($item->getType() ==
"file" || $item->getType() ==
"image_file")
771 if ($item->getType() !=
"section_header")
773 $cfg[
"id"] = $item->getFieldId();
776 if ($item->getInfo() !=
"")
778 $this->tpl->setCurrentBlock(
"description");
779 $this->tpl->setVariable(
"PROPERTY_DESCRIPTION",
781 $this->tpl->parseCurrentBlock();
784 if ($this->
getMode() ==
"subform")
789 if ($item->getRequired())
791 $this->tpl->touchBlock(
"sub_required");
792 $this->required_text =
true;
797 if ($item->getHiddenTitle() !=
"")
799 $this->tpl->setCurrentBlock(
"sub_hid_title");
800 $this->tpl->setVariable(
"SPHID_TITLE",
801 $item->getHiddenTitle());
802 $this->tpl->parseCurrentBlock();
805 $this->tpl->setCurrentBlock(
"sub_prop_start");
806 $this->tpl->setVariable(
"PROPERTY_TITLE", $item->getTitle());
807 $this->tpl->setVariable(
"PROPERTY_CLASS",
"il_".$item->getType());
808 if ($item->getType() !=
"non_editable_value")
810 $this->tpl->setVariable(
"LAB_ID", $item->getFieldId());
812 $this->tpl->parseCurrentBlock();
819 if ($item->getRequired())
821 $this->tpl->touchBlock(
"required");
822 $this->required_text =
true;
827 if ($item->getHiddenTitle() !=
"")
829 $this->tpl->setCurrentBlock(
"std_hid_title");
830 $this->tpl->setVariable(
"PHID_TITLE",
831 $item->getHiddenTitle());
832 $this->tpl->parseCurrentBlock();
835 $this->tpl->setCurrentBlock(
"std_prop_start");
836 $this->tpl->setVariable(
"PROPERTY_TITLE", $item->getTitle());
837 if ($item->getType() !=
"non_editable_value")
839 $this->tpl->setVariable(
"LAB_ID", $item->getFieldId());
843 $this->tpl->setVariable(
"HIDE_LABELS_STYLE",
" ilFormOptionHidden");
845 $this->tpl->parseCurrentBlock();
849 if ($item->getType() !=
"non_editable_value" && $item->getAlert() !=
"")
851 $this->tpl->setCurrentBlock(
"alert");
852 $this->tpl->setVariable(
"IMG_ALERT",
854 $this->tpl->setVariable(
"ALT_ALERT",
856 $this->tpl->setVariable(
"TXT_ALERT",
858 $this->tpl->parseCurrentBlock();
863 if ($item->getType() !=
"non_editable_value" or 1)
865 $sf = $item->getSubForm();
866 if ($item->hideSubForm() && is_object($sf))
868 $this->tpl->setCurrentBlock(
"sub_form_hide");
869 $this->tpl->setVariable(
"DSFID", $item->getFieldId());
870 $this->tpl->parseCurrentBlock();
878 $sf_content = $sf->getContent();
879 if ($sf->getMultipart())
883 $this->tpl->setCurrentBlock(
"sub_form");
884 $this->tpl->setVariable(
"PROP_SUB_FORM", $sf_content);
885 $this->tpl->setVariable(
"SFID", $item->getFieldId());
886 $this->tpl->parseCurrentBlock();
889 $this->tpl->setCurrentBlock(
"prop");
893 $this->tpl->parseCurrentBlock();
897 $this->tpl->touchBlock(
"item");
902 $html = parent::getHTML();
905 foreach($this->items as $item)
908 if(method_exists($item,
"getContentOutsideFormTag"))
910 $outside = $item->getContentOutsideFormTag();
938 protected function keepFileUpload($a_hash, $a_field, $a_tmp_name, $a_name,
$a_type, $a_index = null, $a_sub_index = null)
940 if (trim($a_tmp_name) ==
"")
944 $a_name = ilUtil::getAsciiFileName($a_name);
946 $tmp_file_name = implode(
"~~",
array(session_id(),
951 str_replace(
"/",
"~~",
$a_type),
952 str_replace(
"~~",
"_", $a_name)));
956 if (!is_dir($temp_path))
965 $file_input->setPending($a_name);
981 if($_FILES[$a_field][
"tmp_name"][$a_index][$a_sub_index])
984 "tmp_name" => $_FILES[$a_field][
"tmp_name"][$a_index][$a_sub_index],
985 "name" => $_FILES[$a_field][
"name"][$a_index][$a_sub_index],
986 "type" => $_FILES[$a_field][
"type"][$a_index][$a_sub_index],
987 "error" => $_FILES[$a_field][
"error"][$a_index][$a_sub_index],
988 "size" => $_FILES[$a_field][
"size"][$a_index][$a_sub_index],
993 else if($a_sub_index)
995 if($_FILES[$a_field][
"tmp_name"][$a_index])
998 "tmp_name" => $_FILES[$a_field][
"tmp_name"][$a_index],
999 "name" => $_FILES[$a_field][
"name"][$a_index],
1000 "type" => $_FILES[$a_field][
"type"][$a_index],
1001 "error" => $_FILES[$a_field][
"error"][$a_index],
1002 "size" => $_FILES[$a_field][
"size"][$a_index],
1009 if($_FILES[$a_field][
"tmp_name"])
1012 "tmp_name" => $_FILES[$a_field][
"tmp_name"],
1013 "name" => $_FILES[$a_field][
"name"],
1014 "type" => $_FILES[$a_field][
"type"],
1015 "error" => $_FILES[$a_field][
"error"],
1016 "size" => $_FILES[$a_field][
"size"],
1035 return (
bool)
$data[
"tmp_name"];
1048 function moveFileUpload($a_target_directory, $a_field, $a_target_name = null, $a_index = null, $a_sub_index = null)
1050 if(!is_dir($a_target_directory))
1056 if(
$data[
"tmp_name"] && file_exists(
$data[
"tmp_name"]))
1060 $data[
"name"] = $a_target_name;
1063 $target_file = $a_target_directory.
"/".
$data[
"name"];
1064 $target_file = str_replace(
"//",
"/", $target_file);
1066 if(
$data[
"is_upload"])
1075 if (!rename(
$data[
"tmp_name"], $target_file))
1081 return $target_file;
1090 if(isset(
$_POST[
"ilfilehash"]) &&
$_POST[
"ilfilehash"])
1093 if(is_dir($temp_path))
1095 $temp_files = glob($temp_path.
"/".session_id().
"~~".
$_POST[
"ilfilehash"].
"~~*");
1096 if(is_array($temp_files))
1098 foreach($temp_files as $full_file)
1100 $file = explode(
"~~", basename($full_file));
1109 if(!$_FILES[$field][
"tmp_name"][$idx][$idx2])
1111 $_FILES[$field][
"tmp_name"][$idx][$idx2] = $full_file;
1112 $_FILES[$field][
"name"][$idx][$idx2] =
$name;
1113 $_FILES[$field][
"type"][$idx][$idx2] = $type;
1114 $_FILES[$field][
"error"][$idx][$idx2] = 0;
1115 $_FILES[$field][
"size"][$idx][$idx2] = filesize($full_file);
1120 if(!$_FILES[$field][
"tmp_name"][$idx])
1122 $_FILES[$field][
"tmp_name"][$idx] = $full_file;
1123 $_FILES[$field][
"name"][$idx] =
$name;
1124 $_FILES[$field][
"type"][$idx] = $type;
1125 $_FILES[$field][
"error"][$idx] = 0;
1126 $_FILES[$field][
"size"][$idx] = filesize($full_file);
1131 if(!$_FILES[$field][
"tmp_name"])
1133 $_FILES[$field][
"tmp_name"] = $full_file;
1134 $_FILES[$field][
"name"] =
$name;
1135 $_FILES[$field][
"type"] = $type;
1136 $_FILES[$field][
"error"] = 0;
1137 $_FILES[$field][
"size"] = filesize($full_file);
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.
Create styles array
The data for the language used.
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(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file