ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\Style\Content\ImageFileRepo Class Reference
+ Collaboration diagram for ILIAS\Style\Content\ImageFileRepo:

Public Member Functions

 __construct (InternalDataService $factory, Filesystem\Filesystem $web_files, FileUpload $upload)
 
 getImages (int $style_id)
 Get images of style. More...
 
 getWebPath (string $path)
 
 uploadImage (int $style_id)
 
 deleteImageByFilename (int $style_id, string $filename)
 

Protected Member Functions

 dir (int $style_id)
 

Protected Attributes

const DIR_PATH = "sty/sty_%id%/images"
 
InternalDataService $factory
 
Filesystem Filesystem $web_files
 
FileUpload $upload
 

Detailed Description

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

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

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Style\Content\ImageFileRepo::__construct ( InternalDataService  $factory,
Filesystem\Filesystem  $web_files,
FileUpload  $upload 
)

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

References ILIAS\Style\Content\ImageFileRepo\$factory, ILIAS\Style\Content\ImageFileRepo\$upload, ILIAS\Style\Content\ImageFileRepo\$web_files, and ILIAS\Repository\upload().

45  {
46  $this->web_files = $web_files;
47  $this->factory = $factory;
48  $this->upload = $upload;
49  }
+ Here is the call graph for this function:

Member Function Documentation

◆ deleteImageByFilename()

ILIAS\Style\Content\ImageFileRepo::deleteImageByFilename ( int  $style_id,
string  $filename 
)

Definition at line 130 of file class.ImageFileRepo.php.

References ILIAS\Style\Content\ImageFileRepo\dir().

130  : void
131  {
132  $dir = $this->dir($style_id);
133  $this->web_files->delete($dir . "/" . $filename);
134  }
$filename
Definition: buildRTE.php:78
+ Here is the call graph for this function:

◆ dir()

ILIAS\Style\Content\ImageFileRepo::dir ( int  $style_id)
protected

Definition at line 52 of file class.ImageFileRepo.php.

Referenced by ILIAS\Style\Content\ImageFileRepo\deleteImageByFilename(), ILIAS\Style\Content\ImageFileRepo\getImages(), and ILIAS\Style\Content\ImageFileRepo\uploadImage().

52  : string
53  {
54  return str_replace("%id%", (string) $style_id, self::DIR_PATH);
55  }
+ Here is the caller graph for this function:

◆ getImages()

ILIAS\Style\Content\ImageFileRepo::getImages ( int  $style_id)

Get images of style.

Parameters
int$style_id
Returns
Generator
Exceptions
Filesystem

Definition at line 63 of file class.ImageFileRepo.php.

References ILIAS\Style\Content\ImageFileRepo\dir(), ILIAS\Style\Content\ImageFileRepo\getWebPath(), and ILIAS\Data\DataSize\KB.

Referenced by ILIAS\Style\Content\ImageFileRepo\getWebPath().

65  : Generator {
66  $dir = $this->dir($style_id);
67  if ($this->web_files->hasDir($dir)) {
68  foreach ($this->web_files->listContents($dir) as $meta) {
69  if ($meta->isFile()) {
70  $size = $this->web_files->getSize(
71  $meta->getPath(),
73  );
74  $image_size = getimagesize($this->getWebPath($meta->getPath()));
75  $width = $image_size[0] ?? 0;
76  $height = $image_size[1] ?? 0;
77  yield $this->factory->image(
78  $meta->getPath(),
79  $size,
80  $width,
81  $height
82  );
83  }
84  }
85  }
86  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWebPath()

ILIAS\Style\Content\ImageFileRepo::getWebPath ( string  $path)

Definition at line 89 of file class.ImageFileRepo.php.

References $filename, $i, $path, CLIENT_ID, ILIAS\Style\Content\ImageFileRepo\getImages(), and ILIAS_WEB_DIR.

Referenced by ILIAS\Style\Content\ImageFileRepo\getImages().

89  : string
90  {
91  return ILIAS_WEB_DIR . "/" . CLIENT_ID . "/" . $path;
92  }
$path
Definition: ltiservices.php:32
const CLIENT_ID
Definition: constants.php:41
const ILIAS_WEB_DIR
Definition: constants.php:45
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ uploadImage()

ILIAS\Style\Content\ImageFileRepo::uploadImage ( int  $style_id)
Parameters
int$style_id
Exceptions
Filesystem

Definition at line 111 of file class.ImageFileRepo.php.

References ILIAS\Style\Content\ImageFileRepo\$upload, ILIAS\Style\Content\ImageFileRepo\dir(), ILIAS\FileUpload\FileUpload\getResults(), ILIAS\FileUpload\FileUpload\hasBeenProcessed(), ILIAS\FileUpload\FileUpload\hasUploads(), ILIAS\FileUpload\FileUpload\moveFilesTo(), ILIAS\FileUpload\DTO\ProcessingStatus\OK, ILIAS\FileUpload\FileUpload\process(), and ILIAS\FileUpload\Location\WEB.

111  : void
112  {
114  $dir = $this->dir($style_id);
115  if (!$this->web_files->hasDir($dir)) {
116  $this->web_files->createDir($dir);
117  }
118  if ($upload->hasUploads()) {
119  if (!$upload->hasBeenProcessed()) {
120  $upload->process();
121  }
122  $result = array_values($upload->getResults())[0];
123  if ($result->getStatus()->getCode() === ProcessingStatus::OK) {
125  }
126  }
127  }
process()
Invokes all preprocessors for each uploaded file in the sequence they got registered.
moveFilesTo(string $destination, int $location=Location::STORAGE)
Moves all uploaded files to the given destination after the processors had processed the files...
hasUploads()
Return (bool)true if one ore more file-uploads are in the current request, (bool)false if not...
getResults()
Returns the results of the processing and moving operation of the uploaded files. ...
hasBeenProcessed()
Return (bool)true if the current upload has already been processed.
const WEB
The filesystem within the ilias web root.
Definition: Location.php:35
+ Here is the call graph for this function:

Field Documentation

◆ $factory

InternalDataService ILIAS\Style\Content\ImageFileRepo::$factory
protected

◆ $upload

FileUpload ILIAS\Style\Content\ImageFileRepo::$upload
protected

◆ $web_files

Filesystem Filesystem ILIAS\Style\Content\ImageFileRepo::$web_files
protected

◆ DIR_PATH

const ILIAS\Style\Content\ImageFileRepo::DIR_PATH = "sty/sty_%id%/images"
protected

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


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