From 20e2577d58bd014b74a084305a56fa2312fa0869 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Thu, 12 Feb 2009 15:56:38 +0000 Subject: [PATCH] =?UTF-8?q?-=20LSformRule=5Fimagefile=20:=20Tranformation?= =?UTF-8?q?=20en=20interface=20de=20la=20r=C3=A8gle=20LSformRule=5Fmimetyp?= =?UTF-8?q?e.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../class/class.LSformRule_imagefile.php | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/trunk/includes/class/class.LSformRule_imagefile.php b/trunk/includes/class/class.LSformRule_imagefile.php index 243287a5..d4aa5232 100644 --- a/trunk/includes/class/class.LSformRule_imagefile.php +++ b/trunk/includes/class/class.LSformRule_imagefile.php @@ -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); } }