50 $ilCtrl = $DIC[
'ilCtrl'];
51 $ilTabs = $DIC[
'ilTabs'];
52 $ilToolbar = $DIC[
'ilToolbar'];
55 $ilLog = $DIC[
'ilLog'];
57 $this->ctrl = $ilCtrl;
58 $this->parent_gui = $parent_gui;
59 $this->parent_object = $parent_gui->object;
60 $this->tabs_gui = $this->parent_gui->tabs_gui;
61 $this->toolbar = $ilToolbar;
64 $this->lng->loadLanguageModule(
'user');
65 $this->
ilLog = $ilLog;
66 if (!$this->
ilAccess->checkaccess(
"write",
"", $this->parent_gui->object->getRefId())) {
77 $cmd = $this->ctrl->getCmd();
84 $this->tabs_gui->clearTargets();
85 $this->tabs_gui->setBackTarget($this->lng->txt(
"back"), $this->ctrl->getLinkTarget($this,
'chooseImport'));
89 $this->tabs_gui->clearTargets();
90 $this->tabs_gui->setBackTarget($this->lng->txt(
"back"), $this->ctrl->getLinkTarget($this,
'chooseImport'));
103 $this->ctrl->redirectByClass(
'ilinfoscreengui',
'');
106 $this->tabs_gui->setTabActive(
'view_content');
107 $this->tabs_gui->removeSubTab(
"page_editor");
108 $this->tabs_gui->removeSubTab(
"ordering");
111 $this->toolbar->addButton($this->lng->txt(
"simple_import"), $this->ctrl->getLinkTargetByClass(
"ilOrgUnitSimpleImportGUI",
"importScreen"));
112 $this->toolbar->addButton($this->lng->txt(
"simple_user_import"), $this->ctrl->getLinkTargetByClass(
"ilOrgUnitSimpleUserImportGUI",
"userImportScreen"));
119 $form = $this->
initForm(
"startImport");
120 $this->tpl->setContent($form->getHTML());
127 $input =
new ilFileInputGUI($this->lng->txt(
"import_xml_file"),
"import_file");
129 $input->setSuffixes(array(
'zip',
'xml'));
130 $form->addItem($input);
131 $form->setFormAction($this->ctrl->getFormAction($this));
132 $form->addCommandButton($submit_action, $this->lng->txt(
"import"));
140 $form = $this->
initForm(
"startImport");
141 if (!$form->checkInput()) {
142 $this->tpl->setContent($form->getHTML());
144 $file = $form->getInput(
"import_file");
147 $file_path = $file[
"tmp_name"];
148 $file_type = pathinfo($file[
"name"], PATHINFO_EXTENSION);
149 $file_name = pathinfo($file[
"name"], PATHINFO_FILENAME);
151 if ($file_type ==
"zip") {
152 $extract_path = $file_path .
'_extracted/';
153 $extracted_file = $extract_path . $file_name .
'/manifest.xml';
155 $zip =
new ZipArchive();
156 $res = $zip->open($file_path);
158 $zip->extractTo($extract_path);
161 if (file_exists($extracted_file)) {
162 $file_path = $extracted_file;
167 $importer->simpleImport($file_path);
169 $this->
ilLog->
write($e->getMessage() .
" - " . $e->getTraceAsString());
171 $this->ctrl->redirect($this,
"render");
183 if (!$importer->hasErrors() && !$importer->hasWarnings()) {
184 $stats = $importer->getStats();
185 ilUtil::sendSuccess(sprintf($this->lng->txt(
"import_successful"), $stats[
"created"], $stats[
"updated"], $stats[
"deleted"]),
true);
187 if ($importer->hasWarnings()) {
188 $msg = $this->lng->txt(
"import_terminated_with_warnings") .
" <br/>";
189 foreach ($importer->getWarnings() as $warning) {
190 $msg .=
"-" . $this->lng->txt($warning[
"lang_var"]) .
" (Import ID: " . $warning[
"import_id"] .
")<br />";
194 if ($importer->hasErrors()) {
195 $msg = $this->lng->txt(
"import_terminated_with_errors") .
"<br/>";
196 foreach ($importer->getErrors() as $warning) {
197 $msg .=
"- " . $this->lng->txt($warning[
"lang_var"]) .
" (Import ID: " . $warning[
"import_id"] .
")<br />";
Class ilOrgUnitSimpleImportGUI.
write($a_msg, $a_log_level=null)
logging
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
foreach($_POST as $key=> $value) $res
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
displayImportResults($importer)