2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /****************************************************************/
15 if ( !isset($db) || !defined('AT_INCLUDE_PATH') || !isset($_SESSION['language']) ) { echo 'xx'; exit; }
17 if ($_POST['function'] == 'edit_term') {
18 if ($_POST['submit2']) {
19 delete_term($_POST['v'], $_POST['k']);
21 $success_error = update_term($_POST['text'], $_POST['context'], $_POST['v'], $_POST['k']);
23 } else if ($_POST['function'] == 'add_term') {
24 $success_error = add_term($_POST['text'], $_POST['context'], $_POST['v'], $_POST['k']);
25 $_REQUEST['page'] = 'none';
29 $n = ' checked="checked"';
32 $u = ' checked="checked"';
35 if ($_SESSION['language'] != 'en') {
36 echo '<li>Choose the New and Updated filters to display only language that has not been translated, or language that needs to be modified<br />';
38 echo '<table border="0" cellspacing="0" cellpadding="2" style="border: 1px solid #cccccc;"><tr><td bgcolor="#eeeeee" nowrap="nowrap"><h5 class="heading2">Filter</h5></td><td>';
39 echo '<form method="get" action="'.$_SERVER['PHP_SELF'].'">
40 <input type="hidden" name="v" value="'.$_REQUEST['v'].'" />
41 <input type="hidden" name="f" value="'.$_REQUEST['f'].'" /><input type="checkbox" name="n" id="n" value="1" '.$n.' /><label for="n">New Language</label>, <input type="checkbox" name="u" id="u" value="1" '.$u.'/><label for="u">Updated Language</label> <input type="submit" name="filter" value="Apply" class="submit" /></form></td></tr></table><br />';
46 <!--//display messages and templates, with option to add new language terms/messages//-->
47 <li>Choose Template, Msgs, or Modules to display a list of language variables. Click on a variable name to display its associated language.
49 <?php foreach ($variables as $row) { ?>
51 <?php echo '<a href="'.$_SERVER['PHP_SELF'].'?v='.$row.SEP.'f='.$_REQUEST['f'].SEP.'n='.$_REQUEST['n'].SEP.'u='.$_REQUEST['u'].'">';
52 echo ucwords(str_replace('_', '', $row));
54 if ($_SESSION['status'] == $_USER_ADMIN && ($_SESSION['language'] == 'en')) {
55 echo ' | <a href="'.$_SERVER['PHP_SELF'].'?v='.$row.SEP.'new=1">new</a>';
65 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
66 <input type="text" name="search_term" value="<?php echo htmlspecialchars($stripslashes($_REQUEST['search_term'])); ?>" /> <input type="submit" name="search" value="Search Phrase" class="submit" />
72 <?php if (($_REQUEST['new'] == 1) && $_SESSION['status'] == $_USER_ADMIN) { ?>
74 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>#anchor">
75 <input type="hidden" name="search_term" value="<?php echo htmlspecialchars($stripslashes($_REQUEST['search_term'])); ?>" />
76 <input type="hidden" name="v" value="<?php echo $_REQUEST['v']; ?>" />
77 <input type="hidden" name="page" value="<?php echo $_REQUEST['page']; ?>" />
78 <input type="hidden" name="function" value="add_term" />
80 <table border="0" cellspacing="0" cellpadding="3" width="75%" align="center" class="box">
82 <th colspan="2" class="box">New</th>
85 <td align="right"><b>Variable:</b></td>
86 <td><tt><?php echo $_REQUEST['v'];?></tt></td>
89 <td align="right"><b>Term:</b></td>
90 <td><input type="text" name="k" class="input" /></td>
93 <td align="right"><b>Context:</b></td>
94 <td><input type="text" name="context" class="input" /></td>
97 <td valign="top" align="right" nowrap="nowrap"><b><tt><?php echo $langs[$_SESSION['language']]['name'];?></tt> text:</b></td>
98 <td><textarea cols="45" rows="5" name="text" class="input2"><?php echo $row2['text'];?></textarea></td>
101 <td colspan="2" align="center"><input type="submit" name="submit" value="Save ALT-S" class="submit" accesskey="s" /></td>
107 if ($_REQUEST['v'] && $_REQUEST['k']) {
108 $sql = "SELECT * FROM ".TABLE_PREFIX."language_text WHERE term='$_REQUEST[k]' AND variable='$_REQUEST[v]' AND language_code='$_REQUEST[f]'";
109 $result = mysql_query($sql, $db);
110 $row = mysql_fetch_assoc($result);
113 echo '<p>The source language was not found for that item (try using the English source).</p>';
114 require (AT_INCLUDE_PATH.'footer.inc.php');
118 if ($_SESSION['language'] == 'en') {
121 $sql = "SELECT text FROM ".TABLE_PREFIX."language_text WHERE term='$_REQUEST[k]' AND variable='$_REQUEST[v]' AND language_code='$_SESSION[language]'";
124 $result = mysql_query($sql, $db);
125 $row2 = mysql_fetch_array($result);
127 function trans_form($page) {
132 global $success_error;
136 global $stripslashes;
139 <a name="anchor"></a>
140 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>#anchor">
141 <input type="hidden" name="v" value="<?php echo $row['variable']; ?>" />
142 <input type="hidden" name="k" value="<?php echo $row['term']; ?>" />
143 <input type="hidden" name="f" value="<?php echo $_REQUEST['f']; ?>" />
144 <input type="hidden" name="search_term" value="<?php echo htmlspecialchars($stripslashes($_REQUEST['search_term'])); ?>" />
145 <input type="hidden" name="page" value="<?php echo $page; ?>" />
146 <input type="hidden" name="function" value="edit_term" />
150 <table border="0" cellspacing="0" cellpadding="2" width="90%" align="center" class="box">
152 <th class="box" colspan="2">Edit</th>
155 <td align="right"><b>Context:</b></td>
157 if ($_SESSION['language'] == 'en') {
158 echo '<input type="text" name="context" class="input" value="'.$row['context'].'" size="45" />';
160 if ($row['context'] == '') {
161 echo '<strong>None specified.</strong>';
163 echo $row['context'];
168 <td valign="top" align="right" nowrap="nowrap"><b>Pages:</b></td>
170 $sql = "SELECT * FROM ".TABLE_PREFIX."language_pages WHERE term='$_REQUEST[k]' ORDER BY page LIMIT 11";
171 $result = mysql_query($sql, $db);
173 if (mysql_num_rows($result) > 10) {
174 echo '<strong>Global (more than 10 pages)</strong>';
176 while ($page_row = mysql_fetch_array($result)) {
177 echo $page_row['page'] . '<br />';
185 <td valign="top" align="right" nowrap="nowrap"><b><tt><?php echo $langs[$_REQUEST['f']]['name'];?></tt> text:</b></td>
186 <td><?php echo nl2br(htmlspecialchars($row['text'])); ?></td>
189 <td valign="top" align="right" nowrap="nowrap"><b><tt><?php echo $langs[$_SESSION['language']]['name'];?></tt> text:</b></td>
190 <td><textarea cols="55" rows="8" name="text" class="input2"><?php echo $row2['text'];?></textarea></td>
193 <td colspan="2" align="center"><input type="submit" name="submit" value="Save ALT-S" class="submit" accesskey="s" />
194 <?php if ($_SESSION['language'] == 'en' && $_SESSION['status'] == $_USER_ADMIN): ?>
195 <input type="submit" name="submit2" value="Delete" onClick="return confirm('Do you really want to delete?');" class="submit" />
206 //displaying templates
207 if (!$_REQUEST['search_term'] && ($_REQUEST['v'] == $variables[0])) {
210 echo '<li><a href="'.$_SERVER['PHP_SELF'].'?v='.$_REQUEST['v'].SEP.'page=all'.SEP.'f='.$_REQUEST['f'].SEP.'n='.$_REQUEST['n'].SEP.'u='.$_REQUEST['u'].'#anchor1">View All Terms</a>';
212 if ($_REQUEST['page'] == 'all') {
213 echo '<a name="anchor1"></a>';
214 display_all_terms($_REQUEST['v'], $_REQUEST['k'], $_REQUEST['f'], $_REQUEST['n'], $_REQUEST['u']);
218 echo '<li><a href="'.$_SERVER['PHP_SELF'].'?v='.$_REQUEST['v'].SEP.'page=none'.SEP.'f='.$_REQUEST['f'].SEP.'n='.$_REQUEST['n'].SEP.'u='.$_REQUEST['u'].'#anchor1">View Unused Terms</a>';
220 if ($_REQUEST['page'] == 'none') {
221 echo '<a name="anchor1"></a>';
222 display_unused_terms($_REQUEST['v'], $_REQUEST['k'], $_REQUEST['f'], $_REQUEST['n'], $_REQUEST['u']);
226 $sql0 = "SELECT DISTINCT page FROM ".TABLE_PREFIX."language_pages ORDER BY page";
227 $result0 = mysql_query($sql0, $db);
229 while ($row0 = mysql_fetch_assoc($result0)) {
231 if ($_REQUEST['page'] == $row0['page']) {
232 display_page_terms($_REQUEST['v'], $_REQUEST['k'], $_REQUEST['f'], $_REQUEST['n'], $_REQUEST['u'], $row0['page']);
235 echo '<li><a href="'.$_SERVER['PHP_SELF'].'?v='.$_REQUEST['v'].SEP.'page='.urlencode($row0['page']).SEP.'f='.$_REQUEST['f'].SEP.'n='.$_REQUEST['n'].SEP.'u='.$_REQUEST['u'].'#anchor1">'.$row0['page'].'</a></li>';
239 } else if (!$_REQUEST['search_term'] && ($_REQUEST['v'] == $variables[1])){
240 //displaying messages
241 display_all_terms($_REQUEST['v'], $_REQUEST['k'], $_REQUEST['f'], $_REQUEST['n'], $_REQUEST['u']);
242 } else if (!$_REQUEST['search_term'] && ($_REQUEST['v'] == $variables[2])){
243 display_all_terms($_REQUEST['v'], $_REQUEST['k'], $_REQUEST['f'], $_REQUEST['n'], $_REQUEST['u']);
244 } else if ($_REQUEST['search_term']) {
245 display_search_terms($_REQUEST['v'], $_REQUEST['k'], $_REQUEST['f'], $_REQUEST['n'], $_REQUEST['u']);
249 function delete_term($variable, $term) {
252 $sql = "DELETE FROM ".TABLE_PREFIX."language_text WHERE variable='$variable' AND term='$term'";
253 $result = mysql_query($sql, $db);
255 $sql3 = "DELETE FROM ".TABLE_PREFIX."language_pages WHERE term='$term'";
256 $result3 = mysql_query($sql3, $db);
258 unset($_REQUEST['k']);
259 echo '<div class="feedback2"">Success: deleted.</div>';
262 function update_term($text, $context, $variable, $term) {
263 global $addslashes, $db;
265 $term = $addslashes(trim($term));
266 $text = $addslashes(trim($text));
267 $context = $addslashes(trim($context));
269 if ($_SESSION['language'] == 'en') {
270 $sql = "UPDATE ".TABLE_PREFIX."language_text SET text='$text', revised_date=NOW(), context='$context' WHERE variable='$variable' AND term='$term' AND language_code='en'";
274 $sql = "REPLACE INTO ".TABLE_PREFIX."language_text VALUES ('$_SESSION[language]', '$variable', '$term', '$text', NOW(), '')";
276 $trans = get_html_translation_table(HTML_ENTITIES);
277 $trans = array_flip($trans);
278 $sql = strtr($sql, $trans);
281 $result = mysql_query($sql, $db);
284 echo mysql_error($db);
285 echo '<div class="error">Error: changes not saved!</div>';
286 $success_error = '<div class="error">Error: changes not saved!</div>';
287 return $success_error;
290 echo '<div class="feedback2"">Success: changes saved.</div>';
291 $success_error = '<div class="feedback2"">Success: changes saved.</div>';
292 return $success_error;
296 function add_term($text, $context, $variable, $term) {
297 global $addslashes, $db;
299 $term = $addslashes(trim($term));
300 $text = $addslashes(trim($text));
301 $context = $addslashes(trim($context));
303 $sql = "INSERT INTO ".TABLE_PREFIX."language_text VALUES ('en', '$variable', '$term', '$text', NOW(), '$context')";
304 $result = mysql_query($sql, $db);
307 echo '<div class="error">Error: that term already exists!</div>';
310 echo '<div class="feedback2"">Success: term added.</div>';
311 $success_error = '<div class="feedback2"">Success: term added.</div>';
312 return $success_error;
316 function display_page_terms ($variable, $term1, $lang_code, $new, $updated, $page) {
319 echo '<li><a name="anchor1"></a>';
320 echo '<a href="'.$_SERVER['PHP_SELF'].'?v='.$variable.SEP.'page='.urlencode($page).SEP.'f='.$lang_code.SEP.'n='.$new.SEP.'u='.updated.'#anchor">'.$page.'</a>';
322 $sql1 = "SELECT term FROM ".TABLE_PREFIX."language_pages WHERE page='$page' ORDER BY term";
323 $result1 = mysql_query($sql1, $db);
325 $term_list = array();
327 while ($row1 = mysql_fetch_assoc($result1)) {
329 if ($_SESSION['language'] != 'en') {
330 $sql = "SELECT term, revised_date+0 AS r_date FROM ".TABLE_PREFIX."language_text WHERE variable='$variable' AND language_code='$_SESSION[language]' AND term='$row1[term]' ORDER BY term";
331 $result = mysql_query($sql, $db);
333 while ($row = mysql_fetch_assoc($result)) {
334 $t_keys[$row['term']] = $row['r_date'];
337 $term_list[] = $row1['term'];
342 foreach ($term_list as $term) {
344 if ($_REQUEST['f'] == 'en') {
345 $sql = "SELECT *, revised_date+0 AS r_date FROM ".TABLE_PREFIX."language_text WHERE variable='$_REQUEST[v]' AND language_code='en' AND term='$term'";
347 $sql = "SELECT * FROM ".TABLE_PREFIX."language_text WHERE variable='$_REQUEST[v]' AND language_code='$_REQUEST[f]' AND term='$term'";
350 $result = mysql_query($sql, $db);
351 $row = mysql_fetch_assoc($result);
353 if (mysql_num_rows($result) == 0) continue;
355 if ($_SESSION['language'] != 'en') {
356 if ($new && $updated) {
357 if ((!($t_keys[$row['term']] == '')) && (!(($t_keys[$row['term']] < $row['r_date']) && $t_keys[$row['term']]))) {
361 if (!($t_keys[$row['term']] == '')) {
364 } else if ($updated) {
365 if (!(($t_keys[$row['term']] < $row['r_date']) && $t_keys[$row['term']])) {
371 if ($term == $term1) {
373 echo '<li class="selected">';
379 if ($_SESSION['language'] != 'en') {
380 if ($t_keys[$row['term']] == '') {
381 echo '<b>*New*</b> ';
382 } else if ($t_keys[$term] < $row['r_date']) {
383 echo '<b>*Updated*</b> ';
387 if ($term != $term1) {
388 echo '<a href="'.$_SERVER['PHP_SELF'].'?v='.$variable.SEP.'k='.$term.SEP.'f='.$lang_code.SEP.'n='.$new.SEP.'u='.$updated.SEP.'page='.urlencode($page).'#anchor">';
401 function display_all_terms ($variable, $term1, $lang_code, $new, $updated) {
404 if ($_SESSION['language'] != 'en') {
405 $sql = "SELECT term, revised_date+0 AS r_date FROM ".TABLE_PREFIX."language_text WHERE variable='$variable' AND language_code='$_SESSION[language]' ORDER BY term";
406 $result = mysql_query($sql, $db);
409 while ($row = mysql_fetch_assoc($result)) {
410 $t_keys[$row['term']] = $row['r_date'];
414 if ($lang_code == 'en') {
415 $sql = "SELECT *, revised_date+0 AS r_date FROM ".TABLE_PREFIX."language_text WHERE variable='$variable' AND language_code='en' ORDER BY term";
417 $sql = "SELECT * FROM ".TABLE_PREFIX."language_text WHERE variable='$variable' AND language_code='$lang_code' ORDER BY term";
419 $result = mysql_query($sql, $db);
422 while ($row = mysql_fetch_assoc($result)) {
423 if ($_SESSION['language'] != 'en') {
424 if ($new && $updated) {
425 if ((!($t_keys[$row['term']] == '')) && (!(($t_keys[$row['term']] < $row['r_date']) && $t_keys[$row['term']]))) {
429 if (!($t_keys[$row['term']] == '')) {
432 } else if ($updated) {
433 if (!(($t_keys[$row['term']] < $row['r_date']) && $t_keys[$row['term']])) {
440 if ($row['term'] == $term1) {
442 echo '<li class="selected">';
448 if ($_SESSION['language'] != 'en') {
449 if ($t_keys[$row['term']] == '') {
450 echo '<b>*New*</b> ';
451 } else if ($t_keys[$row['term']] < $row['r_date']) {
452 echo '<b>*Updated*</b> ';
456 if ($row['term'] != $term1) {
457 echo '<a href="'.$_SERVER['PHP_SELF'].'?v='.$variable.SEP.'k='.$row['term'].SEP.'page=all'.SEP.'f='.$lang_code.SEP.'n='.$new.SEP.'u='.$updated.'#anchor">';
469 function display_unused_terms ($variable, $term1, $lang_code, $new, $updated) {
472 if ($_SESSION['language'] != 'en') {
473 $sql = "SELECT term, revised_date+0 AS r_date FROM ".TABLE_PREFIX."language_text WHERE variable='$variable' AND language_code='$_SESSION[language]' ORDER BY term";
474 $result = mysql_query($sql, $db);
477 while ($row = mysql_fetch_assoc($result)) {
478 $t_keys[$row['term']] = $row['r_date'];
482 if ($lang_code == 'en') {
483 $sql = "SELECT lt.*, lt.revised_date+0 AS r_date FROM ".TABLE_PREFIX."language_text lt LEFT JOIN ".TABLE_PREFIX."language_pages lp ON lt.term = lp.term WHERE lp.term IS NULL AND lt.variable='$variable' AND lt.language_code='en' ORDER BY lt.term";
485 $sql = "SELECT lt.* FROM ".TABLE_PREFIX."language_text lt LEFT JOIN ".TABLE_PREFIX."language_pages lp ON lt.term = NULL WHERE lt.variable='$variable' AND lt.language_code='$lang_code' ORDER BY lt.term";
487 $result = mysql_query($sql, $db);
490 while ($row = mysql_fetch_assoc($result)) {
491 if ($_SESSION['language'] != 'en') {
492 if ($new && $updated) {
493 if ((!($t_keys[$row['term']] == '')) && (!(($t_keys[$row['term']] < $row['r_date']) && $t_keys[$row['term']]))) {
497 if (!($t_keys[$row['term']] == '')) {
500 } else if ($updated) {
501 if (!(($t_keys[$row['term']] < $row['r_date']) && $t_keys[$row['term']])) {
508 if ($row['term'] == $term1) {
510 echo '<li class="selected">';
516 if ($_SESSION['language'] != 'en') {
517 if ($t_keys[$row['term']] == '') {
518 echo '<b>*New*</b> ';
519 } else if ($t_keys[$row['term']] < $row['r_date']) {
520 echo '<b>*Updated*</b> ';
524 if ($row['term'] != $term1) {
525 echo '<a href="'.$_SERVER['PHP_SELF'].'?v='.$variable.SEP.'k='.urlencode($row['term']).SEP.'page=none'.SEP.'f='.$lang_code.SEP.'n='.$new.SEP.'u='.$updated.'#anchor">';
538 function display_search_terms ($variable, $term1, $lang_code, $new, $updated) {
539 global $db, $addslashes, $stripslashes;
541 $_REQUEST['search_term'] = $addslashes($_REQUEST['search_term']);
543 $sql = "SELECT term, revised_date+0 AS r_date FROM ".TABLE_PREFIX."language_text WHERE (term LIKE '%$_REQUEST[search_term]%' OR CAST(text AS CHAR) LIKE '%$_REQUEST[search_term]%') AND (language_code='$_SESSION[language]' OR language_code='en') GROUP BY term ORDER BY term";
544 $result = mysql_query($sql, $db);
547 while ($row = mysql_fetch_assoc($result)) {
548 $t_keys[$row['term']] = $row['r_date'];
551 $sql = "SELECT *, revised_date+0 AS r_date FROM ".TABLE_PREFIX."language_text WHERE (term LIKE '%$_REQUEST[search_term]%' OR CAST(text AS CHAR) LIKE '%$_REQUEST[search_term]%') AND (language_code='en' OR language_code='$_SESSION[language]') GROUP BY term ORDER BY term";
552 $result = mysql_query($sql, $db);
554 if (mysql_num_rows($result) == 0) {
555 echo '<ul><li>No results found.</li></ul>';
558 while ($row = mysql_fetch_assoc($result)) {
559 if ($_SESSION['language'] != 'en') {
560 if ($new && $updated) {
561 if ((!($t_keys[$row['term']] == '')) && (!(($t_keys[$row['term']] < $row['r_date']) && $t_keys[$row['term']]))) {
565 if (!($t_keys[$row['term']] == '')) {
568 } else if ($updated) {
569 if (!(($t_keys[$row['term']] < $row['r_date']) && $t_keys[$row['term']])) {
576 if ($row['term'] == $term1) {
577 trans_form('search');
578 echo '<li class="selected">';
584 if ($_SESSION['language'] != 'en') {
585 if ($t_keys[$row['term']] == '') {
586 echo '<b>*New*</b> ';
587 } else if ($t_keys[$row['term']] < $row['r_date']) {
588 echo '<b>*Updated*</b> ';
592 if ($row['term'] != $term1) {
593 echo '<a href="'.$_SERVER['PHP_SELF'].'?v='.$row['variable'].SEP.'search=1'.SEP.'search_term='.urlencode($stripslashes($_REQUEST['search_term'])).SEP.'k='.$row['term'].SEP.'f='.$lang_code.SEP.'n='.$new.SEP.'u='.$updated.'#anchor">';