[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r4206 - in i18nHTML: . src/admin
From: |
grothoff |
Subject: |
[GNUnet-SVN] r4206 - in i18nHTML: . src/admin |
Date: |
Fri, 5 Jan 2007 23:19:37 -0800 (PST) |
Author: grothoff
Date: 2007-01-05 23:19:34 -0800 (Fri, 05 Jan 2007)
New Revision: 4206
Added:
i18nHTML/src/admin/delete.php
Modified:
i18nHTML/src/admin/cleanup.php
i18nHTML/src/admin/dig.php
i18nHTML/src/admin/index.php
i18nHTML/src/admin/languages.php
i18nHTML/todo
Log:
translation deletion enabled
Modified: i18nHTML/src/admin/cleanup.php
===================================================================
--- i18nHTML/src/admin/cleanup.php 2007-01-06 06:08:59 UTC (rev 4205)
+++ i18nHTML/src/admin/cleanup.php 2007-01-06 07:19:34 UTC (rev 4206)
@@ -18,11 +18,28 @@
Boston, MA 02111-1307, USA.
*/
include_once("i18nHTML/i18nhtml.php");
+include_once("login.php");
+DOCTYPE("HTML", "Transitional");
+echo "<html><head>";
+TITLE("WWW translation: automatic cleanup");
+echo "</head><body>";
+generateLanguageBar();
// delete empty translations
+$query = "DELETE FROM ${i18nHTMLsqlPrefix}map WHERE translation=\"\"";
+mysql_query($query, $connection);
+
+// delete empty source text entries
$query = "DELETE FROM ${i18nHTMLsqlPrefix}map WHERE text=\"\"";
mysql_query($query, $connection);
-$query = "DELETE FROM ${i18nHTMLsqlPrefix}map WHERE translation=\"\"";
+
+// delete translations containing only a space
+$query = "DELETE FROM ${i18nHTMLsqlPrefix}map WHERE translation=\" \"";
mysql_query($query, $connection);
-echo "Done.";
+BP();
+H2("Automatic translation cleanup done.");
+EP();
+HR();
+generateFooter();
+echo "</body></html>";
?>
\ No newline at end of file
Added: i18nHTML/src/admin/delete.php
===================================================================
--- i18nHTML/src/admin/delete.php 2007-01-06 06:08:59 UTC (rev 4205)
+++ i18nHTML/src/admin/delete.php 2007-01-06 07:19:34 UTC (rev 4206)
@@ -0,0 +1,83 @@
+<?php
+/*
+ (C) 2006, 2007 Christian Grothoff
+
+ This code is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ The code is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with the code; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+include_once("i18nHTML/i18nhtml.php");
+include("login.php");
+DOCTYPE("HTML", "Transitional");
+echo "<html><head>";
+TITLE("i18nHTML translation deletion");
+echo "</head><body>";
+session_start();
+
+$success = 0;
+$total = 0;
+
+foreach ($_POST as $postval => $selected) {
+ if ($selected != 1)
+ continue;
+ if (strstr($postval, "tid") != $postval)
+ continue;
+ $total++;
+ $tid = substr($postval, 3);
+ if (! is_numeric($tid)) {
+ echo "se: '$tid' - $postval";
+ continue;
+ }
+ $query = "SELECT uid FROM ${i18nHTMLsqlPrefix}map WHERE tid=${tid}";
+ $result = mysql_query($query, $connection);
+ if (! $result) {
+ echo "not found";
+ continue;
+ }
+ $num = mysql_numrows($result);
+ if ($num != 1) {
+ echo "not found - $num";
+ continue; // oops! Primary key not unique!?
+ }
+ $row = mysql_fetch_array($result);
+ $truid = $row["uid"];
+ $query = "SELECT level FROM ${i18nHTMLsqlPrefix}accounts WHERE uid=${truid}";
+ $result = mysql_query($query, $connection);
+ $ok = 1;
+ if ($result) {
+ $num = mysql_numrows($result);
+ if ($num == 1) {
+ $row = mysql_fetch_array($result);
+ $trlevel = $row["level"];
+ if ($level <= $trlevel)
+ $ok = 0; // insufficient level!
+ }
+ }
+ if (! $ok) {
+ echo "access";
+ continue; // refuse!
+ }
+ $query = "DELETE FROM ${i18nHTMLsqlPrefix}map WHERE tid=${tid}";
+ mysql_query($query, $connection);
+ $success++;
+ }
+BP();
+W("Successfully deleted %s translations.",
+ $success);
+if ($success != $total)
+ W("Note that some deletions failed.");
+EP();
+generateFooter();
+echo "</body></html>\n";
+?>
\ No newline at end of file
Modified: i18nHTML/src/admin/dig.php
===================================================================
--- i18nHTML/src/admin/dig.php 2007-01-06 06:08:59 UTC (rev 4205)
+++ i18nHTML/src/admin/dig.php 2007-01-06 07:19:34 UTC (rev 4206)
@@ -22,12 +22,6 @@
- punctuation mismatch (especially ".!?#")
- translation count of UID
*/
- /*
- TODO:
- - actually allow deletion of translations (RC)
- - filter translations of higher-level UIDs
- - disallow page for 0-level UIDs (guard resources)
- */
include_once("i18nHTML/i18nhtml.php");
include_once("login.php");
@@ -36,39 +30,67 @@
echo "<html><head>\n";
TITLE("i18nHTML administration: searching for bad translations");
echo "</head><body>";
+if ($level <= 0) {
+ W("This page requires higher-level access priviledges.");
+ generateFooter();
+ echo "</body></html>";
+ die();
+ }
BP();
W("Using heuristic %s.", $mode);
+BR();
+W("The worst offenders (acccording to the selected heuristic) are shown
towards the end of the table.");
EP();
$data = ARRAY();
-$query = "SELECT name,translation,uid FROM ${i18nHTMLsqlPrefix}map WHERE
lang=\"${lang}\" ORDER BY name";
+$query = "SELECT name,translation,uid,tid FROM ${i18nHTMLsqlPrefix}map WHERE
lang=\"${lang}\" ORDER BY name";
$result = mysql_query($query, $connection);
+$hidden = 0;
+$perfect = 0;
$num = 0;
-$alpha = 0;
+$alpha = 1;
if ($result)
$num = mysql_numrows($result);
while ($num-- > 0) {
$row = mysql_fetch_array($result);
+ if (! $row)
+ continue; // oops!?
$text = stripslashes($row["name"]);
$translation = stripslashes($row["translation"]);
- $uid = $row["uid"];
+ $truid = $row["uid"];
+ $tid = $row["tid"];
+ if (! is_numeric($tid))
+ continue; // oops!?
- $entry = "<tr><td><table border=0><tr><td>"$text"</td></tr>\n" .
- "<tr><td>"$translation"</td></tr></table></td>\n" .
- "<td>$uid</td>\n" . // todo: add link to delete account / etc
- "<td></td></tr>"; // todo: add checkbox in form to delete
translation
+ $query2 = "SELECT level FROM ${i18nHTMLsqlPrefix}accounts WHERE
uid=${truid}";
+ $result2 = mysql_query($query2, $connection);
+ $ok = 1;
+ if ($result2) {
+ $num = mysql_numrows($result2);
+ if ($num == 1) {
+ $row = mysql_fetch_array($result2);
+ $trlevel = $row["level"];
+ if ($level <= $trlevel)
+ $ok = 0; // insufficient level!
+ }
+ }
+ if ($ok == 0) {
+ $hidden++;
+ continue; // not high-enough level, do not show
+ }
+
$score = 0;
switch($mode) {
case "wwcd": // weighted word-count distance
if ( ($text == "") || ($translation == "") ) {
$score = 999999;
} else {
- $wc1 = count(explode($text, " "));
- $wc2 = count(explode($translation, " "));
+ $wc1 = count(explode(" ", $text));
+ $wc2 = count(explode(" ", $translation));
$dist = $wc1 - $wc2;
if ($wc1 == 0)
$wc1 = 1; // avoid division by zero
- $score = intval(1000 * ($dist * $dist) / $wc1);
+ $score = 1000 * $dist * $dist / $wc1;
}
break;
case "wccd": // weighted character-count distance
@@ -77,14 +99,14 @@
$dist = $wc1 - $wc2;
if ($wc1 == 0)
$wc1 = 1; // avoid division by zero
- $score = intval(1000 * ($dist * $dist) / $wc1);
+ $score = 1000 * ($dist * $dist) / $wc1;
break;
case "wlmc": // weighted average word-length mismatch
if ( ($text == "") || ($translation == "") ) {
$score = 999999;
} else {
- $e1 = explode($text, " ");
- $e2 = explode($translation, " ");
+ $e1 = explode(" ", $text);
+ $e2 = explode(" ", $translation);
$l1 = array_map("strlen", $e1);
$l2 = array_map("strlen", $e2);
$t1 = array_sum($l1);
@@ -92,17 +114,17 @@
$a1 = $t1 / count($e1);
$a2 = $t2 / count($e2);
$dist = $a1 - $a2;
- $score = intval(1000 * ($dist * $dist));
+ $score = $dist * $dist;
}
break;
case "psmc": // percent sign mismatch counts
if ( ($text == "") || ($translation == "") ) {
$score = 999999;
} else {
- $e1 = explode($text, "%");
- $e2 = explode($translation, "%");
+ $e1 = explode("%", $text);
+ $e2 = explode("%", $translation);
$total = 0;
- for ($pos=0;$pos<count($e1)-1;$pos++) {
+ for ($pos=1;$pos<count($e1);$pos++) {
$t1 = $e1[$pos];
if (! isset($e2[$pos])) {
$total++;
@@ -110,8 +132,11 @@
}
$t2 = $e2[$pos];
// first character after "%" should match
- if ($t1[0] != $t2[0])
+ if ( (strlen($t1) > 0) &&
+ (strlen($t2) > 0) &&
+ ($t1[0] != $t2[0]) ) {
$total++;
+ }
}
$score = $total;
}
@@ -121,19 +146,29 @@
$score = $alpha++; // alphabetical ordering
break;
}
+ $entry = "<tr><td><table border=0><tr><td>"$text"</td></tr>\n" .
+ "<tr><td>"$translation"</td></tr></table></td>\n" .
+ "<td>$truid</td>\n" . // todo: add link to delete account / etc
+ "<td>$score</td>\n" . // todo: add link to delete account / etc
+ "<td><input type=\"checkbox\" name=\"tid${tid}\" value=\"1\"
/></td></tr>"; // todo: add checkbox in form to delete translation
if (isset($data[$score]))
$entries = $data[$score];
else
$entries = ARRAY();
$entries[] = $entry;
- $data[$score] = $entries;
+ if ($score > 0)
+ $data[$score] = $entries;
+ else
+ $perfect++;
}
-
+ksort($data);
H2("Translations to ${lang}");
+echo "<form name=\"dig_form\" method=\"post\"
action=\"delete.php?xlang=${lang}\">\n";
echo "<table border='5'>\n";
echo "<tr>";
TH("Original and Translation");
TH("Translator");
+TH("Score");
TH("Delete");
echo "</tr>\n";
foreach ($data as $score => $entries) {
@@ -141,7 +176,21 @@
echo $entry;
}
}
-echo "</table>";
+echo "</table>\n";
+BR();
+echo "<input type=\"submit\" class=\"button\" value=\"";
+TRANSLATE("Delete selected translations");
+echo "\"/>";
+echo "</form>\n";
+BP();
+if ($hidden > 0)
+ W("Did not show %s translations due to insufficient level of user.",
+ $hidden);
+BR();
+if ($perfect > 0)
+ W("Did not show %s translations due to perfect proximity score.",
+ $perfect);
+EP();
HR();
generateFooter();
echo "</body></html>";
Modified: i18nHTML/src/admin/index.php
===================================================================
--- i18nHTML/src/admin/index.php 2007-01-06 06:08:59 UTC (rev 4205)
+++ i18nHTML/src/admin/index.php 2007-01-06 07:19:34 UTC (rev 4206)
@@ -32,13 +32,18 @@
echo "<ul>\n";
LILI("editor.php", "Go to mass translation");
-
-LILI("dig.php?mode=wwcd&xlang=$lang&f=", "Search for suspicious translations
using weighted word-count distance");
-LILI("dig.php?mode=wccd&xlang=$lang&f=", "Search for suspicious translations
using weighted character-count distance");
-LILI("dig.php?mode=wlmc&xlang=$lang&f=", "Search for suspicious translations
using weighted word-length distance");
-LILI("dig.php?mode=psmc&xlang=$lang&f=", "Search for suspicious translations
using percent sign mismatch counts");
-LILI("dig.php?mode=alpha&xlang=$lang&f=", "Search for suspicious translations
using alphabetical ordering");
-
+if ($level > 0) {
+ LILI("dig.php?mode=wwcd&xlang=$lang&f=",
+ "Search for suspicious translations using weighted word-count
distance");
+ LILI("dig.php?mode=wccd&xlang=$lang&f=",
+ "Search for suspicious translations using weighted character-count
distance");
+ LILI("dig.php?mode=wlmc&xlang=$lang&f=",
+ "Search for suspicious translations using weighted word-length
distance");
+ LILI("dig.php?mode=psmc&xlang=$lang&f=",
+ "Search for suspicious translations using percent sign mismatch
counts");
+ LILI("dig.php?mode=alpha&xlang=$lang&f=",
+ "Search for suspicious translations using alphabetical ordering");
+ }
echo "</ul>\n";
H2("Account management");
@@ -60,9 +65,9 @@
echo "<ul>\n";
LILI("status.php", "Display statistics");
LILI("tables.php", "Initialize tables");
+LILI("cleanup.php", "Automatic cleanup (trivial translation errors)");
echo "</ul>\n";
-echo "</ul>\n";
generateFooter();
echo "</body></html>";
?>
\ No newline at end of file
Modified: i18nHTML/src/admin/languages.php
===================================================================
--- i18nHTML/src/admin/languages.php 2007-01-06 06:08:59 UTC (rev 4205)
+++ i18nHTML/src/admin/languages.php 2007-01-06 07:19:34 UTC (rev 4206)
@@ -38,7 +38,7 @@
<td width="75%" align="left"><input type="checkbox" name="def" value="1"
/></td>
</tr>
<tr>
-<td colspan="2" align="center"><input type="submit" class="button"
value="<?php W("Submit");?>"/></td>
+<td colspan="2" align="center"><input type="submit" class="button"
value="<?php TRANSLATE("Submit");?>"/></td>
</tr>
</table>
</form>
Modified: i18nHTML/todo
===================================================================
--- i18nHTML/todo 2007-01-06 06:08:59 UTC (rev 4205)
+++ i18nHTML/todo 2007-01-06 07:19:34 UTC (rev 4206)
@@ -1,10 +1,6 @@
Ideas for future development (with priority):
-Translators:
-* allow high-level users to delete translations [HIGH]
-* test bogus translation detection algorithm [HIGH]
-
Users:
* change voting from GET to POST (status.php, translate.php) [HIGH]
* expand on-line documentation [MED]
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r4206 - in i18nHTML: . src/admin,
grothoff <=