ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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
 saveFromHttpRequest (string $tmp_name)
 Save image from request. More...
 

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.

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

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)
+ 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.

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

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)
+ Here is the call graph for this function:

◆ createDirectory()

ilObjectTileImage::createDirectory ( )
protected
Exceptions
IOException

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

References getRelativeDirectory().

Referenced by delete().

152  : void
153  {
154  $this->web->createDir($this->getRelativeDirectory());
155  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createFromImportDir()

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

Implements ilObjectTileImageInterface.

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

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

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);
232  } catch (FileAlreadyExistsException $e) {
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
static _writeContainerSetting(int $a_id, string $a_keyword, string $a_value)
+ Here is the call graph for this function:

◆ delete()

ilObjectTileImage::delete ( )

Implements ilObjectTileImageInterface.

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

References Vendor\Package\$e, $results, ilContainer\_deleteContainerSettings(), CLIENT_WEB_DIR, createDirectory(), ilShellUtil\execConvert(), getFileName(), getRelativeDirectory(), getRelativePath(), persistImageState(), ilObjectTileImageInterface\saveFromHttpRequest(), and ILIAS\Repository\upload().

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  }
static _deleteContainerSettings(int $a_id, string $a_keyword="", bool $a_keyword_like=false)
+ Here is the call graph for this function:

◆ exists()

ilObjectTileImage::exists ( )

Implements ilObjectTileImageInterface.

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

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

Referenced by copy().

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  }
static _lookupContainerSetting(int $a_id, string $a_keyword, string $a_default_value=null)
+ 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.

References $ext.

Referenced by copy(), and getFileName().

46  : string
47  {
48  return $this->ext;
49  }
+ Here is the caller graph for this function:

◆ getFileName()

ilObjectTileImage::getFileName ( )
protected

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

References getExtension().

Referenced by delete(), and getRelativePath().

169  : string
170  {
171  return 'tile_image.' . $this->getExtension();
172  }
+ 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.

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

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  }
static getWebspaceDir(string $mode="filesystem")
get webspace directory
+ Here is the call graph for this function:

◆ getRelativeDirectory()

ilObjectTileImage::getRelativeDirectory ( )

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

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

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  }
+ Here is the caller graph for this function:

◆ getRelativePath()

ilObjectTileImage::getRelativePath ( )
protected

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

References getFileName(), and getRelativeDirectory().

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

174  : string
175  {
176  return implode(
177  DIRECTORY_SEPARATOR,
178  [
179  $this->getRelativeDirectory(),
180  $this->getFileName()
181  ]
182  );
183  }
+ 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.

References ilContainer\_deleteContainerSettings(), and ilContainer\_writeContainerSetting().

Referenced by delete().

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
static _writeContainerSetting(int $a_id, string $a_keyword, string $a_value)
static _deleteContainerSettings(int $a_id, string $a_keyword="", bool $a_keyword_like=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ext

string ilObjectTileImage::$ext
protected

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

Referenced by getExtension().

◆ $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: