blob: 39c53daf02cd3acde737f544557756bd6c2a8d25 [file] [log] [blame]
atoulmee9ec6d82008-11-19 14:41:30 +00001<?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
13header("Content-type: text/plain");
14include("global.php");
atoulme0ddd89d2008-11-24 13:53:57 +000015InitPage("");
atoulmee9ec6d82008-11-19 14:41:30 +000016
atoulme3e5e9342009-01-23 17:34:30 +000017global $dbh;
atoulmee9ec6d82008-11-19 14:41:30 +000018
atoulme0ddd89d2008-11-24 13:53:57 +000019
atoulmee9ec6d82008-11-19 14:41:30 +000020$value = $_GET['string'];
21$nl = $_GET['nl'];
22
23if (!$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
droy68864612009-04-14 15:44:05 +000038 where s.value = BINARY '" . addslashes($value) . "'
atoulmee9ec6d82008-11-19 14:41:30 +000039 and l.iso_code = '" . addslashes($nl) . "' ");
40
41if ($possible_translations and (($translation_row = mysql_fetch_assoc($possible_translations)) != null)) {
42 echo $translation_row['value'];
43}
44
45?>