ILIAS  release_8 Revision v8.24
ilMobMultiSrtUpload Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilMobMultiSrtUpload:

Public Member Functions

 __construct (ilMobMultiSrtInt $a_multi_srt)
 
 getMultiSrtUploadDir ()
 Get directory for multi srt upload. More...
 
 uploadMultipleSubtitleFile (array $a_file)
 Upload multi srt file. More...
 
 clearMultiSrtDirectory ()
 Clear multi feedback directory. More...
 
 getMultiSrtFiles ()
 Get all srt files of srt multi upload. More...
 
 moveMultiSrtFiles ()
 Move all srt files that could be mapped to media objects. More...
 

Protected Attributes

ilMobMultiSrtInt $multi_srt
 
ilLanguage $lng
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Handler class for multi srt upload

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e

Definition at line 24 of file class.ilMobMultiSrtUpload.php.

Constructor & Destructor Documentation

◆ __construct()

ilMobMultiSrtUpload::__construct ( ilMobMultiSrtInt  $a_multi_srt)
Parameters
ilMobMultiSrtInt$a_multi_srtadapter implementation

Definition at line 32 of file class.ilMobMultiSrtUpload.php.

34 {
35 global $DIC;
36
37 $lng = $DIC->language();
38
39 $this->lng = $lng;
40 $this->multi_srt = $a_multi_srt;
41 }
global $DIC
Definition: feed.php:28

References $DIC, $lng, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Member Function Documentation

◆ clearMultiSrtDirectory()

ilMobMultiSrtUpload::clearMultiSrtDirectory ( )

Clear multi feedback directory.

Definition at line 76 of file class.ilMobMultiSrtUpload.php.

76 : void
77 {
79 }
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
getMultiSrtUploadDir()
Get directory for multi srt upload.

References ilFileUtils\delDir().

+ Here is the call graph for this function:

◆ getMultiSrtFiles()

ilMobMultiSrtUpload::getMultiSrtFiles ( )

Get all srt files of srt multi upload.

Definition at line 84 of file class.ilMobMultiSrtUpload.php.

84 : array
85 {
86 $items = array();
87
89
90 $dir = $this->getMultiSrtUploadDir();
91 $files = ilFileUtils::getDir($dir);
92 foreach ($files as $k => $i) {
93 // check directory
94 if ($i["type"] == "file" && !in_array($k, array(".", ".."))) {
95 if (pathinfo($k, PATHINFO_EXTENSION) == "srt") {
96 $lang = "";
97 if (substr($k, strlen($k) - 7, 1) == "_") {
98 $lang = substr($k, strlen($k) - 6, 2);
99 if (!in_array($lang, $lang_codes)) {
100 $lang = "";
101 }
102 }
103 $items[] = array("filename" => $k, "lang" => $lang);
104 }
105 }
106 }
107
108 foreach ($this->multi_srt->getMobIds() as $mob) {
109 $m = new ilObjMediaObject($mob);
110 $mi = $m->getMediaItem("Standard");
111 if ($mi->getLocationType() == "LocalFile" && is_int(strpos($mi->getFormat(), "video"))) {
112 // $loc is e.g. "echo-hereweare.mp4", we not look for
113 // "echo-hereweare_<langcode>.srt" files
114 $loc = pathinfo($mi->getLocation(), PATHINFO_FILENAME);
115 foreach ($items as $i => $item) {
116 if (substr($item["filename"], 0, strlen($loc)) == $loc &&
117 substr($item["filename"], strlen($loc), 1) == "_" &&
118 pathinfo($item["filename"], PATHINFO_EXTENSION) == "srt") {
119 $l = substr($item["filename"], strlen($loc) + 1, 2);
120 if (in_array($l, $lang_codes)) {
121 $items[$i]["lang"] = $l;
122 $items[$i]["mob"] = $mob;
123 $items[$i]["mob_title"] = $m->getTitle();
124 }
125 }
126 }
127 }
128 }
129
130 return $items;
131 }
static getDir(string $a_dir, bool $a_rec=false, ?string $a_sub_dir="")
get directory
$i
Definition: metadata.php:41
$lang
Definition: xapiexit.php:26

References $i, $lang, ilMDLanguageItem\_getPossibleLanguageCodes(), and ilFileUtils\getDir().

+ Here is the call graph for this function:

◆ getMultiSrtUploadDir()

ilMobMultiSrtUpload::getMultiSrtUploadDir ( )

Get directory for multi srt upload.

Definition at line 46 of file class.ilMobMultiSrtUpload.php.

46 : string
47 {
48 return $this->multi_srt->getUploadDir();
49 }

◆ moveMultiSrtFiles()

ilMobMultiSrtUpload::moveMultiSrtFiles ( )

Move all srt files that could be mapped to media objects.

Definition at line 136 of file class.ilMobMultiSrtUpload.php.

136 : int
137 {
138 $items = $this->getMultiSrtFiles();
139 $cnt = 0;
140 foreach ($items as $i) {
141 if ($i["mob"] > 0 && $i["lang"] != "") {
142 $mob = new ilObjMediaObject($i["mob"]);
143 $mob->uploadSrtFile($this->getMultiSrtUploadDir() . "/" . $i["filename"], $i["lang"], "rename");
144 $cnt++;
145 }
146 }
147 return $cnt;
148 }
getMultiSrtFiles()
Get all srt files of srt multi upload.

References $i.

◆ uploadMultipleSubtitleFile()

ilMobMultiSrtUpload::uploadMultipleSubtitleFile ( array  $a_file)

Upload multi srt file.

Parameters
array$a_filefile info array
Exceptions
ilException
ilMobSrtUploadException

Definition at line 59 of file class.ilMobMultiSrtUpload.php.

61 : void {
62 if (!is_file($a_file["tmp_name"])) {
63 throw new ilMobSrtUploadException($this->lng->txt("cont_srt_zip_file_could_not_be_uploaded"));
64 }
65
66 $dir = $this->getMultiSrtUploadDir();
67 ilFileUtils::delDir($dir, true);
69 ilFileUtils::moveUploadedFile($a_file["tmp_name"], "multi_srt.zip", $dir . "/" . "multi_srt.zip");
70 ilFileUtils::unzip($dir . "/multi_srt.zip", true);
71 }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static unzip(string $path_to_zip_file, bool $overwrite_existing=false, bool $unpack_flat=false)
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

Field Documentation

◆ $lng

ilLanguage ilMobMultiSrtUpload::$lng
protected

Definition at line 27 of file class.ilMobMultiSrtUpload.php.

Referenced by __construct().

◆ $multi_srt

ilMobMultiSrtInt ilMobMultiSrtUpload::$multi_srt
protected

Definition at line 26 of file class.ilMobMultiSrtUpload.php.


The documentation for this class was generated from the following file: