Code

Updated path rendering
[gosa.git] / gosa-core / update-gosa
1 #!/usr/bin/php
2 <?php
3 /*
4  * This code is part of GOsa (http://www.gosa-project.org)
5  * Copyright (C) 2003-2008 GONICUS GmbH
6  *
7  * ID: $$Id: main.php 9254 2008-03-03 15:57:49Z cajus $$
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  */
24 define ("GOSA_HOME", dirname(__FILE__));
25 define ("LOCALE_DIR", GOSA_HOME."/locale");
26 define ("PLUGSTATE_DIR", GOSA_HOME."/state");
28 function print_usage()
29 {
30         ?>
31 update-gosa - class cache updated and plugin manager for GOsa
32 Usage: update-gosa install dsc     Install the plugin using the dsc information
33                                    placed in the plugin source directory.
35        update-gosa remove plugin   Remove the plugin named "plugin" from
36                                    the current configuration.
38        update-gosa list           Lists installed plugins
40        update-gosa rescan-i18n     Rebuilds the translations
42        update-gosa rescan-classes  Rebuilds the class list
43        
44        update-gosa                 Shortcut for rescan-classes and rescan-i18n
45 <?php
46         exit (1);
47 }
50 function rmdirRecursive($path, $followLinks=false) {
51   $dir= opendir($path);
52   while($entry= readdir($dir)) {
53     if(is_file($path."/".$entry) || ((!$followLinks) && is_link($path."/".$entry))) {
54       unlink($path."/".$entry);
55     } elseif (is_dir($path."/".$entry) && $entry!='.' && $entry!='..') {
56       rmdirRecursive($path."/".$entry);
57     }
58   }
59   closedir($dir);
60   return rmdir($path);
61 }
64 /* Function to include all class_ files starting at a given directory base */
65 function get_classes($folder= ".")
66 {
67   static $base_dir= "";
68   static $result= array();
70   if ($base_dir == ""){
71     if ($folder == "."){
72       $base_dir= getcwd();
73     } else {
74       $base_dir= $folder;
75     }
76   }
78   $currdir=getcwd();
79   if ($folder){
80     chdir("$folder");
81   }
83   $dh = opendir(".");
84   while(false !== ($file = readdir($dh))){
86     if (preg_match("/.*\.svn.*/", $file) ||
87         preg_match("/.*smarty.*/i",$file) ||
88         preg_match("/.*\.tpl.*/",$file) ||
89         ($file==".") ||($file =="..")){
90       continue;
91     }
93     /* Recurse through all "common" directories */
94     if (is_dir($file)){
95       get_classes($file);
96       continue;
97     }
99     /* Only take care about .inc and .php files... */
100     if (!(preg_match('/\.php$/', $file) || preg_match('/\.inc$/', $file))){
101       continue;
102     }
104     /* Include existing class_ files */
105     $contents= file($file);
106     foreach($contents as $line){
107       $line= chop($line);
108       if (preg_match('/^\s*class\s*\w.*$/', $line)){
109         $class= preg_replace('/^\s*class\s*(\w+).*$/', '\1', $line);
110         $result[$class]= preg_replace("%$base_dir/%", "", "$currdir/$folder/$file");
111       }
112     }
113   }
115   closedir($dh);
116   chdir($currdir);
118   return ($result);
122 function rescan_classes()
124         echo "Updating class cache...\n";
125         $class_mapping= get_classes();
126         $filename= GOSA_HOME."/include/class_location.inc";
128         /* Sanity checks */
129         if (!file_exists($filename) || is_writable($filename)) {
131             if (!$handle= fopen($filename, 'w')) {
132                  echo "Cannot open file \"$filename\" - aborted\n";
133                  exit (1);
134             }
136         } else {
137             echo "File \"$filename\" is not writable - aborted\n";
138             exit (2);
139         }
141         fwrite ($handle, "<?php\n\$class_mapping= array(\n");
142         foreach ($class_mapping as $key => $value){
143           fwrite ($handle, "                \"$key\" => \"$value\",\n");
144         }
145         fwrite ($handle, " );\n");
147         fclose($handle);
151 function rescan_i18n()
153         echo "Updating internationalization...\n";
154         $languages= array();
155         $size= strlen(LOCALE_DIR);
157         /* Get all available messages.po files, sort them for languages */
158         $dir= new RecursiveDirectoryIterator(LOCALE_DIR);
159         $all= new RecursiveIteratorIterator($dir);
160         foreach ( $all as $element ){
161                 if ($element->isFile() && preg_match('/\/LC_MESSAGES\/messages.po$/', $element->getPathname())){
162                         $lang= preg_replace('/^.*\/([^\/]+)\/LC_MESSAGES\/.*$/', '\1', $element);
163                         if (!isset($languages[$lang])){
164                                 $languages[$lang]= array();
165                         }
166                         $languages[$lang][]= substr($element->getPathName(), $size+1);
167                 }
168         }
170         /* For each language, merge the target .mo to the compiled directory. */
171         foreach ($languages as $language => $po_files){
172                 if (!is_dir(LOCALE_DIR."/compiled/${language}/LC_MESSAGES")){
173                         if (!mkdir (LOCALE_DIR."/compiled/${language}/LC_MESSAGES", 0755, TRUE)){
174                                 echo "Failed to create '".LOCALE_DIR."/compiled/${language}/LC_MESSAGES'- aborted";
175                                 exit (3);
176                         }
177                 }
179                 /* Cat all these po files into one single file */
180                 system ("(cd ".LOCALE_DIR." && msgcat --use-first ".implode(" ", $po_files)." > compiled/${language}/LC_MESSAGES/messages.po)", $val);
181                 if ($val != 0){
182                         echo "Merging of message files failed - aborted";
183                         exit (4);
184                 }
185                 system ("(cd ".LOCALE_DIR."/compiled/${language}/LC_MESSAGES && msgfmt -o messages.mo messages.po && rm messages.po)", $val);
186                 if ($val != 0){
187                         echo "Compiling of message files failed - aborted";
188                         exit (5);
189                 }
190         }
192         echo "! Warning: you may need to reload your webservice!\n";
196 function rescan_guide()
198         $master_guide= "doc/guide.xml";
199         echo "Updating Online Help Index...\n";
200         $master_guide_content="<?xml version=\"1.0\"?>\n".
201                 "<!--\n".
202                 "\tWARNING:\n".
203                 "\tThis file is automatically generated by update-online-help.\n".
204                 "\tIf you want to add entries, use doc/core/guide.xml or doc/plugins/\"Appropriate Plugin Directory\"/guide.xml.\n".
205                 "\tThen execute update-online-help to merge them into this file.\n".
206                 "-->\n\n".
207                 "<!--\n".
208                 "\tThis xml file specifies which class is documented in which help file.\n".
209                 "\tIf isset ( \$_SESSION['current_class_for_help'] ) then open the helpfile which is\n".
210                 "\tspecified for this class below.\n".
211                 "-->\n\n".
212                 "<!--\n".
213                 "\t<ENTRY NAME='class name' VALUE='displayed text' PATH='path to helpfiles' FILE='path to htmlfile' />\n".
214                 "\tLeave blank to display message \"There is no helpfile specified for this class.\"\n".
215                 "-->\n".
216                 "<ENTRIES>\n";
218         $guide= 'doc/core/guide.xml';
219         if(file_exists($guide) && is_readable($guide)) {
220                 $master_guide_content.= file_get_contents($guide);
221         }
222         
223         if(file_exists('doc/plugins')) {
224                 $plugins= scandir('doc/plugins');
225                 foreach($plugins as $key => $plugin) {
226                         if($plugin != '.' && $plugin != '..') {
227                                 if(is_dir('doc/plugins/'.$plugin)) {
228                                         $guide= 'doc/plugins/'.$plugin.'/guide.xml';
229                                         if(file_exists($guide) && is_readable($guide)) {
230                                                 $master_guide_content.= file_get_contents($guide);
231                                         }
232                                 }
233                         }
234                 }
235         }
237         $master_guide_content.= "</ENTRIES>";
238         
239         $master_guide_content= preg_replace("/[ \t][ \t]*/", " ", $master_guide_content);
241         if((file_exists($master_guide) && is_writable($master_guide)) || is_writable('doc')) {
242                 file_put_contents($master_guide, $master_guide_content);
243         }
248 function parse_ini($file)
250         global $description, $provides, $depends, $versions, $conflicts;
252         $res= "";
253         if (file_exists($file)){
254                 $tmp= parse_ini_file($file, TRUE);
256                 if (isset($tmp['gosa-plugin'])){
257                         $plugin= &$tmp['gosa-plugin'];
258                         if (isset($plugin['name'])&& isset($plugin['description'])){
259                                 $res= $plugin['name'];
260                                 $description[$res]= $plugin['description'];
261                                 $versions[$res]= $plugin['version'];
262                                 $provides[$res]= $res;
263                                 if (isset($plugin['depends'])){
264                                         $depends[$res]= explode(',', preg_replace('/\s+/', '', $plugin['depends']));
265                                 }
266                                 if (isset($plugin['conflicts'])){
267                                         $conflicts[$res]= explode(',', preg_replace('/\s+/', '', $plugin['conflicts']));
268                                 }
269                         }
270                 }
271         }
273         return $res;
277 function dependency_check()
279         global $description, $provides, $depends;
281         foreach ($depends as $name => $pl_depends){
282                 foreach ($pl_depends as $pl){
283                         if (!in_array($pl, $provides)){
284                                 echo "! Error: plugin '$name' depends on '$pl' which is not provided by any plugin\n\n";
285                                 exit (1);
286                         }
287                 }
288         }
292 function load_plugins()
294         if (!is_dir(PLUGSTATE_DIR)){
295                 if (!mkdir (PLUGSTATE_DIR, 0755, TRUE)){
296                         echo "Cannot create plugstate dir '".PLUGSTATE_DIR."' - aborted\n";
297                         exit (2);
298                 }
299         }
300         $dir= new DirectoryIterator(PLUGSTATE_DIR);
301         foreach ($dir as $entry){
302                 if ($dir->isDir() && !preg_match('/^\./', $dir->__toString())){
303                         $file= $dir->getPathName()."/plugin.dsc";
304                         if (parse_ini($file) == ""){
305                                 echo "! Warning: plugin ".$dir->getPathName()." is missing declarations\n";
306                         }
307                 }
308         }
312 function list_plugins()
314         global $description, $versions;
315         $count= 0;
317         /* Load plugin list */
318         load_plugins();
320         /* Show plugins */
321         foreach ($description as $name => $dsc){
322                 if ($count == 0){
323                         echo "Plugin\t\t|Version |Description\n";
324                         echo "----------------------------------------------------------------------------\n";
325                 }
326                 $ver= $versions[$name];
327                 echo "$name\t\t|$ver\t |$dsc\n";
328                 $count++;
329         }
331         /* Yell about non existing plugins... */
332         if ($count == 0){
333                 echo "No plugins found...\n\n";
334         } else {
335                 # Check for dependencies
336                 dependency_check();
337                 echo "\n";
338         }
342 function install_plugin($file)
344         global $description, $provides, $depends, $conflicts;
346         /* Load plugin list */
347         load_plugins();
349         /* Load .dsc file */
350         if (file_exists($file)){
351                 $tmp= parse_ini_file($file, TRUE);
353                 if (isset($tmp['gosa-plugin'])){
354                         $plugin= &$tmp['gosa-plugin'];
355                         if (isset($plugin['name'])&& isset($plugin['description'])){
356                                 $name= $plugin['name'];
357                                 $description= $plugin['description'];
358                                 $depends= array();
359                                 if (isset($plugin['depends'])){
360                                         $depends= explode(',', preg_replace('/\s+/', '', $plugin['depends']));
361                                 }
363                                 /* Already installed? */
364                                 if (isset($provides[$name])){
365                                         echo "! Error: plugin already installed\n\n";
366                                         exit (3);
367                                 }
369                                 /* Check if dependencies are fullfilled */
370                                 foreach ($depends as $dep){
371                                         $found= false;
372                                         foreach ($provides as $provide => $dummy){
373                                                 if ($dep == $provide){
374                                                         $found= true;
375                                                         break;
376                                                 }
377                                         }
378                                         if (!$found){
379                                                 echo "! Error: plugin depends on '$dep', but this is not installed\n\n";
380                                                 exit (3);
381                                         }
382                                 }
384                                 /* Check for conflicts */
385                                 foreach ($conflicts as $conf){
386                                         if (!in_array($conf, $provides)){
387                                                 echo "! Warning: plugin conflicts with '$conf'\n\n";
388                                         }
389                                 }
391                                 /* Create plugstate directory and touch plugin.lst */
392                                 if (!mkdir (PLUGSTATE_DIR."/$name", 0755, TRUE)){
393                                         echo "Failed to create '".PLUGSTATE_DIR."/$name - aborted";
394                                         exit (3);
395                                 }
396                                 if (!$handle= fopen(PLUGSTATE_DIR."/$name/plugin.lst", 'w')) {
397                                         echo "Cannot open file '$filename' - aborted\n";
398                                         exit (1);
399                                 }
401                                 echo "Installing plugin '$name'...\n";
403                                 /* Copy and fill plugin.lst */
404                                 $path= dirname($file);
405                                 $dir= new RecursiveDirectoryIterator($path);
406                                 $all= new RecursiveIteratorIterator($dir);
407                                 foreach ( $all as $entry ){
408                                         $source= $path."/".substr($entry->getPathName(), strlen($path) + 1);
410                                         /* Skip description - it belongs to the state dir */
411                                         if (preg_match('/\/plugin.dsc$/', $source)){
412                                                 copy ($source, PLUGSTATE_DIR."/$name/plugin.dsc");
413                                                 continue;
414                                         }
416                                         /* Skip well known directories */
417                                         if (preg_match('/^\.+$/', $source) || preg_match('/\/\.svn\//', $source)) {
418                                                 continue;
419                                         }
421                                         /* Calculate destination */
422                                         if (preg_match("%^.*locale/%", $source)){
423                                                 $dest= GOSA_HOME."/locale/plugins/$name/".preg_replace("%^.*locale/%", "", $source);
424                                         } elseif (preg_match("%^.*help/%", $source)) {
425                                                 $dest= GOSA_HOME."/doc/plugins/$name/".preg_replace("%^.*help/%", "", $source);
426                                         } elseif (preg_match("%^.*html/%", $source)) {
427                                                 $dest= GOSA_HOME."/html/plugins/$name/".preg_replace("%^.*html/%", "", $source);
428                                         } else {
429                                                 $dest= GOSA_HOME."/plugins/".substr($entry->getPathName(), strlen($path) + 1);
430                                         }
432                                         /* Destination exists in case of directories? */
433                                         if ($entry->isDir()){
434                                                 if (!is_dir($dest)){
435                                                         mkdir($dest, 0755, TRUE);
436                                                         fwrite ($handle, "$dest\n");
437                                                 }
438                                         } else {
439                                                 if (!is_dir(dirname($dest))){
440                                                         mkdir(dirname($dest), 0755, TRUE);
441                                                         fwrite ($handle, dirname($dest)."\n");
442                                                 }
443                                         }
445                                         /* Copy files */
446                                         if ($entry->isFile()){
447                                                 copy ($source, $dest);
448                                         }
450                                         /* Note what we did... */
451                                         fwrite ($handle, "$dest\n");
452                                 }
454                                 fclose($handle);
455                         }
456                 }
457         }
458         
459         /* Update caches */
460         rescan_classes();
461         rescan_i18n();
462         rescan_guide();
466 function remove_plugin($name)
468         global $description, $depends;
470         /* Load plugin list */
471         load_plugins();
473         /* Present? */
474         if (!isset($description[$name])){
475                 echo "! Error: cannot find a plugin named '$name'\n\n";
476                 exit (1);
477         }
479         /* Depends? */
480         foreach ($depends as $sname => $pl_depends){
481                 if (in_array($name, $pl_depends)){
482                         echo "! Error: plugin '$sname' depends on '$name' - cannot remove it\n\n";
483                         exit (1);
484                 }
485         }
487         /* Load information */
488         if (!file_exists(PLUGSTATE_DIR."/$name/plugin.lst")){
489                 echo "! Error: cannot remove plugin '$name' - no install history found\n\n";
490                 exit (1);
491         }
493         echo "Removing plugin '$name'...\n";
494         $contents= file(PLUGSTATE_DIR."/$name/plugin.lst");
495         $cnv= array();
496         foreach($contents as $line){
497                 $entry= chop($line);
498                 $cnv[strlen($entry).":$entry"]= $entry;
499         }
500         krsort($cnv);
502         /* Remove files first */
503         clearstatcache();
504         foreach ($cnv as $entry){
505                 if (is_dir($entry)){
506                         rmdir($entry);
507                         continue;
508                 }
509                 if (file_exists($entry)){
510                         unlink($entry);
511                 }
512         }
514         /* Remove state directory for plugin */
515         rmdirRecursive(PLUGSTATE_DIR."/$name");
517         /* Update caches */
518         rescan_classes();
519         rescan_i18n();
520         rescan_guide();
524 function rescan_images($path, $theme)
526   $widths= array();
527   $heights= array();
528   $paths= array();
529   $posX= array();
530   $posY= array();
531   $baseLength= strlen($path);
532   $heightStats= array();
533   $warnings= array();
534   $checksums= array();
535   $styles= array();
536   $duplicates= array();
538   // Check for image magick convert
539   if (!function_exists("imageFilter")){
540     exec("which convert", $res, $ret);
541     if ($ret != 0) {
542       die("Your system has no bundled gd support for imageFilter function. Please install imagemagick in order to use an external command.\n");
543     }
544   }
545   
546   // Scan for images in the given path
547   echo "Scanning for images";
548   flush();
549   foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $fileInfo) {
550   
551       // We're only interested in png files
552       $indexPath= substr($fileInfo->getPathname(), $baseLength + 1);
553       $path= $fileInfo->getPathname();
554       if (preg_match('/\.png$/', $indexPath) && !preg_match('/\.svn/', $path) && !preg_match('/themes\/[^\/]+\/img.png$/', $path)){
555   
556          // Grey image if it is not already one
557          if (preg_match('/grey/', $indexPath)) {
558            echo "!";
559            $warnings[]= "Warning: skipped possible *grey* image $path";
560            flush();
561            continue;
562          }
564          // New image if it is not already one
565          if (preg_match('/new/', $indexPath) && !preg_match('/new\.png$/', $indexPath)) {
566            echo "!";
567            $warnings[]= "Warning: skipped possible *new* image $path";
568            flush();
569            continue;
570          }
572          // Catch available themes
573          if (preg_match('/themes\//', $indexPath) && !preg_match('/themes\/'.$theme.'\//', $indexPath)) {
574            continue;
575          }
577          // Load image
578          $img= imageCreateFromPng($path);
579          $width= imageSX($img);
580          $height= imageSY($img);
581          imageDestroy($img);
582          $greyIndexPath= preg_replace('/\.png$/', '-grey.png', $indexPath);
584          // Is this image already there?
585          $checksum= md5_file($path);
586          if (in_array($checksum, $checksums)) {
587            $warnings[]= "Warning: images $indexPath seems to be a duplicate of ".array_search($checksum, $checksums);
588            $duplicates[$indexPath]= array_search($checksum, $checksums);
589            $duplicates[$greyIndexPath]= preg_replace('/\.png$/', '-grey.png', array_search($checksum, $checksums));
590            continue;
591          } else {
592            $checksums[$indexPath]= $checksum;
593          }
595          // Ordinary image
596          $widths[$indexPath]= $width;
597          $heights[$indexPath]= $height;
598          $paths[$indexPath]= $path;
600          // Grey image
601          $widths[$greyIndexPath]= $width;
602          $heights[$greyIndexPath]= $height;
603          $paths[$greyIndexPath]= $path;
605          // Feed height statistics
606          if (!isset($heightStats[$height])) {
607            $heightStats[$height]= 1;
608          } else {
609            $heightStats[$height]++;
610          }
611       }
612   
613     echo ".";
614     flush();
615   }
616   echo "\n";
618   // Do some stupid height calculation
619   arsort($heightStats, SORT_NUMERIC);
620   reset($heightStats);
621   $popular= current($heightStats);
623   krsort($heightStats);
624   reset($heightStats);
625   $max= current($heightStats);
627   $maxHeight= (floor($max / $popular) + 1) * $popular * 6;
628   
629   // Sort to get biggest values
630   arsort($widths, SORT_NUMERIC);
631   reset($widths);
632   echo "Calculating master image dimensions: ";
633   flush();
634   
635   // Build container image
636   $cursorX= 0;
637   $cursorY= 0;
638   $colWidth= 0;
639   $rowHeight= 0;
640   $colX= 0;
641   $colY= 0;
642   $maxY= 0;
643   $maxX= 0;
645   // Walk thru width sorted images
646   foreach ($widths as $imagePath => $imageWidth) {
647     $imageHeight= $heights[$imagePath];
649     // First element in this column
650     if ($colWidth == 0) {
651       $colWidth= $imageWidth;
652     }
654     // First element in this row
655     if ($rowHeight < $imageHeight) {
656       $rowHeight= $imageHeight;
657     }
659     // Does the image match here?
660     if ($cursorX + $imageWidth > $colX + $colWidth) {
662       if ($cursorY + $imageHeight >= $maxHeight) {
664         // Reached max height, move to the next column
665         $colX+= $colWidth;
666         $cursorX= $colX;
667         $colWidth= $imageWidth;
668         $rowHeight= $imageHeight;
669         $colY= $cursorY= 0;
671       } else {
673         // Next row
674         $colY+= $rowHeight;
675         $cursorY= $colY;
676         $cursorX= $colX;
677         $rowHeight= $imageHeight;
678       }
680       $maxY=($colY + $imageHeight > $maxY)?$colY+$imageHeight:$maxY;
681     }
683     // Save calculated position
684     $posX[$imagePath]= $cursorX;
685     $posY[$imagePath]= $cursorY;
687     // Move X cursor to the next position
688     $cursorX+= $imageWidth;
690     $maxX=($colX+$imageWidth > $maxX)?$colX+$imageWidth:$maxX;
691   }
692   
693   // Print maximum dimensions
694   echo $maxY."x".$maxX."\n";
695   echo "Processing";
696   flush();
698   // Create result image
699   $dst= imageCreateTrueColor($maxX, $maxY);
700   imageAlphaBlending($dst, true);
701   $transparent = imagecolorallocatealpha($dst, 0, 0, 0, 127);
702   imageFill($dst, 0, 0, $transparent);
703   imageSaveAlpha($dst, true);
705   // Finally assemble picture
706   foreach ($heights as $imagePath => $imageHeight) {
707     $imageWidth= $widths[$imagePath];
708     $x= $posX[$imagePath];
709     $y= $posY[$imagePath];
711     // Insert source image...
713     // Eventually convert it to grey before
714     if (preg_match('/-grey\.png$/', $imagePath)) {
715       if (!function_exists("imageFilter")){
716         exec("convert ".$paths[$imagePath]." -colorspace Gray /tmp/grey-converted.png");
717         $src= imageCreateFromPng("/tmp/grey-converted.png");
718       } else {
719         $src= imageCreateFromPng($paths[$imagePath]);
720         imageFilter($src, IMG_FILTER_GRAYSCALE);
721       }
722     } else {
723       $src= imageCreateFromPng($paths[$imagePath]);
724     }
726     // Merge image
727     imageCopyResampled($dst, $src, $x, $y, 0, 0, $imageWidth, $imageHeight, $imageWidth, $imageHeight);
728     imageDestroy($src);
730     // Store style
731     $styles[$imagePath]= "background-position:-".$x."px -".$y."px;width:".$imageWidth."px;height:".$imageHeight."px";
733     echo ".";
734     flush();
735   }
737   /* Add duplicates */
738   foreach ($duplicates as $imagePath => $realPath) {
739     $styles[$imagePath]= $styles[$realPath];
740   }
742   imagePNG($dst, "html/themes/$theme/img.png", 9);
743   imageDestroy($dst);
745   // Show warnings images
746   foreach ($warnings as $warn) {
747     echo "$warn\n";
748   }
750   // Write styles
751   echo "Writing styles...";
752   $fp = fopen("ihtml/themes/$theme/img.styles", 'w');
753   fwrite($fp, serialize($styles));
754   fclose($fp);
756   echo "\n";
760 /* Fill global values */
761 $description= $provides= $depends= $versions= $conflicts= array();
763 /* Action specified? */
764 if ($argc < 2){
765         rescan_classes();
766         rescan_i18n();
767         rescan_guide();
768         rescan_images("html", "modern");
769         exit (0);
772 switch ($argv[1]){
773         case 'install':
774                 if (isset($argv[2])){
775                         install_plugin($argv[2]);
776                 } else {
777                         echo "Usage: update-gosa install dsc-file\n\n";
778                         exit (1);
779                 }
780                 break;
781         case 'list':
782                 list_plugins();
783                 break;
784         case 'remove':
785                 if (isset($argv[2])){
786                         remove_plugin($argv[2]);
787                 } else {
788                         echo "Usage: update-gosa remove plugin-name\n\n";
789                         exit (1);
790                 }
791                 break;
792         case 'rescan-i18n':
793                 rescan_i18n();
794                 break;
795         case 'rescan-classes':
796                 rescan_classes();
797                 break;
798         case 'rescan-images':
799                 rescan_images("html", "modern");
800                 break;
801         default:
802                 echo "Error: Supplied command not known\n\n";
803                 print_usage();
804                 break;
808 ?>