Code

Updated locales
[gosa.git] / gosa-core / update-gosa
index 2e54a2aa91df52e7754e3796cd2081bbfb45c1cb..7e65804a7cebddf8339ab96e936317a09febf2a7 100755 (executable)
@@ -2,7 +2,7 @@
 <?php
 /*
  * This code is part of GOsa (http://www.gosa-project.org)
- * Copyright (C) 2003-2008 GONICUS GmbH
+ * Copyright (C) 2003-2010 GONICUS GmbH
  *
  * ID: $$Id: main.php 9254 2008-03-03 15:57:49Z cajus $$
  *
@@ -39,6 +39,8 @@ Usage: update-gosa install dsc     Install the plugin using the dsc information
 
        update-gosa rescan-i18n     Rebuilds the translations
 
+       update-gosa rescan-images   Rebuilds the themes master image
+
        update-gosa rescan-classes  Rebuilds the class list
        
        update-gosa                 Shortcut for rescan-classes and rescan-i18n
@@ -61,6 +63,20 @@ function rmdirRecursive($path, $followLinks=false) {
 }
 
 
+function get_themes()
+{
+  $themes= array();
+  $d = dir(GOSA_HOME."/html/themes");
+  while (false !== ($entry = $d->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= ".")
 {
@@ -81,7 +97,7 @@ function get_classes($folder= ".")
   }
 
   $dh = opendir(".");
-  while(false !== ($file = readdir($dh))){
+  while(is_resource($dh) && false !== ($file = readdir($dh))){
 
     if (preg_match("/.*\.svn.*/", $file) ||
         preg_match("/.*smarty.*/i",$file) ||
@@ -91,7 +107,7 @@ function get_classes($folder= ".")
     }
 
     /* Recurse through all "common" directories */
-    if (is_dir($file)){
+    if (is_dir($file) && !file_exists("{$file}/excludeFromAutoLoad")){
       get_classes($file);
       continue;
     }
@@ -112,7 +128,7 @@ function get_classes($folder= ".")
     }
   }
 
-  closedir($dh);
+  @closedir($dh);
   chdir($currdir);
 
   return ($result);
@@ -193,58 +209,6 @@ function rescan_i18n()
 }
 
 
-function rescan_guide()
-{
-       $master_guide= "doc/guide.xml";
-       echo "Updating Online Help Index...\n";
-       $master_guide_content="<?xml version=\"1.0\"?>\n".
-               "<!--\n".
-               "\tWARNING:\n".
-               "\tThis file is automatically generated by update-online-help.\n".
-               "\tIf you want to add entries, use doc/core/guide.xml or doc/plugins/\"Appropriate Plugin Directory\"/guide.xml.\n".
-               "\tThen execute update-online-help to merge them into this file.\n".
-               "-->\n\n".
-               "<!--\n".
-               "\tThis xml file specifies which class is documented in which help file.\n".
-               "\tIf isset ( \$_SESSION['current_class_for_help'] ) then open the helpfile which is\n".
-               "\tspecified for this class below.\n".
-               "-->\n\n".
-               "<!--\n".
-               "\t<ENTRY NAME='class name' VALUE='displayed text' PATH='path to helpfiles' FILE='path to htmlfile' />\n".
-               "\tLeave blank to display message \"There is no helpfile specified for this class.\"\n".
-               "-->\n".
-               "<ENTRIES>\n";
-
-       $guide= 'doc/core/guide.xml';
-       if(file_exists($guide) && is_readable($guide)) {
-               $master_guide_content.= file_get_contents($guide);
-       }
-       
-       if(file_exists('doc/plugins')) {
-               $plugins= scandir('doc/plugins');
-               foreach($plugins as $key => $plugin) {
-                       if($plugin != '.' && $plugin != '..') {
-                               if(is_dir('doc/plugins/'.$plugin)) {
-                                       $guide= 'doc/plugins/'.$plugin.'/guide.xml';
-                                       if(file_exists($guide) && is_readable($guide)) {
-                                               $master_guide_content.= file_get_contents($guide);
-                                       }
-                               }
-                       }
-               }
-       }
-
-       $master_guide_content.= "</ENTRIES>";
-       
-       $master_guide_content= preg_replace("/[ \t][ \t]*/", " ", $master_guide_content);
-
-       if((file_exists($master_guide) && is_writable($master_guide)) || is_writable('doc')) {
-               file_put_contents($master_guide, $master_guide_content);
-       }
-
-}
-
-
 function parse_ini($file)
 {
        global $description, $provides, $depends, $versions, $conflicts;
@@ -459,7 +423,6 @@ function install_plugin($file)
        /* Update caches */
        rescan_classes();
        rescan_i18n();
-       rescan_guide();
 }
 
 
@@ -517,7 +480,6 @@ function remove_plugin($name)
        /* Update caches */
        rescan_classes();
        rescan_i18n();
-       rescan_guide();
 }
 
 
@@ -535,6 +497,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,7 +508,6 @@ 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) {
   
@@ -556,7 +519,7 @@ 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;
          }
@@ -564,7 +527,7 @@ function rescan_images($path, $theme)
          // New image if it is not already one
          if (preg_match('/new/', $indexPath) && !preg_match('/new\.png$/', $indexPath)) {
            echo "!";
-           $warnings[]= "Warning: skipped possible *new* image $path";
+           $warnings[]= "Warning: skipped possible *new* image $path";
            flush();
            continue;
          }
@@ -584,7 +547,7 @@ 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;
@@ -739,7 +702,7 @@ function rescan_images($path, $theme)
     $styles[$imagePath]= $styles[$realPath];
   }
 
-  imagePNG($dst, "html/themes/$theme/images/img.png", 9);
+  imagePNG($dst, GOSA_HOME."/html/themes/$theme/images/img.png", 9);
   imageDestroy($dst);
 
   // Show warnings images
@@ -749,7 +712,7 @@ function rescan_images($path, $theme)
 
   // Write styles
   echo "Writing styles...";
-  $fp = fopen("ihtml/themes/$theme/img.styles", 'w');
+  $fp = fopen(GOSA_HOME."/ihtml/themes/$theme/img.styles", 'w');
   fwrite($fp, serialize($styles));
   fclose($fp);
 
@@ -764,9 +727,10 @@ $description= $provides= $depends= $versions= $conflicts= array();
 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]){
@@ -796,7 +760,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";