ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilMediaPoolImportGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
4
13{
14 protected $lm;
15
19 function __construct($a_mep)
20 {
21 $this->mep = $a_mep;
22 }
23
27 function executeCommand()
28 {
29 global $ilCtrl;
30
31 $cmd = $ilCtrl->getCmd("showTranslationImportForm");
32
33 if (in_array($cmd, array("showTranslationImportForm", "importTranslation")))
34 {
35 $this->$cmd();
36 }
37 }
38
46 {
47 global $lng, $tpl;
48
49 ilUtil::sendInfo($lng->txt("mep_trans_import_info"));
50 $form = $this->initTranslationImportForm();
51 $tpl->setContent($form->getHTML());
52 }
53
57 public function initTranslationImportForm()
58 {
59 global $lng, $ilCtrl;
60
61 $lng->loadLanguageModule("meta");
62
63 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
64 $form = new ilPropertyFormGUI();
65
66 // import file
67 $fi = new ilFileInputGUI($lng->txt("file"), "importfile");
68 $fi->setSuffixes(array("zip"));
69 $fi->setRequired(true);
70 $fi->setSize(30);
71 $form->addItem($fi);
72
73 include_once("./Services/MetaData/classes/class.ilMDLanguageItem.php");
74 include_once("./Services/Object/classes/class.ilObjectTranslation.php");
75 $ot = ilObjectTranslation::getInstance($this->mep->getId());
76 foreach ($ot->getLanguages() as $l)
77 {
78 if ($l["lang_code"] != $ot->getMasterLanguage())
79 {
80 $options[$l["lang_code"]] = $lng->txt("meta_l_".$l["lang_code"]);
81 }
82 }
83 $si = new ilSelectInputGUI($lng->txt("mep_import_lang"), "import_lang");
84 $si->setOptions($options);
85 $form->addItem($si);
86
87 $form->addCommandButton("importTranslation", $lng->txt("import"));
88 $form->setTitle($lng->txt("mep_import_trans"));
89 $form->setFormAction($ilCtrl->getFormAction($this));
90
91 return $form;
92 }
93
98 {
99 global $ilCtrl, $lng;
100
101 include_once("./Services/Export/classes/class.ilImport.php");
102 $imp = new ilImport();
103 $conf = $imp->getConfig("Modules/MediaPool");
104
105 $target_lang = ilUtil::stripSlashes($_POST["import_lang"]);
106 include_once("./Services/Object/classes/class.ilObjectTranslation.php");
107 $ot = ilObjectTranslation::getInstance($this->mep->getId());
108 if ($target_lang == $ot->getMasterLanguage())
109 {
110 ilUtil::sendFailure($lng->txt("mep_transl_master_language_not_allowed"), true);
111 $ilCtrl->redirect($this, "showTranslationImportForm");
112 }
113
114 $conf->setTranslationImportMode($this->mep, $target_lang);
115 $imp->importObject(null, $_FILES["importfile"]["tmp_name"],
116 $_FILES["importfile"]["name"], "mep", "Modules/MediaPool");
117//echo "h"; exit;
118 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
119 $ilCtrl->redirect($this, "showTranslationImportForm");
120 }
121
122
123}
124
125?>
global $tpl
Definition: ilias.php:8
global $l
Definition: afr.php:30
This class represents a file property in a property form.
Import class.
Import related features for media pools (currently used for translation imports)
initTranslationImportForm()
Init translation input form.
showTranslationImportForm()
Translation import.
importTranslation()
Import translation.
static getInstance($a_obj_id)
Get instance.
This class represents a property form user interface.
This class represents a selection list property in a property form.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$_POST['username']
Definition: cron.php:12
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35
if(!is_array($argv)) $options