ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilMobMultiSrtUploadGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
13 {
17  protected $ctrl;
18 
22  protected $lng;
23 
27  protected $toolbar;
28 
32  protected $tpl;
33 
34  public $multi_srt;
35 
41  public function __construct(ilMobMultiSrtInt $a_multi_srt)
42  {
43  global $DIC;
44 
45  $ilCtrl = $DIC->ctrl();
46  $lng = $DIC->language();
47  $ilToolbar = $DIC->toolbar();
48  $tpl = $DIC["tpl"];
49 
50  $this->tpl = $tpl;
51  $this->lng = $lng;
52  $this->ctrl = $ilCtrl;
53  include_once("./Services/MediaObjects/classes/class.ilMobMultiSrtUpload.php");
54  $this->multi_srt = new ilMobMultiSrtUpload($a_multi_srt);
55  $this->toolbar = $ilToolbar;
56  }
57 
61  public function executeCommand()
62  {
63  $cmd = $this->ctrl->getCmd("uploadMultipleSubtitleFileForm");
64 
65  if (in_array($cmd, array("uploadMultipleSubtitleFileForm", "uploadMultipleSubtitleFile", "showMultiSubtitleConfirmationTable", "cancelMultiSrt", "saveMultiSrt"))) {
66  $this->$cmd();
67  }
68  }
69 
74  {
75  ilUtil::sendInfo($this->lng->txt("cont_upload_multi_srt_howto"));
76 
77  // upload file
78  $this->toolbar->setFormAction($this->ctrl->getFormAction($this), true);
79  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
80  $fi = new ilFileInputGUI($this->lng->txt("cont_subtitle_file") . " (.zip)", "subtitle_file");
81  $fi->setSuffixes(array("zip"));
82  $this->toolbar->addInputItem($fi, true);
83 
84  $this->toolbar->addFormButton($this->lng->txt("upload"), "uploadMultipleSubtitleFile");
85  }
86 
90  public function uploadMultipleSubtitleFile()
91  {
92  try {
93  $this->multi_srt->uploadMultipleSubtitleFile(ilUtil::stripSlashesArray($_FILES["subtitle_file"]));
94  $this->ctrl->redirect($this, "showMultiSubtitleConfirmationTable");
95  } catch (ilLMException $e) {
96  ilUtil::sendFailure($e->getMessage(), true);
97  $this->ctrl->redirect($this, "uploadMultipleSubtitleFileForm");
98  }
99  }
100 
105  {
106  include_once("./Services/MediaObjects/classes/class.ilMobMultiSrtConfirmationTable2GUI.php");
107  $tab = new ilMobMultiSrtConfirmationTable2GUI($this, "showMultiSubtitleConfirmationTable");
108  $this->tpl->setContent($tab->getHTML());
109  }
110 
114  public function cancelMultiSrt()
115  {
116  $this->multi_srt->clearMultiSrtDirectory();
117  $this->ctrl->redirect($this, "uploadMultipleSubtitleFileForm");
118  }
119 
123  public function saveMultiSrt()
124  {
125  $cnt = $this->multi_srt->moveMultiSrtFiles();
126  $this->multi_srt->clearMultiSrtDirectory();
127 
128  ilUtil::sendSuccess($this->lng->txt("cont_moved_srt_files") . " (" . $cnt . ")", true);
129  $this->ctrl->redirect($this, "uploadMultipleSubtitleFileForm");
130  }
131 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
global $DIC
Definition: saml.php:7
This class represents a file property in a property form.
showMultiSubtitleConfirmationTable()
List of srt files in zip file.
Interface ilMobMultiSrtInt.
Base exception class for learning modules.
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
List srt files from zip file for upload confirmation.
Upload SRT files to a set of media objects.
cancelMultiSrt()
Cancel Multi Feedback.
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static stripSlashesArray($a_arr, $a_strip_html=true, $a_allow="")
Strip slashes from array.
Handler class for multi srt upload.
__construct(ilMobMultiSrtInt $a_multi_srt)
Constructor.
uploadMultipleSubtitleFile()
Upload multiple subtitles.
saveMultiSrt()
Save selected srt files as new srt files.
uploadMultipleSubtitleFileForm()
Upload multiple stubtitles.
setSuffixes($a_suffixes)
Set Accepted Suffixes.