Index: phpdoc/scripts/.cvsignore
+++ phpdoc/scripts/.cvsignore
revcheck.html
Index: phpdoc/scripts/revcheck.php
+++ phpdoc/scripts/revcheck.php
#!/usr/bin/php -q
3) {
?>
Check the revision of translated files against
the actual english xml files, and print statistics
Usage:
=$argv[0]?> []
must be a valid language code used
in the repository
If you specify , the script only checks
the files maintaned by the person you add here
The script will generate a revcheck.html file in
the same dir, where the script runs, containing the
information about translations
Revision comment syntax for translated files:
If the revision number is not (yet) known:
Written by Thomas Schöfbeck email protected>>, 2001-08-11
Adapted to phpdoc, developed further: email protected>>
email protected>($file, "r") or die ("Unable to read $file.");
$line = fread($fp, 200);
fclose($fp);
// Checking for english CVS revision tag
if ($val=="en-rev") {
preg_match("//", $line, $match);
return ($match[1]);
}
// Checking for the translations "revision tag"
else {
preg_match ("//", $line, $match);
}
// The tag with revision number is not found so search
// for n/a revision comment
if (count($match) == 0) {
preg_match ("''", $line, $match);
}
return ($match);
} // get_tag() function end
// Checks a file, and gather stats
function check_file($file)
{
// The information is contained in these global arrays and vars
global $miss_file, $miss_tag, $lang, $docdir, $fp, $r_alert,
$s_alert, $t_alert, $maintainer, $cvs_opt;
// Translated file name check
$t_file = preg_replace( "'^".$docdir."en/'", $docdir.$lang."/", $file );
if (!file_exists($t_file)) {
$miss_file[] = array(substr($t_file, strlen($docdir)+strlen($lang)),
round(filesize($file)/1024, 1));
return FALSE;
}
// Get translated files tag, with maintainer if needed
if (empty($maintainer))
$t_tag = get_tag($t_file, "\\S*");
else
$t_tag = get_tag($t_file, $maintainer);
// No tag found
if (count($t_tag) == 0) {
$miss_tag[] = substr($t_file, strlen($docdir));
return FALSE;
}
// Storing values for further processing
$maint = $t_tag[2];
$en_rev = get_tag($file);
// Make diff link if the revision is not n/a
$t_td = substr($t_file, strlen($docdir)+strlen($lang)+1);
if (is_numeric($t_tag[1])) {
$r_diff = intval($en_rev) - intval($t_tag[1]);
$t_rev = "1.".$t_tag[1];
if ($r_diff != 0) {
$t_td = "$t_td";
}
} else {
$r_diff = $t_rev = $t_tag[1];
}
// Compute sizes, times and diffs
$en_size = intval(filesize($file) / 1024);
$t_size = intval(filesize($t_file) / 1024);
$s_diff = intval($en_size) - intval($t_size);
$en_date = intval((time() - filemtime($file)) / 86400);
$t_date = intval((time() - filemtime($t_file)) / 86400);
$t_diff = $en_date - $t_date;
// Taging actuality of files with colors
if ($r_diff === 0) {
$col = "#68D888";
} elseif ($r_diff == "n/a") {
$col = "#f4a460 class=hl";
} elseif ($r_diff >= $r_alert || $s_diff >= $s_alert || $t_diff <= $t_alert) {
$col = "#ff0000 class=hl";
} else {
$col ="#eee8aa";
}
// Write out the line for the file into the file
fwrite($fp, "
\n
$t_td
\n".
"
1.$en_rev
$t_rev
\n".
"
$r_diff
\n".
"
$en_size
\n".
"
$t_size
\n".
"
$s_diff
\n".
"
$en_date
\n".
"
$t_date
\n".
"
$t_diff
\n".
"
$maint
\n".
"
$t_tag[3]
\n
\n");
return TRUE;
} // check_file() end
// Checks a diretory of phpdoc XML files
function check_dir($dir)
{
global $fp, $docdir, $lang;
// Write out directory headline
$display_dir = preg_replace("!$docdir(en)(.+)!", "$lang\\2", $dir);
fwrite($fp, "
$display_dir
");
// Collect files and diretcories in these arrays
$directories = array();
$files = array();
// Open and traverse the directory
$handle = <email protected>($dir);
while ($file = <email protected>($handle)) {
if (preg_match("/^\.{1,2}/",$file) || $file == 'CVS')
continue;
// Collect files and directories
if (is_dir($dir.$file)) { $directories[] = $file; }
else { $files[] = $file; }
}
<email protected>($handle);
// Sort files and directories
sort($directories);
sort($files);
// Files first...
$nofile = TRUE;
foreach ($files as $file) {
if (check_file($dir.$file)) { $nofile = FALSE; }
}
if ($nofile) {
fwrite($fp, "
No
processable file in this directory, or no such directory
");
}
// than the subdirs
foreach ($directories as $file) {
check_dir($dir.$file."/");
}
} // check_dir() end
/*********************************************************************/
/* Here starts the program */
/*********************************************************************/
// Check for directory validity
if (! <email protected>($docdir . $lang)) {
die("The $lang language code is not valid");
}
// If directory is OK, start with the header
echo "\nWriting report into revcheck.html ...\n";
$fp = <email protected>("revcheck.html", "w") or die ("Unable to open file.");
fwrite($fp, "
PHPDOC Revision-check