ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilMediaPoolImportGUI.php
Go to the documentation of this file.
1<?php
2
20
27{
28 protected \ILIAS\MediaPool\StandardGUIRequest $request;
30 protected ilCtrl $ctrl;
31 protected ilLanguage $lng;
33 protected Translations $ot;
34
35 public function __construct(ilObjMediaPool $a_mep)
36 {
37 global $DIC;
38
39 $this->ctrl = $DIC->ctrl();
40 $this->lng = $DIC->language();
41 $this->tpl = $DIC->ui()->mainTemplate();
42 $this->mep = $a_mep;
43 $this->request = $DIC->mediaPool()
44 ->internal()
45 ->gui()
46 ->standardRequest();
47 $this->ot = $a_mep->getObjectProperties()->getPropertyTranslations();
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("mep_trans_import_info"));
67 $form = $this->initTranslationImportForm();
68 $tpl->setContent($form->getHTML());
69 }
70
72 {
74 $ilCtrl = $this->ctrl;
75
76 $lng->loadLanguageModule("meta");
77
78 $form = new ilPropertyFormGUI();
79
80 // import file
81 $fi = new ilFileInputGUI($lng->txt("file"), "importfile");
82 $fi->setSuffixes(array("zip"));
83 $fi->setRequired(true);
84 $fi->setSize(30);
85 $form->addItem($fi);
86
87 $ot = $this->ot;
88 $options = [];
89 foreach ($ot->getLanguages() as $l) {
90 if ($l->getLanguageCode() != $ot->getBaseLanguage()) {
91 $options[$l->getLanguageCode()] = $lng->txt("meta_l_" . $l->getLanguageCode());
92 }
93 }
94 $si = new ilSelectInputGUI($lng->txt("mep_import_lang"), "import_lang");
95 $si->setOptions($options);
96 $form->addItem($si);
97
98 $form->addCommandButton("importTranslation", $lng->txt("import"));
99 $form->setTitle($lng->txt("mep_import_trans"));
100 $form->setFormAction($ilCtrl->getFormAction($this));
101
102 return $form;
103 }
104
105 public function importTranslation(): void
106 {
107 $ilCtrl = $this->ctrl;
109
110 $imp = new ilImport();
111
113 $conf = $imp->getConfig("components/ILIAS/MediaPool");
114
115 $target_lang = $this->request->getImportLang();
116 $ot = $this->ot;
117 if ($target_lang === $ot->getBaseLanguage()) {
118 $this->tpl->setOnScreenMessage('failure', $lng->txt("mep_transl_master_language_not_allowed"), true);
119 $ilCtrl->redirect($this, "showTranslationImportForm");
120 }
121
122 $conf->setTranslationImportMode($this->mep, $target_lang);
123 $imp->importObject(
124 null,
125 $_FILES["importfile"]["tmp_name"],
126 $_FILES["importfile"]["name"],
127 "mep",
128 "components/ILIAS/MediaPool"
129 );
130 //echo "h"; exit;
131 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
132 $ilCtrl->redirect($this, "showTranslationImportForm");
133 }
134}
Class handles translation mode for an object.
Class ilCtrl provides processing control methods.
getCmd(?string $fallback_command=null)
@inheritDoc
This class represents a file property in a property form.
Import class.
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...
Import related features for media pools (currently used for translation imports)
ILIAS MediaPool StandardGUIRequest $request
ilGlobalTemplateInterface $tpl
__construct(ilObjMediaPool $a_mep)
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