Qual: Make code simpler

This commit is contained in:
Laurent Destailleur
2013-09-11 15:17:31 +02:00
parent 4b2ee84ede
commit 74f8a19134

View File

@@ -962,22 +962,11 @@ class CMailFile
$this->html_images[$i]["name"] = $img; $this->html_images[$i]["name"] = $img;
// Content type // Content type
/* if (preg_match('/^.+\.(\w{3,4})$/', $img, $reg))
* preg_replace /e modifier is deprecated in PHP 5.5 {
* but anonymous functions for use in preg_replace_callback are only available from 5.3.0 $ext=strtolower($reg[1]);
*/ $this->html_images[$i]["content_type"] = $this->image_types[$ext];
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
$ext = preg_replace_callback(
'/^.*\.(\w{3,4})$/',
function ($m) {
return strtolower($m[1]);
},
$img
);
} else {
$ext = preg_replace('/^.*\.(\w{3,4})$/e', 'strtolower("$1")', $img);
} }
$this->html_images[$i]["content_type"] = $this->image_types[$ext];
// cid // cid
$this->html_images[$i]["cid"] = dol_hash(uniqid(time())); $this->html_images[$i]["cid"] = dol_hash(uniqid(time()));