ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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

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

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

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:22
+ 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.

Referenced by save().

65  : string
66  {
67  return $this->providerId . "." . $fileExtension;
68  }
+ Here is the caller graph for this function:

◆ convert()

ilLTIConsumeProviderIcon::convert ( )
protected

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

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

Referenced by save().

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

◆ delete()

ilLTIConsumeProviderIcon::delete ( )
protected
Exceptions

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

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

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  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

◆ ensureExistingRelativeDirectory()

ilLTIConsumeProviderIcon::ensureExistingRelativeDirectory ( )
protected
Exceptions

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

References $DIC, and getRelativeDirectory().

Referenced by __construct().

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  }
global $DIC
Definition: shib_login.php:22
+ 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.

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

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  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

◆ getAbsoluteFilePath()

ilLTIConsumeProviderIcon::getAbsoluteFilePath ( )

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

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

Referenced by convert().

92  : string
93  {
94  return implode(DIRECTORY_SEPARATOR, [
96  ]);
97  }
static getWebspaceDir(string $mode="filesystem")
get webspace directory
+ 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.

References $filename.

Referenced by exists(), and getRelativeFilePath().

70  : string
71  {
72  return $this->filename;
73  }
+ Here is the caller graph for this function:

◆ getRelativeDirectory()

ilLTIConsumeProviderIcon::getRelativeDirectory ( )

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

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

80  : string
81  {
82  return implode(DIRECTORY_SEPARATOR, self::$RELATIVE_DIRECTORY_PATH);
83  }
+ Here is the caller graph for this function:

◆ getRelativeFilePath()

ilLTIConsumeProviderIcon::getRelativeFilePath ( )

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

References getFilename(), and getRelativeDirectory().

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

85  : string
86  {
87  return implode(DIRECTORY_SEPARATOR, [
88  $this->getRelativeDirectory(), $this->getFilename()
89  ]);
90  }
+ 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.

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

218  : array
219  {
220  return self::$SUPPORTED_FILE_EXTENSIONS;
221  }
+ Here is the caller graph for this function:

◆ handleUploadInputSubission()

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

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

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

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  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

◆ save()

ilLTIConsumeProviderIcon::save ( string  $uploadFile)
protected
Exceptions

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

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

Referenced by handleUploadInputSubission().

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 Contains several chained tasks and infos about them.
global $DIC
Definition: shib_login.php:22
$results
+ 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.

References $filename.

Referenced by delete(), and save().

75  : void
76  {
77  $this->filename = $filename;
78  }
+ 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.

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