Code

Dont throw away the hidden inputs..
[gosa.git] / gosa-core / update-gosa
index ace236ae48befbb608990b2b8adcf192093c23c2..c94fe9809fc0b7fc9212729fc86ed57d57cf831b 100755 (executable)
@@ -556,15 +556,15 @@ function rescan_images($path, $theme)
          // Grey image if it is not already one
          if (preg_match('/grey/', $indexPath)) {
            echo "!";
-           $warnings[]= "Warning: skipped possible grey image $path";
+           $warnings[]= "Warning: skipped possible *grey* image $path";
            flush();
            continue;
          }
 
-         // Grey image if it is not already one
-         if (preg_match('/new/', $indexPath)) {
+         // New image if it is not already one
+         if (preg_match('/new/', $indexPath) && !preg_match('/new\.png$/', $indexPath)) {
            echo "!";
-           $warnings[]= "Warning: skipped possible grey image $path";
+           $warnings[]= "Warning: skipped possible *new* image $path";
            flush();
            continue;
          }
@@ -587,6 +587,7 @@ function rescan_images($path, $theme)
            $warnings[]= "Warning: images $indexPath seems to be a duplicate of ".array_search($checksum, $checksums);
            $duplicates[$indexPath]= array_search($checksum, $checksums);
            $duplicates[$greyIndexPath]= preg_replace('/\.png$/', '-grey.png', array_search($checksum, $checksums));
+           continue;
          } else {
            $checksums[$indexPath]= $checksum;
          }
@@ -686,7 +687,7 @@ function rescan_images($path, $theme)
     // Move X cursor to the next position
     $cursorX+= $imageWidth;
 
-    $maxX=($colX > $maxX)?$colX:$maxX;
+    $maxX=($colX+$imageWidth > $maxX)?$colX+$imageWidth:$maxX;
   }
   
   // Print maximum dimensions
@@ -709,32 +710,23 @@ function rescan_images($path, $theme)
 
     // Insert source image...
 
-    // Duplicate?
-    if (isset($duplicates[$imagePath])){
-      $imageHeight= $heights[$duplicates[$imagePath]];
-      $imageWidth= $widths[$duplicates[$imagePath]];
-      $x= $posX[$duplicates[$imagePath]];
-      $y= $posY[$duplicates[$imagePath]];
-    } else {
-
-      // Eventually convert it to grey before
-      if (preg_match('/-grey\.png$/', $imagePath)) {
-        if (!function_exists("imageFilter")){
-          exec("convert ".$paths[$imagePath]." -colorspace Gray /tmp/grey-converted.png");
-          $src= imageCreateFromPng("/tmp/grey-converted.png");
-        } else {
-          $src= imageCreateFromPng($paths[$imagePath]);
-          imageFilter($src, IMG_FILTER_GRAYSCALE);
-        }
+    // Eventually convert it to grey before
+    if (preg_match('/-grey\.png$/', $imagePath)) {
+      if (!function_exists("imageFilter")){
+        exec("convert ".$paths[$imagePath]." -colorspace Gray /tmp/grey-converted.png");
+        $src= imageCreateFromPng("/tmp/grey-converted.png");
       } else {
         $src= imageCreateFromPng($paths[$imagePath]);
+        imageFilter($src, IMG_FILTER_GRAYSCALE);
       }
-
-      // Merge image
-      imageCopyResampled($dst, $src, $x, $y, 0, 0, $imageWidth, $imageHeight, $imageWidth, $imageHeight);
-      imageDestroy($src);
+    } else {
+      $src= imageCreateFromPng($paths[$imagePath]);
     }
 
+    // Merge image
+    imageCopyResampled($dst, $src, $x, $y, 0, 0, $imageWidth, $imageHeight, $imageWidth, $imageHeight);
+    imageDestroy($src);
+
     // Store style
     $styles[$imagePath]= "background-position:-".$x."px -".$y."px;width:".$imageWidth."px;height:".$imageHeight."px";
 
@@ -742,6 +734,11 @@ function rescan_images($path, $theme)
     flush();
   }
 
+  /* Add duplicates */
+  foreach ($duplicates as $imagePath => $realPath) {
+    $styles[$imagePath]= $styles[$realPath];
+  }
+
   imagePNG($dst, "html/themes/$theme/img.png", 9);
   imageDestroy($dst);