ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\TestQuestionPool\Questions\Files\QuestionFiles Class Reference
+ Collaboration diagram for ILIAS\TestQuestionPool\Questions\Files\QuestionFiles:

Public Member Functions

 getAllowedFileExtensionsForMimeType (string $mimeType)
 
 isAllowedImageMimeType ($mimeType)
 
 isAllowedImageFileExtension (string $mimeType, string $fileExtension)
 
 buildImagePath ($questionId, $parentObjectId)
 

Static Public Member Functions

static getAllowedImageMaterialFileExtensions ()
 

Data Fields

const IMG_MIME_TYPE_JPG = 'image/jpeg'
 
const IMG_MIME_TYPE_PNG = 'image/png'
 
const IMG_MIME_TYPE_GIF = 'image/gif'
 

Static Protected Attributes

static array $allowedImageMaterialFileExtensionsByMimeType
 
static array $allowedFileExtensionsByMimeType
 
static array $allowedCharsetsByMimeType
 

Detailed Description

Definition at line 23 of file QuestionFiles.php.

Member Function Documentation

◆ buildImagePath()

ILIAS\TestQuestionPool\Questions\Files\QuestionFiles::buildImagePath (   $questionId,
  $parentObjectId 
)

Definition at line 89 of file QuestionFiles.php.

89 : string
90 {
91 return CLIENT_WEB_DIR . '/assessment/' . $parentObjectId . '/' . $questionId . '/images/';
92 }
const CLIENT_WEB_DIR
Definition: constants.php:47

References CLIENT_WEB_DIR.

◆ getAllowedFileExtensionsForMimeType()

ILIAS\TestQuestionPool\Questions\Files\QuestionFiles::getAllowedFileExtensionsForMimeType ( string  $mimeType)

Definition at line 61 of file QuestionFiles.php.

61 : array
62 {
63 foreach (self::$allowedFileExtensionsByMimeType as $allowedMimeType => $extensions) {
64 $rexCharsets = implode('|', self::$allowedCharsetsByMimeType[$allowedMimeType]);
65 $rexMimeType = preg_quote($allowedMimeType, '/');
66
67 $rex = '/^' . $rexMimeType . '(;(\s)*charset=(' . $rexCharsets . '))*$/';
68
69 if (!preg_match($rex, $mimeType)) {
70 continue;
71 }
72
73 return $extensions;
74 }
75
76 return array();
77 }

Referenced by ILIAS\TestQuestionPool\Questions\Files\QuestionFiles\isAllowedImageFileExtension(), and ILIAS\TestQuestionPool\Questions\Files\QuestionFiles\isAllowedImageMimeType().

+ Here is the caller graph for this function:

◆ getAllowedImageMaterialFileExtensions()

static ILIAS\TestQuestionPool\Questions\Files\QuestionFiles::getAllowedImageMaterialFileExtensions ( )
static
Returns
array all allowed file extensions for image material

@noinspection SlowArrayOperationsInLoopInspection

Definition at line 34 of file QuestionFiles.php.

34 : array
35 {
36 $extensions = array();
37
38 foreach (self::$allowedImageMaterialFileExtensionsByMimeType as $mimeType => $mimeExtensions) {
40 $extensions = array_merge($extensions, $mimeExtensions);
41 }
42 return array_unique($extensions);
43 }

◆ isAllowedImageFileExtension()

ILIAS\TestQuestionPool\Questions\Files\QuestionFiles::isAllowedImageFileExtension ( string  $mimeType,
string  $fileExtension 
)

Definition at line 84 of file QuestionFiles.php.

84 : bool
85 {
86 return in_array(strtolower($fileExtension), $this->getAllowedFileExtensionsForMimeType($mimeType), true);
87 }

References ILIAS\TestQuestionPool\Questions\Files\QuestionFiles\getAllowedFileExtensionsForMimeType().

+ Here is the call graph for this function:

◆ isAllowedImageMimeType()

ILIAS\TestQuestionPool\Questions\Files\QuestionFiles::isAllowedImageMimeType (   $mimeType)

Definition at line 79 of file QuestionFiles.php.

79 : bool
80 {
81 return (bool) count($this->getAllowedFileExtensionsForMimeType($mimeType));
82 }

References ILIAS\TestQuestionPool\Questions\Files\QuestionFiles\getAllowedFileExtensionsForMimeType().

+ Here is the call graph for this function:

Field Documentation

◆ $allowedCharsetsByMimeType

array ILIAS\TestQuestionPool\Questions\Files\QuestionFiles::$allowedCharsetsByMimeType
staticprotected
Initial value:
= array(
self::IMG_MIME_TYPE_JPG => array('binary'),
self::IMG_MIME_TYPE_PNG => array('binary'),
self::IMG_MIME_TYPE_GIF => array('binary')
)

Definition at line 55 of file QuestionFiles.php.

◆ $allowedFileExtensionsByMimeType

array ILIAS\TestQuestionPool\Questions\Files\QuestionFiles::$allowedFileExtensionsByMimeType
staticprotected
Initial value:
= array(
self::IMG_MIME_TYPE_JPG => array('jpg', 'jpeg'),
self::IMG_MIME_TYPE_PNG => array('png'),
self::IMG_MIME_TYPE_GIF => array('gif')
)

Definition at line 49 of file QuestionFiles.php.

◆ $allowedImageMaterialFileExtensionsByMimeType

array ILIAS\TestQuestionPool\Questions\Files\QuestionFiles::$allowedImageMaterialFileExtensionsByMimeType
staticprotected
Initial value:
= array(
'image/jpeg' => array('jpg', 'jpeg'),
'image/png' => array('png'),
'image/gif' => array('gif')
)

Definition at line 25 of file QuestionFiles.php.

◆ IMG_MIME_TYPE_GIF

const ILIAS\TestQuestionPool\Questions\Files\QuestionFiles::IMG_MIME_TYPE_GIF = 'image/gif'

Definition at line 47 of file QuestionFiles.php.

◆ IMG_MIME_TYPE_JPG

const ILIAS\TestQuestionPool\Questions\Files\QuestionFiles::IMG_MIME_TYPE_JPG = 'image/jpeg'

Definition at line 45 of file QuestionFiles.php.

◆ IMG_MIME_TYPE_PNG

const ILIAS\TestQuestionPool\Questions\Files\QuestionFiles::IMG_MIME_TYPE_PNG = 'image/png'

Definition at line 46 of file QuestionFiles.php.


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