ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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

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

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

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

Member Function Documentation

◆ buildFilename()

ilLTIConsumeProviderIcon::buildFilename (   $fileExtension)

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

Referenced by save().

53  {
54  return "{$this->providerId}.{$fileExtension}";
55  }
+ Here is the caller graph for this function:

◆ convert()

ilLTIConsumeProviderIcon::convert ( )
protected

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

References $type, ilUtil\execConvert(), and getAbsoluteFilePath().

Referenced by save().

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  }
$type
static execConvert($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 131 of file class.ilLTIConsumeProviderIcon.php.

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

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

◆ ensureExistingRelativeDirectory()

ilLTIConsumeProviderIcon::ensureExistingRelativeDirectory ( )
protected
Exceptions

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

References $DIC, and getRelativeDirectory().

Referenced by __construct().

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  }
$DIC
Definition: xapitoken.php:46
+ 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.

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

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

◆ getAbsoluteFilePath()

ilLTIConsumeProviderIcon::getAbsoluteFilePath ( )
Returns
string

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

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

Referenced by convert().

95  {
96  return implode(DIRECTORY_SEPARATOR, [
98  ]);
99  }
static getWebspaceDir($mode="filesystem")
get webspace directory
+ 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.

References $filename.

Referenced by exists(), and getRelativeFilePath().

60  : string
61  {
62  return $this->filename;
63  }
+ Here is the caller graph for this function:

◆ getRelativeDirectory()

ilLTIConsumeProviderIcon::getRelativeDirectory ( )
Returns
string

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

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

77  {
78  return implode(DIRECTORY_SEPARATOR, self::$RELATIVE_DIRECTORY_PATH);
79  }
+ Here is the caller graph for this function:

◆ getRelativeFilePath()

ilLTIConsumeProviderIcon::getRelativeFilePath ( )
Returns
string

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

References getFilename(), and getRelativeDirectory().

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

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

Referenced by ilLTIConsumeProviderFormGUI\initForm().

226  {
227  return self::$SUPPORTED_FILE_EXTENSIONS;
228  }
+ Here is the caller graph for this function:

◆ handleUploadInputSubission()

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

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

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

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  }
getPostVar()
Get Post Variable.
getDeletionFlag()
Get deletion flag.
$_POST["username"]
+ Here is the call graph for this function:

◆ save()

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

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

References $DIC, $result, $results, buildFilename(), convert(), getRelativeDirectory(), ILIAS\FileUpload\DTO\ProcessingStatus\OK, and setFilename().

Referenced by handleUploadInputSubission().

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 
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 .
$results
$DIC
Definition: xapitoken.php:46
+ 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.

References $filename.

Referenced by delete(), and save().

69  {
70  $this->filename = $filename;
71  }
+ 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.

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