Completed
Branch master (50f5f9)
by Mariusz
04:51
created
src/extensions/SVGExtension.php 3 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -14,64 +14,64 @@
 block discarded – undo
14 14
 
15 15
 class SVGExtension extends DataExtension
16 16
 {
17
-  /**
18
-   * Check file extension SVG
19
-   * @return boolean
20
-   */
21
-  public function isSVG(){
17
+    /**
18
+     * Check file extension SVG
19
+     * @return boolean
20
+     */
21
+    public function isSVG(){
22 22
     if($this->owner->getExtension()=='svg') return true;
23 23
     return false;
24
-  }
24
+    }
25 25
 
26
-  /**
27
-   *
28
-   * SVG RAW LINE
29
-   * @return string|boolean
30
-   */
31
-  public function SVGRAW(){
26
+    /**
27
+     *
28
+     * SVG RAW LINE
29
+     * @return string|boolean
30
+     */
31
+    public function SVGRAW(){
32 32
     if($this->owner->getExtension() != 'svg'){
33
-      return false;
33
+        return false;
34 34
     }
35 35
     $metadata = $this->owner->File->getMetadata();
36 36
     if(array_key_exists('path', $metadata)){
37
-      $filePath = ASSETS_PATH . DIRECTORY_SEPARATOR . $metadata['path'];
38
-      if (file_exists($filePath)) {
37
+        $filePath = ASSETS_PATH . DIRECTORY_SEPARATOR . $metadata['path'];
38
+        if (file_exists($filePath)) {
39 39
 
40 40
         $data = file_get_contents($filePath);
41 41
         if(strpos($data, 'svg') !== false){
42
-          $buffer = trim(preg_replace( "/\r|\n/", "",$data));
43
-          $html = DBHTMLText::create();
44
-          $html->setValue($buffer);
45
-          return $html;
42
+            $buffer = trim(preg_replace( "/\r|\n/", "",$data));
43
+            $html = DBHTMLText::create();
44
+            $html->setValue($buffer);
45
+            return $html;
46
+        }
46 47
         }
47
-      }
48 48
 
49 49
     }
50 50
     return false;
51
-  }
51
+    }
52 52
 
53 53
 
54
-  public function ImageOrSVG(){
54
+    public function ImageOrSVG(){
55 55
     if($this->SVGRAW()){
56
-      return $this->SVGRAW();
56
+        return $this->SVGRAW();
57 57
     }
58 58
     return $this->owner->File->getURL();
59
-  }
59
+    }
60 60
 
61
-  public function getThumbnail(){
61
+    public function getThumbnail(){
62 62
     if($this->owner->ID){
63 63
 
64
-      if($this->owner->getExtension() == 'svg'){
64
+        if($this->owner->getExtension() == 'svg'){
65 65
         $obj= DBHTMLText::create();
66 66
         $obj->setValue(file_get_contents(BASE_PATH.$this->owner->Link()));
67 67
         return ($obj);
68
-      }else {
68
+        }else {
69 69
         return $this->owner->CMSThumbnail();
70
-      }
70
+        }
71 71
     }
72 72
     else
73 73
     {
74
-      return '(No Image)';
74
+        return '(No Image)';
75
+    }
75 76
     }
76
-  }
77 77
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
    * Check file extension SVG
19 19
    * @return boolean
20 20
    */
21
-  public function isSVG(){
22
-    if($this->owner->getExtension()=='svg') return true;
21
+  public function isSVG() {
22
+    if ($this->owner->getExtension() == 'svg') return true;
23 23
     return false;
24 24
   }
25 25
 
@@ -28,18 +28,18 @@  discard block
 block discarded – undo
28 28
    * SVG RAW LINE
29 29
    * @return string|boolean
30 30
    */
31
-  public function SVGRAW(){
32
-    if($this->owner->getExtension() != 'svg'){
31
+  public function SVGRAW() {
32
+    if ($this->owner->getExtension() != 'svg') {
33 33
       return false;
34 34
     }
35 35
     $metadata = $this->owner->File->getMetadata();
36
-    if(array_key_exists('path', $metadata)){
37
-      $filePath = ASSETS_PATH . DIRECTORY_SEPARATOR . $metadata['path'];
36
+    if (array_key_exists('path', $metadata)) {
37
+      $filePath = ASSETS_PATH . DIRECTORY_SEPARATOR . $metadata[ 'path' ];
38 38
       if (file_exists($filePath)) {
39 39
 
40 40
         $data = file_get_contents($filePath);
41
-        if(strpos($data, 'svg') !== false){
42
-          $buffer = trim(preg_replace( "/\r|\n/", "",$data));
41
+        if (strpos($data, 'svg') !== false) {
42
+          $buffer = trim(preg_replace("/\r|\n/", "", $data));
43 43
           $html = DBHTMLText::create();
44 44
           $html->setValue($buffer);
45 45
           return $html;
@@ -51,21 +51,21 @@  discard block
 block discarded – undo
51 51
   }
52 52
 
53 53
 
54
-  public function ImageOrSVG(){
55
-    if($this->SVGRAW()){
54
+  public function ImageOrSVG() {
55
+    if ($this->SVGRAW()) {
56 56
       return $this->SVGRAW();
57 57
     }
58 58
     return $this->owner->File->getURL();
59 59
   }
60 60
 
61
-  public function getThumbnail(){
62
-    if($this->owner->ID){
61
+  public function getThumbnail() {
62
+    if ($this->owner->ID) {
63 63
 
64
-      if($this->owner->getExtension() == 'svg'){
65
-        $obj= DBHTMLText::create();
66
-        $obj->setValue(file_get_contents(BASE_PATH.$this->owner->Link()));
64
+      if ($this->owner->getExtension() == 'svg') {
65
+        $obj = DBHTMLText::create();
66
+        $obj->setValue(file_get_contents(BASE_PATH . $this->owner->Link()));
67 67
         return ($obj);
68
-      }else {
68
+      } else {
69 69
         return $this->owner->CMSThumbnail();
70 70
       }
71 71
     }
Please login to merge, or discard this patch.
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,7 +19,9 @@  discard block
 block discarded – undo
19 19
    * @return boolean
20 20
    */
21 21
   public function isSVG(){
22
-    if($this->owner->getExtension()=='svg') return true;
22
+    if($this->owner->getExtension()=='svg') {
23
+        return true;
24
+    }
23 25
     return false;
24 26
   }
25 27
 
@@ -65,11 +67,10 @@  discard block
 block discarded – undo
65 67
         $obj= DBHTMLText::create();
66 68
         $obj->setValue(file_get_contents(BASE_PATH.$this->owner->Link()));
67 69
         return ($obj);
68
-      }else {
70
+      } else {
69 71
         return $this->owner->CMSThumbnail();
70 72
       }
71
-    }
72
-    else
73
+    } else
73 74
     {
74 75
       return '(No Image)';
75 76
     }
Please login to merge, or discard this patch.
src/models/IconSVG.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
         $fields->addFieldToTab('Root.Main', TextField::create('Title', 'Title'));
45 45
         $fields->addFieldToTab('Root.Main',
46 46
             UploadField::create('Image', 'Image Icon')
47
-                ->setAllowedExtensions(['svg', 'png', 'jpg', 'jpeg'])
47
+                ->setAllowedExtensions([ 'svg', 'png', 'jpg', 'jpeg' ])
48 48
                 ->setRightTitle('(only .svg , .jpg, .png, .jpeg)'));
49 49
 
50 50
         return $fields;
Please login to merge, or discard this patch.
src/admin/IconsAdmin.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,23 +14,23 @@
 block discarded – undo
14 14
 
15 15
 class IconsAdmin extends ModelAdmin
16 16
 {
17
-  private static $url_segment = 'icons';
17
+    private static $url_segment = 'icons';
18 18
 
19
-  private static $managed_models = [
19
+    private static $managed_models = [
20 20
     IconSVG::class,
21 21
 
22
-  ];
22
+    ];
23 23
 
24
-  private static  $menu_icon_class  = 'font-icon-picture';
24
+    private static  $menu_icon_class  = 'font-icon-picture';
25 25
 
26
-  private static $menu_title = 'Icons';
26
+    private static $menu_title = 'Icons';
27 27
 
28
-  public function getEditForm($id = null, $fields = null)
29
-  {
28
+    public function getEditForm($id = null, $fields = null)
29
+    {
30 30
 
31 31
     $form = parent::getEditForm($id, $fields);
32 32
 
33 33
     return $form;
34
-  }
34
+    }
35 35
 
36 36
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 
22 22
   ];
23 23
 
24
-  private static  $menu_icon_class  = 'font-icon-picture';
24
+  private static  $menu_icon_class = 'font-icon-picture';
25 25
 
26 26
   private static $menu_title = 'Icons';
27 27
 
Please login to merge, or discard this patch.