gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 1 | <?php |
| 2 | /******************************************************************************* |
| 3 | * Copyright (c) 2007 Eclipse Foundation and others. |
| 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 |
| 12 | *******************************************************************************/ |
| 13 | |
| 14 | require_once("cb_global.php"); |
| 15 | |
gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 16 | $string_id = $App->getHTTPParameter("string_id", "POST"); |
gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 17 | |
gobrien | 775f358 | 2008-02-29 16:52:30 +0000 | [diff] [blame] | 18 | |
| 19 | if(isset($_SESSION['language']) and isset($_SESSION['version']) and isset($_SESSION['project'])){ |
| 20 | $language = $_SESSION['language']; |
| 21 | $version = $_SESSION['version']; |
| 22 | $project_id = $_SESSION['project']; |
| 23 | }else{ |
| 24 | return false; |
| 25 | } |
| 26 | |
gobrien | 36356fb | 2008-01-11 16:45:26 +0000 | [diff] [blame] | 27 | |
gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 28 | $query = "select |
| 29 | strings.string_id, |
| 30 | strings.value as string_value, |
| 31 | translations.value as translation_value, |
gobrien | 755df67 | 2008-01-18 01:01:33 +0000 | [diff] [blame] | 32 | files.name, |
| 33 | strings.name as token, |
gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 34 | max(translations.version) |
| 35 | from |
gobrien | f3cc8c3 | 2008-01-11 17:31:54 +0000 | [diff] [blame] | 36 | files, |
gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 37 | strings |
| 38 | left join translations on |
gobrien | 36356fb | 2008-01-11 16:45:26 +0000 | [diff] [blame] | 39 | (strings.string_id = translations.string_id |
| 40 | and |
| 41 | translations.is_active != 0 |
| 42 | and |
| 43 | translations.language_id = '".addslashes($language)."') |
gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 44 | where |
| 45 | strings.is_active != 0 |
| 46 | and |
| 47 | strings.string_id = '".addslashes($string_id)."' |
gobrien | f3cc8c3 | 2008-01-11 17:31:54 +0000 | [diff] [blame] | 48 | and |
| 49 | strings.file_id = files.file_id |
| 50 | and |
| 51 | files.version = '".addslashes($version)."' |
gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 52 | group by translations.version |
| 53 | order by translations.version desc |
| 54 | limit 1 |
| 55 | "; |
| 56 | |
gobrien | fc32692 | 2008-01-11 16:46:44 +0000 | [diff] [blame] | 57 | //print $query; |
gobrien | 36356fb | 2008-01-11 16:45:26 +0000 | [diff] [blame] | 58 | |
gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 59 | $res = mysql_query($query,$dbh); |
| 60 | |
| 61 | $line = mysql_fetch_array($res, MYSQL_ASSOC); |
| 62 | |
gobrien | 755df67 | 2008-01-18 01:01:33 +0000 | [diff] [blame] | 63 | //print_r($line); |
| 64 | |
gobrien | da3a450 | 2008-01-28 23:43:26 +0000 | [diff] [blame] | 65 | $trans = ""; |
gobrien | 755df67 | 2008-01-18 01:01:33 +0000 | [diff] [blame] | 66 | |
| 67 | if($line['translation_value']){ |
| 68 | $trans = " AND translations.value = '".addslashes($line['translation_value'])."' |
| 69 | AND |
| 70 | translations.is_active = 1 |
| 71 | "; |
| 72 | }else{ |
| 73 | // $trans = "translations.value is NULL "; |
| 74 | } |
| 75 | |
| 76 | $query = "select |
| 77 | strings.string_id, strings.value, strings.name max(translations.translation_id) |
| 78 | FROM |
| 79 | files, |
| 80 | strings |
| 81 | left join |
| 82 | translations |
| 83 | on |
| 84 | translations.string_id = strings.string_id |
| 85 | where |
| 86 | files.file_id = strings.file_id |
| 87 | AND |
| 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 |
| 95 | group by translations.string_id |
| 96 | "; |
| 97 | // AND |
| 98 | // files.name = (SELECT files.name FROM files as F where F.project_id = '".addslashes($project_id)."') |
| 99 | |
| 100 | $query = "SELECT |
| 101 | S.* |
| 102 | FROM |
| 103 | strings AS S |
| 104 | inner join files AS F on F.file_id = S.file_id |
| 105 | inner join translations AS T on T.string_id = S.string_id |
| 106 | where |
| 107 | F.project_id = '".addslashes($project_id)."' |
| 108 | AND |
| 109 | F.file_id in (SELECT files.file_id FROM files where files.project_id = '".addslashes($project_id)."') |
| 110 | AND |
| 111 | S.value = '".addslashes($line['string_value'])."' |
| 112 | and |
| 113 | T.value = '".addslashes($line['translation_value'])."' |
| 114 | AND |
| 115 | T.is_active = 1 |
| 116 | "; |
| 117 | |
| 118 | //INSERT INTO translations SELECT S.string_id, 2, "Some Enhanced Text", other fields..... FROM strings AS S inner join files AS F on F.file_id = S.file_id inner join translations AS T on T.string_id = S.string_id where F.project_id = "eclipse" AND F.name=(SELECT files.name FROM files where file_id = 7) AND S.name="pluginName" and T.value = "Some Old Text" AND T.is_active = 1 |
| 119 | |
| 120 | //print $query; |
| 121 | |
gobrien | 755df67 | 2008-01-18 01:01:33 +0000 | [diff] [blame] | 122 | |
| 123 | /* |
gobrien | 2cc2646 | 2008-01-23 22:49:49 +0000 | [diff] [blame] | 124 | $res = mysql_query($query,$dbh); |
gobrien | 755df67 | 2008-01-18 01:01:33 +0000 | [diff] [blame] | 125 | while($same_trans = mysql_fetch_array($res, MYSQL_ASSOC)){ |
| 126 | print "<pre>--"; |
| 127 | print_r($same_trans); |
| 128 | print "</pre>"; |
| 129 | } |
| 130 | */ |
gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 131 | ?> |
gobrien | 19d1fa2 | 2008-02-01 00:33:40 +0000 | [diff] [blame] | 132 | <form id='translation-form'> |
| 133 | <input type="hidden" name="string_id" value="<?=$line['string_id'];?>"> |
| 134 | <div id="english-area" class="side-component"> |
| 135 | <h4>English String</h4> |
| 136 | <div style='margin-bottom: .5em;'> |
gobrien | 2edf924 | 2008-02-29 17:20:36 +0000 | [diff] [blame] | 137 | <b><?= htmlspecialchars(nl2br($line['string_value']));?></b> |
gobrien | 19d1fa2 | 2008-02-01 00:33:40 +0000 | [diff] [blame] | 138 | </div> |
| 139 | <h4>Externalized Token</h4> |
| 140 | <div> |
| 141 | <?= htmlspecialchars_decode(nl2br($line['token']));?> |
| 142 | </div> |
| 143 | </div> |
| 144 | <div id="translation-textarea" class="side-component"> |
| 145 | <h4>Current Translation</h4> |
gobrien | 3e52d09 | 2008-02-28 23:08:25 +0000 | [diff] [blame] | 146 | <textarea style='display: inline; width: 320px; height: 150px;' name="translation"><?=(($line['translation_value']));?></textarea> |
gobrien | 19d1fa2 | 2008-02-01 00:33:40 +0000 | [diff] [blame] | 147 | <br> |
| 148 | <button id="allversions" type="submit" name="translateAction" value="All Versions" nClick="translationSumbit(this.form,this);">All Versions</button> |
| 149 | <button id="onlysametrans" type="submit" name="translateAction" value="Only Version <?=$_SESSION['version']?>" nClick="translationSumbit(this.form,this);">Only Version <?=$_SESSION['version']?></button> |
| 150 | </div> |
gobrien | 2db73d5 | 2008-03-04 00:25:48 +0000 | [diff] [blame] | 151 | <div id="translation-history-area" class="side-component"> |
gobrien | 19d1fa2 | 2008-02-01 00:33:40 +0000 | [diff] [blame] | 152 | <h4>History of Translations</h4> |
gobrien | 2db73d5 | 2008-03-04 00:25:48 +0000 | [diff] [blame] | 153 | <div id="translation-history"> |
| 154 | |
| 155 | <table> |
| 156 | <?php |
| 157 | $query = "select value,first_name,last_name,translations.created_on 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"; |
| 158 | $res_history = mysql_query($query,$dbh); |
| 159 | |
| 160 | if(!mysql_num_rows($res_history)){ |
| 161 | print "No history."; |
| 162 | }else{ |
| 163 | while($line = mysql_fetch_array($res_history, MYSQL_ASSOC)){ |
| 164 | print "<tr>"; |
| 165 | print "<td width='40%'>"; |
gobrien | b1d681c | 2008-03-04 18:31:05 +0000 | [diff] [blame^] | 166 | print htmlspecialchars($line['value']).""; |
gobrien | 2db73d5 | 2008-03-04 00:25:48 +0000 | [diff] [blame] | 167 | print "</td>"; |
| 168 | print "<td width='20%'>"; |
| 169 | print $line['first_name']." ".$line['last_name']; |
| 170 | print "</td>"; |
| 171 | print "<td width='40%'>"; |
| 172 | print $line['created_on']; |
| 173 | print "</td>"; |
| 174 | print "</tr>"; |
| 175 | } |
| 176 | } |
| 177 | ?> |
| 178 | </table> |
| 179 | </div> |
gobrien | 19d1fa2 | 2008-02-01 00:33:40 +0000 | [diff] [blame] | 180 | </div> |
| 181 | </form> |