diff --git a/.gitignore b/.gitignore index 9eb208a..c9a1fb9 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ include/jpgraph shared sqlite svn +www/images www/robots.txt \ No newline at end of file diff --git a/include/lib_revcheck.inc.php b/include/lib_revcheck.inc.php index f346897..ff3805a 100644 --- a/include/lib_revcheck.inc.php +++ b/include/lib_revcheck.inc.php @@ -102,7 +102,6 @@ function get_outdated_files($idx, $lang, $dir) } return $tmp; - } // return an array with the outdated files maintained by $user @@ -148,41 +147,23 @@ function get_outdated_translator_files($idx, $lang, $user) } return $tmp; - } -// Return an array of available languages for a revchecked documentation $type +// Return an array of available languages for manual function revcheck_available_languages($idx) { - $tmp = array(); - - if (!$idx) { - return FALSE; - } - - $sql = 'SELECT lang FROM description'; - $result = @$idx->query($sql);; - - if (!$result) { - return FALSE; - } - - if ($result) { - while ($r = $result->fetchArray()) { - $tmp[] = $r['lang']; - } - } - return $tmp; + $result = $idx->query('SELECT lang FROM description'); + return $result->fetchArray(SQLITE3_NUM); } // Return en integer -function get_nb_EN_files($idx) +function count_en_files($idx) { - $sql = "SELECT COUNT(*) AS total FROM files WHERE lang = 'en'"; - $res = $idx->query($sql);; + $sql = "SELECT COUNT(name) FROM files WHERE lang = 'en'"; + $res = $idx->query($sql); $row = $res->fetchArray(); - return $row['total']; + return $row[0]; } function get_missfiles($idx, $lang) @@ -205,9 +186,9 @@ function get_missfiles($idx, $lang) AND b.lang="en" AND - a.revision is NULL + a.revision IS NULL AND - a.size is NULL + a.size IS NULL AND a.dir = d.id'; $result = $idx->query($sql); @@ -250,7 +231,7 @@ function get_misstags($idx, $lang) d.name AS dir, b.size AS en_size, a.size AS trans_size, a.name AS name FROM files a, dirs d LEFT JOIN files b ON a.dir = b.dir AND a.name = b.name - WHERE a.lang="'.$lang.'" AND b.lang="en" AND a.revision IS NULL + WHERE a.lang="'.$lang.'" AND b.lang="en" AND a.revision IS NULL AND a.size IS NOT NULL AND a.dir = d.id'; $result = $idx->query($sql); @@ -261,30 +242,6 @@ function get_misstags($idx, $lang) return $tmp; } -// Return an integer -function get_nb_LANG_files($idx) -{ - $sql = ' - SELECT - lang, - COUNT(*) as total - FROM - files - WHERE - lang != \'en\' - GROUP BY - lang - ORDER BY - lang - '; - - $result = $idx->query($sql); - while ($row = $result->fetchArray()) { - $files[$row['lang']] = $row['total']; - } - return $files; -} - // Return a string function translator_get_wip($idx, $lang) { @@ -345,7 +302,6 @@ function translator_get_old($idx, $lang) return $tmp; } - function translator_get_critical($idx, $lang) { $sql = 'SELECT @@ -425,7 +381,7 @@ function translator_get_uptodate($idx, $lang) function get_translators($idx, $lang) { - $sql= "SELECT nick, name, mail, svn FROM translators WHERE lang = '$lang' ORDER BY nick COLLATE NOCASE"; + $sql = "SELECT nick, name, mail, svn FROM translators WHERE lang = '$lang' ORDER BY nick COLLATE NOCASE"; $persons = array(); $result = $idx->query($sql); while ($r = $result->fetchArray()) { @@ -434,34 +390,6 @@ function get_translators($idx, $lang) return $persons; } -function get_nb_LANG_files_Translated($idx, $lang) -{ - $sql = ' - SELECT - b.lang as language, - COUNT(*) as total - FROM - files a - LEFT JOIN - files b - WHERE - b.lang="' . $lang . '" - AND - a.lang=\'en\' - AND - b.name = a.name - AND - b.dir = a.dir - AND - a.revision = b.revision - GROUP BY - b.lang - '; - - $result = $idx->query($sql); - return $result->fetchArray(); -} - // Return an array function get_stats_uptodate($idx, $lang) { @@ -572,43 +500,18 @@ function get_stats_old($idx, $lang) return $result; } - +// Returns number of untranslated files for specified $lang function get_stats_notrans($idx, $lang) { - $sql = 'SELECT - COUNT(a.name) as total, - sum(b.size) as size - FROM - files a, - dirs d - LEFT JOIN - files b - ON - a.dir = b.dir - AND - a.name = b.name - WHERE - a.lang="' . $lang . '" - AND - b.lang="en" - AND - a.revision is NULL - AND - a.size is NULL - AND - a.dir = d.id'; + $sql = "SELECT COUNT(a.name) AS total, SUM(b.size) as size + FROM files a, dirs d + LEFT JOIN files b ON a.dir = b.dir AND a.name = b.name + WHERE a.lang = '$lang' AND b.lang='en' AND a.revision IS NULL AND a.size IS NULL AND a.dir = d.id"; $result = $idx->query($sql); - $r = $result->fetchArray(); return array($r['total'], $r['size']); - if (sqlite_num_rows($result)) { - $r = $result->fetchArray(); - return array($r['total'], $r['size']); - } else { - return array(0,0); - } } function get_stats_wip($idx, $lang) diff --git a/scripts/gen_picture_info.php b/scripts/gen_picture_info.php index c2dfe03..57b7a55 100644 --- a/scripts/gen_picture_info.php +++ b/scripts/gen_picture_info.php @@ -1,4 +1,6 @@ legend->Pos(0.02,0.18,"right","center"); - $graph->subtitle->Set('(Total: '.$Total_files_lang.' files)'); + $graph->subtitle->Set('(Total: '.$total_files_lang.' files)'); $graph->subtitle->Align('left'); $graph->subtitle->SetColor('darkred'); @@ -79,7 +85,7 @@ function generate_image($lang, $idx) { $p1 = new PiePlot3D($data); $p1->SetSliceColors(array("#68d888", "#ff6347", "#eee8aa", "#dcdcdc", "#f4a460")); - if ($noExplode != 1) { + if ($total_files_lang != $up_to_date) { $p1->ExplodeAll(); } $p1->SetCenter(0.35,0.55); @@ -88,8 +94,5 @@ function generate_image($lang, $idx) { $p1->SetLegends($legend); $graph->Add($p1); - $graph->Stroke('../www/images/revcheck/info_revcheck_php_' . $lang . '.png'); - - - return TRUE; -} + $graph->Stroke("../www/images/revcheck/info_revcheck_php_$lang.png"); +} \ No newline at end of file diff --git a/scripts/gen_picture_info_all_lang.php b/scripts/gen_picture_info_all_lang.php index b39bad8..cec70a0 100644 --- a/scripts/gen_picture_info_all_lang.php +++ b/scripts/gen_picture_info_all_lang.php @@ -9,12 +9,12 @@ $idx = new SQLite3(SQLITE_DIR . 'rev.php.sqlite'); $language = revcheck_available_languages($idx); sort($language); -$files_EN = get_nb_EN_files($idx); +$files_EN = count_en_files($idx); foreach ($language as $lang) { - $tmp = get_nb_LANG_files_Translated($idx, $lang); + $tmp = get_stats_uptodate($idx, $lang); - $percent_tmp[] = round($tmp['total'] * 100 / $files_EN); + $percent_tmp[] = round($tmp[0] * 100 / $files_EN); $legend_tmp[] = $lang; } @@ -72,5 +72,4 @@ function generate_image() { // Display the graph $graph->Stroke('../www/images/revcheck/info_revcheck_php_all_lang.png'); - -} +} \ No newline at end of file