blob: 09a4b017f64923947242777c19c80a6762da2387 [file] [log] [blame]
gobrien48275462007-11-29 21:29:17 +00001<?php
2/*******************************************************************************
droy8ca58752018-02-28 10:45:34 -05003 * Copyright (c) 2007-2018 Eclipse Foundation and others.
gobrien48275462007-11-29 21:29:17 +00004 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Paul Colton (Aptana)- initial API and implementation
11 * Eclipse Foundation
kitlo8d374b12012-02-01 18:23:46 +000012 * Kit Lo (IBM) - [281434] Syncup overuses the "possibly incorrect" flag
gobrien48275462007-11-29 21:29:17 +000013*******************************************************************************/
14
15require_once("cb_global.php");
16
atoulme3e5e9342009-01-23 17:34:30 +000017$string_id = getHTTPParameter("string_id", "POST");
18$stringTableIndex = getHTTPParameter("stringTableIndex", "POST");
gobrien775f3582008-02-29 16:52:30 +000019
20if(isset($_SESSION['language']) and isset($_SESSION['version']) and isset($_SESSION['project'])){
21 $language = $_SESSION['language'];
22 $version = $_SESSION['version'];
23 $project_id = $_SESSION['project'];
24}else{
25 return false;
26}
27
gobrien36356fb2008-01-11 16:45:26 +000028
gobrien48275462007-11-29 21:29:17 +000029$query = "select
30 strings.string_id,
gobrien2a4a2082008-05-21 17:51:41 +000031 strings.non_translatable,
gobrien48275462007-11-29 21:29:17 +000032 strings.value as string_value,
33 translations.value as translation_value,
droye3dc1112008-11-19 18:21:28 +000034 translations.possibly_incorrect as fuzzy,
gobrien755df672008-01-18 01:01:33 +000035 files.name,
36 strings.name as token,
gobrien48275462007-11-29 21:29:17 +000037 max(translations.version)
38 from
gobrienf3cc8c32008-01-11 17:31:54 +000039 files,
gobrien48275462007-11-29 21:29:17 +000040 strings
41 left join translations on
gobrien36356fb2008-01-11 16:45:26 +000042 (strings.string_id = translations.string_id
43 and
44 translations.is_active != 0
45 and
46 translations.language_id = '".addslashes($language)."')
gobrien48275462007-11-29 21:29:17 +000047 where
48 strings.is_active != 0
49 and
50 strings.string_id = '".addslashes($string_id)."'
gobrienf3cc8c32008-01-11 17:31:54 +000051 and
52 strings.file_id = files.file_id
53 and
54 files.version = '".addslashes($version)."'
gobrien48275462007-11-29 21:29:17 +000055 group by translations.version
56 order by translations.version desc
droy8ca58752018-02-28 10:45:34 -050057 limit 1";
gobrien48275462007-11-29 21:29:17 +000058
gobrienfc326922008-01-11 16:46:44 +000059//print $query;
gobrien36356fb2008-01-11 16:45:26 +000060
kitlo2c8d8a92018-04-19 13:25:09 -040061$res = mysqli_query($dbh, $query);
gobrien48275462007-11-29 21:29:17 +000062
droya3815a52019-09-25 12:49:18 -040063$line = mysqli_fetch_array($res, MYSQLI_ASSOC);
gobrien48275462007-11-29 21:29:17 +000064
gobrien755df672008-01-18 01:01:33 +000065//print_r($line);
66
gobrienda3a4502008-01-28 23:43:26 +000067$trans = "";
gobrien755df672008-01-18 01:01:33 +000068
69if($line['translation_value']){
droy3f4d7fd2018-03-02 09:53:51 -050070 $trans = " AND translations.value = '".addslashes($line['translation_value'])."'
gobrien755df672008-01-18 01:01:33 +000071 AND
72 translations.is_active = 1
73 ";
gobrien755df672008-01-18 01:01:33 +000074}
75
76$query = "select
77 strings.string_id, strings.value, strings.name max(translations.translation_id)
78 FROM
79 files,
droy3f4d7fd2018-03-02 09:53:51 -050080 strings
gobrien755df672008-01-18 01:01:33 +000081 left join
82 translations
83 on
84 translations.string_id = strings.string_id
85 where
86 files.file_id = strings.file_id
droy3f4d7fd2018-03-02 09:53:51 -050087 AND
gobrien755df672008-01-18 01:01:33 +000088 files.project_id = '".addslashes($project_id)."'
89 AND
90 strings.value = '".addslashes($line['string_value'])."'
91
92 $trans
93 AND
94 files.is_active = 1
droy3f4d7fd2018-03-02 09:53:51 -050095 group by translations.string_id";
96
gobrien755df672008-01-18 01:01:33 +000097$query = "SELECT
98 S.*
99 FROM
100 strings AS S
101 inner join files AS F on F.file_id = S.file_id
102 inner join translations AS T on T.string_id = S.string_id
103 where
104 F.project_id = '".addslashes($project_id)."'
105 AND
106 F.file_id in (SELECT files.file_id FROM files where files.project_id = '".addslashes($project_id)."')
107 AND
108 S.value = '".addslashes($line['string_value'])."'
109 and
110 T.value = '".addslashes($line['translation_value'])."'
111 AND
112 T.is_active = 1
113 ";
gobrien48275462007-11-29 21:29:17 +0000114?>
gobrien2a4a2082008-05-21 17:51:41 +0000115
gobrien19d1fa22008-02-01 00:33:40 +0000116<form id='translation-form'>
droyb2ab7e12012-11-01 13:27:44 -0400117 <input type="hidden" name="string_id" value="<?= $line['string_id'] ?>">
118 <input type="hidden" name="stringTableIndex" value="<?= $stringTableIndex ?>">
gobrien198300d2008-03-04 23:22:36 +0000119
gobrien19d1fa22008-02-01 00:33:40 +0000120 <div id="english-area" class="side-component">
droyb2ab7e12012-11-01 13:27:44 -0400121 <h4>English String [<a id="copy-english-string-link">Copy</a>]</h4>
kitlo8d374b12012-02-01 18:23:46 +0000122 <div style='overflow: auto; height: 75px;'>
kitlo7197f8f2008-08-02 02:03:59 +0000123 <div id="english-string"><?= nl2br(htmlspecialchars($line['string_value'])); ?></div>
gobrien19d1fa22008-02-01 00:33:40 +0000124 </div>
droya9a08542018-02-28 15:52:47 -0500125 <h4 id="translation-hints-title">Translation Hints [<a id="clear-btn" href="javascript:clearHints();">Clear</a>]</h4>
kitlo8d374b12012-02-01 18:23:46 +0000126 <div id="translation-hints" style='overflow-x: hidden; overflow-y: auto; height: 75px;'>
droy3f4d7fd2018-03-02 09:53:51 -0500127 <b>Select some English text above to find similar translations</b><?php
128 # offer up some hints is the string is not translated
129 if($line['translation_value'] == "") {
130 $q_th = "SELECT DISTINCT t.value
droy8ca58752018-02-28 10:45:34 -0500131 FROM translations as t
132 INNER JOIN strings AS s ON s.string_id = t.string_id
133 INNER JOIN files AS f ON s.file_id = f.file_id
134 WHERE s.value like '" . addslashes(substr($line['string_value'], 0, 15)) . "%'
135 AND t.is_active
droy3f4d7fd2018-03-02 09:53:51 -0500136 AND t.language_id = '" . addslashes($language) . "'
droy8ca58752018-02-28 10:45:34 -0500137 ORDER BY LENGTH(t.value) ASC LIMIT 10";
kitlo2c8d8a92018-04-19 13:25:09 -0400138 $res_th = mysqli_query($dbh, $q_th);
kitlo1d027092018-04-19 17:44:07 -0400139 if(mysqli_affected_rows($dbh) > 0) {
droy3f4d7fd2018-03-02 09:53:51 -0500140 echo "<b>, or use from the following:</b><ul>";
droya3815a52019-09-25 12:49:18 -0400141 while($translation_hints = mysqli_fetch_array($res_th, MYSQLI_ASSOC)){
droy3f4d7fd2018-03-02 09:53:51 -0500142 echo "<li>", $translation_hints['value'], "</li>";
143 }
144 echo "</ul>";
droy8ca58752018-02-28 10:45:34 -0500145 }
droy8ca58752018-02-28 10:45:34 -0500146 }
147 ?>
gobrien2a4a2082008-05-21 17:51:41 +0000148 </div>
149
droye3dc1112008-11-19 18:21:28 +0000150 <input id='non-translatable-checkbox' type=checkbox name="non_translatable_string" <?= $line['non_translatable'] ? 'checked' : '' ;?>>Non-Translatable
gobrien19d1fa22008-02-01 00:33:40 +0000151 </div>
152 <div id="translation-textarea" class="side-component">
droyb2ab7e12012-11-01 13:27:44 -0400153 <?php if($line['non_translatable'] == 0) {?>
kitlo2c3287b2008-07-30 15:27:48 +0000154 <h4>
155 Current Translation
156 [<a id="reset-current-translation-link">Reset</a>]
157 [<a id="clear-current-translation-link">Clear</a>]
158 </h4>
droye3dc1112008-11-19 18:21:28 +0000159
droyb2ab7e12012-11-01 13:27:44 -0400160 <textarea id="current-translation" style='display: inline; width: 95%; height: 154px;' name="translation"><?=(($line['translation_value']));?></textarea>
droye3dc1112008-11-19 18:21:28 +0000161 <br />
kitlo8d374b12012-02-01 18:23:46 +0000162 <!-- [281434] Syncup overuses the "possibly incorrect" flag
droye3dc1112008-11-19 18:21:28 +0000163 <input id='fuzzy' type=checkbox name="fuzzy_checkbox" <?= $line['fuzzy'] ? 'checked' : '' ;?>> Translation is possibly incorrect
164 <br />
kitlo8d374b12012-02-01 18:23:46 +0000165 -->
kitlo22fff0f2008-07-21 20:35:50 +0000166 <button id="allversions" type="submit" name="translateAction" value="All Versions">Submit</button>
droye3dc1112008-11-19 18:21:28 +0000167
droyb2ab7e12012-11-01 13:27:44 -0400168 <?php }else{?>
gobrien2a4a2082008-05-21 17:51:41 +0000169 <h4>Non Translatable String</h4>
droyb2ab7e12012-11-01 13:27:44 -0400170 <br /><br /><br />
gobrien2a4a2082008-05-21 17:51:41 +0000171 <div style='text-align:center;'>This string has been marked as <b>'non-translatable'</b>.</div>
gobrien2a4a2082008-05-21 17:51:41 +0000172
droyb2ab7e12012-11-01 13:27:44 -0400173 <?php }?>
gobrien19d1fa22008-02-01 00:33:40 +0000174 </div>
gobrien2db73d52008-03-04 00:25:48 +0000175 <div id="translation-history-area" class="side-component">
gobrien19d1fa22008-02-01 00:33:40 +0000176 <h4>History of Translations</h4>
gobrien2db73d52008-03-04 00:25:48 +0000177 <div id="translation-history">
gobrien2db73d52008-03-04 00:25:48 +0000178 <table>
179 <?php
droye3dc1112008-11-19 18:21:28 +0000180 $query = "select value,first_name,last_name,translations.created_on, possibly_incorrect as fuzzy from translations,users where string_id = '".addslashes($line['string_id'])."' and language_id = '".addslashes($language)."' and translations.userid = users.userid order by translations.created_on desc";
kitlo2c8d8a92018-04-19 13:25:09 -0400181 $res_history = mysqli_query($dbh, $query);
gobrien2db73d52008-03-04 00:25:48 +0000182
kitlo1d027092018-04-19 17:44:07 -0400183 if(!mysqli_num_rows($res_history)){
gobrien2db73d52008-03-04 00:25:48 +0000184 print "No history.";
185 }else{
droya3815a52019-09-25 12:49:18 -0400186 while($line = mysqli_fetch_array($res_history, MYSQLI_ASSOC)){
droye3dc1112008-11-19 18:21:28 +0000187 $fuzzy = "";
188 if($line['fuzzy'] == 1) {
189 $fuzzy = "<img src='images/fuzzy.png' />";
190 }
gobrien2db73d52008-03-04 00:25:48 +0000191 print "<tr>";
192 print "<td width='40%'>";
kitlo8d374b12012-02-01 18:23:46 +0000193 // [281434] Syncup overuses the "possibly incorrect" flag
194 // print "<div>$fuzzy".nl2br(htmlspecialchars($line['value']))."</div>";
195 print "<div>".nl2br(htmlspecialchars($line['value']))."</div>";
gobrien2db73d52008-03-04 00:25:48 +0000196 print "</td>";
197 print "<td width='20%'>";
198 print $line['first_name']." ".$line['last_name'];
199 print "</td>";
200 print "<td width='40%'>";
201 print $line['created_on'];
202 print "</td>";
203 print "</tr>";
204 }
205 }
206 ?>
207 </table>
208 </div>
gobrien19d1fa22008-02-01 00:33:40 +0000209 </div>
210</form>