[DOC-WEB] [web-doc] master: Use revcheck information generated by doc-base/scripts/translation/genrevdb.php (#58)
[email protected] (Jim Winstead via GitHub) Mon, 11 Nov 2024 20:32:45 +0000
| Newsgroups | php.doc.web |
|---|---|
| Message-ID | <[email protected]> |
Author: Jim Winstead (jimwins)
Committer: GitHub (web-flow)
Pusher: jimwins
Date: 2024-11-11T12:28:47-08:00
Commit: https://github.com/php/web-doc/commit/4e57bbbc6ed10617cdf82ad3de08a31e759b322c
Raw diff: https://github.com/php/web-doc/commit/4e57bbbc6ed10617cdf82ad3de08a31e759b322c.diff
Use revcheck information generated by doc-base/scripts/translation/genrevdb.php (#58)
Changed paths:
D build-ops.php.sample
D build-ops.sample
D scripts/gen_doc_activity_email.php
D scripts/generation.sh
D scripts/populatedocs.sh
D scripts/rev.php
M include/init.inc.php
M include/lib_revcheck.inc.php
M www/img-status-all.php
M www/img-status-lang.php
M www/redirect.php
M www/revcheck.php
Diff:
diff --git a/build-ops.php.sample b/build-ops.php.sample
deleted file mode 100644
index abbfd05..0000000
--- a/build-ops.php.sample
+++ /dev/null
@@ -1,5 +0,0 @@
-<?php
-// Please read README.md in the same directory to get more info about filling in this file
-
-define('GIT_DIR', '@GITDIR@');
-define('SQLITE_DIR', '@SQLITEDIR@');
diff --git a/build-ops.sample b/build-ops.sample
deleted file mode 100644
index e54196c..0000000
--- a/build-ops.sample
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-# Please read README.md in the same directory to get more info about filling in this file
-
-PHP=@PHP@
-GITDIR=@GITDIR@
-DOCWEB=@DOCWEB@
-PHDDIR=@PHDDIR@
-SCRIPTSDIR=@SCRIPTSDIR@
-SQLITE_DIR=@SQLITEDIR@
-SRCDIR=@SRCDIR@
diff --git a/include/init.inc.php b/include/init.inc.php
index 96e65c4..78ce2df 100644
--- a/include/init.inc.php
+++ b/include/init.inc.php
@@ -21,24 +21,19 @@
*/
// get paths
-$build_ops = dirname(realpath(__FILE__)) . '/../build-ops.php';
-if (file_exists($build_ops)) {
- require_once($build_ops);
-} else {
- $GIT_DIR = getenv('PHPDOC_GIT_DIR');
- if ($GIT_DIR == '') {
- die("Unable to find Git repositories, set `PHPDOC_GIT_DIR` environment variable!");
- }
- $GIT_DIR .= (substr($GIT_DIR, -1) == '/' ? '' : '/');
- define('GIT_DIR', $GIT_DIR);
+$GIT_DIR = getenv('PHPDOC_GIT_DIR');
+if ($GIT_DIR == '') {
+ die("Unable to find Git repositories, set `PHPDOC_GIT_DIR` environment variable!");
+}
+$GIT_DIR .= (substr($GIT_DIR, -1) == '/' ? '' : '/');
+define('GIT_DIR', $GIT_DIR);
- $SQLITE_DIR = getenv('SQLITE_DIR');
- if ($SQLITE_DIR == '') {
- die("Don't know where to place SQLite database, set `SQLITE_DIR` enviromment variable!");
- }
- $SQLITE_DIR .= (substr($SQLITE_DIR, -1) == '/' ? '' : '/');
- define('SQLITE_DIR', $SQLITE_DIR);
+$SQLITE_DIR = getenv('SQLITE_DIR');
+if ($SQLITE_DIR == '') {
+ die("Don't know where to find SQLite database, set `SQLITE_DIR` enviromment variable!");
}
+$SQLITE_DIR .= (substr($SQLITE_DIR, -1) == '/' ? '' : '/');
+define('SQLITE_DIR', $SQLITE_DIR);
// Cache is considered stale after (seconds):
define('CACHE_BUGS_COUNT', 300); // 300 = 5mins
diff --git a/include/lib_revcheck.inc.php b/include/lib_revcheck.inc.php
index ce534a0..882452b 100644
--- a/include/lib_revcheck.inc.php
+++ b/include/lib_revcheck.inc.php
@@ -20,20 +20,35 @@
+----------------------------------------------------------------------+
*/
+$TRANSLATION_STATUSES = [
+ 'TranslatedOk' => 'Up to date',
+ 'TranslatedOld' => 'Outdated',
+ 'TranslatedWip' => 'Work in progress',
+ 'RevTagProblem' => 'No revision tag',
+ 'NotInEnTree' => 'Not in EN tree',
+ 'Untranslated' => 'Available for translation',
+];
+
+function get_language_intro($idx, $lang) {
+ $result = $idx->query("SELECT intro FROM languages WHERE lang = '$lang'");
+ $answer = $result->fetchArray();
+ return is_array($answer) ? $answer[0] : null;
+}
+
// Return an array of directory containing outdated files
function get_dirs($idx, $lang) {
- $sql = "SELECT
- d.path AS dir
- FROM
- translated a,
- dirs d
- WHERE
- a.lang = '$lang'
- AND a.id = d.id
- AND (a.syncStatus = 'TranslatedOld'
- OR a.syncStatus = 'TranslatedWip')
- ORDER BY
- d.id";
+ $sql = <<<SQL
+ SELECT
+ path AS dir
+ FROM
+ files
+ WHERE
+ lang = '$lang'
+ AND
+ (status = 'TranslatedOld' OR status = 'TranslatedWip')
+ ORDER BY
+ path
+ SQL;
$result = $idx->query($sql);
@@ -48,34 +63,39 @@ function get_dirs($idx, $lang) {
// return an array with the outdated files; can be optionally filtered by user or dir
function get_outdated_files($idx, $lang, $filter = null, $value = null)
{
- $sql = "SELECT a.status, a.name AS file, a.maintainer, a.additions, a.deletions, c.revision AS en_rev, a.revision AS trans_rev, b.path AS dir
- FROM translated a, dirs b, enfiles c
- WHERE a.lang = '$lang'
- AND c.name = a.name AND b.id = a.id AND b.id = c.id
- AND (a.syncStatus = 'TranslatedOld'
- OR a.syncStatus = 'TranslatedWip')";
-
- if ($filter == 'dir') {
- $sql .= " AND b.path = '$value'";
- }
- elseif ($filter == 'translator') {
- $sql .= ' AND a.maintainer = "'.SQLite3::escapeString($value).'"';
- }
-
- $sql .= ' ORDER BY b.path';
+ $value = SQLite3::escapeString($value ?? '');
+
+ $sql_filter = match ($filter) {
+ 'dir' => "AND path = '{$value}'",
+ 'translator' => "AND maintainer = '{$value}'",
+ default => ''
+ };
+
+ $sql = <<<SQL
+ SELECT
+ status,
+ name AS file,
+ path AS name,
+ maintainer,
+ adds AS additions,
+ dels AS deletions,
+ hashLast as en_rev,
+ hashRvtg as trans_rev
+ FROM
+ files
+ WHERE
+ lang = '{$lang}'
+ AND
+ (status = 'TranslatedOld' OR status = 'TranslatedWip')
+ {$sql_filter}
+ ORDER BY
+ path
+ SQL;
$result = $idx->query($sql);
$tmp = array();
- while ($r = $result->fetchArray()) {
- $tmp[] = array(
- 'file' => $r['file'],
- 'en_rev' => $r['en_rev'],
- 'trans_rev' => $r['trans_rev'],
- 'status' => $r['status'],
- 'maintainer' => $r['maintainer'],
- 'name' => $r['dir'],
- 'additions' => $r['additions'],
- 'deletions' => $r['deletions']);
+ while ($r = $result->fetchArray(SQLITE3_ASSOC)) {
+ $tmp[] = $r;
}
return $tmp;
@@ -84,7 +104,7 @@ function get_outdated_files($idx, $lang, $filter = null, $value = null)
// Return an array of available languages for manual
function revcheck_available_languages($idx)
{
- $result = $idx->query('SELECT lang FROM descriptions');
+ $result = $idx->query('SELECT lang FROM languages');
while ($row = $result->fetchArray(SQLITE3_NUM)) {
$tmp[] = $row[0];
}
@@ -92,39 +112,26 @@ function revcheck_available_languages($idx)
return $tmp;
}
-
-// Return en integer
-function count_en_files($idx)
-{
- $sql = "SELECT COUNT(name) FROM enfiles";
- $res = $idx->query($sql);
- $row = $res->fetchArray();
- return $row[0];
-}
-
function get_missfiles($idx, $lang)
{
- $sql = "SELECT
- d.path as dir,
- a.name as file,
- b.revision as revision,
- a.size as size
- FROM
- Untranslated a,
- enfiles b,
- dirs d
- WHERE
- a.lang = '$lang'
- AND
- a.name = b.name
- AND
- a.id = b.id
- AND
- a.id = d.id";
+ $sql = <<<SQL
+ SELECT
+ path AS dir,
+ name AS file,
+ hashLast AS revision,
+ size / 1024 AS size
+ FROM
+ files
+ WHERE
+ lang = '{$lang}'
+ AND
+ status = 'Untranslated'
+ SQL;
+
$result = $idx->query($sql);
- while ($r = $result->fetchArray()) {
- $tmp[] = array('dir' => $r['dir'], 'size' => $r['size'], 'revision' => $r['revision'], 'file' => $r['file']);
+ while ($r = $result->fetchArray(SQLITE3_ASSOC)) {
+ $tmp[] = $r;
}
return $tmp;
@@ -132,26 +139,36 @@ function get_missfiles($idx, $lang)
function get_oldfiles($idx, $lang)
{
- $sql = "SELECT path, name, size
- FROM notinen
- WHERE lang = '$lang'";
+ $sql = <<<SQL
+ SELECT
+ path AS dir,
+ name AS file,
+ size / 1024 AS size
+ FROM
+ files
+ WHERE
+ lang = '$lang'
+ AND
+ status = 'NotInEnTree'
+ SQL;
$result = $idx->query($sql);
$tmp = array();
- while ($r = $result->fetchArray()) {
- $tmp[] = array('dir' => $r['path'], 'size' => $r['size'], 'file' => $r['name']);
+ while ($r = $result->fetchArray(SQLITE3_ASSOC)) {
+ $tmp[] = $r;
}
return $tmp;
}
function get_misstags($idx, $lang)
{
- $sql = "SELECT d.path AS dir, a.size AS en_size, b.size AS trans_size, a.name AS name
- FROM enfiles a, translated b, dirs d
- WHERE b.lang = '$lang' AND b.syncStatus = 'RevTagProblem'
- AND a.id = b.id AND a.name = b.name AND a.id = d.id
- ORDER BY dir, name";
+ $sql = <<<SQL
+ SELECT path AS dir, name AS name
+ FROM files
+ WHERE lang = '{$lang}' AND status = 'RevTagProblem'
+ ORDER BY dir, name
+ SQL;
$tmp = NULL;
$result = $idx->query($sql);
while($row = $result->fetchArray()) {
@@ -161,83 +178,62 @@ function get_misstags($idx, $lang)
return $tmp;
}
-/**
- * Returns translators' stats of specified $lang
- * Replaces old translator_get_wip(), translator_get_old(),
- * translator_get_critical() and translator_get_uptodate() functions
- *
- * @param string $status one of [uptodate, old, critical, wip]
- * @return array
- */
-function get_translators_stats($idx, $lang, $status) {
- if ($status == 'wip') { // special case, ehh; does anyone still use this status?
- $sql = "SELECT files_wip AS total, nick AS maintainer
- FROM translators
- WHERE lang = '$lang'
- GROUP BY maintainer";
- } elseif ($status == 'uptodate') {
- $sql = "SELECT files_uptodate AS total, nick AS maintainer
- FROM translators
- WHERE lang = '$lang'
- GROUP BY maintainer";
- } elseif ($status == 'outdated') {
- $sql = "SELECT files_outdated AS total, nick AS maintainer
- FROM translators
- WHERE lang = '$lang'
- GROUP BY maintainer";
- }
- $result = $idx->query($sql);
- $tmp = array();
- while ($r = $result->fetchArray()) {
- $tmp[$r['maintainer']] = $r['total'];
- }
-
- return $tmp;
-}
-
function get_translators($idx, $lang)
{
- $sql = "SELECT nick, name, mail, vcs FROM translators WHERE lang = '$lang' ORDER BY nick COLLATE NOCASE";
- $persons = array();
+ $sql = <<<SQL
+ SELECT
+ nick, name, email AS mail, vcs AS karma,
+ countOk, countOld, countOther
+ FROM
+ translators
+ WHERE
+ lang = '{$lang}'
+ ORDER BY
+ nick COLLATE NOCASE
+ SQL;
+
$result = $idx->query($sql);
- while ($r = $result->fetchArray()) {
- $persons[$r['nick']] = array('name' => $r['name'], 'mail' => $r['mail'], 'karma' => $r['vcs']);
+ while ($r = $result->fetchArray(SQLITE3_ASSOC)) {
+ $persons[$r['nick']] = $r;
}
return $persons;
}
-/**
- * Returns statistics of specified $lang
- * Replaces old get_stats_uptodate(), get_stats_old(),
- * get_stats_critical(), get_stats_wip(), get_stats_notrans()
- * and get_stats_notag() functions
- *
- * @param string $status one of [uptodate, old, critical, wip, notrans, norev]
- * @return array
+/*
+ * Returns statistics for specified language
*/
-function get_stats($idx, $lang, $status) {
- $sql = "SELECT COUNT(a.name) AS total, SUM(b.size) AS size
- FROM translated a, enfiles b
- WHERE a.lang = '$lang' AND a.id = b.id AND a.name = b.name AND ";
- if ($status == 'wip') {
- $sql .= "a.syncStatus = 'TranslatedWip'";
- } elseif ($status == 'notrans') {
- $sql = "SELECT COUNT(name) AS total, SUM(size) AS size
- FROM Untranslated
- WHERE lang = '$lang'";
- } elseif ($status == 'uptodate') {
- $sql .= "a.syncStatus = 'TranslatedOk'";
- } elseif ($status == 'outdated') {
- $sql .= "syncStatus = 'TranslatedOld'";
- } elseif ($status == 'norev') {
- $sql .= "syncStatus = 'RevTagProblem'";
- } else { //notinen
- $sql = "SELECT COUNT(name) AS total, SUM(size) AS size
- FROM notinen WHERE lang = '$lang'";
+function get_lang_stats($idx, $lang) {
+ $sql = <<<SQL
+ SELECT
+ status,
+ COUNT(*) AS total,
+ SUM(size) / 1024 AS size
+ FROM
+ files
+ WHERE
+ lang = '{$lang}'
+ GROUP BY
+ status
+ SQL;
+
+ $result = $idx->query($sql);
+
+ $stats = [];
+ $total = [ 'total' => 0, 'size' => 0 ];
+ while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
+ $stats[$row['status']] = $row;
+ if ($row['status'] != 'NotInEnTree') {
+ $total['total'] += $row['total'];
+ $total['size'] += $row['size'];
+ }
+ }
+
+ if ($total['total'] > 0) {
+ $stats['total'] = $total;
}
- $result = $idx->query($sql)->fetchArray();
- return array($result['total'], $result['size']);
+
+ return $stats;
}
function showdiff ()
diff --git a/scripts/gen_doc_activity_email.php b/scripts/gen_doc_activity_email.php
deleted file mode 100644
index 80f4a38..0000000
--- a/scripts/gen_doc_activity_email.php
+++ /dev/null
@@ -1,198 +0,0 @@
-<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
-+----------------------------------------------------------------------+
-| PHP Documentation Site Source Code |
-+----------------------------------------------------------------------+
-| Copyright (c) 1997-2011 The PHP Group |
-+----------------------------------------------------------------------+
-| This source file is subject to version 3.01 of the PHP license, |
-| that is bundled with this package in the file LICENSE, and is |
-| available through the world-wide-web at the following url: |
-| http://www.php.net/license/3_01.txt. |
-| If you did not receive a copy of the PHP license and are unable to |
-| obtain it through the world-wide-web, please send a note to |
-| [email protected] so we can mail you a copy immediately. |
-+----------------------------------------------------------------------+
-| Author: Philip Olson <[email protected]> |
-+----------------------------------------------------------------------+
-
-Notes:
- - This emails the documentation list each # days (7, via cron) with
- PHP documentation activity information.
- - These are only numbers/statistics, so there are no winners or
- losers except for the documentation.
-Todo:
- - Add SVN lines changed/added/deleted instead of # commits
- - Add other bug activities? So, not only bug->closed?
- - Determine if posting statistics is wise (good or bad)
-*/
-
-// build-ops.php is generated by web/doc/trunk/ setup
-require '../build-ops.php';
-
-date_default_timezone_set('UTC');
-
-define('DEBUG_MODE', FALSE); // Enable to not send emails.
-define('DAYS_LOOKUP', 7); // Number of days, in the past, to search/use for the report
-
-$svn_modules = array('phpdoc', 'phd', 'web/doc-editor');
-$time_past = date('Y-m-d', strtotime('-'. DAYS_LOOKUP . ' days'));
-$time_future = date('Y-m-d', strtotime('+'. DAYS_LOOKUP . ' days'));
-$time_now = date('Y-m-d');
-
-if (!function_exists('sqlite_open')) {
- echo 'Fail. I require ext/sqlite to work.', PHP_EOL;
- exit;
-}
-if (!function_exists('simplexml_load_string')) {
- echo 'Fail. I require ext/simplexml to work.', PHP_EOL;
- exit;
-}
-
-$email_text = <<<TEMPLATE
-
-Hello!
-
-This lists some of the activity found within the PHP documentation over at php.net. Of course numbers mean nothing alone, but they do show general activity around the PHP documentation. Dates of activity include: DATES_ACTIVITY
-
-Those who made SVN commits:
------------------------------------------------
- (php.net svn modules: SVN_MODULES_LIST)
-
-SVN_COMMIT_COUNTS
-
-Those who closed documentation bugs:
------------------------------------------------
- (bug categories: problem, translation, phd, editor)
-
-BUGS_CLOSED
-
-Those who handled user notes:
------------------------------------------------
- (actions: delete, reject, edit)
-
-NOTES_HANDLED
-
----
-See also:
- - Edit the documentation online: https://edit.php.net/
- - Documentation HOWTO: https://doc.php.net/dochowto/
-
-TEMPLATE;
-
-/****************************************************************************/
-/**** Weekly commits ********************************************************/
-/****************************************************************************/
-
-$counts = array();
-$text = '';
-foreach ($svn_modules as $svn_module) {
-
- $command = "svn log http://svn.php.net/repository/$svn_module --revision \{$time_past}:\{$time_future} --non-interactive --xml";
- $results = shell_exec($command);
-
- // Elementless XML file has strlen of 35
- if (!$results || strlen($results) < 35) {
- continue;
- }
-
- $xml = new SimpleXMLElement($results);
-
- if (empty($xml->logentry)) {
- continue;
- }
-
- foreach ($xml as $info) {
- @$counts[ (string) $info->author ]++;
- }
-}
-
-if ($counts && !empty($counts)) {
-
- arsort($counts);
-
- $text = '';
- foreach ($counts as $name => $count) {
- $text .= sprintf("%20s %5s\n", $name, $count);
- }
-
-} else {
- $text = 'No commits made last week. So sad. :(';
-}
-
-$email_text = str_replace('SVN_COMMIT_COUNTS', $text, $email_text);
-
-/****************************************************************************/
-/**** Weekly closed bugs ****************************************************/
-/****************************************************************************/
-
-$rawbuginfo = file_get_contents('http://bugs.php.net/api.php?type=docs&action=closed&interval=' . DAYS_LOOKUP);
-
-$text = '';
-if (!empty($rawbuginfo)) {
-
- $buginfo = unserialize($rawbuginfo);
-
- if (!is_array($buginfo)) {
- $text = 'Incorrect bugs information gathered.';
- } else {
- if (count($buginfo) > 0) {
- foreach ($buginfo as $info) {
- $text .= sprintf("%20s %5s\n", $info['reporter_name'], $info['count']);
- }
- } else {
- $text = 'No closed bugs last week. So sad. :(';
- }
- }
-} else {
- $text = 'Bug information could not be gathered.';
-}
-
-$email_text = str_replace('BUGS_CLOSED', $text, $email_text);
-
-/****************************************************************************/
-/**** Weekly notes stats ****************************************************/
-/****************************************************************************/
-
-// Note: notes_stats.sqlite is generated via web/doc/trunk/scripts/notes*.php
-// It's used for other note related activities, but we're using it for this too.
-$dbfile = SQLITE_DIR . 'notes_stats.sqlite';
-$text = '';
-if (is_readable($dbfile) && $db = sqlite_open($dbfile, 0666)) {
-
- $seconds = 86400*DAYS_LOOKUP;
-
- $sql = "SELECT who, count(*) as count FROM notes WHERE time > (strftime('%s', 'now')-{$seconds}) GROUP BY who ORDER BY count DESC";
-
- $res = sqlite_query($db, $sql);
- if ($res) {
-
- if (sqlite_num_fields($res) > 0) {
-
- $rows = sqlite_fetch_all($res, SQLITE_ASSOC);
-
- foreach ($rows as $row) {
- $text .= sprintf("%20s %5s\n", $row['who'], $row['count']);
- }
- } else {
- $text = 'No notes were edited last week. So sad. :(';
- }
- } else {
- $text = 'Unable to query the notes database';
- }
-
-} else {
- $text = 'The notes data cannot be found';
-}
-
-$email_text = str_replace('NOTES_HANDLED', $text, $email_text);
-
-/**** Misc ******************************************************************/
-$email_text = str_replace('SVN_MODULES_LIST', implode($svn_modules, ', '), $email_text);
-$email_text = str_replace('DATES_ACTIVITY', "$time_past to $time_now", $email_text);
-
-if (!DEBUG_MODE) {
- mail('[email protected]', 'The PHP documentation activity report', $email_text, 'From: [email protected]', '[email protected]');
-} else {
- echo $email_text;
-}
diff --git a/scripts/generation.sh b/scripts/generation.sh
deleted file mode 100755
index 05afae5..0000000
--- a/scripts/generation.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-
-. `dirname $0`/../build-ops
-
-echo "Generating revcheck databases"
-
-# cd back again
-cd ${SCRIPTSDIR}
-
-# PHP
-echo "Generating PHP database"
-${PHP} -q ./rev.php
-echo "... done."
-echo "Generating PHP pictures"
-${PHP} -q ./gen_picture_info.php
-echo "... done"
-
-echo "Generating global graphs"
-${PHP} -q ./gen_picture_info_all_lang.php
-echo "... done"
diff --git a/scripts/populatedocs.sh b/scripts/populatedocs.sh
deleted file mode 100755
index 88cd5df..0000000
--- a/scripts/populatedocs.sh
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/bin/bash
-# +----------------------------------------------------------------------+
-# | PHP Documentation Tools Site Source Code |
-# +----------------------------------------------------------------------+
-# | Copyright (c) 1997-2014 The PHP Group |
-# +----------------------------------------------------------------------+
-# | This source file is subject to version 3.0 of the PHP license, |
-# | that is bundled with this package in the file LICENSE, and is |
-# | available at through the world-wide-web at |
-# | http://www.php.net/license/3_0.txt. |
-# | If you did not receive a copy of the PHP license and are unable to |
-# | obtain it through the world-wide-web, please send a note to |
-# | [email protected] so we can mail you a copy immediately. |
-# +----------------------------------------------------------------------+
-# | Authors: Nilgün Belma Bugüner <[email protected]> |
-# | Jacques Marneweck <[email protected]> |
-# +----------------------------------------------------------------------+
-#
-LANGS="de en es fr it ja pl pt_br ro ru tr uk zh"
-
-GITBIN="/usr/bin/env git"
-pushd .
-
-cd `dirname $0`/..
-source ./build-ops
-
-if [ ! -d ${GITDIR} ]
-then
- echo "Making GIT directory: ${GITDIR}"
- /bin/mkdir ${GITDIR}
-fi
-
-echo "Changing to GIT directory: ${GITDIR}"
-cd ${GITDIR}
-
-echo "Checking out PHP docs..."
-if [ -d en ]
-then
- for L in $LANGS
- do
- (cd ${L} && ${GITBIN} pull)
- done
-else
- for L in $LANGS
- do
- ${GITBIN} clone https://github.com/php/doc-${L}.git ${L}
- done
-fi
-
-echo -n "Reverting directory:"
-popd
diff --git a/scripts/rev.php b/scripts/rev.php
deleted file mode 100644
index acdc831..0000000
--- a/scripts/rev.php
+++ /dev/null
@@ -1,640 +0,0 @@
-<?php
-/*
-+----------------------------------------------------------------------+
-| PHP Documentation Tools Site Source Code |
-+----------------------------------------------------------------------+
-| Copyright (c) 1997-2014 The PHP Group |
-+----------------------------------------------------------------------+
-| This source file is subject to version 3.0 of the PHP license, |
-| that is bundled with this package in the file LICENSE, and is |
-| available through the world-wide-web at the following url: |
-| http://www.php.net/license/3_0.txt. |
-| If you did not receive a copy of the PHP license and are unable to |
-| obtain it through the world-wide-web, please send a note to |
-| [email protected] so we can mail you a copy immediately. |
-+----------------------------------------------------------------------+
-| Original Authors: Thomas Schö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: |
-| Nilgün Belma Bugüner <nilgun at php dot net> |
-| Mehdi Achour <didou at php dot net> |
-| Maciej Sobaczewski <sobak at php dot net> |
-+----------------------------------------------------------------------+
-*/
-error_reporting(E_ALL);
-set_time_limit(0);
-
-// include required files
-include '../include/init.inc.php';
-include '../include/lib_proj_lang.inc.php';
-
-$time_start = microtime(true);
-
-function mark_time($time_start, $message)
-{
- static $last = null;
- if (!$last) $last = $time_start;
- $now = microtime(true);
- $time = $now - $time_start;
- $since_last = $now - $last;
- $last = $now;
-
- echo sprintf("Mark: %s: %.02fs elapsed, %.02f since last\n", $message, $time, $since_last);
-}
-
-$DOCS = GIT_DIR;
-
-// Test the languages:
-$LANGS = array_keys($LANGUAGES);
-$langc = count($LANGS);
-for ($i = 0; $i < $langc; $i++) {
- if (!is_dir($DOCS . $LANGS[$i])) {
- echo "Error: the \"{$LANGS[$i]}\" lang doesn't exist in dir {$DOCS}, skipping..\n";
- unset($LANGS[$i]);
- }
-}
-if (count($LANGS) == 0) {
- echo "Error: No language to revcheck, exiting.\n";
- exit;
-}
-
-$CREATE = <<<SQL
-
-CREATE TABLE descriptions (
- lang TEXT,
- intro TEXT,
- UNIQUE (lang)
-);
-
-CREATE TABLE translators (
- lang TEXT,
- nick TEXT,
- name TEXT,
- mail TEXT,
- vcs TEXT,
- files_uptodate INT,
- files_outdated INT,
- files_wip INT,
- files_sum INT,
- files_other INT,
- UNIQUE (lang, nick)
-);
-
-CREATE TABLE translated (
- id INT,
- lang TEXT,
- name TEXT,
- revision TEXT,
- size INT,
- maintainer TEXT,
- status TEXT,
- syncStatus TEXT,
- additions INT,
- deletions INT,
- UNIQUE(lang, id, name)
-);
-
-CREATE INDEX translated_1 ON translated (lang, id, name);
-
-CREATE TABLE dirs (
- id INT,
- path TEXT,
- UNIQUE (path)
-);
-
-CREATE INDEX dirs_1 ON dirs (path);
-
-CREATE TABLE enfiles (
- id INT,
- name TEXT,
- revision TEXT,
- size INT,
- UNIQUE(id, name)
-);
-
-CREATE INDEX enfiles_1 ON enfiles (id, name);
-
-CREATE TABLE Untranslated (
- id INT,
- lang TEXT,
- name TEXT,
- size INT,
- UNIQUE(lang, id, name)
-);
-
-CREATE INDEX Untrans_1 ON Untranslated (lang, id, name);
-
-CREATE TABLE notinen (
- lang TEXT,
- path TEXT,
- name TEXT,
- size INT,
- UNIQUE(lang, path, name)
-);
-
-CREATE INDEX notinen_1 ON notinen (lang, path, name);
-
-CREATE TABLE wip (
- id INT,
- lang TEXT,
- name TEXT,
- size INT,
- person TEXT
-);
-
-SQL;
-
-$SQL_BUFF = "";
-
-$enFiles = populateFileTree( 'en' );
-
-mark_time($time_start, "Populated 'en' tree");
-
-captureGitValues( $gitData );
-
-mark_time($time_start, "Captured Git hashes");
-
-foreach ($LANGS as $lang){
- $trFiles[$lang] = populateFileTree( $lang );
- mark_time($time_start, "Populated '{$lang}' tree");
-}
-
-class FileStatusInfo
-{
- public $path;
- public $name;
- public $size;
- public $hash;
- public $skip;
- public $hashes;
- public $syncStatus;
- public $maintainer;
- public $completion;
- public $credits;
-
- public function getKey()
- {
- return trim( $this->path . '/' . $this->name , '/' );
- }
-}
-
-class FileStatusEnum
-{
- const Untranslated = 'Untranslated';
- const RevTagProblem = 'RevTagProblem';
- const TranslatedWip = 'TranslatedWip';
- const TranslatedOk = 'TranslatedOk';
- const TranslatedOld = 'TranslatedOld';
- const TranslatedCritial = 'TranslatedCritial';
- const NotInEnTree = 'NotInEnTree';
-}
-
-class TranslatorInfo
-{
- public $name;
- public $email;
- public $nick;
- public $vcs;
-
- public $files_uptodate;
- public $files_outdated;
- public $files_wip;
- public $files_sum;
- public $files_other;
-
- public function __construct() {
- $this->files_uptodate = 0;
- $this->files_outdated = 0;
- $this->files_wip = 0;
- $this->files_sum = 0;
- $this->files_other = 0;
- }
-
- public static function getKey( $fileStatus ) {
- switch ( $fileStatus ) {
- case FileStatusEnum::RevTagProblem:
- case FileStatusEnum::TranslatedOld:
- case FileStatusEnum::TranslatedCritial:
- case FileStatusEnum::NotInEnTree:
- return "files_outdated";
- break;
- case FileStatusEnum::TranslatedWip:
- return "files_wip";
- break;
- case FileStatusEnum::TranslatedOk:
- return "files_uptodate";
- break;
- default:
- return "files_other";
- }
- }
-}
-
-// Get a multidimensional array with tag attributes
-function parse_attr_string ( $tags_attrs ) {
- $tag_attrs_processed = array();
-
- foreach($tags_attrs as $attrib_list) {
- preg_match_all("!(.+)=\\s*([\"'])\\s*(.+)\\2!U", $attrib_list, $attribs);
-
- $attrib_array = array();
- foreach ($attribs[1] as $num => $attrname) {
- $attrib_array[trim($attrname)] = trim($attribs[3][$num]);
- }
-
- $tag_attrs_processed[] = $attrib_array;
- }
-
- return $tag_attrs_processed;
-}
-
-function computeTranslatorStatus( $lang, $enFiles, $trFiles )
-{
- global $SQL_BUFF, $DOCS, $LANGUAGES;
- $translation_xml = $DOCS . $lang . "/translation.xml";
- $charset = 'utf-8';
-
- if (!file_exists($translation_xml)) {
- return [];
- }
-
- $txml = join("", file($translation_xml));
- $txml = preg_replace("/\\s+/", " ", $txml);
-
- $intro = "No intro available for the {$LANGUAGES[$lang]} translation of the manual.";
- if ( preg_match("!<intro>(.+)</intro>!s", $txml, $match) )
- $intro = SQLite3::escapeString(@iconv($charset, 'UTF-8//IGNORE', trim($match[1])));
-
- $SQL_BUFF .= "INSERT INTO descriptions VALUES ('$lang', '$intro');\n";
-
- $pattern = "!<person(.+)/\\s?>!U";
- preg_match_all($pattern, $txml, $matches);
- $translators = parse_attr_string($matches[1]);
-
- $translatorInfos = [];
- $unknownInfo = new TranslatorInfo();
- $unknownInfo->nick = "unknown";
- $translatorInfos["unknown"] = $unknownInfo;
-
- foreach ($translators as $key => $translator)
- {
- $info = new TranslatorInfo();
- $info->name = $translator["name"];
- $info->email = $translator["email"];
- $info->nick = $translator["nick"];
- $info->vcs = isset($translator["vcs"]) ? $translator["vcs"] : '';
-
- $translatorInfos[$info->nick] = $info;
- }
-
- foreach( $enFiles as $key => $enFile ) {
- $info_exists = false;
- if (array_key_exists($enFile->getKey(), $trFiles)) {
- $trFile = $trFiles[$enFile->getKey()];
- $statusKey = TranslatorInfo::getKey($trFile->syncStatus);
- if (array_key_exists($trFile->maintainer, $translatorInfos)) {
- $translatorInfos[$trFile->maintainer]->$statusKey++;
- $translatorInfos[$trFile->maintainer]->files_sum++;
- $info_exists = true;
- }
- }
- if (!$info_exists) {
- $translatorInfos["unknown"]->$statusKey++;
- $translatorInfos["unknown"]->files_sum++;
- }
- }
- foreach ($translatorInfos as $key => $person)
- {
- if ($person->nick != "unknown" )
- {
- $nick = SQLite3::escapeString($person->nick);
- $name = SQLite3::escapeString(@iconv($charset, 'UTF-8//IGNORE', $person->name));
- $email = SQLite3::escapeString($person->email);
- $vcs = SQLite3::escapeString($person->vcs);
-
- $SQL_BUFF .= "INSERT INTO translators VALUES ('$lang',
- '$nick', '$name', '$email', '$vcs', $person->files_uptodate,
- $person->files_outdated, $person->files_wip,
- $person->files_sum, $person->files_other);\n";
- }
- }
-}
-
-function populateFileTree( $lang )
-{
- global $DOCS;
- $dir = new \DirectoryIterator( $DOCS . $lang );
- if ( $dir === false )
- {
- print "$lang is not a directory.\n";
- exit;
- }
- $cwd = getcwd();
- $ret = array();
- chdir( $DOCS . $lang );
- populateFileTreeRecurse( $lang , "." , $ret );
- chdir( $cwd );
- return $ret;
-}
-
-function populateFileTreeRecurse( $lang , $path , & $output )
-{
- global $DOCS, $SQL_BUFF;
- $dir = new DirectoryIterator( $path );
- if ( $dir === false )
- {
- print "$path is not a directory.\n";
- exit;
- }
- $todoPaths = [];
- $trimPath = ltrim( $path , "./");
- foreach( $dir as $entry )
- {
- $filename = $entry->getFilename();
- if ( $filename[0] == '.' )
- continue;
- if ( substr( $filename , 0 , 9 ) == "entities." )
- continue;
- if ( $entry->isDir() )
- {
- $todoPaths[] = $path . '/' . $entry->getFilename();
- continue;
- }
- if ( $entry->isFile() )
- {
- $ignoredFileNames = [
- 'README.md',
- 'translation.xml',
- 'readme.first',
- 'license.xml',
- 'extensions.xml',
- 'versions.xml',
- 'book.developer.xml',
- 'contributors.ent',
- 'contributors.xml',
- 'README',
- 'DO_NOT_TRANSLATE',
- 'rsusi.txt',
- 'missing-ids.xml',
- ];
-
- $ignoredDirectories = [
- 'chmonly',
- 'output',
- ];
-
- $ignoredFullPaths = [
- 'appendices/reserved.constants.xml',
- 'appendices/extensions.xml',
- 'reference/datetime/timezones.xml',
- ];
-
- if(
- in_array($trimPath, $ignoredDirectories, true)
- || in_array($filename, $ignoredFileNames, true)
- || (strpos($filename, 'entities.') === 0)
- || !in_array(substr($filename, -3), ['xml','ent'], true)
- || (substr($filename, -13) === 'PHPEditBackup')
- || (in_array($trimPath . '/' .$filename, $ignoredFullPaths, true))
- ) continue;
-
- $file = new FileStatusInfo;
- $file->path = $trimPath;
- $file->name = $filename;
- $file->size = filesize( $path . '/' . $filename );
- $file->syncStatus = null;
- if ( $lang != 'en' )
- {
- parseRevisionTag( $entry->getPathname() , $file );
- $path_en = $DOCS . 'en/' . $trimPath . '/' . $filename;
- if( !is_file($path_en) ) //notinen
- {
- $filesize = $file->size < 1024 ? 1 : floor( $file->size / 1024 );
- $SQL_BUFF .= "INSERT INTO notinen VALUES ('$lang', '$trimPath', '$filename', $filesize);\n";
- } else {
- $output[ $file->getKey() ] = $file;
- }
- } else {
- $output[ $file->getKey() ] = $file;
- }
- }
- }
- sort( $todoPaths );
- foreach( $todoPaths as $path )
- populateFileTreeRecurse( $lang , $path , $output );
-}
-
-function parseRevisionTag( $filename , FileStatusInfo $file )
-{
- $fp = fopen( $filename , "r" );
- $contents = fread( $fp , 1024 );
- fclose( $fp );
-
- // No match before the preg
- $match = array ();
-
- $regex = "'<!--\s*EN-Revision:\s*(.+)\s*Maintainer:\s*(.+)\s*Status:\s*(.+)\s*-->'U";
- if (preg_match ($regex , $contents , $match )) {
- $file->hash = trim( $match[1] );
- $file->maintainer = trim( $match[2] );
- $file->completion = trim( $match[3] );
- }
- if ( $file->hash == null or strlen( $file->hash ) != 40 or
- $file->maintainer == null or
- $file->completion == null )
- $file->syncStatus = FileStatusEnum::RevTagProblem;
-
- $regex = "/<!--\s*CREDITS:\s*(.+)\s*-->/U";
- $match = array();
- preg_match ( $regex , $contents , $match );
- if ( count( $match ) == 2 )
- $file->credits = str_replace( ' ' , '' , trim( $match[1] ) );
- else
- $file->credits = '';
-}
-
-function captureGitValues( & $output )
-{
- global $DOCS;
- $cwd = getcwd();
- chdir( $DOCS . 'en' );
- $fp = popen( "git --no-pager log --name-only" , "r" );
- $hash = null;
- $skipThisCommit = false;
-
- while ( ( $line = fgets( $fp ) ) !== false )
- {
- if ( substr( $line , 0 , 7 ) == "commit " )
- {
- $hash = trim( substr( $line , 7 ) );
- $skipThisCommit = false;
- continue;
- }
- if ( strpos( $line , 'Date:' ) === 0 )
- continue;
- if ( trim( $line ) == "" )
- continue;
- if ( substr( $line , 0 , 4 ) == ' ' )
- {
- if ( stristr( $line, '[skip-revcheck]' ) !== false )
- {
- $skipThisCommit = true;
- }
- continue;
- }
- if ( strpos( $line , ': ' ) > 0 )
- continue;
- $filename = trim( $line );
- if ( isset( $output[$filename] ) )
- continue;
- $output[$filename]['hash'] = $hash;
- $output[$filename]['skip'] = $skipThisCommit;
- }
- pclose( $fp );
- chdir( $cwd );
-}
-
-/**
-* Script execution
-**/
-
-$path = null;
-$id = 0;
-asort( $enFiles );
-foreach( $enFiles as $key => $en )
-{
- if ( $path !== $en->path )
- {
- $id++;
- $path = $en->path;
- $path2 = $path == '' ? '/' : $path;
- $SQL_BUFF .= "INSERT INTO dirs VALUES ($id, '$path2');\n";
- }
-
- $size = $en->size < 1024 ? 1 : floor( $en->size / 1024 );
- $filename = $path . ($path == '' ? '' : '/') . $en->name;
- $en->hash = null;
- if ( isset( $gitData[ $filename ] ) )
- {
- $en->hash = $gitData[ $filename ]['hash'];
- $en->skip = $gitData[ $filename ]['skip'];
- }
- else
- print "Warn: No hash for en/$filename\n";
-
- $SQL_BUFF .= "INSERT INTO enfiles VALUES ($id, '$en->name', '$en->hash', $size);\n";
-
- foreach( $LANGS as $lang )
- {
- $trFile = isset( $trFiles[$lang][$filename] ) ? $trFiles[$lang][$filename] : null;
- if ( $trFile == null ) // Untranslated
- {
- $SQL_BUFF .= "INSERT INTO Untranslated VALUES ($id, '$lang',
- '$en->name', $size);\n";
- }
- else if ($trFile->syncStatus == FileStatusEnum::RevTagProblem)
- {
- $SQL_BUFF .= "INSERT INTO translated VALUES ($id, '$lang',
- '$en->name', '$trFile->hash', $size, '$trFile->maintainer',
- '$trFile->completion', '$trFile->syncStatus', 0, 0);\n";
- }
- else
- {
- $additions = $deletions = -1;
- if ( $en->hash == $trFile->hash ){
- $trFile->syncStatus = FileStatusEnum::TranslatedOk;
- } elseif ( $trFile->hash != null and strlen( $trFile->hash ) == 40 ) {
- $trFile->syncStatus = FileStatusEnum::TranslatedOld;
-
- $cwd = getcwd();
- chdir( $DOCS . 'en' );
- $subject = `git diff --numstat {$trFile->hash} -- {$filename}`;
- chdir( $cwd );
- if ( $subject ) {
- preg_match('/(\d+)\s+(\d+)/', $subject, $matches);
- if ($matches)
- [, $additions, $deletions] = $matches;
- }
- }
- if ( $trFile->completion != null && $trFile->completion != "ready" )
- $trFile->syncStatus = FileStatusEnum::TranslatedWip;
- if ( $en->skip ) {
- if (!$en->hashes) {
- $cwd = getcwd();
- chdir( $DOCS . 'en' );
- $en->hashes = explode ( "\n" , `git log -2 --format=%H -- {$filename}` );
- }
- chdir( $cwd );
- if ( $en->hashes[1] == $trFile->hash )
- $trFile->syncStatus = FileStatusEnum::TranslatedOk;
- }
- $SQL_BUFF .= "INSERT INTO translated VALUES ($id, '$lang',
- '$en->name', '$trFile->hash', $size, '$trFile->maintainer',
- '$trFile->completion', '$trFile->syncStatus', $additions, $deletions);\n";
- }
- }
-}
-
-mark_time($time_start, "Computed 'enfiles', 'translated', and 'Untranslated'");
-
-foreach( $LANGS as $lang ) {
- computeTranslatorStatus( $lang, $enFiles, $trFiles[$lang] );
-}
-
-mark_time($time_start, "Computed translator status");
-
-$db_name = SQLITE_DIR . 'rev.php.sqlite';
-$tmp_db = SQLITE_DIR . 'rev.php.tmp.sqlite';
-
-// 1 - Drop the old database and create the new one
-if (is_file($tmp_db)) {
- echo "Temporary database found: remove.\n";
-
- if (!@unlink($tmp_db)) {
- echo "Error: Can't remove temporary database\n";
- exit;
- }
-}
-
-// 2 - Create the new database
-try {
- $db = new SQLite3($tmp_db);
- /* Didn't throw exception at some point? */
- if (!$db) {
- throw Exception("Cant open $tmp_db");
- }
-
-} catch(Exception $e) {
- echo $e->getMessage();
- echo "Could not open $tmp_db";
- exit;
-}
-
-$db->exec($CREATE);
-
-// 3 - Fill in the description table while cleaning the langs
-// without revision.xml file
-// 4 - Recurse in the manual seeking for files and fill $SQL_BUFF
-
-
-
-
-// 5 - Query $SQL_BUFF and exit
-$db->exec('BEGIN TRANSACTION');
-$db->exec($SQL_BUFF);
-$db->exec('COMMIT');
-$db->close();
-
-mark_time($time_start, "Populated SQLite database");
-
-echo "Copying temporary database to final database\n";
-
-copy($tmp_db, $db_name);
-@unlink($tmp_db);
-
-$time = microtime(true) - $time_start;
-
-echo "Time of generation: $time s\n";
-echo "End\n";
diff --git a/www/img-status-all.php b/www/img-status-all.php
index 6e2f5f8..ff8e62d 100644
--- a/www/img-status-all.php
+++ b/www/img-status-all.php
@@ -5,16 +5,17 @@
require_once __DIR__ . '/../include/init.inc.php';
require_once __DIR__ . '/../include/lib_revcheck.inc.php';
-$idx = new SQLite3(SQLITE_DIR . 'rev.php.sqlite');
+$idx = new SQLite3(SQLITE_DIR . 'status.sqlite');
$language = revcheck_available_languages($idx);
sort($language);
-$files_EN = count_en_files($idx);
foreach ($language as $lang) {
- $tmp = get_stats($idx, $lang, 'uptodate');
+ $stats = get_lang_stats($idx, $lang);
- $percent_tmp[] = round($tmp[0] * 100 / $files_EN);
+ if (!$stats) die("No stats for $lang");
+
+ $percent_tmp[] = round($stats['TranslatedOk']['total'] * 100 / $stats['total']['total']);
$legend_tmp[] = $lang;
}
@@ -24,7 +25,6 @@
// Create the graph. These two calls are always required
$graph = new Graph(600,262);
$graph->SetScale("textlin");
-$graph->yaxis->scale->SetGrace(20);
$graph->xaxis->SetLabelmargin(5);
$graph->xaxis->SetTickLabels($legend);
@@ -39,29 +39,27 @@
// Create a bar pot
$bplot = new BarPlot($percent);
+$graph->Add($bplot);
// Adjust fill color
-$bplot->SetFillColor('#9999CC');
+$bplot->SetFillColor([ '#9999CC', '#99CC99', '#CC9999' ]);
$bplot->SetShadow();
$bplot->value->Show();
-$bplot->value->SetFont(FF_ARIAL,FS_BOLD,10);
-$bplot->value->SetAngle(45);
-$bplot->value->SetFormat('%0.0f');
+$bplot->value->SetFont(FF_FONT1,FS_NORMAL,10);
+$bplot->value->SetFormat('%0.0f%%');
// Width
$bplot->SetWidth(0.6);
-$graph->Add($bplot);
-
// Setup the titles
$graph->title->Set("PHP Translation Status");
$graph->xaxis->title->Set("Language");
$graph->yaxis->title->Set("Files up to date (%)");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
-$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
-$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
+$graph->yaxis->title->SetFont(FF_FONT1,FS_NORMAL);
+$graph->xaxis->title->SetFont(FF_FONT1,FS_NORMAL);
// Display the graph
$graph->Stroke();
diff --git a/www/img-status-lang.php b/www/img-status-lang.php
index 183223e..ba54520 100644
--- a/www/img-status-lang.php
+++ b/www/img-status-lang.php
@@ -8,7 +8,7 @@
require_once __DIR__ . '/../include/lib_revcheck.inc.php';
require_once __DIR__ . '/../include/lib_proj_lang.inc.php';
-$idx = new SQLite3(SQLITE_DIR . 'rev.php.sqlite');
+$idx = new SQLite3(SQLITE_DIR . 'status.sqlite');
$available_langs = revcheck_available_languages($idx);
@@ -23,17 +23,15 @@
function generate_image($lang, $idx) {
global $LANGUAGES;
- $up_to_date = get_stats($idx, $lang, 'uptodate');
- $up_to_date = $up_to_date[0];
+ $stats = get_lang_stats($idx, $lang);
+
+ $up_to_date = $stats['TranslatedOk']['total'] ?? 0;
//
- $outdated = @get_stats($idx, $lang, 'outdated');
- $outdated = $outdated[0];
+ $outdated = $stats['TranslatedOld']['total'] ?? 0;
//
- $missing = get_stats($idx, $lang, 'notrans');
- $missing = $missing[0];
+ $missing = $stats['Untranslated']['total'] ?? 0;
//
- $no_tag = @get_stats($idx, $lang, 'norev');
- $no_tag = $no_tag[0];
+ $no_tag = $stats['RevTagProblem']['total'] ?? 0;
$data = array(
$up_to_date,
diff --git a/www/redirect.php b/www/redirect.php
index 22547e8..b7db191 100644
--- a/www/redirect.php
+++ b/www/redirect.php
@@ -17,7 +17,6 @@
+----------------------------------------------------------------------+
*/
-require_once(__DIR__ . '/../build-ops.php');
require_once(__DIR__ . '/../include/lib_proj_lang.inc.php');
/* mime types for downloading files */
diff --git a/www/revcheck.php b/www/revcheck.php
index 41ccd35..28e2bc0 100644
--- a/www/revcheck.php
+++ b/www/revcheck.php
@@ -31,26 +31,26 @@
die;
}
-$DBLANG = SQLITE_DIR . 'rev.php.sqlite';
+$DBLANG = SQLITE_DIR . 'status.sqlite';
-// Check if db connection can be established and if revcheck for requested lang exists
-if ($dbhandle = new SQLite3($DBLANG)) {
- $check_lang_tmp = $dbhandle->query("SELECT COUNT(lang) AS count FROM descriptions WHERE lang = '$lang'");
- $check_lang = $check_lang_tmp->fetchArray();
- if ($lang != 'en' && $check_lang['count'] < 0) {
- site_header();
- echo "<p>This revision check doesn't exist yet.</p>";
- site_footer();
- die;
- }
-}
-else {
+$dbhandle = new SQLite3($DBLANG);
+if (!$dbhandle) {
site_header();
echo "<p>Database connection couldn't be established</p>";
site_footer();
die;
}
+// Check if db connection can be established and if revcheck for requested lang exists
+$lang_intro = get_language_intro($dbhandle, $lang);
+
+if ($lang !== 'en' && is_null($lang_intro)) {
+ site_header();
+ echo "<p>This revision check doesn't exist yet.</p>";
+ site_footer();
+ die;
+}
+
site_header();
switch($tool) {
case 'translators':
@@ -60,18 +60,14 @@
echo '<p>Error: no translators info found in database.</p>';
}
else {
- $uptodate = get_translators_stats($dbhandle, $lang, 'uptodate');
- $outdated = get_translators_stats($dbhandle, $lang, 'outdated');
- $wip = get_translators_stats($dbhandle, $lang, 'wip');
-
foreach($translators as $nick =>$data) {
- $files_w[$nick] = array('uptodate' => '', 'outdated' => '', 'norev' => '', 'wip' => '');
- $files_w[$nick]['uptodate'] = isset($uptodate[$nick]) ? $uptodate[$nick] : '';
- $files_w[$nick]['wip'] = isset($wip[$nick]) ? $wip[$nick] : '';
- $files_w[$nick]['outdated'] = isset($outdated[$nick]) ? $outdated[$nick] : '';
- }
+ $files_w[$nick] = array('uptodate' => '', 'outdated' => '', 'norev' => '', 'wip' => '');
+ $files_w[$nick]['uptodate'] = $data['countOk'];
+ $files_w[$nick]['wip'] = $data['countOther'];
+ $files_w[$nick]['outdated'] = $data['countOld'];
+ }
- echo <<<TRANSLATORS_HEAD
+ echo <<<TRANSLATORS_HEAD
<table class="c">
<tr>
<th rowspan="2">Name</th>
@@ -87,19 +83,19 @@
</tr>
TRANSLATORS_HEAD;
- foreach ($translators as $nick => $data) {
- echo '<tr>',
- '<td><a href="mailto:'.$data['mail'].'">'.$data['name'].'</a></td>',
- '<td><a href="/revcheck.php?p=files&user='.$nick.'&lang='.$lang.'">'.$nick.'</a></td>',
- '<td>'.(($data['karma'] == 'yes') ? '✓' : ' ').'</td>',
- '<td>' , @$files_w[$nick]['uptodate'], '</td>',
- '<td>' , $files_w[$nick]['outdated'], '</td>',
- '<td>', $files_w[$nick]['wip'], '</td>',
- '<th>' , @array_sum($files_w[$nick]), '</th>',
- '</tr>';
- }
- echo '</table>';
- }
+ foreach ($translators as $nick => $data) {
+ echo '<tr>',
+ '<td><a href="mailto:'.$data['mail'].'">'.$data['name'].'</a></td>',
+ '<td><a href="/revcheck.php?p=files&user='.$nick.'&lang='.$lang.'">'.$nick.'</a></td>',
+ '<td>'.(($data['karma'] == 'yes') ? '✓' : ' ').'</td>',
+ '<td>' , @$files_w[$nick]['uptodate'], '</td>',
+ '<td>' , $files_w[$nick]['outdated'], '</td>',
+ '<td>', $files_w[$nick]['wip'], '</td>',
+ '<th>' , @array_sum($files_w[$nick]), '</th>',
+ '</tr>';
+ }
+ echo '</table>';
+ }
echo gen_date($DBLANG);
break;
@@ -209,88 +205,36 @@
break;
case 'filesummary':
- $files_uptodate = get_stats($dbhandle, $lang, 'uptodate');
- $files_outdated = get_stats($dbhandle, $lang, 'outdated');
- $files_norev = get_stats($dbhandle, $lang, 'norev');
- $files_notrans = get_stats($dbhandle, $lang, 'notrans');
- $files_wip = get_stats($dbhandle, $lang, 'wip');
- $files_notinen = get_stats($dbhandle, $lang, 'notinen');
-
- $files_outdated[1] = $files_outdated[1] > 0 ? $files_outdated[1] : 0;
- $files_norev[1] = $files_norev[1] > 0 ? $files_norev[1] : 0;
- $files_wip[1] = $files_wip[1] > 0 ? $files_wip[1] : 0;
- $files_notinen[1] = $files_notinen[1] > 0 ? $files_notinen[1] : 0;
+ $stats = get_lang_stats($dbhandle, $lang);
echo '<table class="c">';
echo '<tr><th>File status type</th><th>Number of files</th><th>Percent of files</th><th>Size of files (kB)</th><th>Percent of size</th></tr>';
- $percent[0] = 0;
- $percent[1] = 0;
- $count = count_en_files($dbhandle);
-
- $percent[1] += $files_uptodate[1];
- $percent[1] += $files_outdated[1];
- $percent[1] += $files_norev[1];
- $percent[1] += $files_notrans[1];
- $percent[1] += $files_wip[1];
-
- $num_uptodate_percent = number_format($files_uptodate[0] * 100 / $count, 2 );
- $num_outdated_percent = number_format($files_outdated[0] * 100 / $count, 2 );
- $num_wip_percent = number_format($files_wip[0] * 100 / $count, 2 );
- $num_norev_percent = number_format($files_norev[0] * 100 / $count, 2 );
- $num_notrans_percent = number_format($files_notrans[0] * 100 / $count, 2 );
-
- $size_uptodate_percent = number_format($files_uptodate[1] * 100 / $percent[1], 2 );
- $size_outdated_percent = number_format($files_outdated[1] * 100 / $percent[1], 2 );
- $size_wip_percent = number_format($files_wip[1] * 100 / $percent[1], 2 );
- $size_norev_percent = number_format($files_norev[1] * 100 / $percent[1], 2 );
- $size_notrans_percent = number_format($files_notrans[1] * 100 / $percent[1], 2 );
- print <<<HTML
-<tr>
-<td>Up to date files</td>
-<td>{$files_uptodate[0]}</td>
-<td>{$num_uptodate_percent}%</td>
-<td>{$files_uptodate[1]}</td>
-<td>{$size_uptodate_percent}%</td>
-</tr><tr>
-<td>Outdated files</td>
-<td>{$files_outdated[0]}</td>
-<td>{$num_outdated_percent}%</td>
-<td>{$files_outdated[1]}</td>
-<td>{$size_outdated_percent}%</td>
-</tr><tr>
-<td>Work in progress</td>
-<td>{$files_wip[0]}</td>
-<td>{$num_wip_percent}%</td>
-<td>{$files_wip[1]}</td>
-<td>{$size_wip_percent}%</td>
-</tr><tr>
-<td>Files without revision number</td>
-<td>{$files_norev[0]}</td>
-<td>{$num_norev_percent}%</td>
-<td>$files_norev[1]</td>
-<td>{$size_norev_percent}%</td>
-</tr><tr>
-<td>Not in EN tree</td>
-<td>{$files_notinen[0]}</td>
-<td>0.00%</td>
-<td>{$files_notinen[1]}</td>
-<td>0.00%</td>
-</tr><tr>
-<td>Files available for translation </td>
-<td>{$files_notrans[0]}</td>
-<td>{$num_notrans_percent}%</td>
-<td>{$files_notrans[1]}</td>
-<td>{$size_notrans_percent}%</td>
-</tr><tr>
-<th>Files total</th>
-<th>$count</th>
-<th>100%</th>
-<th>{$percent[1]}</th
-><th>100%</th>
-</tr></table>
-HTML;
- echo gen_date($DBLANG);
+ foreach ($TRANSLATION_STATUSES as $status => $description) {
+ echo
+ '<tr>',
+ '<td>', $description, '</td>',
+ '<td>', $stats[$status]['total'] ?? 0, '</td>',
+ '<td>',
+ sprintf('%.2f%%', 100 * (($stats[$status]['total'] ?? 0) / $stats['total']['total'])),
+ '</td>',
+ '<td>', $stats[$status]['size'] ?? 0, '</td>',
+ '<td>',
+ sprintf('%.2f%%', 100 * (($stats[$status]['size'] ?? 0) / $stats['total']['size'])),
+ '</td>',
+ '</tr>';
+ }
+ echo
+ '<tr>',
+ '<th>Total</th>',
+ '<th>', $stats['total']['total'] ?? 0, '</th>',
+ '<th>100.00%</th>',
+ '<th>', $stats['total']['size'] ?? 0, '</th>',
+ '<th>100.00%</th>',
+ '</tr>';
+ echo '</table>';
+
+ echo gen_date($DBLANG);
break;
@@ -428,10 +372,8 @@
$sidebar = nav_languages();
site_footer($sidebar);
} else {
- $intro_result = $dbhandle->query("SELECT intro FROM descriptions WHERE lang = '$lang'");
- $intro = $intro_result->fetchArray();
echo '<h2>Intro for language</h2>';
- echo '<p>'.$intro[0].'</p>';
+ echo '<p>'.$lang_intro.'</p>';
echo '<img src="img-status-lang.php?lang=', $lang, '" width="680" height="300" alt="info">';
echo gen_date($DBLANG);
echo '<p>Links to available tools are placed on the right sidebar.</p>';