ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 }
This class represents a file property in a property form.
showMultiSubtitleConfirmationTable()
List of srt files in zip file.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setSuffixes(array $a_suffixes)
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:22
Handler class for multi srt upload.
__construct(ilMobMultiSrtInt $a_multi_srt)
ilGlobalTemplateInterface $tpl
uploadMultipleSubtitleFile()
Upload multiple subtitles.
saveMultiSrt()
Save selected srt files as new srt files.
static stripSlashesArray(array $a_arr, bool $a_strip_html=true, string $a_allow="")