소스 검색

Minor - format code, fix php warning

jmontoyaa 7 년 전
부모
커밋
810d818b71
2개의 변경된 파일27개의 추가작업 그리고 18개의 파일을 삭제
  1. 1 3
      main/inc/lib/extra_field_value.lib.php
  2. 26 15
      main/inc/lib/image.lib.php

+ 1 - 3
main/inc/lib/extra_field_value.lib.php

@@ -135,10 +135,9 @@ class ExtraFieldValue extends Model
                 }
             }
 
+            $value = '';
             if (isset($params['extra_'.$field_variable])) {
                 $value = $params['extra_'.$field_variable];
-            } else {
-                $value = '';
             }
 
             $resultsExist[$field_variable] = isset($value) && $value !== '' ? true : false;
@@ -226,7 +225,6 @@ class ExtraFieldValue extends Model
                         $fieldRelTag->setFieldId($extraFieldInfo['id']);
                         $fieldRelTag->setItemId($params['item_id']);
                         $fieldRelTag->setTagId($tag->getId());
-
                         $em->persist($fieldRelTag);
                     }
 

+ 26 - 15
main/inc/lib/image.lib.php

@@ -61,26 +61,35 @@ class Image
         }
     }
 
+    /**
+     * @param $cropParameters
+     * @return bool
+     */
     public function crop($cropParameters)
     {
         $image_size = $this->get_image_size($this->image_wrapper->path);
         $src_width = $image_size['width'];
         $src_height = $image_size['height'];
-        $cropParameters = explode(",", $cropParameters);
-        $x = intval($cropParameters[0]);
-        $y = intval($cropParameters[1]);
-        $width = intval($cropParameters[2]);
-        $height = intval($cropParameters[3]);
-
-        $image = $this->image_wrapper->crop(
-            $x,
-            $y,
-            $width,
-            $height,
-            $src_width,
-            $src_height
-        );
-        return $image;
+        $cropParameters = explode(',', $cropParameters);
+
+        if (isset($cropParameters[0]) && isset($cropParameters[1])) {
+            $x = intval($cropParameters[0]);
+            $y = intval($cropParameters[1]);
+            $width = intval($cropParameters[2]);
+            $height = intval($cropParameters[3]);
+
+            $image = $this->image_wrapper->crop(
+                $x,
+                $y,
+                $width,
+                $height,
+                $src_width,
+                $src_height
+            );
+            return $image;
+        }
+
+        return false;
     }
 
     /**
@@ -257,6 +266,7 @@ class ImagickWrapper extends ImageWrapper
      * @param int $height the height of the crop
      * @param int $src_width the source width of the original image
      * @param int $src_height the source height of the original image
+     * @return bool
      */
     public function crop($x, $y, $width, $height, $src_width, $src_height)
     {
@@ -266,6 +276,7 @@ class ImagickWrapper extends ImageWrapper
         $this->image->cropimage($width, $height, $x, $y);
         $this->width = $width;
         $this->height = $height;
+        return true;
     }
 
     public function send_image(