blob: ea90ac9d372d7ff1b6e5b8cfd6a8a9758597589d [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*******************************************************************************/
droy51e2bcc2008-07-16 15:14:43 +000013error_reporting('E_NONE'); ini_set("display_errors", false);
gobrien48275462007-11-29 21:29:17 +000014require_once("cb_global.php");
15
atoulme3e5e9342009-01-23 17:34:30 +000016$project_id = getHTTPParameter("proj", "POST");
17$version = getHTTPParameter("version", "POST");
gobrienad11d892007-12-19 08:33:25 +000018
19//THE 3 VALID STATES
20// UNSTRANSLATED (DEFUALT)
21// FLAGGED (FLAGGED INCORRECT IN DATABASE)
22// AWAITING (TRANSLATED BUT NO RAITINGS YET)
atoulme3e5e9342009-01-23 17:34:30 +000023$state = getHTTPParameter("state", "POST");
gobrienad11d892007-12-19 08:33:25 +000024
gobrienda3a4502008-01-28 23:43:26 +000025if(!isset($proj_post)){
26 if(isset($_SESSION['project']))
27 $project_id = $_SESSION['project'];
28
29 if(isset($_SESSION['version']))
30 $version = $_SESSION['version'];
31
32 if(isset($_SESSION['language']))
33 $language = $_SESSION['language'];
34
35 if(isset($_SESSION['file']))
36 $file = $_SESSION['file'];
droy0eaf9582008-07-15 20:14:36 +000037
38 if(isset($_SESSION['string']))
39 $string = $_SESSION['string'];
gobrien48275462007-11-29 21:29:17 +000040}
gobrieneebd0e12008-03-04 00:42:59 +000041
gobrienad11d892007-12-19 08:33:25 +000042switch($state){
43 case "flagged" :
44 break;
45 $query = "select
46 strings.value as string,
droy51e2bcc2008-07-16 15:14:43 +000047 strings.name as stringName,
gobrien2a4a2082008-05-21 17:51:41 +000048 strings.non_translatable,
droye3dc1112008-11-19 18:21:28 +000049 translations.value as translation,
50 translations.possibly_incorrect as fuzzy
gobrienad11d892007-12-19 08:33:25 +000051 from
52 strings,
53 files
54 left join translations on
55 translations.language_id = '".addslashes($language)."'
56 and
57 string_id = translations.string_id
58 where
59 strings.is_active != 0
60 and
61 strings.file_id = files.file_id
62 and
63 files.project_id = '".addslashes($project_id)."'
64 and
65 files.version = '".addslashes($version)."'
66 ";
67 case "translated" :
68 break;
69 $query = "select
70 strings.value as string,
droy51e2bcc2008-07-16 15:14:43 +000071 strings.name as stringName,
gobrien2a4a2082008-05-21 17:51:41 +000072 strings.non_translatable,
gobrieneebd0e12008-03-04 00:42:59 +000073 translations.value as translation,
droye3dc1112008-11-19 18:21:28 +000074 translations.possibly_incorrect as fuzzy,
gobrieneebd0e12008-03-04 00:42:59 +000075 users.username as translator
76 from
gobrienad11d892007-12-19 08:33:25 +000077 strings,
gobrieneebd0e12008-03-04 00:42:59 +000078 users,
gobrienad11d892007-12-19 08:33:25 +000079 files
80 left join translations on
81 translations.language_id = '".addslashes($language)."'
82 and
83 string_id = translations.string_id
84 where
85 strings.is_active != 0
86 and
87 strings.file_id = files.file_id
88 and
89 files.project_id = '".addslashes($project_id)."'
90 and
91 files.version = '".addslashes($version)."'
gobrieneebd0e12008-03-04 00:42:59 +000092 and
93 users.userid = translations.userid
gobrienad11d892007-12-19 08:33:25 +000094 ";
95
96 case "untranslated" :
97 default:
98 $query = "select
99 strings.string_id as stringId,
droy0eaf9582008-07-15 20:14:36 +0000100 strings.name as stringName,
gobrien2a4a2082008-05-21 17:51:41 +0000101 strings.non_translatable,
gobrienad11d892007-12-19 08:33:25 +0000102 strings.value as text,
103 strings.created_on as createdOn,
droybef64372008-07-16 15:20:21 +0000104 translations.value as translationString,
droye3dc1112008-11-19 18:21:28 +0000105 translations.possibly_incorrect as fuzzy,
droybef64372008-07-16 15:20:21 +0000106 users.first_name as first,
107 users.last_name as last
gobrieneebd0e12008-03-04 00:42:59 +0000108 from
gobrienf3cc8c32008-01-11 17:31:54 +0000109 files,
110 strings
gobrienf3cc8c32008-01-11 17:31:54 +0000111 left join translations on (
112 translations.language_id = '".addslashes($language)."'
113 and
114 translations.string_id = strings.string_id
gobrien755df672008-01-18 01:01:33 +0000115 and
116 translations.is_active = 1
gobrienf3cc8c32008-01-11 17:31:54 +0000117 )
gobrien1bc0e192008-01-31 15:43:41 +0000118
119 left join users on (
120 translations.userid = users.userid
121 )
gobrienf3cc8c32008-01-11 17:31:54 +0000122 where
123 strings.is_active = 1
124 and
125 files.file_id = strings.file_id
126 and
127 files.version = '".addslashes($version)."'
gobrienda265d32008-01-24 01:08:14 +0000128 and
129 files.name = '".addslashes($file)."'
gobrienf3cc8c32008-01-11 17:31:54 +0000130 and
131 files.project_id = '".addslashes($project_id)."'
gobrienf3cc8c32008-01-11 17:31:54 +0000132 group by strings.string_id,translations.version desc
133 ";
gobrienad11d892007-12-19 08:33:25 +0000134}
gobrien6a36e892007-12-20 23:55:04 +0000135
gobrienad11d892007-12-19 08:33:25 +0000136//print $query."<br>";
gobrien48275462007-11-29 21:29:17 +0000137
kitlo2c8d8a92018-04-19 13:25:09 -0400138$res = mysqli_query($dbh, $query);
gobrien48275462007-11-29 21:29:17 +0000139
kitloa59efea2018-05-11 12:40:40 -0400140//print mysqli_error($dbh);
gobrienad11d892007-12-19 08:33:25 +0000141
142$stringids = Array();
143$return = Array();
droya3815a52019-09-25 12:49:18 -0400144while($line = mysqli_fetch_array($res, MYSQLI_ASSOC)){
gobrienda3a4502008-01-28 23:43:26 +0000145 if(isset($stringids[$line['stringId']])){
gobrienad11d892007-12-19 08:33:25 +0000146 continue;
147 }else{
kitlo7197f8f2008-08-02 02:03:59 +0000148 $line['text'] = nl2br(htmlspecialchars($line['text']));
droy0eaf9582008-07-15 20:14:36 +0000149 if(isset($string) && $line['stringName'] == $string){
150 $line['current'] = true;
151 }
152 else {
153 $line['current'] = false;
droy749bf842008-07-17 16:10:42 +0000154 }
kitlo7197f8f2008-08-02 02:03:59 +0000155 $line['translationString'] = nl2br(htmlspecialchars($line['translationString']));
156 $line['translator'] = nl2br(htmlspecialchars($line['first']." ".$line['last']));
gobrien2a4a2082008-05-21 17:51:41 +0000157 if($line['non_translatable']){
158 $line['translationString'] = "<span style='font-style: italic;'>non-translatable string";
159 $line['nontranslatable'] = true;
droye3dc1112008-11-19 18:21:28 +0000160 }
gobrienad11d892007-12-19 08:33:25 +0000161 $return[] = $line;
162 $stringids[$line['stringId']] = 1;
163 }
gobrien48275462007-11-29 21:29:17 +0000164}
165
gobrien36fa1e72008-11-17 19:05:57 +0000166$pagesize = 50;
gobrien15f85782008-11-17 18:31:25 +0000167
168if(count($return) > $pagesize and $_GET['paged'] < count($return) ){
169 if(isset($_GET['paged'])){
170 $return = array_slice($return,$_GET['paged'],$pagesize);
171 $pg->paged = $_GET['paged']+$pagesize;
172 $return[] = $pg;
173 }else{
174 $return = array_slice($return,0,$pagesize);
175 $pg->paged = $pagesize;
176 $return[] = $pg;
177 }
gobrien1922e032008-11-17 19:05:07 +0000178 print json_encode($return);
179}else{
180 if($_GET['paged'] < count($return) ){
181 print json_encode($return);
182 }else{
183 print json_encode(array());
184 }
gobrien15f85782008-11-17 18:31:25 +0000185}
186
gobrienad11d892007-12-19 08:33:25 +0000187exit();
gobrienad11d892007-12-19 08:33:25 +0000188?>