atoulme | e9ec6d8 | 2008-11-19 14:41:30 +0000 | [diff] [blame] | 1 | <?php |
| 2 | /******************************************************************************* |
| 3 | * Copyright (c) 2007-2008 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 | * Antoine Toulme, Intalio Inc. bug 255775: Open a REST API for people to query for translations |
| 11 | *******************************************************************************/ |
| 12 | |
| 13 | header("Content-type: text/plain"); |
| 14 | include("global.php"); |
atoulme | 0ddd89d | 2008-11-24 13:53:57 +0000 | [diff] [blame] | 15 | InitPage(""); |
atoulme | e9ec6d8 | 2008-11-19 14:41:30 +0000 | [diff] [blame] | 16 | |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 17 | global $dbh; |
atoulme | e9ec6d8 | 2008-11-19 14:41:30 +0000 | [diff] [blame] | 18 | |
atoulme | 0ddd89d | 2008-11-24 13:53:57 +0000 | [diff] [blame] | 19 | |
atoulme | e9ec6d8 | 2008-11-19 14:41:30 +0000 | [diff] [blame] | 20 | $value = $_GET['string']; |
| 21 | $nl = $_GET['nl']; |
| 22 | |
| 23 | if (!$value || !$nl) { |
| 24 | exit(); |
| 25 | } |
| 26 | |
| 27 | // we could add more checks on the values being entered. |
| 28 | |
| 29 | // we also need to discuss how to deal with the encoding of the value, |
| 30 | // since & and spaces should be encoded for example |
| 31 | |
| 32 | $value = html_entity_decode($value); |
| 33 | |
| 34 | $possible_translations = mysql_query( |
| 35 | "SELECT t.value |
| 36 | from strings As s inner join translations AS t on s.string_id = t.string_id |
| 37 | inner join languages As l on l.language_id = t.language_id |
droy | 6886461 | 2009-04-14 15:44:05 +0000 | [diff] [blame] | 38 | where s.value = BINARY '" . addslashes($value) . "' |
atoulme | e9ec6d8 | 2008-11-19 14:41:30 +0000 | [diff] [blame] | 39 | and l.iso_code = '" . addslashes($nl) . "' "); |
| 40 | |
| 41 | if ($possible_translations and (($translation_row = mysql_fetch_assoc($possible_translations)) != null)) { |
| 42 | echo $translation_row['value']; |
| 43 | } |
| 44 | |
| 45 | ?> |