19declare(strict_types=1);
33 protected string $ext =
'';
37 private ?
string $obj_type,
39 private ResourceStorageServices $storage_services,
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
69 if ($this->object_type_specific_property_providers !==
null &&
71 $specific_tile_image = $this->object_type_specific_property_providers->getObjectTypeSpecificTileImage(
74 $this->storage_services
77 return $specific_tile_image;
82 return $image_factory->responsive(
$path,
'');
88 ImageFactory $image_factory,
91 $flavour = $this->storage_services->flavours()->
get($resource, $this->flavour_definition);
92 $urls = $this->storage_services->consume()->flavourUrls($flavour)->getURLsAsArray();
97 $available_widths = $this->flavour_definition->getWidths();
98 array_pop($available_widths);
100 if (!isset($urls[count($available_widths)])) {
104 $image = $image_factory->responsive($urls[count($available_widths)],
'');
107 function ($carry, $size) use ($urls) {
108 $image = $carry[
'image']->withAdditionalHighResSource($urls[$carry[
'counter']], $size / 2);
115 [
'image' => $image,
'counter' => 0]
126 if ($this->rid ===
null || $this->rid ===
'') {
130 $resource = $this->storage_services->manage()->find($this->rid);
131 if ($resource ===
null) {
135 $flavour = $this->storage_services->flavours()->get($resource, $this->flavour_definition);
136 $urls = $this->storage_services->consume()->flavourUrls($flavour)->getURLsAsArray(
false);
138 return array_pop($urls) ??
'';
143 $clone = clone $this;
144 $clone->object_id = $new_object_id;
146 if ($this->rid !==
null
147 && ($rid = $this->storage_services->manage()->find($this->rid)) !==
null) {
148 $i = $this->storage_services->manage()->clone($rid);
149 $clone->rid = $i->serialize();
157 $sourceFS = LegacyPathHelper::deriveFilesystemFrom($source_dir);
158 $sourceDir = LegacyPathHelper::createRelativePath($source_dir);
159 $sourceList = $sourceFS->listContents($sourceDir,
true);
161 foreach ($sourceList as $item) {
162 if ($item->isDir()) {
166 $path = $source_dir . DIRECTORY_SEPARATOR . basename($item->getPath());
168 $i = $this->storage_services->manage()->stream($stream, $this->storage_stakeholder,
'Tile Image');
169 $this->rid = $i->serialize();
The legacy path helper provides convenient functions for the integration of the filesystem service wi...
getImageFromIRSS(ImageFactory $image_factory, ResourceIdentification $resource)
cloneFor(int $new_object_id)
getImage(ImageFactory $image_factory)
createFromImportDir(string $source_dir)
__construct(private int $object_id, private ?string $obj_type, private ?string $rid, private ResourceStorageServices $storage_services, private Stakeholder $storage_stakeholder, private FlavourDefinition $flavour_definition, private ?ObjectTypeSpecificPropertyProviders $object_type_specific_property_providers)
Class ResourceIdentification.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
This is how the factory for UI elements looks.
if(!file_exists('../ilias.ini.php'))