ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\MediaObjects\MediaObjectManager Class Reference
+ Collaboration diagram for ILIAS\MediaObjects\MediaObjectManager:

Public Member Functions

 __construct (protected InternalDataService $data, InternalRepoService $repo, protected InternalDomainService $domain, protected \ilMobStakeholder $stakeholder)
 
 create (int $id, string $title, int $from_mob_id=0)
 
 addLocalDirectory (int $mob_id, string $dir)
 
 addFileFromLegacyUpload (int $mob_id, string $tmp_name, string $target_path="")
 
 addFileFromUpload (int $mob_id, UploadResult $result, string $path="/")
 
 addFileFromLocal (int $mob_id, string $tmp_name, string $path)
 
 removeLocation (int $mob_id, string $location)
 
 getLocationStream (int $mob_id, string $location)
 
 addStream (int $mob_id, string $location, FileStream $stream)
 
 getLocalSrc (int $mob_id, string $location)
 
 hasLocalFile (int $mob_id, string $location)
 
 getContainerResource (int $mob_id)
 
 getContainerResourceId (int $mob_id)
 
 getFilesOfPath (int $mob_id, string $dir_path)
 
 getInfoOfEntry (int $mob_id, string $path)
 
 deliverEntry (int $mob_id, string $path)
 
 generatePreview (int $mob_id, string $location, bool $local, string $format, int $sec=1, string $target_location="mob_vpreview.png")
 
 addPreviewFromUrl (int $mob_id, string $url, string $target_location)
 

Protected Attributes

ImageOutputOptions $output_options
 
Images $image_converters
 
MediaObjectRepository $repo
 

Detailed Description

Definition at line 33 of file MediaObjectManager.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\MediaObjects\MediaObjectManager::__construct ( protected InternalDataService  $data,
InternalRepoService  $repo,
protected InternalDomainService  $domain,
protected \ilMobStakeholder  $stakeholder 
)

Definition at line 39 of file MediaObjectManager.php.

44  {
45  $this->repo = $repo->mediaObject();
46  $this->image_converters = new Images(true);
47  $this->output_options = new ImageOutputOptions();
48  }

Member Function Documentation

◆ addFileFromLegacyUpload()

ILIAS\MediaObjects\MediaObjectManager::addFileFromLegacyUpload ( int  $mob_id,
string  $tmp_name,
string  $target_path = "" 
)

Definition at line 68 of file MediaObjectManager.php.

68  : void
69  {
70  $this->repo->addFileFromLegacyUpload($mob_id, $tmp_name, $target_path);
71  }

◆ addFileFromLocal()

ILIAS\MediaObjects\MediaObjectManager::addFileFromLocal ( int  $mob_id,
string  $tmp_name,
string  $path 
)

Definition at line 81 of file MediaObjectManager.php.

81  : void
82  {
83  $this->repo->addFileFromLocal($mob_id, $tmp_name, $path);
84  }
$path
Definition: ltiservices.php:29

◆ addFileFromUpload()

ILIAS\MediaObjects\MediaObjectManager::addFileFromUpload ( int  $mob_id,
UploadResult  $result,
string  $path = "/" 
)

Definition at line 73 of file MediaObjectManager.php.

References $path.

77  : void {
78  $this->repo->addFileFromUpload($mob_id, $result, $path);
79  }
$path
Definition: ltiservices.php:29

◆ addLocalDirectory()

ILIAS\MediaObjects\MediaObjectManager::addLocalDirectory ( int  $mob_id,
string  $dir 
)

Definition at line 63 of file MediaObjectManager.php.

63  : void
64  {
65  $this->repo->addLocalDirectory($mob_id, $dir);
66  }

◆ addPreviewFromUrl()

ILIAS\MediaObjects\MediaObjectManager::addPreviewFromUrl ( int  $mob_id,
string  $url,
string  $target_location 
)

Definition at line 226 of file MediaObjectManager.php.

References $res.

230  : void {
231  $str = file_get_contents($url);
232  $res = fopen('php://memory', 'r+');
233  fwrite($res, $str);
234  rewind($res);
235  $stream = new Stream($res);
236  $this->repo->addStream(
237  $mob_id,
238  $target_location,
239  $stream
240  );
241  }
$res
Definition: ltiservices.php:66
$url
Definition: shib_logout.php:66

◆ addStream()

ILIAS\MediaObjects\MediaObjectManager::addStream ( int  $mob_id,
string  $location,
FileStream  $stream 
)

Definition at line 100 of file MediaObjectManager.php.

104  : void {
105  $this->repo->addStream($mob_id, $location, $stream);
106  }
$location
Definition: buildRTE.php:22

◆ create()

ILIAS\MediaObjects\MediaObjectManager::create ( int  $id,
string  $title,
int  $from_mob_id = 0 
)

Definition at line 50 of file MediaObjectManager.php.

54  : void {
55  $this->repo->create(
56  $id,
57  $title,
58  $this->stakeholder,
59  $from_mob_id
60  );
61  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ deliverEntry()

ILIAS\MediaObjects\MediaObjectManager::deliverEntry ( int  $mob_id,
string  $path 
)

Definition at line 158 of file MediaObjectManager.php.

161  : void {
162  $this->repo->deliverEntry($mob_id, $path);
163  }
$path
Definition: ltiservices.php:29

◆ generatePreview()

ILIAS\MediaObjects\MediaObjectManager::generatePreview ( int  $mob_id,
string  $location,
bool  $local,
string  $format,
int  $sec = 1,
string  $target_location = "mob_vpreview.png" 
)

Definition at line 166 of file MediaObjectManager.php.

References ilObjMediaObject\DEFAULT_PREVIEW_SIZE, ilFFmpeg\extractPNGFromVideoInZip(), and ILIAS\Filesystem\Util\Convert\ImageOutputOptions\FORMAT_PNG.

173  : void {
174 
175  $is_image = is_int(strpos($format, "image/"));
176  $is_video = in_array($format, ["video/mp4", "video/webm"]);
177 
178  if ($local) {
179  if ($is_image) {
180  $width = $height = \ilObjMediaObject::DEFAULT_PREVIEW_SIZE;
181  $image_quality = 60;
182 
183  // the zip stream is not seekable, which is needed by Imagick
184  // so we create a seekable stream first
185  $tempStream = fopen('php://temp', 'w+');
186  stream_copy_to_stream($this->repo->getLocationStream($mob_id, $location)->detach(), $tempStream);
187  rewind($tempStream);
188  $stream = new Stream($tempStream);
189 
190  $converter = $this->image_converters->resizeToFixedSize(
191  $stream,
192  $width,
193  $height,
194  true,
195  $this->output_options
196  ->withQuality($image_quality)
197  ->withFormat(ImageOutputOptions::FORMAT_PNG)
198  );
199  $this->repo->addStream(
200  $mob_id,
201  $target_location,
202  $converter->getStream()
203  );
204  fclose($tempStream);
205  }
206  if ($is_video) {
207  $zip_uri = $this->repo->getContainerPath($mob_id);
209  $zip_uri,
210  $location,
211  $sec
212  );
213  $png_res = fopen('php://memory', 'r+');
214  fwrite($png_res, $image_str);
215  rewind($png_res);
216  $png_stream = new Stream($png_res);
217  $this->repo->addStream(
218  $mob_id,
219  $target_location,
220  $png_stream
221  );
222  }
223  }
224  }
$location
Definition: buildRTE.php:22
static extractPNGFromVideoInZip(string $zip, string $path, int $sec=1)
+ Here is the call graph for this function:

◆ getContainerResource()

ILIAS\MediaObjects\MediaObjectManager::getContainerResource ( int  $mob_id)

Definition at line 129 of file MediaObjectManager.php.

131  : ?StorableResource {
132  return $this->repo->getContainerResource($mob_id);
133  }

◆ getContainerResourceId()

ILIAS\MediaObjects\MediaObjectManager::getContainerResourceId ( int  $mob_id)

Definition at line 135 of file MediaObjectManager.php.

137  : ?ResourceIdentification {
138  return $this->repo->getContainerResourceId($mob_id);
139  }

◆ getFilesOfPath()

ILIAS\MediaObjects\MediaObjectManager::getFilesOfPath ( int  $mob_id,
string  $dir_path 
)

Definition at line 141 of file MediaObjectManager.php.

144  : array {
145  return $this->repo->getFilesOfPath($mob_id, $dir_path);
146  }

◆ getInfoOfEntry()

ILIAS\MediaObjects\MediaObjectManager::getInfoOfEntry ( int  $mob_id,
string  $path 
)

Definition at line 148 of file MediaObjectManager.php.

151  : array {
152  return $this->repo->getInfoOfEntry(
153  $mob_id,
154  $path
155  );
156  }
$path
Definition: ltiservices.php:29

◆ getLocalSrc()

ILIAS\MediaObjects\MediaObjectManager::getLocalSrc ( int  $mob_id,
string  $location 
)

Definition at line 108 of file MediaObjectManager.php.

References Vendor\Package\$e, $location, ilObjMediaObject\_getURL(), and ilWACSignedPath\signFile().

108  : string
109  {
110  $src = $this->repo->getLocalSrc(
111  $mob_id,
112  $location
113  );
114  if ($src === "") { // fallback: old source
115  $path_to_file = \ilObjMediaObject::_getURL($mob_id) . "/" . $location;
116  try {
117  $src = \ilWACSignedPath::signFile($path_to_file);
118  } catch (Exception $e) {
119  }
120  }
121  return $src;
122  }
$location
Definition: buildRTE.php:22
static signFile(string $path_to_file)
static _getURL(int $a_mob_id)
get directory for files of media object
+ Here is the call graph for this function:

◆ getLocationStream()

ILIAS\MediaObjects\MediaObjectManager::getLocationStream ( int  $mob_id,
string  $location 
)

Definition at line 93 of file MediaObjectManager.php.

96  : ZIPStream {
97  return $this->repo->getLocationStream($mob_id, $location);
98  }
$location
Definition: buildRTE.php:22

◆ hasLocalFile()

ILIAS\MediaObjects\MediaObjectManager::hasLocalFile ( int  $mob_id,
string  $location 
)

Definition at line 124 of file MediaObjectManager.php.

124  : bool
125  {
126  return $this->repo->hasLocalFile($mob_id, $location);
127  }
$location
Definition: buildRTE.php:22

◆ removeLocation()

ILIAS\MediaObjects\MediaObjectManager::removeLocation ( int  $mob_id,
string  $location 
)

Definition at line 86 of file MediaObjectManager.php.

89  : void {
90  $this->repo->removeLocation($mob_id, $location);
91  }
$location
Definition: buildRTE.php:22

Field Documentation

◆ $image_converters

Images ILIAS\MediaObjects\MediaObjectManager::$image_converters
protected

Definition at line 36 of file MediaObjectManager.php.

◆ $output_options

ImageOutputOptions ILIAS\MediaObjects\MediaObjectManager::$output_options
protected

Definition at line 35 of file MediaObjectManager.php.

◆ $repo

MediaObjectRepository ILIAS\MediaObjects\MediaObjectManager::$repo
protected

Definition at line 37 of file MediaObjectManager.php.


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