From af111e08961496e705461097ff0bef85aa2ecd82 Mon Sep 17 00:00:00 2001
From: yannick
Date: Sun, 3 Jul 2005 08:49:02 +0000
Subject: [PATCH] add information about old files
---
docs/scripts/revcheck.php | 112 +++++++++++++++++++++++++++++++++++++-
1 file changed, 110 insertions(+), 2 deletions(-)
diff --git a/docs/scripts/revcheck.php b/docs/scripts/revcheck.php
index f5c3cab0..dc98cbd8 100755
--- a/docs/scripts/revcheck.php
+++ b/docs/scripts/revcheck.php
@@ -355,6 +355,80 @@ function get_dir_status($dir)
} // get_dir_status() function end
+// Check for files removed in the EN tree, but still living in the translation
+function get_old_files($dir)
+{
+
+ global $DOCDIR, $LANG;
+
+ // Collect files and diretcories in these arrays
+ $directories = array();
+ $files = array();
+
+ $special_files = array(
+ // french
+ 'translation.xml'
+
+ // todo: add all missing languages
+ );
+
+ // Open the directory
+ $handle = @opendir($dir);
+
+ // Walk through all names in the directory
+ while ($file = @readdir($handle)) {
+
+ // If we found a file with one or two point as a name,
+ // or a CVS directory, skip the file
+ if (preg_match("/^\.{1,2}/", $file) || $file == 'CVS')
+ continue;
+
+ // skip this files
+ if (in_array($file, $special_files)) {
+ continue;
+ }
+
+ // Collect files and directories
+ if (is_dir($dir.$file)) {
+ $directories[] = $file;
+ } else {
+ $files[] = $file;
+ }
+
+ }
+
+ // Close the directory
+ @closedir($handle);
+
+ // Sort files and directories
+ sort($directories);
+ sort($files);
+
+ // Go through files first
+ $old_files_status = array();
+ foreach ($files as $file) {
+
+ $en_dir = preg_replace("'^".$DOCDIR.$LANG."/'", $DOCDIR."en/", $dir);
+
+ if (!@file_exists($en_dir.$file) ) {
+ $old_files_status[$dir.$file] = array(0=>intval(filesize($dir.$file)/1024));
+ }
+
+ }
+
+ // Then go through subdirectories, merging all the info
+ // coming from subdirs to one array
+ foreach ($directories as $file) {
+ $old_files_status = array_merge(
+ $old_files_status,
+ get_old_files($dir.$file.'/')
+ );
+ }
+
+ return $old_files_status;
+
+} // get_old_files() function end
+
// =========================================================================
// Functions to read in the translation.xml file and process contents
// =========================================================================
@@ -509,6 +583,8 @@ foreach ($translation["files"] as $num => $fileinfo) {
// Get all files status
$files_status = get_dir_status($DOCDIR."en/");
+// Get all old files in directory
+$old_files = get_old_files($DOCDIR.$LANG."/");
$navbar = "Introduction | " .
"Translators | " .
@@ -517,7 +593,8 @@ $navbar = "
Introduction | " .
if (count($translation["files"]) != 0)
$navbar .= "Work in progress | ";
$navbar .= "Missing revision numbers | " .
- "Untranslated files
\n";
+ "Untranslated files | " .
+ "Old files
\n";
// Figure out generation date
@@ -940,7 +1017,38 @@ if ($count > 0) {
}
+// Files not in EN tree
+$count = count($old_files);
+if ($count > 0) {
+ print "" .
+ "\n" .
+ "" .
+ " Not in EN Tree ($count files): | kB |
\n";
+
+ foreach($old_files as $file => $info) {
+ // Shorten the filename (we have directory headers)
+ $short_file = basename($file);
+
+ // Guess the new directory from the full name of the file
+ $new_dir = dirname($file);
+
+ // If this is a new directory, put out dir headline
+ if ($new_dir != $prev_dir) {
+
+ // Print out directory header if not "."
+ print "$new_dir |
\n";
+
+ // Store the new actual directory
+ $prev_dir = $new_dir;
+ }
+
+ print "$short_file | " .
+ "$info[0] |
\n";
+ }
+ print "
\n
\n$navbar
\n";
+}
+
// All OK, end the file
print "