mirror of
https://github.com/php/web-doc.git
synced 2025-08-10 02:56:24 +00:00
Apply Yannick's revcheck patches
This commit is contained in:
@ -217,6 +217,32 @@ function get_missfiles($idx, $lang)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_oldfiles($idx, $lang)
|
||||||
|
{
|
||||||
|
$sql = 'SELECT
|
||||||
|
dir, file, size
|
||||||
|
|
||||||
|
FROM
|
||||||
|
old_files
|
||||||
|
|
||||||
|
WHERE
|
||||||
|
lang="' . $lang . '"
|
||||||
|
';
|
||||||
|
|
||||||
|
$result = sqlite_query($idx, $sql);
|
||||||
|
$num = sqlite_num_rows($result);
|
||||||
|
if ($num == 0) {
|
||||||
|
// only 'null' will produce a 0 with sizeof()
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
$tmp = array();
|
||||||
|
while ($r = sqlite_fetch_array($result, SQLITE_ASSOC)) {
|
||||||
|
$tmp[] = array('dir' => $r['dir'], 'size' => $r['size'], 'file' => $r['file']);
|
||||||
|
}
|
||||||
|
return $tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function get_description($idx, $lang)
|
function get_description($idx, $lang)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT intro FROM description WHERE lang = "' . $lang . '";';
|
$sql = 'SELECT intro FROM description WHERE lang = "' . $lang . '";';
|
||||||
|
@ -147,6 +147,13 @@ CREATE TABLE files (
|
|||||||
UNIQUE(lang, dir, name)
|
UNIQUE(lang, dir, name)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE TABLE old_files (
|
||||||
|
lang TEXT,
|
||||||
|
dir TEXT,
|
||||||
|
file TEXT,
|
||||||
|
size INT
|
||||||
|
);
|
||||||
|
|
||||||
SQL;
|
SQL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -252,6 +259,23 @@ function dir_sort($a, $b) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function dir_sort_old($a, $b) {
|
||||||
|
global $DOCS, $dir, $lang;
|
||||||
|
$a = $DOCS . $lang . $dir . '/' . $a;
|
||||||
|
$b = $DOCS . $lang . $dir . '/' . $b;
|
||||||
|
if (is_dir($a) && is_dir($b)) {
|
||||||
|
return 0;
|
||||||
|
} elseif (is_file($a) && is_file($b)) {
|
||||||
|
return 0;
|
||||||
|
} elseif (is_file($a) && is_dir($b)) {
|
||||||
|
return -1;
|
||||||
|
} elseif (is_dir($a) && is_file($b)) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function do_revcheck($dir = '') {
|
function do_revcheck($dir = '') {
|
||||||
global $LANGS, $DOCS, $SQL_BUFF;
|
global $LANGS, $DOCS, $SQL_BUFF;
|
||||||
static $id = 1;
|
static $id = 1;
|
||||||
@ -334,6 +358,65 @@ function do_revcheck($dir = '') {
|
|||||||
closedir($dh);
|
closedir($dh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function check_old_files($dir = '', $lang) {
|
||||||
|
global $DOCS, $SQL_BUFF;
|
||||||
|
static $id = 1;
|
||||||
|
|
||||||
|
if ($dh = opendir($DOCS . $lang . $dir)) {
|
||||||
|
|
||||||
|
$entriesDir = array();
|
||||||
|
$entriesFiles = array();
|
||||||
|
|
||||||
|
while (($file = readdir($dh)) !== false) {
|
||||||
|
if (
|
||||||
|
(!is_dir($DOCS . $lang . $dir.'/' .$file) && !in_array(substr($file, -3), array('xml','ent')) && substr($file, -13) != 'PHPEditBackup' )
|
||||||
|
|| ($file == "functions.xml" && strpos($dir, '/reference') !== false)
|
||||||
|
|| $dir == '/chmonly'
|
||||||
|
|| $file == 'contributors.ent' || $file == 'contributors.xml'
|
||||||
|
|| ($dir == '/appendices' && $file == 'reserved.constants.xml')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($file != '.' && $file != '..' && $file != 'CVS' && $dir != '/functions') {
|
||||||
|
|
||||||
|
if (is_dir($DOCS . $lang . $dir.'/' .$file)) {
|
||||||
|
$entriesDir[] = $file;
|
||||||
|
} elseif (is_file($DOCS . $lang . $dir.'/' .$file)) {
|
||||||
|
$entriesFiles[] = $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Files first
|
||||||
|
if (sizeof($entriesFiles) > 0 ) {
|
||||||
|
|
||||||
|
foreach($entriesFiles as $file) {
|
||||||
|
|
||||||
|
$path_en = $DOCS . 'en/' . $dir . '/' . $file;
|
||||||
|
$path = $DOCS . $lang . $dir . '/' . $file;
|
||||||
|
|
||||||
|
if( !@is_file($path_en) ) {
|
||||||
|
|
||||||
|
$size = intval(filesize($path) / 1024);
|
||||||
|
$SQL_BUFF .= "INSERT INTO old_files VALUES ('$lang', '$dir', '$file', '$size');\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Directories..
|
||||||
|
if (sizeof($entriesDir) > 0) {
|
||||||
|
|
||||||
|
usort($entriesDir, 'dir_sort_old');
|
||||||
|
reset($entriesDir);
|
||||||
|
|
||||||
|
foreach ($entriesDir as $Edir) {
|
||||||
|
check_old_files($dir . '/' . $Edir, $lang);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir($dh);
|
||||||
|
}
|
||||||
|
|
||||||
function get_tags($file)
|
function get_tags($file)
|
||||||
{
|
{
|
||||||
@ -431,6 +514,12 @@ foreach ($LANGS as $id => $lang) {
|
|||||||
// 4 - Recurse in the manual seeking for files and fill $SQL_BUFF
|
// 4 - Recurse in the manual seeking for files and fill $SQL_BUFF
|
||||||
do_revcheck();
|
do_revcheck();
|
||||||
|
|
||||||
|
// 4:1 - Recurse in the manuel seeking for old files for each language and fill $SQL_BUFF
|
||||||
|
|
||||||
|
foreach ($LANGS as $lang) {
|
||||||
|
check_old_files('', $lang);
|
||||||
|
}
|
||||||
|
|
||||||
// 5 - Query $SQL_BUFF and exit
|
// 5 - Query $SQL_BUFF and exit
|
||||||
|
|
||||||
sqlite_query($idx, 'BEGIN TRANSACTION');
|
sqlite_query($idx, 'BEGIN TRANSACTION');
|
||||||
|
@ -120,6 +120,7 @@ array (REV_NOTRANS, "Files available for translation")
|
|||||||
<li<?php echo ($PART == 'files' ) ? ' class="liSelected"' : ''; ?>><a href="<?php echo BASE_URL . '/revcheck.php?p=files">Files</a>'; ?></li>
|
<li<?php echo ($PART == 'files' ) ? ' class="liSelected"' : ''; ?>><a href="<?php echo BASE_URL . '/revcheck.php?p=files">Files</a>'; ?></li>
|
||||||
<li<?php echo ($PART == 'misstags' ) ? ' class="liSelected"' : ''; ?>><a href="<?php echo BASE_URL . '/revcheck.php?p=misstags">Missing revision numbers</a>'; ?></li>
|
<li<?php echo ($PART == 'misstags' ) ? ' class="liSelected"' : ''; ?>><a href="<?php echo BASE_URL . '/revcheck.php?p=misstags">Missing revision numbers</a>'; ?></li>
|
||||||
<li<?php echo ($PART == 'missfiles' ) ? ' class="liSelected"' : ''; ?>><a href="<?php echo BASE_URL . '/revcheck.php?p=missfiles">Untranslated files</a>'; ?></li>
|
<li<?php echo ($PART == 'missfiles' ) ? ' class="liSelected"' : ''; ?>><a href="<?php echo BASE_URL . '/revcheck.php?p=missfiles">Untranslated files</a>'; ?></li>
|
||||||
|
<li<?php echo ($PART == 'oldfiles' ) ? ' class="liSelected"' : ''; ?>><a href="<?php echo BASE_URL . '/revcheck.php?p=oldfiles">Not in EN tree</a>'; ?></li>
|
||||||
<li<?php echo ($PART == 'graph' ) ? ' class="liSelected"' : ''; ?>><a href="<?php echo BASE_URL . '/revcheck.php?p=graph">Graph</a>'; ?></li>
|
<li<?php echo ($PART == 'graph' ) ? ' class="liSelected"' : ''; ?>><a href="<?php echo BASE_URL . '/revcheck.php?p=graph">Graph</a>'; ?></li>
|
||||||
</ul>
|
</ul>
|
||||||
<?php
|
<?php
|
||||||
@ -233,6 +234,43 @@ MISSTAGS_HEAD;
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'oldfiles' :
|
||||||
|
$oldfiles = get_oldfiles($dbhandle, $LANG);
|
||||||
|
if (!$oldfiles) {
|
||||||
|
echo 'No old file info';
|
||||||
|
} else {
|
||||||
|
$num = count($oldfiles);
|
||||||
|
echo <<<OLDTAGS_HEAD
|
||||||
|
<p> </p>
|
||||||
|
<div style="text-align:center"> <!-- Compatibility with old IE -->
|
||||||
|
<table width="400" border="0" cellpadding="3" cellspacing="1" class="Tc">
|
||||||
|
<tr class="blue">
|
||||||
|
<th rowspan="1">Not in EN tree ($num files):</th>
|
||||||
|
<th colspan="1">kB</th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
OLDTAGS_HEAD;
|
||||||
|
|
||||||
|
$last_dir = false;
|
||||||
|
$total_size = 0;
|
||||||
|
foreach ($oldfiles as $old) {
|
||||||
|
if (!$last_dir || $last_dir != $old['dir']) {
|
||||||
|
echo '<tr class="blue"><th colspan="2">' . $old['dir'] . '</th></tr>';
|
||||||
|
$last_dir = $old['dir'];
|
||||||
|
}
|
||||||
|
echo '<tr class="wip"><td>', $old['file'], '</td><td class="r">', $old['size'], '</td></tr>';
|
||||||
|
$total_size += $old['size'];
|
||||||
|
// flush every 200 kbytes
|
||||||
|
if (($total_size % 200) == 0) {
|
||||||
|
flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo '<tr class="blue">
|
||||||
|
<th colspan="2">Total Size ('.$num.' files): '.$total_size.' kB</th>
|
||||||
|
</tr>';
|
||||||
|
echo '</table></div>';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'misstags' :
|
case 'misstags' :
|
||||||
$sql = 'select
|
$sql = 'select
|
||||||
|
Reference in New Issue
Block a user