ILIAS  release_7 Revision v7.30-3-g800a261c036
ilMobMultiSrtUpload Class Reference

Handler class for multi srt upload. More...

+ Collaboration diagram for ilMobMultiSrtUpload:

Public Member Functions

 __construct (ilMobMultiSrtInt $a_multi_srt)
 Construcotr. More...
 
 getMultiSrtUploadDir ()
 Get directory for multi srt upload. More...
 
 uploadMultipleSubtitleFile ($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

 $lng
 
 $lm
 

Detailed Description

Handler class for multi srt upload.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilMobMultiSrtUpload::__construct ( ilMobMultiSrtInt  $a_multi_srt)

Construcotr.

Parameters
ilMobMultiSrtInt$a_multi_srtadapter implementation

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

27 {
28 global $DIC;
29
30 $lng = $DIC->language();
31
32 $this->lng = $lng;
33 $this->multi_srt = $a_multi_srt;
34 }
global $DIC
Definition: goto.php:24

References $DIC, and $lng.

Member Function Documentation

◆ clearMultiSrtDirectory()

ilMobMultiSrtUpload::clearMultiSrtDirectory ( )

Clear multi feedback directory.

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

71 {
73 }
getMultiSrtUploadDir()
Get directory for multi srt upload.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively

References ilUtil\delDir(), and getMultiSrtUploadDir().

+ Here is the call graph for this function:

◆ getMultiSrtFiles()

ilMobMultiSrtUpload::getMultiSrtFiles ( )

Get all srt files of srt multi upload.

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

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

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

Referenced by moveMultiSrtFiles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMultiSrtUploadDir()

ilMobMultiSrtUpload::getMultiSrtUploadDir ( )

Get directory for multi srt upload.

Returns
string diretory

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

42 {
43 return $this->multi_srt->getUploadDir();
44 }

Referenced by clearMultiSrtDirectory(), getMultiSrtFiles(), moveMultiSrtFiles(), and uploadMultipleSubtitleFile().

+ Here is the caller graph for this function:

◆ moveMultiSrtFiles()

ilMobMultiSrtUpload::moveMultiSrtFiles ( )

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

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

133 {
134 $items = $this->getMultiSrtFiles();
135 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
136 $cnt = 0;
137 foreach ($items as $i) {
138 if ($i["mob"] > 0 && $i["lang"] != "") {
139 $mob = new ilObjMediaObject($i["mob"]);
140 $mob->uploadSrtFile($this->getMultiSrtUploadDir() . "/" . $i["filename"], $i["lang"], "rename");
141 $cnt++;
142 }
143 }
144 return $cnt;
145 }
getMultiSrtFiles()
Get all srt files of srt multi upload.

References $i, getMultiSrtFiles(), and getMultiSrtUploadDir().

+ Here is the call graph for this function:

◆ uploadMultipleSubtitleFile()

ilMobMultiSrtUpload::uploadMultipleSubtitleFile (   $a_file)

Upload multi srt file.

Parameters
array$a_filefile info array
Exceptions
ilLMException

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

54 {
55 include_once("./Services/MediaObjects/exceptions/class.ilMobSrtUploadException.php");
56 if (!is_file($a_file["tmp_name"])) {
57 throw new ilMobSrtUploadException($this->lng->txt("cont_srt_zip_file_could_not_be_uploaded"));
58 }
59
60 $dir = $this->getMultiSrtUploadDir();
61 ilUtil::delDir($dir, true);
63 ilUtil::moveUploadedFile($a_file["tmp_name"], "multi_srt.zip", $dir . "/" . "multi_srt.zip");
64 ilUtil::unzip($dir . "/multi_srt.zip", true);
65 }
Exception class for srt upload.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static unzip(string $path_to_zip_file, bool $overwrite_existing=false, bool $unpack_flat=false)
static makeDirParents($a_dir)
Create a new directory and all parent directories.

References ilUtil\delDir(), getMultiSrtUploadDir(), ilUtil\makeDirParents(), ilUtil\moveUploadedFile(), and ilUtil\unzip().

+ Here is the call graph for this function:

Field Documentation

◆ $lm

ilMobMultiSrtUpload::$lm
protected

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

◆ $lng

ilMobMultiSrtUpload::$lng
protected

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

Referenced by __construct().


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