forked from NB-Core/lotgd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
untranslated.php
158 lines (143 loc) · 7.07 KB
/
untranslated.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
// translator ready
// addnews ready
// mail ready
// Okay, someone wants to use this outside of normal game flow.. no real harm
define("OVERRIDE_FORCED_NAV",true);
// Translate Untranslated Strings
// Originally Written by Christian Rutsch
// Slightly modified by JT Traub
require_once("common.php");
require_once("lib/http.php");
check_su_access(SU_IS_TRANSLATOR);
tlschema("untranslated");
$op = httpget('op');
page_header("Untranslated Texts");
require_once("lib/superusernav.php");
//chcek if he/she is allowed to edit that language
if (!in_array($session['user']['prefs']['language'],explode(",",$session['user']['translatorlanguages']))) {
output("Sorry, please change your language to one you are allowed to translate.`n`n");
superusernav();
page_footer();
}
if ($op == "list") {
$mode = httpget('mode');
$namespace = httpget('ns');
if ($mode == "save") {
$intext = httppost('intext');
$outtext = httppost('outtext');
if ($outtext <> "") {
$login = $session['user']['login'];
$language = $session['user']['prefs']['language'];
$sql = "INSERT INTO " . db_prefix("translations") . " (language,uri,intext,outtext,author,version) VALUES" . " ('$language','$namespace','$intext','$outtext','$login','$logd_version')";
db_query($sql);
$sql = "DELETE FROM " . db_prefix("untranslated") . " WHERE intext = '$intext' AND language = '$language' AND namespace = '$namespace'";
db_query($sql);
}
}
if ($mode == "edit") {
rawoutput("<form action='untranslated.php?op=list&mode=save&ns=".rawurlencode($namespace)."' method='post'>");
addnav("", "untranslated.php?op=list&mode=save&ns=".rawurlencode($namespace));
} else {
rawoutput("<form action='untranslated.php?op=list' method='get'>");
addnav("", "untranslated.php?op=list");
}
$sql = "SELECT namespace,count(*) AS c FROM " . db_prefix("untranslated") . " WHERE language='".$session['user']['prefs']['language']."' GROUP BY namespace ORDER BY namespace ASC";
$result = db_query($sql);
rawoutput("<input type='hidden' name='op' value='list'>");
output("Known Namespaces:");
rawoutput("<select name='ns'>");
while ($row = db_fetch_assoc($result)){
rawoutput("<option value=\"".htmlentities($row['namespace'], ENT_COMPAT, getsetting("charset", "ISO-8859-1"))."\"".((htmlentities($row['namespace'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) == $namespace) ? "selected" : "").">".htmlentities($row['namespace'], ENT_COMPAT, getsetting("charset", "ISO-8859-1"))." ({$row['c']})</option>");
}
rawoutput("</select>");
rawoutput("<input type='submit' class='button' value='". translate_inline("Show") ."'>");
rawoutput("<br>");
if ($mode == "edit") {
rawoutput(translate_inline("Text:"). "<br>");
rawoutput("<textarea name='intext' cols='60' rows='5' readonly>".htmlentities(stripslashes(httpget('intext')), ENT_COMPAT, getsetting("charset", "ISO-8859-1"))."</textarea><br/>");
rawoutput(translate_inline("Translation:"). "<br>");
rawoutput("<textarea name='outtext' cols='60' rows='5'></textarea><br/>");
rawoutput("<input type='submit' value='". translate_inline("Save") ."' class='button'>");
} else {
rawoutput("<table border='0' cellpadding='2' cellspacing='0'>");
rawoutput("<tr class='trhead'><td>". translate_inline("Ops") ."</td><td>". translate_inline("Text") ."</td></tr>");
$sql = "SELECT * FROM " . db_prefix("untranslated") . " WHERE language='".$session['user']['prefs']['language']."' AND namespace='".$namespace."'";
$result = db_query($sql);
if (db_num_rows($result)>0){
$i = 0;
while ($row = db_fetch_assoc($result)){
$i++;
rawoutput("<tr class='".($i%2?"trlight":"trdark")."'><td>");
rawoutput("<a href='untranslated.php?op=list&mode=edit&ns=". rawurlencode($row['namespace']) ."&intext=". rawurlencode($row['intext']) ."'>". translate_inline("Edit") ."</a>");
addnav("", "untranslated.php?op=list&mode=edit&ns=". rawurlencode($row['namespace']) ."&intext=". rawurlencode($row['intext']));
rawoutput("</td><td>");
rawoutput(htmlentities($row['intext'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")));
rawoutput("</td></tr>");
}
}else{
rawoutput("<tr><td colspan='2'>". translate_inline("No rows found") ."</td></tr>");
}
rawoutput("</table>");
}
rawoutput("</form>");
} else {
if ($op == "step2") {
$intext = httppost('intext');
$outtext = httppost('outtext');
$namespace = httppost('namespace');
$language = httppost('language');
if ($outtext <> "") {
$login = $session['user']['login'];
$sql = "INSERT INTO " . db_prefix("translations") . " (language,uri,intext,outtext,author,version) VALUES" . " ('$language','$namespace','$intext','$outtext','$login','$logd_version')";
db_query($sql);
$sql = "DELETE FROM " . db_prefix("untranslated") . " WHERE intext = '$intext' AND language = '$language' AND namespace = '$namespace'";
db_query($sql);
invalidatedatacache("translations-".$namespace."-".$language);
}
}
$sql = "SELECT count(intext) AS count FROM " . db_prefix("untranslated");
$count = db_fetch_assoc(db_query($sql));
if ($count['count'] > 0) {
$sql = "SELECT * FROM " . db_prefix("untranslated") . " WHERE language = '" . $session['user']['prefs']['language'] . "' ORDER BY rand(".e_rand().") LIMIT 1";
$result = db_query($sql);
if (db_num_rows($result) == 1) {
$row = db_fetch_assoc($result);
$row['intext'] = stripslashes($row['intext']);
$submit = translate_inline("Save Translation");
$skip = translate_inline("Skip Translation");
rawoutput("<form action='untranslated.php?op=step2' method='post'>");
output("`^`cThere are `&%s`^ untranslated texts in the database.`c`n`n", $count['count']);
rawoutput("<table width='80%'>");
rawoutput("<tr><td width='30%'>");
output("Target Language: %s", $row['language']);
rawoutput("</td><td></td></tr>");
rawoutput("<tr><td width='30%'>");
output("Namespace: %s", $row['namespace']);
rawoutput("</td><td></td></tr>");
rawoutput("<tr><td width='30%'><textarea cols='35' rows='4' name='intext'>".$row['intext']."</textarea></td>");
rawoutput("<td width='30%'><textarea cols='25' rows='4' name='outtext'></textarea></td></tr></table>");
rawoutput("<input type='hidden' name='id' value='{$row['id']}'>");
rawoutput("<input type='hidden' name='language' value='{$row['language']}'>");
rawoutput("<input type='hidden' name='namespace' value='{$row['namespace']}'>");
rawoutput("<input type='submit' value='$submit' class='button'>");
rawoutput("</form>");
rawoutput("<form action='untranslated.php' method='post'>");
rawoutput("<input type='submit' value='$skip' class='button'>");
rawoutput("</form>");
addnav("", "untranslated.php?op=step2");
addnav("", "untranslated.php");
} else {
output("There are `&%s`^ untranslated texts in the database, but none for your selected language.", $count['count']);
output("Please change your language to translate these texts.");
}
} else {
output("There are no untranslated texts in the database!");
output("Congratulations!!!");
} // end if
} // end list if
addnav("R?Restart Translator", "untranslated.php");
addnav("N?Translate by Namespace", "untranslated.php?op=list");
superusernav();
page_footer();
?>