ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLMImportGUI.php
Go to the documentation of this file.
1<?php
2
20
26{
27 protected ilCtrl $ctrl;
28 protected ilLanguage $lng;
32 public function __construct(ilObjLearningModule $a_lm)
33 {
34 global $DIC;
35
36 $this->request = $DIC
37 ->learningModule()
38 ->internal()
39 ->gui()
40 ->editing()
41 ->request();
42
43
44 $this->ctrl = $DIC->ctrl();
45 $this->lng = $DIC->language();
46 $this->tpl = $DIC["tpl"];
47 $this->lm = $a_lm;
48 }
49
50 public function executeCommand(): void
51 {
52 $ilCtrl = $this->ctrl;
53
54 $cmd = $ilCtrl->getCmd("showTranslationImportForm");
55
56 if (in_array($cmd, array("showTranslationImportForm", "importTranslation"))) {
57 $this->$cmd();
58 }
59 }
60
61 public function showTranslationImportForm(): void
62 {
65
66 $this->tpl->setOnScreenMessage('info', $lng->txt("cont_trans_import_info"));
67 $form = $this->initTranslationImportForm();
68 $tpl->setContent($form->getHTML());
69 }
70
72 {
74 $ilCtrl = $this->ctrl;
75
76 $options = [];
77
78 $lng->loadLanguageModule("meta");
79
80 $form = new ilPropertyFormGUI();
81
82 // import file
83 $fi = new ilFileInputGUI($lng->txt("file"), "importfile");
84 $fi->setSuffixes(array("zip"));
85 $fi->setRequired(true);
86 $fi->setSize(30);
87 $form->addItem($fi);
88
89 $ot = $this->lm->getObjectProperties()->getPropertyTranslations();
90 foreach ($ot->getLanguages() as $l) {
91 if ($l->getLanguageCode() !== $ot->getBaseLanguage()) {
92 $options[$l->getLanguageCode()] = $lng->txt("meta_l_" . $l->getLanguageCode());
93 }
94 }
95 $si = new ilSelectInputGUI($lng->txt("cont_import_lang"), "import_lang");
96 $si->setOptions($options);
97 $form->addItem($si);
98
99 $form->addCommandButton("importTranslation", $lng->txt("import"));
100 $form->setTitle($lng->txt("cont_import_trans"));
101 $form->setFormAction($ilCtrl->getFormAction($this));
102
103 return $form;
104 }
105
106 public function importTranslation(): void
107 {
108 $ilCtrl = $this->ctrl;
110
111 $imp = new ilImport();
112 $conf = $imp->getConfig("components/ILIAS/LearningModule");
113
114 $target_lang = $this->request->getImportLang();
115 $ot = $this->lm->getObjectProperties()->getPropertyTranslations();
116 if ($target_lang == $ot->getBaseLanguage() || $target_lang == "") {
117 $this->tpl->setOnScreenMessage('failure', $lng->txt("cont_transl_master_language_not_allowed"), true);
118 $ilCtrl->redirect($this, "showTranslationImportForm");
119 }
120
121 $conf->setTranslationImportMode($this->lm, $target_lang);
122 $imp->importObject(
123 null,
124 $_FILES["importfile"]["tmp_name"],
125 $_FILES["importfile"]["name"],
126 "lm",
127 "components/ILIAS/LearningModule"
128 );
129 //echo "h"; exit;
130 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
131 $ilCtrl->redirect($this, "showTranslationImportForm");
132 }
133}
Class ilCtrl provides processing control methods.
getCmd(?string $fallback_command=null)
@inheritDoc
This class represents a file property in a property form.
Import class.
Import related features for learning modules.
EditingGUIRequest $request
ilObjLearningModule $lm
ilGlobalTemplateInterface $tpl
__construct(ilObjLearningModule $a_lm)
language handling
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a property form user interface.
This class represents a selection list property in a property form.
setOnScreenMessage(string $type, string $a_txt, bool $a_keep=false)
Set a message to be displayed to the user.
setContent(string $a_html)
Sets content for standard template.
global $DIC
Definition: shib_login.php:26