mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-12-18 22:43:47 +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
|
* Règle de validation : fichier de type image
|
||||||
*
|
*
|
||||||
|
@ -43,24 +45,15 @@ class LSformRule_imagefile extends LSformRule {
|
||||||
|
|
||||||
$mimetype = mime_content_type($file);
|
$mimetype = mime_content_type($file);
|
||||||
|
|
||||||
if (isset($options['params']['mimeType'])) {
|
if ( (!isset($options['params']['mimeType'])) && (!isset($options['params']['mimeTypeRegEx'])) ) {
|
||||||
if ($mimetype != $options['params']['mimeType']) {
|
$options = array(
|
||||||
return;
|
'params' => array(
|
||||||
}
|
'mimeTypeRegEx' => '/image\/.*/'
|
||||||
}
|
)
|
||||||
else {
|
);
|
||||||
if (isset($options['params']['mimeTypeRegEx'])) {
|
|
||||||
$regex = $options['params']['mimeTypeRegEx'];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$regex = '/image\/.*/';
|
|
||||||
}
|
|
||||||
if (!preg_match($regex, $mimetype)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return LSformRule_mimetype :: validate($value,$options,$formElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue