19declare(strict_types=1);
36 protected string $ext =
'';
40 private ?
string $obj_type,
42 private ResourceStorageServices $storage_services,
54 public function withRid(?
string $rid): self
62 ImageFactory $image_factory
64 if ($this->rid !== null
66 && ($resource = $this->storage_services->manage()->find($this->rid)) !== null
67 && ($from_IRSS = $this->
getImageFromIRSS($image_factory, $resource)) !== null
72 if ($this->object_type_specific_property_providers !==
null &&
74 $specific_tile_image = $this->object_type_specific_property_providers->getObjectTypeSpecificTileImage(
77 $this->storage_services
80 return $specific_tile_image;
85 return $image_factory->responsive(
$path,
'');
91 ImageFactory $image_factory,
94 $flavour = $this->storage_services->flavours()->
get($resource, $this->flavour_definition);
95 $urls = $this->storage_services->consume()->flavourUrls($flavour)->getURLsAsArray();
100 $available_widths = $this->flavour_definition->getWidths();
101 array_pop($available_widths);
103 if (!isset($urls[count($available_widths)])) {
107 $image = $image_factory->responsive($urls[count($available_widths)],
'');
110 function ($carry, $size) use ($urls) {
111 $image = $carry[
'image']->withAdditionalHighResSource($urls[$carry[
'counter']], $size / 2);
118 [
'image' => $image,
'counter' => 0]
129 if ($this->rid ===
null || $this->rid ===
'') {
133 $resource = $this->storage_services->manage()->find($this->rid);
134 if ($resource ===
null) {
138 $flavour = $this->storage_services->flavours()->get($resource, $this->flavour_definition);
139 $urls = $this->storage_services->consume()->flavourUrls($flavour)->getURLsAsArray(
false);
141 return array_pop($urls) ??
'';
146 $clone = clone $this;
147 $clone->object_id = $new_object_id;
149 if ($this->rid !==
null
150 && ($rid = $this->storage_services->manage()->find($this->rid)) !==
null) {
151 $i = $this->storage_services->manage()->clone($rid);
152 $clone->rid = $i->serialize();
160 $sourceFS = LegacyPathHelper::deriveFilesystemFrom($source_dir);
161 $sourceDir = LegacyPathHelper::createRelativePath($source_dir);
162 $sourceList = $sourceFS->listContents($sourceDir,
true);
164 foreach ($sourceList as $item) {
165 if ($item->isDir()) {
169 $path = $source_dir . DIRECTORY_SEPARATOR . basename($item->getPath());
171 $i = $this->storage_services->manage()->stream($stream, $this->storage_stakeholder,
'Tile Image');
172 $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)
const SUPPORTED_MIME_TYPES
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'))