blob: cb3d44f32dcf3bf831e20b36bea7b5dec920b00b [file] [log] [blame]
gobrien48275462007-11-29 21:29:17 +00001<?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
14require_once("cb_global.php");
15
gobrienad11d892007-12-19 08:33:25 +000016$string_id = $App->getHTTPParameter("string_id", "POST");
gobrien48275462007-11-29 21:29:17 +000017
gobrien775f3582008-02-29 16:52:30 +000018
19if(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
gobrien36356fb2008-01-11 16:45:26 +000027
gobrien48275462007-11-29 21:29:17 +000028$query = "select
29 strings.string_id,
30 strings.value as string_value,
31 translations.value as translation_value,
gobrien755df672008-01-18 01:01:33 +000032 files.name,
33 strings.name as token,
gobrien48275462007-11-29 21:29:17 +000034 max(translations.version)
35 from
gobrienf3cc8c32008-01-11 17:31:54 +000036 files,
gobrien48275462007-11-29 21:29:17 +000037 strings
38 left join translations on
gobrien36356fb2008-01-11 16:45:26 +000039 (strings.string_id = translations.string_id
40 and
41 translations.is_active != 0
42 and
43 translations.language_id = '".addslashes($language)."')
gobrien48275462007-11-29 21:29:17 +000044 where
45 strings.is_active != 0
46 and
47 strings.string_id = '".addslashes($string_id)."'
gobrienf3cc8c32008-01-11 17:31:54 +000048 and
49 strings.file_id = files.file_id
50 and
51 files.version = '".addslashes($version)."'
gobrien48275462007-11-29 21:29:17 +000052 group by translations.version
53 order by translations.version desc
54 limit 1
55 ";
56
gobrienfc326922008-01-11 16:46:44 +000057//print $query;
gobrien36356fb2008-01-11 16:45:26 +000058
gobrien48275462007-11-29 21:29:17 +000059$res = mysql_query($query,$dbh);
60
61$line = mysql_fetch_array($res, MYSQL_ASSOC);
62
gobrien755df672008-01-18 01:01:33 +000063//print_r($line);
64
gobrienda3a4502008-01-28 23:43:26 +000065$trans = "";
gobrien755df672008-01-18 01:01:33 +000066
67if($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
gobrien755df672008-01-18 01:01:33 +0000122
123/*
gobrien2cc26462008-01-23 22:49:49 +0000124$res = mysql_query($query,$dbh);
gobrien755df672008-01-18 01:01:33 +0000125while($same_trans = mysql_fetch_array($res, MYSQL_ASSOC)){
126 print "<pre>--";
127 print_r($same_trans);
128 print "</pre>";
129}
130*/
gobrien48275462007-11-29 21:29:17 +0000131?>
gobrien19d1fa22008-02-01 00:33:40 +0000132<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;'>
gobrien2edf9242008-02-29 17:20:36 +0000137 <b><?= htmlspecialchars(nl2br($line['string_value']));?></b>
gobrien19d1fa22008-02-01 00:33:40 +0000138 </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>
gobrien3e52d092008-02-28 23:08:25 +0000146 <textarea style='display: inline; width: 320px; height: 150px;' name="translation"><?=(($line['translation_value']));?></textarea>
gobrien19d1fa22008-02-01 00:33:40 +0000147 <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>
gobrien2db73d52008-03-04 00:25:48 +0000151 <div id="translation-history-area" class="side-component">
gobrien19d1fa22008-02-01 00:33:40 +0000152 <h4>History of Translations</h4>
gobrien2db73d52008-03-04 00:25:48 +0000153 <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%'>";
gobrienb1d681c2008-03-04 18:31:05 +0000166 print htmlspecialchars($line['value'])."";
gobrien2db73d52008-03-04 00:25:48 +0000167 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>
gobrien19d1fa22008-02-01 00:33:40 +0000180 </div>
181</form>