modifié:         core/lib/Thelia/Controller/Admin/FileController.php
	modifié:         core/lib/Thelia/Tests/Tools/MimeTypesToolsTest.php
	modifié:         core/lib/Thelia/Tools/MimeTypeTools.php
This commit is contained in:
Benjamin Perche
2014-07-28 11:19:57 +02:00
parent 4b2ee0d357
commit d1a9115626
3 changed files with 14 additions and 13 deletions

View File

@@ -57,11 +57,11 @@ class FileController extends BaseAdminController
/** /**
* Manage how a file collection has to be saved * Manage how a file collection has to be saved
* *
* @param int $parentId Parent id owning files being saved * @param int $parentId Parent id owning files being saved
* @param string $parentType Parent Type owning files being saved (product, category, content, etc.) * @param string $parentType Parent Type owning files being saved (product, category, content, etc.)
* @param string $objectType Object type, e.g. image or document * @param string $objectType Object type, e.g. image or document
* @param array $validMimeTypes an array of valid mime types. If empty, any mime type is allowed. * @param array $validMimeTypes an array of valid mime types. If empty, any mime type is allowed.
* @param array $blackList an array of blacklisted mime types. * @param array $blackList an array of blacklisted mime types.
* @return Response * @return Response
*/ */
public function saveFileAjaxAction( public function saveFileAjaxAction(

View File

@@ -10,7 +10,7 @@
/* file that was distributed with this source code. */ /* file that was distributed with this source code. */
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Tests\Type; namespace Thelia\Tests\Tools;
use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\Container;
use Thelia\Core\Translation\Translator; use Thelia\Core\Translation\Translator;
use Thelia\Tools\MimeTypeTools; use Thelia\Tools\MimeTypeTools;
@@ -113,4 +113,4 @@ class MimeTypesToolsTest extends \PHPUnit_Framework_TestCase
"thismimetype/doesntexists", "foo.bar" "thismimetype/doesntexists", "foo.bar"
)); ));
} }
} }

View File

@@ -19,7 +19,7 @@ use Thelia\Exception\FileException;
* @package Thelia\Tools * @package Thelia\Tools
* @author Benjamin Perche <bperche@openstudio.fr> * @author Benjamin Perche <bperche@openstudio.fr>
*/ */
class MimeTypeTools class MimeTypeTools
{ {
const TYPES_FILE = "local/config/mime.types"; const TYPES_FILE = "local/config/mime.types";
@@ -65,7 +65,8 @@ class MimeTypeTools
* @param $fileName * @param $fileName
* @return bool * @return bool
*/ */
public function validateMimeTypeExtension($mimeType, $fileName) { public function validateMimeTypeExtension($mimeType, $fileName)
{
$mimeType = strtolower($mimeType); $mimeType = strtolower($mimeType);
$extensions = $this->guessExtensionsFromMimeType($mimeType); $extensions = $this->guessExtensionsFromMimeType($mimeType);
@@ -79,11 +80,11 @@ class MimeTypeTools
$oneMatch &= !!preg_match("#\.$extension$#i", $fileName); $oneMatch &= !!preg_match("#\.$extension$#i", $fileName);
} }
return (bool)$oneMatch ? static::TYPE_MATCH : static::TYPE_NOT_MATCH; return (bool) $oneMatch ? static::TYPE_MATCH : static::TYPE_NOT_MATCH;
} }
/** /**
* @param null $filePath * @param null $filePath
* @return array * @return array
* @throws \Thelia\Exception\FileException * @throws \Thelia\Exception\FileException
*/ */
@@ -138,7 +139,7 @@ class MimeTypeTools
/** /**
* @param $string * @param $string
* @param string $characterMask * @param string $characterMask
* @return mixed|string * @return mixed|string
*/ */
public function realTrim($string, $characterMask = "\t\n\r ") public function realTrim($string, $characterMask = "\t\n\r ")
@@ -154,4 +155,4 @@ class MimeTypeTools
return $string; return $string;
} }
} }