@@ -31,14 +31,14 @@ discard block |
||
31 | 31 | |
32 | 32 | public function previewIconFilter(\Twig_Environment $twig, $secretKey = '') |
33 | 33 | { |
34 | - if($secretKey == '') |
|
34 | + if ($secretKey == '') |
|
35 | 35 | return ''; |
36 | 36 | |
37 | 37 | $mimeType = $this->getMimeType($secretKey); |
38 | 38 | $icon = ''; |
39 | 39 | $link = ''; |
40 | 40 | |
41 | - if(preg_match('/^image/', $mimeType) === 0) { |
|
41 | + if (preg_match('/^image/', $mimeType) === 0) { |
|
42 | 42 | $icon = $this->getIcon($mimeType); |
43 | 43 | $link = $this->generatePath(true, $icon); |
44 | 44 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | protected function generatePath($isIcon, $str) |
64 | 64 | { |
65 | - if($isIcon === true) { |
|
65 | + if ($isIcon === true) { |
|
66 | 66 | return $this->requestStack->getSchemeAndHttpHost().$this->requestStack->getBasePath().'/bundles/media/images/'.$str; |
67 | 67 | } |
68 | 68 | |
@@ -71,12 +71,12 @@ discard block |
||
71 | 71 | |
72 | 72 | public function generatePathFromSecretKey($secretKey) |
73 | 73 | { |
74 | - if($secretKey == '') |
|
74 | + if ($secretKey == '') |
|
75 | 75 | return ''; |
76 | 76 | |
77 | 77 | $mimeType = $this->getMimeType($secretKey); |
78 | 78 | |
79 | - if(preg_match('/^image/', $mimeType) === 0) { |
|
79 | + if (preg_match('/^image/', $mimeType) === 0) { |
|
80 | 80 | $icon = $this->getIcon($mimeType); |
81 | 81 | return $this->generatePath(true, $icon); |
82 | 82 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | public function transform($data) |
55 | 55 | { |
56 | - if($data instanceof Collection) { |
|
56 | + if ($data instanceof Collection) { |
|
57 | 57 | return $this->reverseTransform($data); |
58 | 58 | } |
59 | 59 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | protected function transformSingleEntity($data) |
81 | 81 | { |
82 | - if($data instanceof Media) |
|
82 | + if ($data instanceof Media) |
|
83 | 83 | return $data->getSecretKey(); |
84 | 84 | else |
85 | 85 | return $this->em->getRepository($this->class)->findOneBySecretKey($data); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | return null; |
92 | 92 | } |
93 | 93 | |
94 | - if(!($data instanceof Collection)) { |
|
94 | + if (!($data instanceof Collection)) { |
|
95 | 95 | return $this->transform($data); |
96 | 96 | } |
97 | 97 |
@@ -48,13 +48,13 @@ |
||
48 | 48 | { |
49 | 49 | $results = $event->getForm()->getData(); |
50 | 50 | |
51 | - if($results === null) |
|
51 | + if ($results === null) |
|
52 | 52 | return; |
53 | 53 | |
54 | - if(!is_array($results)) |
|
54 | + if (!is_array($results)) |
|
55 | 55 | $results = array($results); |
56 | 56 | |
57 | - foreach($results as $media) { |
|
57 | + foreach ($results as $media) { |
|
58 | 58 | $mediaEvent = new MediaEvent($media); |
59 | 59 | $this->dispatcher->dispatch(MediaEvent::POST_SUBMIT, $mediaEvent); |
60 | 60 | } |
@@ -20,11 +20,11 @@ discard block |
||
20 | 20 | protected $allowedMimetypes; |
21 | 21 | |
22 | 22 | const SIZE_OF_KIBIOCTET = 1024; |
23 | - const OCTET_IN_KO = 1; |
|
24 | - const OCTET_IN_MO = 2; |
|
25 | - const OCTET_IN_GO = 3; |
|
26 | - const OCTET_IN_TO = 4; |
|
27 | - const OCTET_IN_PO = 5; |
|
23 | + const OCTET_IN_KO = 1; |
|
24 | + const OCTET_IN_MO = 2; |
|
25 | + const OCTET_IN_GO = 3; |
|
26 | + const OCTET_IN_TO = 4; |
|
27 | + const OCTET_IN_PO = 5; |
|
28 | 28 | |
29 | 29 | public function __construct(Registry $doctrine, Kernel $kernel, $uploadDir, $allowedMimetypes) |
30 | 30 | { |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | |
51 | 51 | //checking mimetypes |
52 | 52 | $mimeTypePassed = false; |
53 | - foreach($this->allowedMimetypes as $mimeType) { |
|
54 | - if(preg_match('@'.$mimeType.'@', $file->getMimeType())) |
|
53 | + foreach ($this->allowedMimetypes as $mimeType) { |
|
54 | + if (preg_match('@'.$mimeType.'@', $file->getMimeType())) |
|
55 | 55 | { |
56 | 56 | $mimeTypePassed = true; |
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
60 | - if(!$mimeTypePassed) { |
|
60 | + if (!$mimeTypePassed) { |
|
61 | 61 | throw new InvalidMimeTypeException; |
62 | 62 | } |
63 | 63 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | // Checking for a media with the same name |
83 | 83 | $mediaExists = $this->doctrine->getRepository('MediaBundle:Media')->findOneByUri($dest_folder.$filename); |
84 | - if(count($mediaExists) === 0) { |
|
84 | + if (count($mediaExists) === 0) { |
|
85 | 85 | $mediaExists = $fs->exists($this->uploadDir.$dest_folder.$filename); |
86 | 86 | } |
87 | 87 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | |
186 | 186 | public function setAllowedMimeTypes(array $type) |
187 | 187 | { |
188 | - if($type !== null) { |
|
188 | + if ($type !== null) { |
|
189 | 189 | $this->allowedMimetypes = $type; |
190 | 190 | } |
191 | 191 | |
@@ -199,8 +199,8 @@ discard block |
||
199 | 199 | |
200 | 200 | public function convertOctetIn($size, $convert) |
201 | 201 | { |
202 | - if($convert > 0) { |
|
203 | - $size = ($size / self::SIZE_OF_KIBIOCTET) * 1; |
|
202 | + if ($convert > 0) { |
|
203 | + $size = ($size / self::SIZE_OF_KIBIOCTET) * 1; |
|
204 | 204 | return $this->convertOctetIn($size, $convert - 1); |
205 | 205 | } |
206 | 206 |
@@ -16,9 +16,9 @@ |
||
16 | 16 | |
17 | 17 | public function onPostSubmit(MediaEvent $event) |
18 | 18 | { |
19 | - $media = $event->getMedia(); |
|
19 | + $media = $event->getMedia(); |
|
20 | 20 | |
21 | - if($media !== null) { |
|
21 | + if ($media !== null) { |
|
22 | 22 | $media->setLifetime(null); |
23 | 23 | $this->registry->getManager()->persist($media); |
24 | 24 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | */ |
20 | 20 | public function uploadAction() |
21 | 21 | { |
22 | - $returnData = array(); |
|
22 | + $returnData = array(); |
|
23 | 23 | |
24 | 24 | if ($this->get('request')->get('lifetime') !== null) { |
25 | 25 | $lifetime = new \DateTime($this->get('request')->get('lifetime')); |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | |
32 | 32 | $mediaPreview = $this->container->get('twig.extension.media_preview_extension'); |
33 | 33 | foreach ($this->get('request')->files as $files) { |
34 | - if(!is_array($files)) |
|
34 | + if (!is_array($files)) |
|
35 | 35 | $files = array($files); |
36 | - foreach($files as $file) { |
|
36 | + foreach ($files as $file) { |
|
37 | 37 | $media = $this->get('media')->upload($file, $this->get('request')->get('folder'), $lifetime); |
38 | 38 | $path = $mediaPreview->generatePathFromSecretKey($media->getSecretKey()); |
39 | 39 | $returnData[] = array( |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | $src = $this->get('media')->getAbsolutePath($media); |
91 | 91 | $isImage = @getimagesize($src); |
92 | 92 | |
93 | - if($isImage) { |
|
93 | + if ($isImage) { |
|
94 | 94 | $response->headers->set('Content-disposition', 'inline;filename='.$media->getName()); |
95 | 95 | if (!empty($filter) && $isImage) { |
96 | 96 | |
97 | 97 | $src = $this->get('media')->getAbsolutePath($media, $filter); |
98 | - $dataManager = $this->get('liip_imagine.data.manager'); // the data manager service |
|
99 | - $filterManager = $this->get('liip_imagine.filter.manager');// the filter manager service |
|
98 | + $dataManager = $this->get('liip_imagine.data.manager'); // the data manager service |
|
99 | + $filterManager = $this->get('liip_imagine.filter.manager'); // the filter manager service |
|
100 | 100 | |
101 | 101 | $uploadDir = $this->get('media')->getUploadDir($filter); |
102 | 102 | |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | $path = 'upload/'.$media->getUri(); |
110 | - $image = $dataManager->find($filter, $path); // find the image and determine its type |
|
111 | - $responseData = $filterManager->applyFilter($image, $filter); // run the filter |
|
112 | - $data = $responseData->getContent(); // get the image from the response |
|
110 | + $image = $dataManager->find($filter, $path); // find the image and determine its type |
|
111 | + $responseData = $filterManager->applyFilter($image, $filter); // run the filter |
|
112 | + $data = $responseData->getContent(); // get the image from the response |
|
113 | 113 | file_put_contents($uploadDir.$media->getUri(), $data); |
114 | 114 | } else { |
115 | 115 | $data = file_get_contents($src); |