diff --git a/update-gosa b/update-gosa
index a09bbd74128a17dfde2ca409c355c865691092cd..4c63d13e00ddaec329ec737ec539872f78859477 100755 (executable)
--- a/update-gosa
+++ b/update-gosa
/* Function to include all class_ files starting at a given directory base */
function get_classes($folder= ".")
{
+ static $base_dir= "";
static $result= array();
+ if ($base_dir == ""){
+ $base_dir= getcwd();
+ }
+
$currdir=getcwd();
if ($folder){
chdir("$folder");
continue;
}
+ /* Only take care about .inc and .php files... */
+ if (!(preg_match('/\.php$/', $file) || preg_match('/\.inc$/', $file))){
+ continue;
+ }
+
/* Include existing class_ files */
- if (preg_match("/^class_.*\.inc$/", $file)) {
-
- $result[]= "$currdir/$folder/$file";
+ $contents= file($file);
+ foreach($contents as $line){
+ $line= chop($line);
+ if (preg_match('/^\s*class\s*\w.*$/', $line)){
+ $class= preg_replace('/^\s*class\s*(\w+).*$/', '\1', $line);
+ $result[$class]= preg_replace("%$base_dir/%", "", "$currdir/$folder/$file");
+ }
}
}
return ($result);
}
-print_r(get_declared_classes());
-exit (0);
$class_mapping= get_classes();
+$filename= "include/class_location.inc";
+
+/* Sanity checks */
+if (is_writable($filename)) {
+
+ if (!$handle= fopen($filename, 'w')) {
+ echo "Cannot open file \"$filename\" - aborted\n";
+ exit (1);
+ }
+
+} else {
+ echo "File \"$filename\" is not writable - aborted\n";
+ exit (2);
+}
+
+fwrite ($handle, "<?php\n\$class_mapping= array(\n");
foreach ($class_mapping as $key => $value){
- echo "$key located in $value\n";
+ fwrite ($handle, " \"$key\" => \"$value\",\n");
}
+fwrite ($handle, " );\n?>");
+
+fclose($handle);
?>