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 | *******************************************************************************/ |
droy | 51e2bcc | 2008-07-16 15:14:43 +0000 | [diff] [blame] | 13 | error_reporting('E_NONE'); ini_set("display_errors", false); |
gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 14 | require_once("cb_global.php"); |
| 15 | |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 16 | $project_id = getHTTPParameter("proj", "POST"); |
| 17 | $version = getHTTPParameter("version", "POST"); |
gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 18 | |
| 19 | //THE 3 VALID STATES |
| 20 | // UNSTRANSLATED (DEFUALT) |
| 21 | // FLAGGED (FLAGGED INCORRECT IN DATABASE) |
| 22 | // AWAITING (TRANSLATED BUT NO RAITINGS YET) |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 23 | $state = getHTTPParameter("state", "POST"); |
gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 24 | |
gobrien | da3a450 | 2008-01-28 23:43:26 +0000 | [diff] [blame] | 25 | if(!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']; |
droy | 0eaf958 | 2008-07-15 20:14:36 +0000 | [diff] [blame] | 37 | |
| 38 | if(isset($_SESSION['string'])) |
| 39 | $string = $_SESSION['string']; |
gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 40 | } |
gobrien | eebd0e1 | 2008-03-04 00:42:59 +0000 | [diff] [blame] | 41 | |
gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 42 | switch($state){ |
| 43 | case "flagged" : |
| 44 | break; |
| 45 | $query = "select |
| 46 | strings.value as string, |
droy | 51e2bcc | 2008-07-16 15:14:43 +0000 | [diff] [blame] | 47 | strings.name as stringName, |
gobrien | 2a4a208 | 2008-05-21 17:51:41 +0000 | [diff] [blame] | 48 | strings.non_translatable, |
droy | e3dc111 | 2008-11-19 18:21:28 +0000 | [diff] [blame] | 49 | translations.value as translation, |
| 50 | translations.possibly_incorrect as fuzzy |
gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 51 | 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, |
droy | 51e2bcc | 2008-07-16 15:14:43 +0000 | [diff] [blame] | 71 | strings.name as stringName, |
gobrien | 2a4a208 | 2008-05-21 17:51:41 +0000 | [diff] [blame] | 72 | strings.non_translatable, |
gobrien | eebd0e1 | 2008-03-04 00:42:59 +0000 | [diff] [blame] | 73 | translations.value as translation, |
droy | e3dc111 | 2008-11-19 18:21:28 +0000 | [diff] [blame] | 74 | translations.possibly_incorrect as fuzzy, |
gobrien | eebd0e1 | 2008-03-04 00:42:59 +0000 | [diff] [blame] | 75 | users.username as translator |
| 76 | from |
gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 77 | strings, |
gobrien | eebd0e1 | 2008-03-04 00:42:59 +0000 | [diff] [blame] | 78 | users, |
gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 79 | 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)."' |
gobrien | eebd0e1 | 2008-03-04 00:42:59 +0000 | [diff] [blame] | 92 | and |
| 93 | users.userid = translations.userid |
gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 94 | "; |
| 95 | |
| 96 | case "untranslated" : |
| 97 | default: |
| 98 | $query = "select |
| 99 | strings.string_id as stringId, |
droy | 0eaf958 | 2008-07-15 20:14:36 +0000 | [diff] [blame] | 100 | strings.name as stringName, |
gobrien | 2a4a208 | 2008-05-21 17:51:41 +0000 | [diff] [blame] | 101 | strings.non_translatable, |
gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 102 | strings.value as text, |
| 103 | strings.created_on as createdOn, |
droy | bef6437 | 2008-07-16 15:20:21 +0000 | [diff] [blame] | 104 | translations.value as translationString, |
droy | e3dc111 | 2008-11-19 18:21:28 +0000 | [diff] [blame] | 105 | translations.possibly_incorrect as fuzzy, |
droy | bef6437 | 2008-07-16 15:20:21 +0000 | [diff] [blame] | 106 | users.first_name as first, |
| 107 | users.last_name as last |
gobrien | eebd0e1 | 2008-03-04 00:42:59 +0000 | [diff] [blame] | 108 | from |
gobrien | f3cc8c3 | 2008-01-11 17:31:54 +0000 | [diff] [blame] | 109 | files, |
| 110 | strings |
gobrien | f3cc8c3 | 2008-01-11 17:31:54 +0000 | [diff] [blame] | 111 | left join translations on ( |
| 112 | translations.language_id = '".addslashes($language)."' |
| 113 | and |
| 114 | translations.string_id = strings.string_id |
gobrien | 755df67 | 2008-01-18 01:01:33 +0000 | [diff] [blame] | 115 | and |
| 116 | translations.is_active = 1 |
gobrien | f3cc8c3 | 2008-01-11 17:31:54 +0000 | [diff] [blame] | 117 | ) |
gobrien | 1bc0e19 | 2008-01-31 15:43:41 +0000 | [diff] [blame] | 118 | |
| 119 | left join users on ( |
| 120 | translations.userid = users.userid |
| 121 | ) |
gobrien | f3cc8c3 | 2008-01-11 17:31:54 +0000 | [diff] [blame] | 122 | where |
| 123 | strings.is_active = 1 |
| 124 | and |
| 125 | files.file_id = strings.file_id |
| 126 | and |
| 127 | files.version = '".addslashes($version)."' |
gobrien | da265d3 | 2008-01-24 01:08:14 +0000 | [diff] [blame] | 128 | and |
| 129 | files.name = '".addslashes($file)."' |
gobrien | f3cc8c3 | 2008-01-11 17:31:54 +0000 | [diff] [blame] | 130 | and |
| 131 | files.project_id = '".addslashes($project_id)."' |
gobrien | f3cc8c3 | 2008-01-11 17:31:54 +0000 | [diff] [blame] | 132 | group by strings.string_id,translations.version desc |
| 133 | "; |
gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 134 | } |
gobrien | 6a36e89 | 2007-12-20 23:55:04 +0000 | [diff] [blame] | 135 | |
gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 136 | //print $query."<br>"; |
gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 137 | |
kitlo | 2c8d8a9 | 2018-04-19 13:25:09 -0400 | [diff] [blame] | 138 | $res = mysqli_query($dbh, $query); |
gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 139 | |
kitlo | a59efea | 2018-05-11 12:40:40 -0400 | [diff] [blame] | 140 | //print mysqli_error($dbh); |
gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 141 | |
| 142 | $stringids = Array(); |
| 143 | $return = Array(); |
droy | a3815a5 | 2019-09-25 12:49:18 -0400 | [diff] [blame] | 144 | while($line = mysqli_fetch_array($res, MYSQLI_ASSOC)){ |
gobrien | da3a450 | 2008-01-28 23:43:26 +0000 | [diff] [blame] | 145 | if(isset($stringids[$line['stringId']])){ |
gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 146 | continue; |
| 147 | }else{ |
kitlo | 7197f8f | 2008-08-02 02:03:59 +0000 | [diff] [blame] | 148 | $line['text'] = nl2br(htmlspecialchars($line['text'])); |
droy | 0eaf958 | 2008-07-15 20:14:36 +0000 | [diff] [blame] | 149 | if(isset($string) && $line['stringName'] == $string){ |
| 150 | $line['current'] = true; |
| 151 | } |
| 152 | else { |
| 153 | $line['current'] = false; |
droy | 749bf84 | 2008-07-17 16:10:42 +0000 | [diff] [blame] | 154 | } |
kitlo | 7197f8f | 2008-08-02 02:03:59 +0000 | [diff] [blame] | 155 | $line['translationString'] = nl2br(htmlspecialchars($line['translationString'])); |
| 156 | $line['translator'] = nl2br(htmlspecialchars($line['first']." ".$line['last'])); |
gobrien | 2a4a208 | 2008-05-21 17:51:41 +0000 | [diff] [blame] | 157 | if($line['non_translatable']){ |
| 158 | $line['translationString'] = "<span style='font-style: italic;'>non-translatable string"; |
| 159 | $line['nontranslatable'] = true; |
droy | e3dc111 | 2008-11-19 18:21:28 +0000 | [diff] [blame] | 160 | } |
gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 161 | $return[] = $line; |
| 162 | $stringids[$line['stringId']] = 1; |
| 163 | } |
gobrien | 4827546 | 2007-11-29 21:29:17 +0000 | [diff] [blame] | 164 | } |
| 165 | |
gobrien | 36fa1e7 | 2008-11-17 19:05:57 +0000 | [diff] [blame] | 166 | $pagesize = 50; |
gobrien | 15f8578 | 2008-11-17 18:31:25 +0000 | [diff] [blame] | 167 | |
| 168 | if(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 | } |
gobrien | 1922e03 | 2008-11-17 19:05:07 +0000 | [diff] [blame] | 178 | 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 | } |
gobrien | 15f8578 | 2008-11-17 18:31:25 +0000 | [diff] [blame] | 185 | } |
| 186 | |
gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 187 | exit(); |
gobrien | ad11d89 | 2007-12-19 08:33:25 +0000 | [diff] [blame] | 188 | ?> |