ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilLTIConsumeProviderIcon Class Reference
+ Collaboration diagram for ilLTIConsumeProviderIcon:

Public Member Functions

 __construct (int $providerId, string $filename='')
 ilLTIConsumeProviderIcon constructor. More...
 
 buildFilename (string $fileExtension)
 
 getFilename ()
 
 setFilename (string $filename)
 
 getRelativeDirectory ()
 
 getRelativeFilePath ()
 
 getAbsoluteFilePath ()
 
 exists ()
 
 handleUploadInputSubission (ilImageFileInputGUI $fileInput, array $fileData)
 

Static Public Member Functions

static getSupportedFileExtensions ()
 

Data Fields

const MAX_ICON_SIZE = 32
 

Protected Member Functions

 ensureExistingRelativeDirectory ()
 
 delete ()
 
 convert ()
 
 save (string $uploadFile)
 

Protected Attributes

int $providerId
 
string $filename
 

Static Protected Attributes

static array $RELATIVE_DIRECTORY_PATH
 
static array $SUPPORTED_FILE_EXTENSIONS
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilLTIConsumeProviderIcon::__construct ( int  $providerId,
string  $filename = '' 
)

ilLTIConsumeProviderIcon constructor.

Exceptions

ILIAS\Filesystem\Exception\IOException

Definition at line 55 of file class.ilLTIConsumeProviderIcon.php.

56 {
57 global $DIC; /* @var \ILIAS\DI\Container $DIC */
58
59 $this->providerId = $providerId;
60 $this->filename = $filename;
61
63 }
global $DIC
Definition: shib_login.php:26

References $DIC, $filename, $providerId, and ensureExistingRelativeDirectory().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildFilename()

ilLTIConsumeProviderIcon::buildFilename ( string  $fileExtension)

Definition at line 65 of file class.ilLTIConsumeProviderIcon.php.

65 : string
66 {
67 return $this->providerId . "." . $fileExtension;
68 }

Referenced by save().

+ Here is the caller graph for this function:

◆ convert()

ilLTIConsumeProviderIcon::convert ( )
protected

Definition at line 137 of file class.ilLTIConsumeProviderIcon.php.

137 : void
138 {
139 // convert to square with same side length (optimal for tile view)
140
141 list($width, $height, $type, $attr) = getimagesize($this->getAbsoluteFilePath());
142 $minSize = min($width, $height);
143
144 if (self::MAX_ICON_SIZE) {
145 $minSize = min($minSize, self::MAX_ICON_SIZE);
146 }
147
148 $convertCmd = "{$this->getAbsoluteFilePath()}[0]";
149 $convertCmd .= " -geometry {$minSize}x{$minSize}^ -gravity center";
150 $convertCmd .= " -extent {$minSize}x{$minSize}";
151 $convertCmd .= " {$this->getAbsoluteFilePath()}";
152
153 ilShellUtil::execConvert($convertCmd);
154 }
static execConvert(string $args)
execute convert command

References ilShellUtil\execConvert(), and getAbsoluteFilePath().

Referenced by save().

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

◆ delete()

ilLTIConsumeProviderIcon::delete ( )
protected
Exceptions

ILIAS\Filesystem\Exception\FileNotFoundException

Exceptions

ILIAS\Filesystem\Exception\IOException

Definition at line 126 of file class.ilLTIConsumeProviderIcon.php.

126 : void
127 {
128 global $DIC; /* @var \ILIAS\DI\Container $DIC */
129
130 if ($DIC->filesystem()->web()->has($this->getRelativeFilePath())) {
131 $DIC->filesystem()->web()->delete($this->getRelativeFilePath());
132 }
133
134 $this->setFilename('');
135 }

References $DIC, getRelativeFilePath(), and setFilename().

+ Here is the call graph for this function:

◆ ensureExistingRelativeDirectory()

ilLTIConsumeProviderIcon::ensureExistingRelativeDirectory ( )
protected
Exceptions

ILIAS\Filesystem\Exception\IOException

Definition at line 102 of file class.ilLTIConsumeProviderIcon.php.

102 : void
103 {
104 global $DIC; /* @var \ILIAS\DI\Container $DIC */
105
106 if (!$DIC->filesystem()->web()->has($this->getRelativeDirectory())) {
107 $DIC->filesystem()->web()->createDir($this->getRelativeDirectory());
108 }
109 }

References $DIC, and getRelativeDirectory().

Referenced by __construct().

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

◆ exists()

ilLTIConsumeProviderIcon::exists ( )

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

111 : bool
112 {
113 global $DIC; /* @var \ILIAS\DI\Container $DIC */
114
115 if ($this->getFilename() === '') {
116 return false;
117 }
118
119 return $DIC->filesystem()->web()->has($this->getRelativeFilePath());
120 }

References $DIC, getFilename(), and getRelativeFilePath().

+ Here is the call graph for this function:

◆ getAbsoluteFilePath()

ilLTIConsumeProviderIcon::getAbsoluteFilePath ( )

Definition at line 92 of file class.ilLTIConsumeProviderIcon.php.

92 : string
93 {
94 return implode(DIRECTORY_SEPARATOR, [
96 ]);
97 }
static getWebspaceDir(string $mode="filesystem")
get webspace directory

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

Referenced by convert().

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

◆ getFilename()

ilLTIConsumeProviderIcon::getFilename ( )

Definition at line 70 of file class.ilLTIConsumeProviderIcon.php.

70 : string
71 {
72 return $this->filename;
73 }

References $filename.

Referenced by exists(), and getRelativeFilePath().

+ Here is the caller graph for this function:

◆ getRelativeDirectory()

ilLTIConsumeProviderIcon::getRelativeDirectory ( )

Definition at line 80 of file class.ilLTIConsumeProviderIcon.php.

80 : string
81 {
82 return implode(DIRECTORY_SEPARATOR, self::$RELATIVE_DIRECTORY_PATH);
83 }

Referenced by ensureExistingRelativeDirectory(), getRelativeFilePath(), and save().

+ Here is the caller graph for this function:

◆ getRelativeFilePath()

ilLTIConsumeProviderIcon::getRelativeFilePath ( )

Definition at line 85 of file class.ilLTIConsumeProviderIcon.php.

85 : string
86 {
87 return implode(DIRECTORY_SEPARATOR, [
88 $this->getRelativeDirectory(), $this->getFilename()
89 ]);
90 }

References getFilename(), and getRelativeDirectory().

Referenced by delete(), exists(), and getAbsoluteFilePath().

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

◆ getSupportedFileExtensions()

static ilLTIConsumeProviderIcon::getSupportedFileExtensions ( )
static
Returns
mixed[]

Definition at line 218 of file class.ilLTIConsumeProviderIcon.php.

218 : array
219 {
221 }

References $SUPPORTED_FILE_EXTENSIONS.

Referenced by ilLTIConsumeProviderFormGUI\initForm(), and ilLTIConsumeProviderFormGUI\initToolConfigForm().

+ Here is the caller graph for this function:

◆ handleUploadInputSubission()

ilLTIConsumeProviderIcon::handleUploadInputSubission ( ilImageFileInputGUI  $fileInput,
array  $fileData 
)
Exceptions

ILIAS\FileUpload\Exception\IllegalStateException

Exceptions

ILIAS\Filesystem\Exception\FileNotFoundException

Exceptions

ILIAS\Filesystem\Exception\IOException

Definition at line 202 of file class.ilLTIConsumeProviderIcon.php.

202 : void
203 {
204 global $DIC;
205
206 if ($fileInput->getDeletionFlag()) {
207 $this->delete();
208 }
209
210 if ($fileData['tmp_name']) {
211 $this->save($fileData['tmp_name']);
212 }
213 }

References $DIC, ilImageFileInputGUI\getDeletionFlag(), and save().

+ Here is the call graph for this function:

◆ save()

ilLTIConsumeProviderIcon::save ( string  $uploadFile)
protected
Exceptions

ILIAS\FileUpload\Exception\IllegalStateException

Exceptions

ILIAS\Filesystem\Exception\FileNotFoundException

Exceptions

ILIAS\Filesystem\Exception\IOException

Definition at line 161 of file class.ilLTIConsumeProviderIcon.php.

161 : void
162 {
163 global $DIC; /* @var \ILIAS\DI\Container $DIC */
164
165 if ($DIC->upload()->hasUploads()) {
166 if (!$DIC->upload()->hasBeenProcessed()) {
167 $DIC->upload()->process();
168 }
169
170 /* @var \ILIAS\FileUpload\DTO\UploadResult $result */
171
172 $results = $DIC->upload()->getResults();
173
174 if (isset($results[$uploadFile])) {
175 $result = $results[$uploadFile];
176
177 if ($result->isOK()) {
178 $fileExtentsion = pathinfo($result->getName(), PATHINFO_EXTENSION);
179 $this->setFilename($this->buildFilename($fileExtentsion));
180
181 $DIC->upload()->moveOneFileTo(
182 $result,
183 $this->getRelativeDirectory(),
184 \ILIAS\FileUpload\Location::WEB,
185 $this->getFileName(),
186 true
187 );
188
189 if ($fileExtentsion !== "svg") {
190 $this->convert();
191 }
192 }
193 }
194 }
195 }
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
$results

References $DIC, $results, buildFilename(), convert(), getRelativeDirectory(), and setFilename().

Referenced by handleUploadInputSubission().

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

◆ setFilename()

ilLTIConsumeProviderIcon::setFilename ( string  $filename)

Definition at line 75 of file class.ilLTIConsumeProviderIcon.php.

75 : void
76 {
77 $this->filename = $filename;
78 }

References $filename.

Referenced by delete(), and save().

+ Here is the caller graph for this function:

Field Documentation

◆ $filename

string ilLTIConsumeProviderIcon::$filename
protected

Definition at line 49 of file class.ilLTIConsumeProviderIcon.php.

Referenced by __construct(), getFilename(), and setFilename().

◆ $providerId

int ilLTIConsumeProviderIcon::$providerId
protected

Definition at line 44 of file class.ilLTIConsumeProviderIcon.php.

Referenced by __construct().

◆ $RELATIVE_DIRECTORY_PATH

array ilLTIConsumeProviderIcon::$RELATIVE_DIRECTORY_PATH
staticprotected
Initial value:
= [
'lti_data', 'provider_icon'
]

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

◆ $SUPPORTED_FILE_EXTENSIONS

array ilLTIConsumeProviderIcon::$SUPPORTED_FILE_EXTENSIONS
staticprotected
Initial value:
= [
'png', 'jpg', 'jpeg', 'svg'
]

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

Referenced by getSupportedFileExtensions().

◆ MAX_ICON_SIZE

const ilLTIConsumeProviderIcon::MAX_ICON_SIZE = 32

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


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