ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
ilObjectTileImage Class Reference
+ Inheritance diagram for ilObjectTileImage:
+ Collaboration diagram for ilObjectTileImage:

Public Member Functions

 __construct (ilObjectService $service, int $obj_id)
 
 getExtension ()
 
 copy (int $target_obj_id)
 
 delete ()
 
 getRelativeDirectory ()
 
 exists ()
 
 getFullPath ()
 
 createFromImportDir (string $source_dir, string $ext)
 
- Public Member Functions inherited from ilObjectTileImageInterface
 getExtension ()
 
 copy (int $target_obj_id)
 
 delete ()
 
 saveFromHttpRequest (string $tmp_name)
 Save image from request. More...
 
 exists ()
 
 getFullPath ()
 
 createFromImportDir (string $source_dir, string $ext)
 

Protected Member Functions

 persistImageState (string $filename)
 
 createDirectory ()
 
 getFileName ()
 
 getRelativePath ()
 

Protected Attributes

ilObjectService $service
 
int $obj_id
 
Filesystem $web
 
FileUpload $upload
 
string $ext
 

Detailed Description

Definition at line 29 of file class.ilObjectTileImage.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjectTileImage::__construct ( ilObjectService  $service,
int  $obj_id 
)

Definition at line 37 of file class.ilObjectTileImage.php.

38 {
39 $this->service = $service;
40 $this->obj_id = $obj_id;
41 $this->web = $service->filesystem()->web();
42 $this->upload = $service->upload();
43 $this->ext = ilContainer::_lookupContainerSetting($obj_id, 'tile_image');
44 }
static _lookupContainerSetting(int $a_id, string $a_keyword, string $a_default_value=null)

References $obj_id, $service, ilContainer\_lookupContainerSetting(), ilObjectService\filesystem(), ilObjectService\upload(), and ILIAS\Repository\upload().

+ Here is the call graph for this function:

Member Function Documentation

◆ copy()

ilObjectTileImage::copy ( int  $target_obj_id)

Implements ilObjectTileImageInterface.

Definition at line 51 of file class.ilObjectTileImage.php.

51 : void
52 {
53 if (!$this->exists()) {
54 ilContainer::_deleteContainerSettings($target_obj_id, 'tile_image');
55 return;
56 }
57
58 try {
59 $this->web->copy(
60 $this->getRelativePath(),
61 preg_replace(
62 '/(' . "tile_image_" . ')(\d*)\/(.*)$/',
63 '${1}' . $target_obj_id . '/${3}',
64 $this->getRelativePath()
65 )
66 );
67
68 ilContainer::_writeContainerSetting($target_obj_id, 'tile_image', $this->getExtension());
69 } catch (Exception $e) {
70 ilContainer::_deleteContainerSettings($target_obj_id, 'tile_image');
71 }
72 }
static _writeContainerSetting(int $a_id, string $a_keyword, string $a_value)
static _deleteContainerSettings(int $a_id, string $a_keyword="", bool $a_keyword_like=false)

References Vendor\Package\$e, ilContainer\_deleteContainerSettings(), ilContainer\_writeContainerSetting(), exists(), getExtension(), and getRelativePath().

+ Here is the call graph for this function:

◆ createDirectory()

ilObjectTileImage::createDirectory ( )
protected
Exceptions
IOException

Definition at line 152 of file class.ilObjectTileImage.php.

152 : void
153 {
154 $this->web->createDir($this->getRelativeDirectory());
155 }

References getRelativeDirectory().

+ Here is the call graph for this function:

◆ createFromImportDir()

ilObjectTileImage::createFromImportDir ( string  $source_dir,
string  $ext 
)

Implements ilObjectTileImageInterface.

Definition at line 206 of file class.ilObjectTileImage.php.

206 : void
207 {
208 $target_dir = implode(
209 DIRECTORY_SEPARATOR,
210 [
212 $this->getRelativeDirectory()
213 ]
214 );
215 $sourceFS = LegacyPathHelper::deriveFilesystemFrom($source_dir);
216 $targetFS = LegacyPathHelper::deriveFilesystemFrom($target_dir);
217
218 $sourceDir = LegacyPathHelper::createRelativePath($source_dir);
219 $targetDir = LegacyPathHelper::createRelativePath($target_dir);
220
221
222 $sourceList = $sourceFS->listContents($sourceDir, true);
223
224 foreach ($sourceList as $item) {
225 if ($item->isDir()) {
226 continue;
227 }
228 try {
229 $itemPath = $targetDir . '/' . substr($item->getPath(), strlen($sourceDir));
230 $stream = $sourceFS->readStream($item->getPath());
231 $targetFS->writeStream($itemPath, $stream);
233 // Do nothing with that type of exception
234 }
235 }
236
237 ilContainer::_writeContainerSetting($this->obj_id, 'tile_image', $ext);
238 }
static getWebspaceDir(string $mode="filesystem")
get webspace directory

References Vendor\Package\$e, $ext, ilContainer\_writeContainerSetting(), getRelativeDirectory(), and ilFileUtils\getWebspaceDir().

+ Here is the call graph for this function:

◆ delete()

ilObjectTileImage::delete ( )

Implements ilObjectTileImageInterface.

Definition at line 74 of file class.ilObjectTileImage.php.

74 : void
75 {
76 if ($this->web->hasDir($this->getRelativeDirectory())) {
77 try {
78 $this->web->deleteDir($this->getRelativeDirectory());
79 } catch (Exception $e) {
80 }
81 }
82
83 ilContainer::_deleteContainerSettings($this->obj_id, 'tile_image');
84 }

References Vendor\Package\$e, ilContainer\_deleteContainerSettings(), and getRelativeDirectory().

+ Here is the call graph for this function:

◆ exists()

ilObjectTileImage::exists ( )

Implements ilObjectTileImageInterface.

Definition at line 185 of file class.ilObjectTileImage.php.

185 : bool
186 {
187 if (!ilContainer::_lookupContainerSetting($this->obj_id, 'tile_image', '0')) {
188 return false;
189 }
190
191 return $this->web->has($this->getRelativePath());
192 }

References ilContainer\_lookupContainerSetting(), and getRelativePath().

Referenced by copy().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExtension()

ilObjectTileImage::getExtension ( )

Implements ilObjectTileImageInterface.

Definition at line 46 of file class.ilObjectTileImage.php.

46 : string
47 {
48 return $this->ext;
49 }

References $ext.

Referenced by copy(), and getFileName().

+ Here is the caller graph for this function:

◆ getFileName()

ilObjectTileImage::getFileName ( )
protected

Definition at line 169 of file class.ilObjectTileImage.php.

169 : string
170 {
171 return 'tile_image.' . $this->getExtension();
172 }

References getExtension().

Referenced by getRelativePath().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFullPath()

ilObjectTileImage::getFullPath ( )

Implements ilObjectTileImageInterface.

Definition at line 194 of file class.ilObjectTileImage.php.

194 : string
195 {
196 // TODO: Currently there is no option to get the relative base directory of a filesystem
197 return implode(
198 DIRECTORY_SEPARATOR,
199 [
201 $this->getRelativePath()
202 ]
203 );
204 }

References getRelativePath(), and ilFileUtils\getWebspaceDir().

+ Here is the call graph for this function:

◆ getRelativeDirectory()

ilObjectTileImage::getRelativeDirectory ( )

Definition at line 157 of file class.ilObjectTileImage.php.

157 : string
158 {
159 return implode(
160 DIRECTORY_SEPARATOR,
161 [
162 'obj_data',
163 'tile_image',
164 'tile_image_' . $this->obj_id
165 ]
166 );
167 }

Referenced by createDirectory(), createFromImportDir(), delete(), and getRelativePath().

+ Here is the caller graph for this function:

◆ getRelativePath()

ilObjectTileImage::getRelativePath ( )
protected

Definition at line 174 of file class.ilObjectTileImage.php.

174 : string
175 {
176 return implode(
177 DIRECTORY_SEPARATOR,
178 [
179 $this->getRelativeDirectory(),
180 $this->getFileName()
181 ]
182 );
183 }

References getFileName(), and getRelativeDirectory().

Referenced by copy(), exists(), and getFullPath().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ persistImageState()

ilObjectTileImage::persistImageState ( string  $filename)
protected

Definition at line 138 of file class.ilObjectTileImage.php.

138 : void
139 {
140 $ext = pathinfo($filename, PATHINFO_EXTENSION);
141
142 if ($this->web->has($filename)) {
143 ilContainer::_writeContainerSetting($this->obj_id, 'tile_image', $ext);
144 } else {
145 ilContainer::_deleteContainerSettings($this->obj_id, 'tile_image');
146 }
147 }
$filename
Definition: buildRTE.php:78

References $ext, $filename, ilContainer\_deleteContainerSettings(), and ilContainer\_writeContainerSetting().

+ Here is the call graph for this function:

Field Documentation

◆ $ext

string ilObjectTileImage::$ext
protected

◆ $obj_id

int ilObjectTileImage::$obj_id
protected

Definition at line 32 of file class.ilObjectTileImage.php.

Referenced by __construct().

◆ $service

ilObjectService ilObjectTileImage::$service
protected

Definition at line 31 of file class.ilObjectTileImage.php.

Referenced by __construct().

◆ $upload

FileUpload ilObjectTileImage::$upload
protected

Definition at line 34 of file class.ilObjectTileImage.php.

◆ $web

Filesystem ilObjectTileImage::$web
protected

Definition at line 33 of file class.ilObjectTileImage.php.


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