gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 1 | <?php |
| 2 | /******************************************************************************* |
droy | 8ca5875 | 2018-02-28 10:45:34 -0500 | [diff] [blame] | 3 | * Copyright (c) 2007-2018 Eclipse Foundation and others. |
gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 4 | * 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 |
kitlo | 8d374b1 | 2012-02-01 18:23:46 +0000 | [diff] [blame] | 12 | * Kit Lo (IBM) - [281434] Syncup overuses the "possibly incorrect" flag |
gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 13 | *******************************************************************************/ |
| 14 | |
| 15 | require_once("cb_global.php"); |
| 16 | |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 17 | $string_id = getHTTPParameter("string_id", "POST"); |
| 18 | $stringTableIndex = getHTTPParameter("stringTableIndex", "POST"); |
gobrien | 775f358 | 2008-02-29 16:52:30 +0000 | [diff] [blame] | 19 | |
| 20 | if(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 | |
gobrien | 36356fb | 2008-01-11 16:45:26 +0000 | [diff] [blame] | 28 | |
gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 29 | $query = "select |
| 30 | strings.string_id, |
gobrien | 2a4a208 | 2008-05-21 17:51:41 +0000 | [diff] [blame] | 31 | strings.non_translatable, |
gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 32 | strings.value as string_value, |
| 33 | translations.value as translation_value, |
droy | e3dc111 | 2008-11-19 18:21:28 +0000 | [diff] [blame] | 34 | translations.possibly_incorrect as fuzzy, |
gobrien | 755df67 | 2008-01-18 01:01:33 +0000 | [diff] [blame] | 35 | files.name, |
| 36 | strings.name as token, |
gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 37 | max(translations.version) |
| 38 | from |
gobrien | f3cc8c3 | 2008-01-11 17:31:54 +0000 | [diff] [blame] | 39 | files, |
gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 40 | strings |
| 41 | left join translations on |
gobrien | 36356fb | 2008-01-11 16:45:26 +0000 | [diff] [blame] | 42 | (strings.string_id = translations.string_id |
| 43 | and |
| 44 | translations.is_active != 0 |
| 45 | and |
| 46 | translations.language_id = '".addslashes($language)."') |
gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 47 | where |
| 48 | strings.is_active != 0 |
| 49 | and |
| 50 | strings.string_id = '".addslashes($string_id)."' |
gobrien | f3cc8c3 | 2008-01-11 17:31:54 +0000 | [diff] [blame] | 51 | and |
| 52 | strings.file_id = files.file_id |
| 53 | and |
| 54 | files.version = '".addslashes($version)."' |
gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 55 | group by translations.version |
| 56 | order by translations.version desc |
droy | 8ca5875 | 2018-02-28 10:45:34 -0500 | [diff] [blame] | 57 | limit 1"; |
gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 58 | |
gobrien | fc32692 | 2008-01-11 16:46:44 +0000 | [diff] [blame] | 59 | //print $query; |
gobrien | 36356fb | 2008-01-11 16:45:26 +0000 | [diff] [blame] | 60 | |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 61 | $res = mysqli_query($dbh, $query); |
gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 62 | |
droy | a3815a5 | 2019-09-25 12:49:18 -0400 | [diff] [blame] | 63 | $line = mysqli_fetch_array($res, MYSQLI_ASSOC); |
gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 64 | |
gobrien | 755df67 | 2008-01-18 01:01:33 +0000 | [diff] [blame] | 65 | //print_r($line); |
| 66 | |
gobrien | da3a450 | 2008-01-28 23:43:26 +0000 | [diff] [blame] | 67 | $trans = ""; |
gobrien | 755df67 | 2008-01-18 01:01:33 +0000 | [diff] [blame] | 68 | |
| 69 | if($line['translation_value']){ |
droy | 3f4d7fd | 2018-03-02 09:53:51 -0500 | [diff] [blame] | 70 | $trans = " AND translations.value = '".addslashes($line['translation_value'])."' |
gobrien | 755df67 | 2008-01-18 01:01:33 +0000 | [diff] [blame] | 71 | AND |
| 72 | translations.is_active = 1 |
| 73 | "; |
gobrien | 755df67 | 2008-01-18 01:01:33 +0000 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | $query = "select |
| 77 | strings.string_id, strings.value, strings.name max(translations.translation_id) |
| 78 | FROM |
| 79 | files, |
droy | 3f4d7fd | 2018-03-02 09:53:51 -0500 | [diff] [blame] | 80 | strings |
gobrien | 755df67 | 2008-01-18 01:01:33 +0000 | [diff] [blame] | 81 | left join |
| 82 | translations |
| 83 | on |
| 84 | translations.string_id = strings.string_id |
| 85 | where |
| 86 | files.file_id = strings.file_id |
droy | 3f4d7fd | 2018-03-02 09:53:51 -0500 | [diff] [blame] | 87 | AND |
gobrien | 755df67 | 2008-01-18 01:01:33 +0000 | [diff] [blame] | 88 | 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 |
droy | 3f4d7fd | 2018-03-02 09:53:51 -0500 | [diff] [blame] | 95 | group by translations.string_id"; |
| 96 | |
gobrien | 755df67 | 2008-01-18 01:01:33 +0000 | [diff] [blame] | 97 | $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 | "; |
gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 114 | ?> |
gobrien | 2a4a208 | 2008-05-21 17:51:41 +0000 | [diff] [blame] | 115 | |
gobrien | 19d1fa2 | 2008-02-01 00:33:40 +0000 | [diff] [blame] | 116 | <form id='translation-form'> |
droy | b2ab7e1 | 2012-11-01 13:27:44 -0400 | [diff] [blame] | 117 | <input type="hidden" name="string_id" value="<?= $line['string_id'] ?>"> |
| 118 | <input type="hidden" name="stringTableIndex" value="<?= $stringTableIndex ?>"> |
gobrien | 198300d | 2008-03-04 23:22:36 +0000 | [diff] [blame] | 119 | |
gobrien | 19d1fa2 | 2008-02-01 00:33:40 +0000 | [diff] [blame] | 120 | <div id="english-area" class="side-component"> |
droy | b2ab7e1 | 2012-11-01 13:27:44 -0400 | [diff] [blame] | 121 | <h4>English String [<a id="copy-english-string-link">Copy</a>]</h4> |
kitlo | 8d374b1 | 2012-02-01 18:23:46 +0000 | [diff] [blame] | 122 | <div style='overflow: auto; height: 75px;'> |
kitlo | 7197f8f | 2008-08-02 02:03:59 +0000 | [diff] [blame] | 123 | <div id="english-string"><?= nl2br(htmlspecialchars($line['string_value'])); ?></div> |
gobrien | 19d1fa2 | 2008-02-01 00:33:40 +0000 | [diff] [blame] | 124 | </div> |
droy | a9a0854 | 2018-02-28 15:52:47 -0500 | [diff] [blame] | 125 | <h4 id="translation-hints-title">Translation Hints [<a id="clear-btn" href="javascript:clearHints();">Clear</a>]</h4> |
kitlo | 8d374b1 | 2012-02-01 18:23:46 +0000 | [diff] [blame] | 126 | <div id="translation-hints" style='overflow-x: hidden; overflow-y: auto; height: 75px;'> |
droy | 3f4d7fd | 2018-03-02 09:53:51 -0500 | [diff] [blame] | 127 | <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 |
droy | 8ca5875 | 2018-02-28 10:45:34 -0500 | [diff] [blame] | 131 | 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 |
droy | 3f4d7fd | 2018-03-02 09:53:51 -0500 | [diff] [blame] | 136 | AND t.language_id = '" . addslashes($language) . "' |
droy | 8ca5875 | 2018-02-28 10:45:34 -0500 | [diff] [blame] | 137 | ORDER BY LENGTH(t.value) ASC LIMIT 10"; |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 138 | $res_th = mysqli_query($dbh, $q_th); |
kitlo | 1d02709 | 2018-04-19 17:44:07 -0400 | [diff] [blame] | 139 | if(mysqli_affected_rows($dbh) > 0) { |
droy | 3f4d7fd | 2018-03-02 09:53:51 -0500 | [diff] [blame] | 140 | echo "<b>, or use from the following:</b><ul>"; |
droy | a3815a5 | 2019-09-25 12:49:18 -0400 | [diff] [blame] | 141 | while($translation_hints = mysqli_fetch_array($res_th, MYSQLI_ASSOC)){ |
droy | 3f4d7fd | 2018-03-02 09:53:51 -0500 | [diff] [blame] | 142 | echo "<li>", $translation_hints['value'], "</li>"; |
| 143 | } |
| 144 | echo "</ul>"; |
droy | 8ca5875 | 2018-02-28 10:45:34 -0500 | [diff] [blame] | 145 | } |
droy | 8ca5875 | 2018-02-28 10:45:34 -0500 | [diff] [blame] | 146 | } |
| 147 | ?> |
gobrien | 2a4a208 | 2008-05-21 17:51:41 +0000 | [diff] [blame] | 148 | </div> |
| 149 | |
droy | e3dc111 | 2008-11-19 18:21:28 +0000 | [diff] [blame] | 150 | <input id='non-translatable-checkbox' type=checkbox name="non_translatable_string" <?= $line['non_translatable'] ? 'checked' : '' ;?>>Non-Translatable |
gobrien | 19d1fa2 | 2008-02-01 00:33:40 +0000 | [diff] [blame] | 151 | </div> |
| 152 | <div id="translation-textarea" class="side-component"> |
droy | b2ab7e1 | 2012-11-01 13:27:44 -0400 | [diff] [blame] | 153 | <?php if($line['non_translatable'] == 0) {?> |
kitlo | 2c3287b | 2008-07-30 15:27:48 +0000 | [diff] [blame] | 154 | <h4> |
| 155 | Current Translation |
| 156 | [<a id="reset-current-translation-link">Reset</a>] |
| 157 | [<a id="clear-current-translation-link">Clear</a>] |
| 158 | </h4> |
droy | e3dc111 | 2008-11-19 18:21:28 +0000 | [diff] [blame] | 159 | |
droy | b2ab7e1 | 2012-11-01 13:27:44 -0400 | [diff] [blame] | 160 | <textarea id="current-translation" style='display: inline; width: 95%; height: 154px;' name="translation"><?=(($line['translation_value']));?></textarea> |
droy | e3dc111 | 2008-11-19 18:21:28 +0000 | [diff] [blame] | 161 | <br /> |
kitlo | 8d374b1 | 2012-02-01 18:23:46 +0000 | [diff] [blame] | 162 | <!-- [281434] Syncup overuses the "possibly incorrect" flag |
droy | e3dc111 | 2008-11-19 18:21:28 +0000 | [diff] [blame] | 163 | <input id='fuzzy' type=checkbox name="fuzzy_checkbox" <?= $line['fuzzy'] ? 'checked' : '' ;?>> Translation is possibly incorrect |
| 164 | <br /> |
kitlo | 8d374b1 | 2012-02-01 18:23:46 +0000 | [diff] [blame] | 165 | --> |
kitlo | 22fff0f | 2008-07-21 20:35:50 +0000 | [diff] [blame] | 166 | <button id="allversions" type="submit" name="translateAction" value="All Versions">Submit</button> |
droy | e3dc111 | 2008-11-19 18:21:28 +0000 | [diff] [blame] | 167 | |
droy | b2ab7e1 | 2012-11-01 13:27:44 -0400 | [diff] [blame] | 168 | <?php }else{?> |
gobrien | 2a4a208 | 2008-05-21 17:51:41 +0000 | [diff] [blame] | 169 | <h4>Non Translatable String</h4> |
droy | b2ab7e1 | 2012-11-01 13:27:44 -0400 | [diff] [blame] | 170 | <br /><br /><br /> |
gobrien | 2a4a208 | 2008-05-21 17:51:41 +0000 | [diff] [blame] | 171 | <div style='text-align:center;'>This string has been marked as <b>'non-translatable'</b>.</div> |
gobrien | 2a4a208 | 2008-05-21 17:51:41 +0000 | [diff] [blame] | 172 | |
droy | b2ab7e1 | 2012-11-01 13:27:44 -0400 | [diff] [blame] | 173 | <?php }?> |
gobrien | 19d1fa2 | 2008-02-01 00:33:40 +0000 | [diff] [blame] | 174 | </div> |
gobrien | 2db73d5 | 2008-03-04 00:25:48 +0000 | [diff] [blame] | 175 | <div id="translation-history-area" class="side-component"> |
gobrien | 19d1fa2 | 2008-02-01 00:33:40 +0000 | [diff] [blame] | 176 | <h4>History of Translations</h4> |
gobrien | 2db73d5 | 2008-03-04 00:25:48 +0000 | [diff] [blame] | 177 | <div id="translation-history"> |
gobrien | 2db73d5 | 2008-03-04 00:25:48 +0000 | [diff] [blame] | 178 | <table> |
| 179 | <?php |
droy | e3dc111 | 2008-11-19 18:21:28 +0000 | [diff] [blame] | 180 | $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"; |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 181 | $res_history = mysqli_query($dbh, $query); |
gobrien | 2db73d5 | 2008-03-04 00:25:48 +0000 | [diff] [blame] | 182 | |
kitlo | 1d02709 | 2018-04-19 17:44:07 -0400 | [diff] [blame] | 183 | if(!mysqli_num_rows($res_history)){ |
gobrien | 2db73d5 | 2008-03-04 00:25:48 +0000 | [diff] [blame] | 184 | print "No history."; |
| 185 | }else{ |
droy | a3815a5 | 2019-09-25 12:49:18 -0400 | [diff] [blame] | 186 | while($line = mysqli_fetch_array($res_history, MYSQLI_ASSOC)){ |
droy | e3dc111 | 2008-11-19 18:21:28 +0000 | [diff] [blame] | 187 | $fuzzy = ""; |
| 188 | if($line['fuzzy'] == 1) { |
| 189 | $fuzzy = "<img src='images/fuzzy.png' />"; |
| 190 | } |
gobrien | 2db73d5 | 2008-03-04 00:25:48 +0000 | [diff] [blame] | 191 | print "<tr>"; |
| 192 | print "<td width='40%'>"; |
kitlo | 8d374b1 | 2012-02-01 18:23:46 +0000 | [diff] [blame] | 193 | // [281434] Syncup overuses the "possibly incorrect" flag |
| 194 | // print "<div>$fuzzy".nl2br(htmlspecialchars($line['value']))."</div>"; |
| 195 | print "<div>".nl2br(htmlspecialchars($line['value']))."</div>"; |
gobrien | 2db73d5 | 2008-03-04 00:25:48 +0000 | [diff] [blame] | 196 | 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> |
gobrien | 19d1fa2 | 2008-02-01 00:33:40 +0000 | [diff] [blame] | 209 | </div> |
| 210 | </form> |