Completed
Pull Request — master (#3)
by
unknown
05:10
created
Controller/MediasController.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -97,6 +97,9 @@
 block discarded – undo
97 97
         }
98 98
     }
99 99
 
100
+    /**
101
+     * @param \Symfony\Component\HttpFoundation\FileBag $file
102
+     */
100 103
     private function initEvent($file,$model,$model_id)
101 104
     {
102 105
         $event = new UploadEvent();
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
                     'bundle'=>$bundle,
81 81
                 ]);
82 82
                 return JsonResponse($event->getMedia());
83
-            }else{
83
+            } else{
84 84
                 $response = new Response();
85 85
                 $response->setContent(json_encode(array(
86 86
                     'error'=>"Le format n'est pas valid"
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
                     'bundle'=>$bundle,
126 126
                     'model_id'=>$model_id
127 127
                 ]);
128
-            }else{
128
+            } else{
129 129
                 $response = new Response();
130 130
                 $response->setContent(json_encode(array(
131 131
                     'error'=>"Le format n'est pas valid"
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
                 'alt'=>$request->get('alt')
188 188
             ];
189 189
             $params['media'] = $this->getManage()->getRepository('MykeesMediaBundle:Media')->findOneBy(['name'=>$params['alt'],'model'=>$model]);
190
-        }else{
190
+        } else{
191 191
             $params = [
192 192
                 'media'=>$this->getManage()->getRepository('MykeesMediaBundle:Media')->find($id),
193 193
                 'class'=>null
Please login to merge, or discard this patch.
Manager/MediaManager.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -109,6 +109,9 @@
 block discarded – undo
109 109
         return $this->em->getRepository('MykeesMediaBundle:Media')->queryForModelAndId($model,$model_id);
110 110
     }
111 111
 
112
+    /**
113
+     * @param string $model
114
+     */
112 115
     public function unlink($model, Media $media)
113 116
     {
114 117
         $info  = pathinfo($media->getFile());
Please login to merge, or discard this patch.
Util/Urlizer.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -232,6 +232,7 @@
 block discarded – undo
232 232
     * Note: this function has been modified to simple return true or false
233 233
     * @author <[email protected]>
234 234
     * @param string UTF-8 encoded string
235
+    * @param string $str
235 236
     * @return boolean true if valid
236 237
     * @see http://hsivonen.iki.fi/php-utf8/
237 238
     */
Please login to merge, or discard this patch.
Braces   +31 added lines, -9 removed lines patch added patch discarded remove patch
@@ -39,17 +39,39 @@
 block discarded – undo
39 39
     {
40 40
         $stringLength = strlen($string);
41 41
         for ($i = 0; $i < $stringLength; $i++) {
42
-            if (ord($string[$i]) < 0x80) continue; # 0bbbbbbb
43
-            elseif ((ord($string[$i]) & 0xE0) == 0xC0) $n=1; # 110bbbbb
44
-            elseif ((ord($string[$i]) & 0xF0) == 0xE0) $n=2; # 1110bbbb
45
-            elseif ((ord($string[$i]) & 0xF8) == 0xF0) $n=3; # 11110bbb
46
-            elseif ((ord($string[$i]) & 0xFC) == 0xF8) $n=4; # 111110bb
47
-            elseif ((ord($string[$i]) & 0xFE) == 0xFC) $n=5; # 1111110b
48
-            else return false; # Does not match any model
49
-            for ($j=0; $j<$n; $j++) { # n bytes matching 10bbbbbb follow ?
50
-                if ((++$i == strlen($string)) || ((ord($string[$i]) & 0xC0) != 0x80))
42
+            if (ord($string[$i]) < 0x80) {
43
+                continue;
44
+            }
45
+            # 0bbbbbbb
46
+            elseif ((ord($string[$i]) & 0xE0) == 0xC0) {
47
+                $n=1;
48
+            }
49
+            # 110bbbbb
50
+            elseif ((ord($string[$i]) & 0xF0) == 0xE0) {
51
+                $n=2;
52
+            }
53
+            # 1110bbbb
54
+            elseif ((ord($string[$i]) & 0xF8) == 0xF0) {
55
+                $n=3;
56
+            }
57
+            # 11110bbb
58
+            elseif ((ord($string[$i]) & 0xFC) == 0xF8) {
59
+                $n=4;
60
+            }
61
+            # 111110bb
62
+            elseif ((ord($string[$i]) & 0xFE) == 0xFC) {
63
+                $n=5;
64
+            }
65
+            # 1111110b
66
+            else {
51 67
                 return false;
52 68
             }
69
+            # Does not match any model
70
+            for ($j=0; $j<$n; $j++) { # n bytes matching 10bbbbbb follow ?
71
+                if ((++$i == strlen($string)) || ((ord($string[$i]) & 0xC0) != 0x80)) {
72
+                                return false;
73
+                }
74
+            }
53 75
         }
54 76
         return true;
55 77
     }
Please login to merge, or discard this patch.