big WS cleaning, this file was a mess,

reword and shorten the usage to fit in a normal term
fix some logic
This commit is contained in:
Mehdi Achour
2004-10-30 23:36:55 +00:00
parent 547d61523e
commit ca033bd0e5

View File

@ -26,20 +26,20 @@
error_reporting(E_ALL);
/**
* Usage
**/
* Usage
**/
// keep this call, we need it
$self = array_shift($argv);
if ($argc < 3) {
?>
Check the revision of translated files against the actual english
xml files, and create an sqlite database to generate statisctics
Usage:
<?php echo $self;?> type lang1 [lang2 [lang3 [..]]]
Checks the revision of translated files against the actual english
xml files, and create an sqlite database to generate statisctics
type should be a registered documentation type in
<?php echo dirname($self);?>/common.php
@ -50,19 +50,13 @@ xml files, and create an sqlite database to generate statisctics
the PHP Documentation Howto :
http://php.net/manual/howto/translation-revtrack.html (9.4.2)
Original Authors: Thomas Sch<63>fbeck <tom at php dot net>
Gabor Hojtsy <goba at php dot net>
Mark Kronsbein <mk at php dot net>
Jan Fabry <cheezy at php dot net>
SQLite version Authors:
Mehdi Achour <didou at php dot net>
<?php
exit(0);
}
/**
* Configuration
**/
* Configuration
**/
// define some common variables
$inCli = true;
@ -76,7 +70,7 @@ $TYPE = array_shift($argv);
//if (!documentation_exists($TYPE)) {
// die("$TYPE is not a valid documentation type\n");
//} else {
$DOCS = CVS_DIR . get_cvs_dir($TYPE);
$DOCS = CVS_DIR . get_cvs_dir($TYPE);
//}
// $argv was shifted before
@ -131,8 +125,8 @@ CREATE TABLE files (
SQL;
/**
* Functions
**/
* Functions
**/
function parse_translation($lang)
{
@ -220,7 +214,7 @@ function dir_sort($a, $b) {
global $DOCS, $dir;
$a = $DOCS . 'en' . $dir . '/' . $a;
$b = $DOCS . 'en' . $dir . '/' . $b;
// echo "$a\n$b\n\n";
// echo "$a\n$b\n\n";
if (is_dir($a) && is_dir($b))
return 0;
if (is_file($a) && is_file($b))
@ -286,7 +280,7 @@ function do_revcheck($dir = '') {
}
}
// Puis les r<EFBFBD>pertoires.
// Puis les r?pertoires.
if( sizeof($entriesDir) > 0 ) {
usort($entriesDir, 'dir_sort');
@ -361,7 +355,7 @@ function get_original_rev($file)
function getmicrotime()
{
list($usec, $sec) = explode(" ",microtime());
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
@ -370,20 +364,19 @@ function getmicrotime()
$time_start = getmicrotime();
/**
* Script execution
**/
* Script execution
**/
$db_name = SQLITE_DIR . 'rev.' . $TYPE . '.sqlite';
$tmp_db = SQLITE_DIR . 'rev.' . $TYPE . '.tmp.sqlite';
// 1 - Drop the old database and create the new one
if( is_file($tmp_db)) {
if (is_file($tmp_db)) {
echo "Temporary database found : remove.\n";
if( !@unlink($tmp_db) ) {
if (!@unlink($tmp_db)) {
echo "Error : Can't remove temporary database\n";
exit(0);
}
}
@ -399,7 +392,7 @@ sqlite_query($idx, $CREATE);
// 3 - Fill in the description table while cleaning the langs
// without revision.xml file
foreach($LANGS as $id => $lang) {
foreach ($LANGS as $id => $lang) {
echo "Fetching the $lang description\n";
parse_translation($lang);
}
@ -417,19 +410,17 @@ sqlite_close($idx);
echo "Copy temporary database to final database\n";
copy($tmp_db, $db_name);
if( !@unlink($tmp_db) ) {
if (!@unlink($tmp_db)) {
echo "Error : Can't drop temporary database. Check permissions\n";
}
$time_end = getmicrotime();
$time = $time_end - $time_start;
if( $time > 60 ) {
if ($time > 60) {
$time = ($time / 60) . ' minuts';
} else {
} else {
$time = $time . ' seconds';
}
}
echo "/---- Time of generation : " .$time . "\n";
?>