mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-17 15:59:06 +01:00
- LSformRule_imagefile : Tranformation en interface de la règle LSformRule_mimetype.
This commit is contained in:
parent
e694a1fefe
commit
20e2577d58
1 changed files with 9 additions and 16 deletions
|
@ -20,6 +20,8 @@
|
|||
|
||||
******************************************************************************/
|
||||
|
||||
LSsession :: loadLSclass('LSformRule_mimetype');
|
||||
|
||||
/**
|
||||
* Règle de validation : fichier de type image
|
||||
*
|
||||
|
@ -43,24 +45,15 @@ class LSformRule_imagefile extends LSformRule {
|
|||
|
||||
$mimetype = mime_content_type($file);
|
||||
|
||||
if (isset($options['params']['mimeType'])) {
|
||||
if ($mimetype != $options['params']['mimeType']) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isset($options['params']['mimeTypeRegEx'])) {
|
||||
$regex = $options['params']['mimeTypeRegEx'];
|
||||
}
|
||||
else {
|
||||
$regex = '/image\/.*/';
|
||||
}
|
||||
if (!preg_match($regex, $mimetype)) {
|
||||
return false;
|
||||
}
|
||||
if ( (!isset($options['params']['mimeType'])) && (!isset($options['params']['mimeTypeRegEx'])) ) {
|
||||
$options = array(
|
||||
'params' => array(
|
||||
'mimeTypeRegEx' => '/image\/.*/'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
return LSformRule_mimetype :: validate($value,$options,$formElement);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue