ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilMobMultiSrtUploadGUI.php
Go to the documentation of this file.
1<?php
2
25{
26 protected ilCtrl $ctrl;
27 protected ilLanguage $lng;
31
32 public function __construct(ilMobMultiSrtInt $a_multi_srt)
33 {
34 global $DIC;
35
36 $ilCtrl = $DIC->ctrl();
37 $lng = $DIC->language();
38 $ilToolbar = $DIC->toolbar();
39 $tpl = $DIC["tpl"];
40
41 $this->tpl = $tpl;
42 $this->lng = $lng;
43 $this->ctrl = $ilCtrl;
44 $this->multi_srt = new ilMobMultiSrtUpload($a_multi_srt);
45 $this->toolbar = $ilToolbar;
46 }
47
48 public function executeCommand(): void
49 {
50 $cmd = $this->ctrl->getCmd("uploadMultipleSubtitleFileForm");
51
52 if (in_array($cmd, array("uploadMultipleSubtitleFileForm", "uploadMultipleSubtitleFile", "showMultiSubtitleConfirmationTable", "cancelMultiSrt", "saveMultiSrt"))) {
53 $this->$cmd();
54 }
55 }
56
57 public function uploadMultipleSubtitleFileForm(): void
58 {
59 $this->tpl->setOnScreenMessage('info', $this->lng->txt("cont_upload_multi_srt_howto"));
60
61 // upload file
62 $this->toolbar->setFormAction($this->ctrl->getFormAction($this), true);
63 $fi = new ilFileInputGUI($this->lng->txt("cont_subtitle_file") . " (.zip)", "subtitle_file");
64 $fi->setSuffixes(array("zip"));
65 $this->toolbar->addInputItem($fi, true);
66
67 $this->toolbar->addFormButton($this->lng->txt("upload"), "uploadMultipleSubtitleFile");
68 }
69
73 public function uploadMultipleSubtitleFile(): void
74 {
75 try {
76 $this->multi_srt->uploadMultipleSubtitleFile(ilArrayUtil::stripSlashesArray($_FILES["subtitle_file"]));
77 $this->ctrl->redirect($this, "showMultiSubtitleConfirmationTable");
78 } catch (ilLMException $e) {
79 $this->tpl->setOnScreenMessage('failure', $e->getMessage(), true);
80 $this->ctrl->redirect($this, "uploadMultipleSubtitleFileForm");
81 }
82 }
83
87 public function showMultiSubtitleConfirmationTable(): void
88 {
89 $tab = new ilMobMultiSrtConfirmationTable2GUI($this, "showMultiSubtitleConfirmationTable");
90 $this->tpl->setContent($tab->getHTML());
91 }
92
93 public function cancelMultiSrt(): void
94 {
95 $this->multi_srt->clearMultiSrtDirectory();
96 $this->ctrl->redirect($this, "uploadMultipleSubtitleFileForm");
97 }
98
102 public function saveMultiSrt(): void
103 {
104 $cnt = $this->multi_srt->moveMultiSrtFiles();
105 $this->multi_srt->clearMultiSrtDirectory();
106
107 $this->tpl->setOnScreenMessage('success', $this->lng->txt("cont_moved_srt_files") . " (" . $cnt . ")", true);
108 $this->ctrl->redirect($this, "uploadMultipleSubtitleFileForm");
109 }
110}
static stripSlashesArray(array $a_arr, bool $a_strip_html=true, string $a_allow="")
Class ilCtrl provides processing control methods.
This class represents a file property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
showMultiSubtitleConfirmationTable()
List of srt files in zip file.
ilGlobalTemplateInterface $tpl
uploadMultipleSubtitleFile()
Upload multiple subtitles.
saveMultiSrt()
Save selected srt files as new srt files.
__construct(ilMobMultiSrtInt $a_multi_srt)
Handler class for multi srt upload.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26