X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-core%2Fupdate-gosa;h=8107fd7c910f32433a4151d42df0cf0f14c61e4f;hb=198fc11cacca32ca2c0dc33505bde39a38b999e6;hp=ace236ae48befbb608990b2b8adcf192093c23c2;hpb=65bfb157b04025de1afe4c07c0615150dc471818;p=gosa.git diff --git a/gosa-core/update-gosa b/gosa-core/update-gosa index ace236ae4..8107fd7c9 100755 --- a/gosa-core/update-gosa +++ b/gosa-core/update-gosa @@ -2,7 +2,7 @@ read())) { + if ($entry[0] != '.') { + $themes[]= basename($entry); + } + } + $d->close(); + + return $themes; +} + /* Function to include all class_ files starting at a given directory base */ function get_classes($folder= ".") { @@ -535,6 +549,8 @@ function rescan_images($path, $theme) $styles= array(); $duplicates= array(); + echo "Updating master image for theme '$theme'..."; + // Check for image magick convert if (!function_exists("imageFilter")){ exec("which convert", $res, $ret); @@ -544,27 +560,26 @@ function rescan_images($path, $theme) } // Scan for images in the given path - echo "Scanning for images"; flush(); foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $fileInfo) { // We're only interested in png files $indexPath= substr($fileInfo->getPathname(), $baseLength + 1); $path= $fileInfo->getPathname(); - if (preg_match('/\.png$/', $indexPath) && !preg_match('/\.svn/', $path) && !preg_match('/themes\/[^\/]+\/img.png$/', $path)){ + if (preg_match('/\.png$/', $indexPath) && !preg_match('/\.svn/', $path) && !preg_match('/themes\/[^\/]+\/images\/img.png$/', $path)){ // 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; } @@ -584,9 +599,10 @@ function rescan_images($path, $theme) // Is this image already there? $checksum= md5_file($path); if (in_array($checksum, $checksums)) { - $warnings[]= "Warning: images $indexPath seems to be a duplicate of ".array_search($checksum, $checksums); + $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 +702,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 +725,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,7 +749,12 @@ function rescan_images($path, $theme) flush(); } - imagePNG($dst, "html/themes/$theme/img.png", 9); + /* Add duplicates */ + foreach ($duplicates as $imagePath => $realPath) { + $styles[$imagePath]= $styles[$realPath]; + } + + imagePNG($dst, "html/themes/$theme/images/img.png", 9); imageDestroy($dst); // Show warnings images @@ -768,8 +780,10 @@ if ($argc < 2){ rescan_classes(); rescan_i18n(); rescan_guide(); - rescan_images("html", "modern"); - exit (0); + foreach (get_themes() as $theme) { + rescan_images(GOSA_HOME."/html", $theme); + } + exit (0); } switch ($argv[1]){ @@ -799,7 +813,9 @@ switch ($argv[1]){ rescan_classes(); break; case 'rescan-images': - rescan_images("html", "modern"); + foreach (get_themes() as $theme) { + rescan_images("html", $theme); + } break; default: echo "Error: Supplied command not known\n\n";