index.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. <?php
  2. session_start();
  3. $http_host = $_SERVER['HTTP_HOST'];
  4. include("../functions.php");
  5. $proto = getProtocol();
  6. $con = startdb();
  7. $server = "$proto$http_host";
  8. //Language
  9. $lang = 'es';
  10. include("../lang/lang_es.php");
  11. $cur_section = 'Traducciones';
  12. $l = strtolower(mysqli_real_escape_string($con, $_GET['l'])); // language
  13. if ($l != 'en' && $l != 'eu'){
  14. ?>
  15. <!DOCTYPE html>
  16. <html>
  17. <head>
  18. <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
  19. <meta charset="utf-8"/>
  20. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
  21. <title><?=$lng["translation_title"]?> - Gasteizko Margolariak</title>
  22. <link rel="shortcut icon" href="<?=$server?>/img/logo/favicon.ico">
  23. <!-- CSS files -->
  24. <style>
  25. <?php
  26. include("../css/ui.css");
  27. include("../css/traducir.css");
  28. ?>
  29. </style>
  30. <!-- CSS for mobile version -->
  31. <style media="(max-width : 990px)">
  32. <?php
  33. include("../css/m/ui.css");
  34. include("../css/m/traducir.css");
  35. ?>
  36. </style>
  37. <!-- Script files -->
  38. <script type="text/javascript">
  39. <?php
  40. include("../script/ui.js");
  41. ?>
  42. </script>
  43. <!-- Meta tags -->
  44. <link rel='canonical' href='<?=$server?>/traducir/'/>
  45. <link rel='author' href='<?=server?>'/>
  46. <link rel='publisher' href='<?=server?>'/>
  47. <meta name='description' content='Traduccion de contenidos de la web de Gasteizko Margolariak'/>
  48. <meta property='og:title' content='<?=$lng["translation_title"]?> - Gasteizko Margolariak'/>
  49. <meta property='og:url' content='<?=$server?>/traducir/'/>
  50. <meta property='og:description' content='<?=$lng["translation_description"]?>'/>
  51. <meta property='og:image' content='<?=$server?>/img/logo/logo.png'/>
  52. <meta property='og:site_name' content='Gasteizko Margolariak'/>
  53. <meta property='og:type' content='website'/>
  54. <meta property='og:locale' content='<?=$lang?>'/>
  55. <meta name='twitter:card' content='summary'/>
  56. <meta name='twitter:title' content='<?=$lng["translation_title"]?> - Gasteizko Margolariak'/>
  57. <meta name='twitter:description' content='<?=$lng["translation_description"]?>'/>
  58. <meta name='twitter:image' content='<?=$server?>/img/logo/logo.png'/>
  59. <meta name='twitter:url' content='<?$server?>/traducir/'/>
  60. <meta name='robots' content='noindex nofollow'/>
  61. </head>
  62. <body>
  63. <?php include("../header.php"); ?>
  64. <div id="content">
  65. <div class='section' id='w_init'>
  66. <h3 class='section_title'><?=$lng["translation_title"]?></h3>
  67. <div class='entry'>
  68. <a class='lang' href='<?=$server?>/traducir/eu/'<?=$lng["translation_to_eu"]?></a>
  69. <a class='lang' href='<?=$server?>/traducir/en/'<?=$lng["translation_to_en"]?></a>
  70. </div>
  71. </div>
  72. </div>
  73. </body>
  74. </html>
  75. <?php
  76. }
  77. else{
  78. $q_string="
  79. SELECT * FROM (
  80. SELECT * FROM (
  81. SELECT 'activity' AS tab, 'title' AS field, id, title_es AS es, title_eu AS eu, title_en AS en, dtime FROM activity WHERE title_es = title_XX
  82. UNION
  83. SELECT 'activity' AS tab, 'text' AS field, id, text_es AS es, text_eu AS eu, text_en AS en, dtime FROM activity WHERE text_es = text_XX
  84. UNION
  85. SELECT 'activity' AS tab, 'after' AS field, id, after_es AS es, after_eu AS eu, after_en AS en, dtime FROM activity WHERE after_es IS NOT NULL AND after_es = after_XX
  86. UNION
  87. SELECT 'activity_itinerary' AS tab, 'name' AS field, activity_itinerary.id AS id, name_es AS es, name_eu AS eu, name_en AS en, dtime FROM activity, activity_itinerary WHERE activity = activity.id AND name_es = name_XX
  88. UNION
  89. SELECT 'activity_itinerary' AS tab, 'text' AS field, activity_itinerary.id AS id, text_es AS es, text_eu AS eu, text_en AS en, dtime FROM activity, activity_itinerary WHERE activity = activity.id AND text_es IS NOT null AND text_es = text_XX
  90. UNION
  91. SELECT 'album' AS tab, 'title' AS field, id, title_es AS es, title_eu AS eu, title_en AS en, dtime FROM album WHERE title_es = title_XX
  92. UNION
  93. SELECT 'album' AS tab, 'description' AS field, id, description_es AS es, description_eu AS eu, description_en AS en, dtime FROM album WHERE description_es IS NOT NULL AND description_es = description_XX
  94. UNION
  95. SELECT 'festival' AS tab, 'text' AS field, id, text_es AS es, text_eu AS eu, text_en AS en, str_to_date(year || '-' || month(sysdate()) || '-' || day(sysdate()), '%Y-%m-%d') AS dtime FROM festival WHERE text_es = text_XX
  96. UNION
  97. SELECT 'festival' AS tab, 'summary' AS field, id, summary_es AS es, summary_eu AS eu, summary_en AS en, str_to_date(year || '-' || month(sysdate()) || '-' || day(sysdate()), '%Y-%m-%d') AS dtime FROM festival WHERE summary_es IS NOT null AND summary_es = summary_XX
  98. UNION
  99. SELECT 'festival_day' AS tab, 'name' AS field, id AS id, name_es AS es, name_eu AS eu, name_en AS en, date AS dtime FROM festival_day WHERE name_es = name_XX
  100. UNION
  101. SELECT 'festival_event' AS tab, 'title' AS field, id, title_es AS es, title_eu AS eu, title_en AS en, start AS dtime FROM festival_event WHERE title_es = title_XX
  102. UNION
  103. SELECT 'festival_event' AS tab, 'description' AS field, id, description_es AS es, description_eu AS eu, description_en AS en, start AS dtime FROM festival_event WHERE description_es IS NOT null AND description_es = description_XX
  104. UNION
  105. SELECT 'festival_offer' AS tab, 'name' AS field, id AS id, name_es AS es, name_eu AS eu, name_en AS en, str_to_date(year || '-' || month(sysdate()) || '-' || day(sysdate()), '%Y-%m-%d') AS dtime FROM festival_offer WHERE name_es = name_XX
  106. UNION
  107. SELECT 'festival_offer' AS tab, 'description' AS field, id AS id, description_es AS es, description_eu AS eu, description_en AS en, str_to_date(year || '-' || month(sysdate()) || '-' || day(sysdate()), '%Y-%m-%d') AS dtime FROM festival_offer WHERE description_es IS NOT null AND description_es = description_XX
  108. UNION
  109. SELECT 'photo' AS tab, 'title' AS field, id, title_es AS es, title_eu AS eu, title_en AS en, dtime FROM photo WHERE title_es IS NOT null AND title_es = title_XX
  110. UNION
  111. SELECT 'photo' AS tab, 'description' AS field, id, description_es AS es, description_eu AS eu, description_en AS en, dtime FROM photo WHERE description_es IS NOT null AND description_es = description_XX
  112. UNION
  113. SELECT 'place' AS tab, 'name' AS field, id AS id, name_es AS es, name_eu AS eu, name_en AS en, DATE_SUB(sysdate(), INTERVAL 7 DAY) AS dtime FROM place WHERE name_es = name_XX
  114. UNION
  115. SELECT 'place' AS tab, 'address' AS field, id AS id, address_es AS es, address_eu AS eu, address_en AS en, DATE_SUB(sysdate(), INTERVAL 7 DAY) AS dtime FROM place WHERE address_es = address_XX
  116. UNION
  117. SELECT 'post' AS tab, 'title' AS field, id, title_es AS es, title_eu AS eu, title_en AS en, dtime FROM post WHERE title_es = title_XX
  118. UNION
  119. SELECT 'post' AS tab, 'text' AS field, id, text_es AS es, text_eu AS eu, text_en AS en, dtime FROM post WHERE text_es = text_XX
  120. UNION
  121. SELECT 'sponsor' AS tab, 'name' AS field, id AS id, name_es AS es, name_eu AS eu, name_en AS en, DATE_SUB(sysdate(), INTERVAL 8 DAY) AS dtime FROM sponsor WHERE name_es = name_XX
  122. UNION
  123. SELECT 'sponsor' AS tab, 'text' AS field, id AS id, text_es AS es, text_eu AS eu, text_en AS en, DATE_SUB(sysdate(), INTERVAL 8 DAY) AS dtime FROM sponsor WHERE text_es = text_XX
  124. UNION
  125. SELECT 'sponsor' AS tab, 'address' AS field, id AS id, address_es AS es, address_eu AS eu, address_en AS en, DATE_SUB(sysdate(), INTERVAL 8 DAY) AS dtime FROM sponsor WHERE address_es = address_XX
  126. ) d ORDER BY dtime DESC LIMIT 100
  127. ) f ORDER BY rand();
  128. ";
  129. // Select language
  130. $q_string = str_replace('XX', $l, $q_string);
  131. ?>
  132. <!DOCTYPE html>
  133. <html>
  134. <head>
  135. <meta content='text/html; charset=utf-8' http-equiv='content-type'/>
  136. <meta charset='utf-8'/>
  137. <meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1'>
  138. <title><?=$lng["translation_title"]?> - Gasteizko Margolariak</title>
  139. <link rel='shortcut icon' href='<?=$server?>/img/logo/favicon.ico'>
  140. <!-- CSS files -->
  141. <style>
  142. <?php
  143. include("../css/ui.css");
  144. include("../css/traducir.css");
  145. ?>
  146. </style>
  147. <!-- CSS for mobile version -->
  148. <style media="(max-width : 990px)">
  149. <?php
  150. include("../css/m/ui.css");
  151. include("../css/m/traducir.css");
  152. ?>
  153. </style>
  154. <!-- Script files -->
  155. <script type="text/javascript">
  156. <?php
  157. include("../script/ui.js");
  158. ?>
  159. var table = [];
  160. var field = [];
  161. var id = [];
  162. var es = [];
  163. var en = [];
  164. var eu = [];
  165. var idx = 0;
  166. <?php
  167. $q = mysqli_query($con, $q_string);
  168. $i = 0;
  169. while ($r = mysqli_fetch_array($q)){
  170. // Populate arrays
  171. ?>
  172. table[<?=$i?>] = '<?=$r['tab']?>';
  173. field[<?=$i?>] = '<?=$r['field']?>';
  174. id[<?=$i?>] = '<?=$r['id']?>';
  175. es[<?=$i?>] = '<?=str_replace("'", "´", $r['es'])?>';
  176. en[<?=$i?>] = '<?=str_replace("'", "´", $r['en'])?>';
  177. eu[<?=$i?>] = '<?=str_replace("'", "´", $r['eu'])?>';
  178. <?php
  179. $i = $i + 1;
  180. }
  181. ?>
  182. function prepare(){
  183. while (es[idx].length == 0){
  184. idx = idx + 1;
  185. }
  186. if (es[idx].length <= 180){
  187. document.getElementById('i_original').innerHTML = es[idx];
  188. document.getElementById('i_original').style.display = 'inline-block';
  189. document.getElementById('i_translation').value = '';
  190. document.getElementById('i_translation').style.display = 'inline-block';
  191. document.getElementById('t_original').innerHTML = '';
  192. document.getElementById('t_original').style.display = 'none';
  193. document.getElementById('t_translation').innerHTML = '';
  194. document.getElementById('t_translation').innerText = '';
  195. document.getElementById('t_translation').value = '';
  196. document.getElementById('t_translation').style.display = 'none';
  197. document.getElementById('type').value = 'i';
  198. }
  199. else{
  200. document.getElementById('i_original').innerHTML = '';
  201. document.getElementById('i_original').style.display = 'none';
  202. document.getElementById('i_translation').value = '';
  203. document.getElementById('i_translation').style.display = 'none';
  204. document.getElementById('t_original').innerHTML = es[idx];
  205. document.getElementById('t_original').style.display = 'inline-block';
  206. document.getElementById('t_translation').innerHTML = '';
  207. document.getElementById('t_translation').innerText = '';
  208. document.getElementById('t_translation').value = '';
  209. document.getElementById('t_translation').style.display = 'inline-block';
  210. document.getElementById('type').value = 't';
  211. }
  212. }
  213. function error(title, text){
  214. document.getElementById('error_title').innerHTML = title;
  215. document.getElementById('error_msg').innerHTML = text;
  216. document.getElementById('w_error').style.display = 'block';
  217. document.getElementById('w_error').style.opacity = 1;
  218. }
  219. function closeError(){
  220. document.getElementById('w_error').style.opacity = 0;
  221. setTimeout(function(){ document.getElementById('w_error').style.display = 'none'; }, 500);
  222. }
  223. function save(){
  224. if (document.getElementById('name').value.length == 0){
  225. error("Introduce tu nombre.", "Es necesario un nombre para identificar de quien provienen las traducciones.");
  226. return;
  227. }
  228. if (((document.getElementById('type').value == 'i') && (document.getElementById('i_translation').value.length == 0)) || ((document.getElementById('type').value == 't') && (document.getElementById('t_translation').value.length == 0))){
  229. error("Introduce una traducci&oacute;n.", "No has introducido una traducci&oacute;n. Si lo prefieres, utiliza el boton rojo para saltar esta traducci&oacute;n.");
  230. return;
  231. }
  232. // Get data
  233. var t = encodeURI(table[idx]);
  234. var f = encodeURI(field[idx]);
  235. var i = encodeURI(id[idx]);
  236. var c = "";
  237. var l = "<?=$l?>";
  238. var n = document.getElementById('name').value;
  239. if (document.getElementById('type').value == 'i'){
  240. c = encodeURI(document.getElementById('i_translation').value);
  241. }
  242. else{
  243. c = encodeURI(document.getElementById('t_translation').value);
  244. }
  245. var url = "<?=$server?>/traducir/load.php?t=" + t + "&f=" + f + "&i=" + i + "&c=" + c + "&l=" + l + "&n=" + n;
  246. var xhttp = new XMLHttpRequest();
  247. xhttp.onreadystatechange = function() {
  248. // I won't notify 400 status code. I dont' want to be anoying.
  249. if (this.readyState == 4 && (this.status == 200 || this.status == 400)) {
  250. next();
  251. }
  252. };
  253. xhttp.open("GET", url, true);
  254. xhttp.send();
  255. }
  256. function next(){
  257. idx = idx + 1;
  258. prepare();
  259. }
  260. </script>
  261. <!-- Meta tags -->
  262. <link rel='canonical' href='<?=$server?>/traducir/'/>
  263. <link rel='author' href='<?=$server?>'/>
  264. <link rel='publisher' href='<?=$server?>'/>
  265. <meta name='description' content='<?=$lng["translation_description"]?>'/>
  266. <meta property='og:title' content='<?=$lng["translation_title"]?> - Gasteizko Margolariak'/>
  267. <meta property='og:url' content='<?=$server?>/traducir/'/>
  268. <meta property='og:description' content='<?=$lng["translation_description"]?>'/>
  269. <meta property='og:image' content='<?=$server?>/img/logo/logo.png'/>
  270. <meta property='og:site_name' content='Gasteizko Margolariak'/>
  271. <meta property='og:type' content='website'/>
  272. <meta property='og:locale' content='<?=$lang?>'/>
  273. <meta name='twitter:card' content='summary'/>
  274. <meta name='twitter:title' content='<?=$lng["translation_title"]?> - Gasteizko Margolariak'/>
  275. <meta name='twitter:description' content='<?=$lng["translation_description"]?>'/>
  276. <meta name='twitter:image' content='<?=$server?>/img/logo/logo.png'/>
  277. <meta name='twitter:url' content='<?=$server?>/traducir/'/>
  278. <meta name='robots' content='noindex nofollow'/>
  279. </head>
  280. <body onLoad='prepare();'>
  281. <?php
  282. include("../header.php");
  283. ?>
  284. <div id="content">
  285. <div class='section'>
  286. <h3 class='section_title'>Traducciones en
  287. <?=$lng["translation_translating_$l"]?>
  288. </h3>
  289. <div class='entry' id='w_target'>
  290. <div class='translation' id='original'>
  291. <h3 class='entry_title'><?=$lng["translation_original"]?></h3>
  292. <span id='i_original'></span>
  293. <p id='t_original'></p>
  294. </div>
  295. <div class='translation' id='translation'>
  296. <h3 class='entry_title'><?=$lng["translation_translation_$l"]?></h3>
  297. <input type='text' id='i_translation'/>
  298. <textarea id='t_translation'></textarea>
  299. </div>
  300. <input type='hidden' id='type' value='i'/>
  301. <input type='hidden' id='lang' value='<?=$l?>'/>
  302. </div> <!-- #w_target -->
  303. <div class='entry'>
  304. <table id='buttons'>
  305. <tr>
  306. <td>
  307. <input type='text' id='name' placeholder='<?=$lng["translation_name"]?>'/>
  308. </td>
  309. <td>
  310. <input type='button' id='next' value='<?=$lng["translation_skip"]?>' onClick='next();'/>
  311. </td>
  312. <td>
  313. <input type='button' id='save' value='<?=$lng["translation_save"]?>' onClick='save();'/>
  314. </td>
  315. </tr>
  316. </table>
  317. </div>
  318. </div> <!-- .section -->
  319. <br/><br/><br/>
  320. <div class='section' id='w_error'>
  321. <h3 class='section_title' id='error_title'></h3>
  322. <div class='entry'>
  323. <table>
  324. <tr>
  325. <td>
  326. <span id='error_msg'></span>
  327. <br/><br/><br/><br/>
  328. </td>
  329. </tr>
  330. <tr>
  331. <td>
  332. <input type='button' value='Cerrar' onClick='closeError();'>
  333. </td>
  334. </tr>
  335. </table>
  336. </div>
  337. </div>
  338. </div> <!-- #content -->
  339. </body>
  340. </html>
  341. <?php
  342. } //if ($l != 'en' && $l != 'en'){ -- ELSE
  343. ?>