ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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.

References $DIC, and $lng.

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: saml.php:7

Member Function Documentation

◆ clearMultiSrtDirectory()

ilMobMultiSrtUpload::clearMultiSrtDirectory ( )

Clear multi feedback directory.

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

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

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
+ 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.

References $files, $i, $l, $lang, $m, ilMDLanguageItem\_getPossibleLanguageCodes(), array, ilUtil\getDir(), and getMultiSrtUploadDir().

Referenced by moveMultiSrtFiles().

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  }
$files
Definition: add-vimline.php:18
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
getMultiSrtUploadDir()
Get directory for multi srt upload.
Class ilObjMediaObject.
Create styles array
The data for the language used.
global $l
Definition: afr.php:30
$i
Definition: disco.tpl.php:19
+ 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.

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

42  {
43  return $this->multi_srt->getUploadDir();
44  }
+ 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.

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

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.
getMultiSrtUploadDir()
Get directory for multi srt upload.
Class ilObjMediaObject.
$i
Definition: disco.tpl.php:19
+ 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.

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

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  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
getMultiSrtUploadDir()
Get directory for multi srt upload.
Exception class for srt upload.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ 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: