ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilLTIConsumeProviderIcon Class Reference
+ Collaboration diagram for ilLTIConsumeProviderIcon:

Public Member Functions

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

Static Public Member Functions

static getSupportedFileExtensions ()
 

Data Fields

const MAX_ICON_SIZE = 32
 

Protected Member Functions

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

Protected Attributes

 $providerId
 
 $filename
 

Static Protected Attributes

static $RELATIVE_DIRECTORY_PATH
 
static $SUPPORTED_FILE_EXTENSIONS
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

ilLTIConsumeProviderIcon constructor.

Parameters
int$providerId
string$filename
Exceptions

ILIAS\Filesystem\Exception\IOException

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

43 {
44 global $DIC; /* @var \ILIAS\DI\Container $DIC */
45
46 $this->providerId = $providerId;
47 $this->filename = $filename;
48
50 }
$DIC
Definition: xapitoken.php:46

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

+ Here is the call graph for this function:

Member Function Documentation

◆ buildFilename()

ilLTIConsumeProviderIcon::buildFilename (   $fileExtension)

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

53 {
54 return "{$this->providerId}.{$fileExtension}";
55 }

Referenced by save().

+ Here is the caller graph for this function:

◆ convert()

ilLTIConsumeProviderIcon::convert ( )
protected

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

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

References $type, ilUtil\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 131 of file class.ilLTIConsumeProviderIcon.php.

132 {
133 global $DIC; /* @var \ILIAS\DI\Container $DIC */
134
135 if ($DIC->filesystem()->web()->has($this->getRelativeFilePath())) {
136 $DIC->filesystem()->web()->delete($this->getRelativeFilePath());
137 }
138
139 $this->setFilename('');
140 }

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 104 of file class.ilLTIConsumeProviderIcon.php.

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

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 ( )
Returns
bool

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

117 {
118 global $DIC; /* @var \ILIAS\DI\Container $DIC */
119
120 if (!strlen($this->getFilename())) {
121 return false;
122 }
123
124 return $DIC->filesystem()->web()->has($this->getRelativeFilePath());
125 }

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

+ Here is the call graph for this function:

◆ getAbsoluteFilePath()

ilLTIConsumeProviderIcon::getAbsoluteFilePath ( )
Returns
string

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

95 {
96 return implode(DIRECTORY_SEPARATOR, [
98 ]);
99 }
static getWebspaceDir($mode="filesystem")
get webspace directory

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

Referenced by convert().

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

◆ getFilename()

ilLTIConsumeProviderIcon::getFilename ( )
Returns
string

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

60 : string
61 {
62 return $this->filename;
63 }

References $filename.

Referenced by exists(), and getRelativeFilePath().

+ Here is the caller graph for this function:

◆ getRelativeDirectory()

ilLTIConsumeProviderIcon::getRelativeDirectory ( )
Returns
string

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

77 {
78 return implode(DIRECTORY_SEPARATOR, self::$RELATIVE_DIRECTORY_PATH);
79 }

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

+ Here is the caller graph for this function:

◆ getRelativeFilePath()

ilLTIConsumeProviderIcon::getRelativeFilePath ( )
Returns
string

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

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

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
array

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

References $SUPPORTED_FILE_EXTENSIONS.

Referenced by ilLTIConsumeProviderFormGUI\initForm().

+ Here is the caller graph for this function:

◆ handleUploadInputSubission()

ilLTIConsumeProviderIcon::handleUploadInputSubission ( ilImageFileInputGUI  $fileInput)
Parameters
ilImageFileInputGUI$fileInput
Exceptions

ILIAS\FileUpload\Exception\IllegalStateException

Exceptions

ILIAS\Filesystem\Exception\FileNotFoundException

Exceptions

ILIAS\Filesystem\Exception\IOException

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

208 {
209 if ($fileInput->getDeletionFlag()) {
210 $this->delete();
211 }
212
213 // ilImageFileInputGUI does NOT come with a set value that could be fetched with
214 // $fileInput->getValue(). Instead ilImageFileInputGUI provides upload info in $_POST.
215 $fileData = $_POST[$fileInput->getPostVar()];
216
217 if ($fileData['tmp_name']) {
218 $this->save($fileData['tmp_name']);
219 }
220 }
$_POST["username"]
getPostVar()
Get Post Variable.
getDeletionFlag()
Get deletion flag.

References $_POST, ilImageFileInputGUI\getDeletionFlag(), ilFormPropertyGUI\getPostVar(), and save().

+ Here is the call graph for this function:

◆ save()

ilLTIConsumeProviderIcon::save ( string  $uploadFile)
protected
Parameters
string$uploadFile
Exceptions

ILIAS\FileUpload\Exception\IllegalStateException

Exceptions

ILIAS\Filesystem\Exception\FileNotFoundException

Exceptions

ILIAS\Filesystem\Exception\IOException

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

168 {
169 global $DIC; /* @var \ILIAS\DI\Container $DIC */
170
171 if ($DIC->upload()->hasUploads()) {
172 if (!$DIC->upload()->hasBeenProcessed()) {
173 $DIC->upload()->process();
174 }
175
176 /* @var \ILIAS\FileUpload\DTO\UploadResult $result */
177
178 $results = $DIC->upload()->getResults();
179
180 if (isset($results[$uploadFile])) {
181 $result = $results[$uploadFile];
182
183 if ($result->getStatus() == \ILIAS\FileUpload\DTO\ProcessingStatus::OK) {
184 $fileExtentsion = pathinfo($result->getName(), PATHINFO_EXTENSION);
185 $this->setFilename($this->buildFilename($fileExtentsion));
186
187 $DIC->upload()->moveOneFileTo(
188 $result,
189 $this->getRelativeDirectory(),
190 \ILIAS\FileUpload\Location::WEB,
191 $this->getFileName(),
192 true
193 );
194
195 $this->convert();
196 }
197 }
198 }
199 }
$result
Class ChatMainBarProvider \MainMenu\Provider.
$results

References $DIC, $result, $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)
Parameters
string$filename

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

69 {
70 $this->filename = $filename;
71 }

References $filename.

Referenced by delete(), and save().

+ Here is the caller graph for this function:

Field Documentation

◆ $filename

ilLTIConsumeProviderIcon::$filename
protected

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

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

◆ $providerId

ilLTIConsumeProviderIcon::$providerId
protected

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

Referenced by __construct().

◆ $RELATIVE_DIRECTORY_PATH

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

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

◆ $SUPPORTED_FILE_EXTENSIONS

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

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

Referenced by getSupportedFileExtensions().

◆ MAX_ICON_SIZE

const ilLTIConsumeProviderIcon::MAX_ICON_SIZE = 32

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


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