19 declare(strict_types=1);
33 protected string $ext =
'';
36 private int $object_id,
37 private ?
string $obj_type,
51 public function withRid(?
string $rid): self
59 ImageFactory $image_factory
61 if ($this->rid !== null
63 && ($resource = $this->storage_services->manage()->find($this->rid)) !== null
64 && ($from_IRSS = $this->
getImageFromIRSS($image_factory, $resource)) !== null
70 return $image_factory->responsive($this->
getFullPath(),
'');
73 if ($this->object_type_specific_property_providers !== null &&
75 $specific_tile_image = $this->object_type_specific_property_providers->getObjectTypeSpecificTileImage(
78 $this->storage_services
81 return $specific_tile_image;
86 return $image_factory->responsive(
$path,
'');
92 ImageFactory $image_factory,
95 $flavour = $this->storage_services->flavours()->get($resource, $this->flavour_definition);
96 $urls = $this->storage_services->consume()->flavourUrls($flavour)->getURLsAsArray();
101 $available_widths = $this->flavour_definition->getWidths();
102 array_pop($available_widths);
104 if (!isset($urls[count($available_widths)])) {
108 $image = $image_factory->responsive($urls[count($available_widths)],
'');
111 function ($carry, $size) use ($urls) {
112 $image = $carry[
'image']->withAdditionalHighResSource($urls[$carry[
'counter']], $size / 2);
113 $counter = ++$carry[
'counter'];
116 'counter' => $counter
119 [
'image' => $image,
'counter' => 0]
130 if ($this->rid !== null && $this->rid !==
'') {
131 $resource = $this->storage_services->manage()->find($this->rid);
132 if ($resource === null) {
136 $flavour = $this->storage_services->flavours()->get($resource, $this->flavour_definition);
137 $urls = $this->storage_services->consume()->flavourUrls($flavour)->getURLsAsArray(
false);
139 return array_pop($urls) ??
'';
151 unlink(ILIAS_ABSOLUTE_PATH . DIRECTORY_SEPARATOR . $this->
getFullPath());
152 rmdir(dirname(ILIAS_ABSOLUTE_PATH . DIRECTORY_SEPARATOR . $this->
getFullPath()));
159 $clone = clone $this;
160 $clone->object_id = $new_object_id;
162 if ($this->rid !== null
164 && ($resource = $this->storage_services->manage()->find($this->rid)) !== null) {
165 $i = $this->storage_services->manage()->clone($resource);
166 $clone->rid = $i->serialize();
183 if ($this->ext ===
'') {
193 'tile_image_' . $this->object_id,
194 'tile_image.' . $this->ext
203 $sourceList = $sourceFS->listContents($sourceDir,
true);
205 foreach ($sourceList as $item) {
206 if ($item->isDir()) {
210 $path = $source_dir . DIRECTORY_SEPARATOR . basename($item->getPath());
212 $i = $this->storage_services->manage()->stream($stream, $this->storage_stakeholder,
'Tile Image');
213 $this->rid = $i->serialize();
static getWebspaceDir(string $mode="filesystem")
get webspace directory
static createRelativePath(string $absolute_path)
Creates a relative path from an absolute path which starts with a valid storage location.
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
createFromImportDir(string $source_dir)
static _lookupContainerSetting(int $a_id, string $a_keyword, string $a_default_value=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ResourceIdentification.
__construct(private int $object_id, private ?string $obj_type, private ?string $rid, private ResourceStorageServices $storage_services, private ilObjectTileImageStakeholder $storage_stakeholder, private ilObjectTileImageFlavourDefinition $flavour_definition, private ?ilObjectTypeSpecificPropertyProviders $object_type_specific_property_providers)
getImageFromIRSS(ImageFactory $image_factory, ResourceIdentification $resource)
getImage(ImageFactory $image_factory)
static deriveFilesystemFrom(string $absolute_path)
Tries to fetch the filesystem responsible for the absolute path.
cloneFor(int $new_object_id)
This is how the factory for UI elements looks.
static _deleteContainerSettings(int $a_id, string $a_keyword="", bool $a_keyword_like=false)