ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilObjectTileImage Class Reference

Tile image object. More...

+ Inheritance diagram for ilObjectTileImage:
+ Collaboration diagram for ilObjectTileImage:

Public Member Functions

 __construct (ilObjectService $service, int $obj_id)
 Constructor. More...
 
 getExtension ()
 Get extenstion.
Returns
string
More...
 
 copy (int $target_obj_id)
 Copy tile image to repository object.
Parameters
int$target_obj_id
More...
 
 delete ()
 Delete tile image. More...
 
 getRelativeDirectory ()
 
 exists ()
 Does tile image file exist?
Returns
bool
More...
 
 getFullPath ()
 Get full path of the tile image file.
Returns
string
More...
 
 createFromImportDir ($source_dir, $ext)
 
- Public Member Functions inherited from ilObjectTileImageInterface
 saveFromHttpRequest (string $tmpname)
 Save image from request. More...
 

Protected Member Functions

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

Protected Attributes

 $service
 
 $obj_id
 
 $web
 
 $upload
 
 $ext
 

Detailed Description

Tile image object.

Author
killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

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

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

42  {
43  $this->service = $service;
44  $this->obj_id = $obj_id;
45  $this->web = $service->filesystem()->web();
46  $this->upload = $service->upload();
47  $this->ext = ilContainer::_lookupContainerSetting($obj_id, 'tile_image');
48  }
upload()
Get filesystems.
filesystem()
Get filesystems.
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.
+ Here is the call graph for this function:

Member Function Documentation

◆ copy()

ilObjectTileImage::copy ( int  $target_obj_id)

Copy tile image to repository object.

Parameters
int$target_obj_id

Implements ilObjectTileImageInterface.

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

References ilContainer\_deleteContainerSettings(), ilContainer\_writeContainerSetting(), exists(), getExtension(), and getRelativePath().

62  {
63  if (!$this->exists()) {
64  ilContainer::_deleteContainerSettings($target_obj_id, 'tile_image');
65  return;
66  }
67 
68  try {
69  $this->web->copy(
70  $this->getRelativePath(),
71  preg_replace(
72  '/(' . "tile_image_" . ')(\d*)\/(.*)$/',
73  '${1}' . $target_obj_id . '/${3}',
74  $this->getRelativePath()
75  )
76  );
77 
78  ilContainer::_writeContainerSetting($target_obj_id, 'tile_image', $this->getExtension());
79  } catch (\Exception $e) {
80  ilContainer::_deleteContainerSettings($target_obj_id, 'tile_image');
81  }
82  }
exists()
Does tile image file exist?bool
getExtension()
Get extenstion.string
static _deleteContainerSettings($a_id, $a_keyword=null, $a_keyword_like=false)
static _writeContainerSetting($a_id, $a_keyword, $a_value)
+ Here is the call graph for this function:

◆ createDirectory()

ilObjectTileImage::createDirectory ( )
protected
Exceptions

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

References getRelativeDirectory().

Referenced by delete().

161  {
162  $this->web->createDir($this->getRelativeDirectory());
163 
164  /*
165 
166  $rel_directory = $this->getRelDirectory();
167 
168  if (!$this->web->has(dirname($rel_directory))) {
169  $this->web->createDir(dirname($rel_directory));
170  }
171 
172  if (!$this->web->has($rel_directory)) {
173  $this->web->createDir($rel_directory);
174  }*/
175  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createFromImportDir()

ilObjectTileImage::createFromImportDir (   $source_dir,
  $ext 
)
Parameters
$source_dir
$ext
Exceptions

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

References $ext, ilContainer\_writeContainerSetting(), getRelativeDirectory(), ilUtil\getWebspaceDir(), and ilUtil\rCopy().

239  {
240  $target_dir = implode(DIRECTORY_SEPARATOR, [
242  $this->getRelativeDirectory()
243  ]);
244  ilUtil::rCopy($source_dir, $target_dir);
245  ilContainer::_writeContainerSetting($this->obj_id, 'tile_image', $ext);
246  }
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static _writeContainerSetting($a_id, $a_keyword, $a_value)
static getWebspaceDir($mode="filesystem")
get webspace directory
+ Here is the call graph for this function:

◆ delete()

ilObjectTileImage::delete ( )

Delete tile image.

Implements ilObjectTileImageInterface.

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

References $result, $results, $type, ilContainer\_deleteContainerSettings(), createDirectory(), ilUtil\execConvert(), getFileName(), getRelativeDirectory(), getRelativePath(), ILIAS\FileUpload\DTO\ProcessingStatus\OK, persistImageState(), and ilObjectTileImageInterface\saveFromHttpRequest().

88  {
89  if ($this->web->hasDir($this->getRelativeDirectory())) {
90  try {
91  $this->web->deleteDir($this->getRelativeDirectory());
92  } catch (\Exception $e) {
93  }
94  }
95 
96  ilContainer::_deleteContainerSettings($this->obj_id, 'tile_image');
97  }
static _deleteContainerSettings($a_id, $a_keyword=null, $a_keyword_like=false)
+ Here is the call graph for this function:

◆ exists()

ilObjectTileImage::exists ( )

Does tile image file exist?

Returns
bool

Implements ilObjectTileImageInterface.

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

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

Referenced by copy().

211  : bool
212  {
213  if (!\ilContainer::_lookupContainerSetting($this->obj_id, 'tile_image', 0)) {
214  return false;
215  }
216  return $this->web->has($this->getRelativePath());
217  }
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExtension()

ilObjectTileImage::getExtension ( )

Get extenstion.

Returns
string

Implements ilObjectTileImageInterface.

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

References $ext.

Referenced by copy(), and getFileName().

53  : string
54  {
55  return $this->ext;
56  }
+ Here is the caller graph for this function:

◆ getFileName()

ilObjectTileImage::getFileName ( )
protected
Returns
string

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

References getExtension().

Referenced by delete(), and getRelativePath().

193  {
194  return 'tile_image.' . $this->getExtension();
195  }
getExtension()
Get extenstion.string
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFullPath()

ilObjectTileImage::getFullPath ( )

Get full path of the tile image file.

Returns
string

Implements ilObjectTileImageInterface.

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

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

222  : string
223  {
224  // TODO: Currently there is no option to get the relative base directory of a filesystem
225  return implode(DIRECTORY_SEPARATOR, [
227  $this->getRelativePath()
228  ]);
229  }
static getWebspaceDir($mode="filesystem")
get webspace directory
+ Here is the call graph for this function:

◆ getRelativeDirectory()

ilObjectTileImage::getRelativeDirectory ( )
Returns
string

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

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

181  {
182  return implode(DIRECTORY_SEPARATOR, [
183  "obj_data",
184  "tile_image",
185  "tile_image_" . $this->obj_id
186  ]);
187  }
+ Here is the caller graph for this function:

◆ getRelativePath()

ilObjectTileImage::getRelativePath ( )
protected
Returns
string

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

References getFileName(), and getRelativeDirectory().

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

201  {
202  return implode(DIRECTORY_SEPARATOR, [
203  $this->getRelativeDirectory(),
204  $this->getFileName()
205  ]);
206  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ persistImageState()

ilObjectTileImage::persistImageState (   $filename)
protected
Parameters
string$filename

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

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

Referenced by delete().

147  {
148  $ext = pathinfo($filename, PATHINFO_EXTENSION);
149 
150  if ($this->web->has($filename)) {
151  ilContainer::_writeContainerSetting($this->obj_id, 'tile_image', $ext);
152  } else {
153  ilContainer::_deleteContainerSettings($this->obj_id, 'tile_image');
154  }
155  }
static _deleteContainerSettings($a_id, $a_keyword=null, $a_keyword_like=false)
$filename
Definition: buildRTE.php:89
static _writeContainerSetting($a_id, $a_keyword, $a_value)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ext

ilObjectTileImage::$ext
protected

◆ $obj_id

ilObjectTileImage::$obj_id
protected

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

Referenced by __construct().

◆ $service

ilObjectTileImage::$service
protected

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

Referenced by __construct().

◆ $upload

ilObjectTileImage::$upload
protected

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

◆ $web

ilObjectTileImage::$web
protected

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


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