blob: 913ac714cbb99062ef2acfd7d34bf467c33f969c [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
gobrien48275462007-11-29 21:29:17 +000061$res = mysql_query($query,$dbh);
62
63$line = mysql_fetch_array($res, MYSQL_ASSOC);
64
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']){
70 $trans = " AND translations.value = '".addslashes($line['translation_value'])."'
71 AND
72 translations.is_active = 1
73 ";
74}else{
75// $trans = "translations.value is NULL ";
76}
77
78$query = "select
79 strings.string_id, strings.value, strings.name max(translations.translation_id)
80 FROM
81 files,
82 strings
83 left join
84 translations
85 on
86 translations.string_id = strings.string_id
87 where
88 files.file_id = strings.file_id
89 AND
90 files.project_id = '".addslashes($project_id)."'
91 AND
92 strings.value = '".addslashes($line['string_value'])."'
93
94 $trans
95 AND
96 files.is_active = 1
97 group by translations.string_id
98 ";
99// AND
100// files.name = (SELECT files.name FROM files as F where F.project_id = '".addslashes($project_id)."')
101
102$query = "SELECT
103 S.*
104 FROM
105 strings AS S
106 inner join files AS F on F.file_id = S.file_id
107 inner join translations AS T on T.string_id = S.string_id
108 where
109 F.project_id = '".addslashes($project_id)."'
110 AND
111 F.file_id in (SELECT files.file_id FROM files where files.project_id = '".addslashes($project_id)."')
112 AND
113 S.value = '".addslashes($line['string_value'])."'
114 and
115 T.value = '".addslashes($line['translation_value'])."'
116 AND
117 T.is_active = 1
118 ";
gobrien48275462007-11-29 21:29:17 +0000119?>
gobrien2a4a2082008-05-21 17:51:41 +0000120
gobrien19d1fa22008-02-01 00:33:40 +0000121<form id='translation-form'>
droyb2ab7e12012-11-01 13:27:44 -0400122 <input type="hidden" name="string_id" value="<?= $line['string_id'] ?>">
123 <input type="hidden" name="stringTableIndex" value="<?= $stringTableIndex ?>">
gobrien198300d2008-03-04 23:22:36 +0000124
gobrien19d1fa22008-02-01 00:33:40 +0000125 <div id="english-area" class="side-component">
droyb2ab7e12012-11-01 13:27:44 -0400126 <h4>English String [<a id="copy-english-string-link">Copy</a>]</h4>
kitlo8d374b12012-02-01 18:23:46 +0000127 <div style='overflow: auto; height: 75px;'>
kitlo7197f8f2008-08-02 02:03:59 +0000128 <div id="english-string"><?= nl2br(htmlspecialchars($line['string_value'])); ?></div>
gobrien19d1fa22008-02-01 00:33:40 +0000129 </div>
droya9a08542018-02-28 15:52:47 -0500130 <h4 id="translation-hints-title">Translation Hints [<a id="clear-btn" href="javascript:clearHints();">Clear</a>]</h4>
kitlo8d374b12012-02-01 18:23:46 +0000131 <div id="translation-hints" style='overflow-x: hidden; overflow-y: auto; height: 75px;'>
droy8ca58752018-02-28 10:45:34 -0500132 Select some English text above to find similar translations
133 <?php
134 $q_th = "SELECT DISTINCT t.value
135 FROM translations as t
136 INNER JOIN strings AS s ON s.string_id = t.string_id
137 INNER JOIN files AS f ON s.file_id = f.file_id
138 WHERE s.value like '" . addslashes(substr($line['string_value'], 0, 15)) . "%'
139 AND t.is_active
140 AND t.language_id = '".addslashes($language)."'
141 ORDER BY LENGTH(t.value) ASC LIMIT 10";
142 $res_th = mysql_query($q_th, $dbh);
143 if(mysql_affected_rows($dbh) > 0) {
144 echo ", or use from the following:<ul>";
145 while($line = mysql_fetch_array($res_th, MYSQL_ASSOC)){
146 echo "<li>", $line['value'], "</li>";
147 }
148 echo "</ul>";
149 }
150 ?>
gobrien2a4a2082008-05-21 17:51:41 +0000151 </div>
152
droye3dc1112008-11-19 18:21:28 +0000153 <input id='non-translatable-checkbox' type=checkbox name="non_translatable_string" <?= $line['non_translatable'] ? 'checked' : '' ;?>>Non-Translatable
gobrien19d1fa22008-02-01 00:33:40 +0000154 </div>
155 <div id="translation-textarea" class="side-component">
droyb2ab7e12012-11-01 13:27:44 -0400156 <?php if($line['non_translatable'] == 0) {?>
kitlo2c3287b2008-07-30 15:27:48 +0000157 <h4>
158 Current Translation
159 [<a id="reset-current-translation-link">Reset</a>]
160 [<a id="clear-current-translation-link">Clear</a>]
161 </h4>
droye3dc1112008-11-19 18:21:28 +0000162
droyb2ab7e12012-11-01 13:27:44 -0400163 <textarea id="current-translation" style='display: inline; width: 95%; height: 154px;' name="translation"><?=(($line['translation_value']));?></textarea>
droye3dc1112008-11-19 18:21:28 +0000164 <br />
kitlo8d374b12012-02-01 18:23:46 +0000165 <!-- [281434] Syncup overuses the "possibly incorrect" flag
droye3dc1112008-11-19 18:21:28 +0000166 <input id='fuzzy' type=checkbox name="fuzzy_checkbox" <?= $line['fuzzy'] ? 'checked' : '' ;?>> Translation is possibly incorrect
167 <br />
kitlo8d374b12012-02-01 18:23:46 +0000168 -->
kitlo22fff0f2008-07-21 20:35:50 +0000169 <button id="allversions" type="submit" name="translateAction" value="All Versions">Submit</button>
droye3dc1112008-11-19 18:21:28 +0000170
droyb2ab7e12012-11-01 13:27:44 -0400171 <?php }else{?>
gobrien2a4a2082008-05-21 17:51:41 +0000172 <h4>Non Translatable String</h4>
droyb2ab7e12012-11-01 13:27:44 -0400173 <br /><br /><br />
gobrien2a4a2082008-05-21 17:51:41 +0000174 <div style='text-align:center;'>This string has been marked as <b>'non-translatable'</b>.</div>
gobrien2a4a2082008-05-21 17:51:41 +0000175
droyb2ab7e12012-11-01 13:27:44 -0400176 <?php }?>
gobrien19d1fa22008-02-01 00:33:40 +0000177 </div>
gobrien2db73d52008-03-04 00:25:48 +0000178 <div id="translation-history-area" class="side-component">
gobrien19d1fa22008-02-01 00:33:40 +0000179 <h4>History of Translations</h4>
gobrien2db73d52008-03-04 00:25:48 +0000180 <div id="translation-history">
gobrien2db73d52008-03-04 00:25:48 +0000181 <table>
182 <?php
droye3dc1112008-11-19 18:21:28 +0000183 $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";
gobrien2db73d52008-03-04 00:25:48 +0000184 $res_history = mysql_query($query,$dbh);
185
186 if(!mysql_num_rows($res_history)){
187 print "No history.";
188 }else{
189 while($line = mysql_fetch_array($res_history, MYSQL_ASSOC)){
droye3dc1112008-11-19 18:21:28 +0000190 $fuzzy = "";
191 if($line['fuzzy'] == 1) {
192 $fuzzy = "<img src='images/fuzzy.png' />";
193 }
gobrien2db73d52008-03-04 00:25:48 +0000194 print "<tr>";
195 print "<td width='40%'>";
kitlo8d374b12012-02-01 18:23:46 +0000196 // [281434] Syncup overuses the "possibly incorrect" flag
197 // print "<div>$fuzzy".nl2br(htmlspecialchars($line['value']))."</div>";
198 print "<div>".nl2br(htmlspecialchars($line['value']))."</div>";
gobrien2db73d52008-03-04 00:25:48 +0000199 print "</td>";
200 print "<td width='20%'>";
201 print $line['first_name']." ".$line['last_name'];
202 print "</td>";
203 print "<td width='40%'>";
204 print $line['created_on'];
205 print "</td>";
206 print "</tr>";
207 }
208 }
209 ?>
210 </table>
211 </div>
gobrien19d1fa22008-02-01 00:33:40 +0000212 </div>
213</form>