2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2010 */
6 /* Inclusive Design Institute */
8 /* This program is free software. You can redistribute it and/or */
9 /* modify it under the terms of the GNU General Public License */
10 /* as published by the Free Software Foundation. */
11 /************************************************************************/
13 define('TR_INCLUDE_PATH', '../include/');
15 include_once(TR_INCLUDE_PATH.'vitals.inc.php');
16 include_once(TR_INCLUDE_PATH.'classes/DAO/DAO.class.php');
17 include_once(TR_INCLUDE_PATH.'classes/DAO/LanguagesDAO.class.php');
18 include_once(TR_INCLUDE_PATH.'classes/DAO/LanguageTextDAO.class.php');
20 global $msg, $addslashes;
23 $languagesDAO = new LanguagesDAO();
24 $languageTextDAO = new LanguageTextDAO();
25 //debug($_REQUEST);exit;
26 if (isset($_REQUEST['reset_filter'])) unset($_REQUEST);
28 if (isset($_REQUEST['submit']) || isset($_REQUEST['search']))
30 if (isset($_REQUEST['submit']))
32 if (isset($_REQUEST['term_type']) && $_REQUEST['term_type'] <> '') $term_type = $_REQUEST['term_type'];
34 $sql = "SELECT * FROM ".TABLE_PREFIX."language_text
35 WHERE language_code='".DEFAULT_LANGUAGE_CODE."'";
37 if ($term_type <> '') $sql .= " AND variable = '".$term_type."'";
39 if (isset($_REQUEST['new_or_translated']) && ($_REQUEST['new_or_translated'] == 1 || $_REQUEST['new_or_translated'] == 2))
41 $subquery = "(SELECT term FROM ".TABLE_PREFIX."language_text
42 WHERE language_code='".$_REQUEST['lang_code']."'
45 if ($_REQUEST['new_or_translated'] == 1) $sql .= " AND term NOT IN ".$subquery;
46 if ($_REQUEST['new_or_translated'] == 2) $sql .= " AND term IN ".$subquery;
49 if (isset($_REQUEST['new_or_translated']) && $_REQUEST['new_or_translated'] == 3)
51 $sql = "select * from ".TABLE_PREFIX."language_text a
52 where language_code='".DEFAULT_LANGUAGE_CODE."'
53 and exists (select 1 from ".TABLE_PREFIX."language_text b
54 where language_code = '".$_REQUEST['lang_code']."'
56 and a.revised_date > b.revised_date)";
60 if (isset($_REQUEST['search']))
62 $sql = "SELECT * FROM ".TABLE_PREFIX."language_text
63 WHERE language_code='".DEFAULT_LANGUAGE_CODE."'
64 AND lower(term) like '%".$addslashes(strtolower(trim($_REQUEST['search_phase'])))."%'";
67 $rows = $dao->execute($sql);
69 if (is_array($rows)) $num_results = count($rows);
70 else $num_results = 0;
73 if (isset($_REQUEST["save"]))
75 $sql_save = "REPLACE INTO ".TABLE_PREFIX."language_text VALUES ('".$_POST["lang_code"]."', '".$_POST["variable"]."', '".$_POST["term"]."', '".$addslashes($_POST["translated_text"])."', NOW(), '')";
77 $trans = get_html_translation_table(HTML_ENTITIES);
78 $trans = array_flip($trans);
79 $sql_save = strtr($sql_save, $trans);
81 if (!$dao->execute($sql_save)) {
82 $success_error = '<div class="error">Error: changes not saved!</div>';
85 $success_error = '<div class="feedback2"">Success: changes saved.</div>';
89 //$rows_lang = $languagesDAO->getAllExceptLangCode(DEFAULT_LANGUAGE_CODE);
90 $rows_lang = $languagesDAO->getAll();
92 include(TR_INCLUDE_PATH.'header.inc.php');
95 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
96 <!-- DO NOT REMOVE. It sets the "search" button as the default button, which means when user hit ENTER,
97 the "search" button is fired instead of "submit" button -->
98 <div style="display:none">
99 <input type="submit" name="search" value="<?php echo _AT('search_phase'); ?>" class="submit" />
101 <div class="input-form">
103 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span>
104 <label for="lang_code"><?php echo _AT('choose_lang'); ?></label>:
105 <select name="lang_code" id="lang_code">
107 foreach ($rows_lang as $row_lang)
110 <option value="<?php echo $row_lang['language_code']; ?>" <?php if ((isset($_REQUEST["lang_code"]) && $_REQUEST["lang_code"] == $row_lang['language_code']) || (!isset($_REQUEST["lang_code"]) && $row_lang['language_code'] == $_SESSION['lang'])) echo 'selected="selected"'; ?>><?php echo $row_lang["english_name"]; ?></option>
118 <fieldset class="group_form"><legend class="group_form"><?php echo _AT('filter'); ?></legend>
120 <?php if (isset($num_results)) { ?>
122 <h2><?php echo _AT('results_found', $num_results); ?></h2>
127 <?php echo _AT('new_or_translated'); ?><br />
128 <input type="radio" name="new_or_translated" value="0" id="u0" <?php if (!isset($_REQUEST['new_or_translated']) || $_REQUEST['new_or_translated'] == 0) { echo 'checked="checked"'; } ?> /><label for="u0"><?php echo _AT('all'); ?></label>
129 <input type="radio" name="new_or_translated" value="1" id="u1" <?php if ($_REQUEST['new_or_translated'] == 1) { echo 'checked="checked"'; } ?> /><label for="u1"><?php echo _AT('new_terms'); ?></label>
130 <input type="radio" name="new_or_translated" value="2" id="u2" <?php if ($_REQUEST['new_or_translated'] == 2) { echo 'checked="checked"'; } ?> /><label for="u2"><?php echo _AT('translated_terms'); ?></label>
131 <input type="radio" name="new_or_translated" value="3" id="u3" <?php if ($_REQUEST['new_or_translated'] == 3) { echo 'checked="checked"'; } ?> /><label for="u3"><?php echo _AT('updated_terms'); ?></label>
135 <?php echo _AT('term_type'); ?><br />
136 <input type="radio" name="term_type" value="" id="t0" <?php if (!isset($_REQUEST['term_type']) || $_REQUEST['term_type'] == "") { echo 'checked="checked"'; } ?> /><label for="t0"><?php echo _AT('all'); ?></label>
137 <input type="radio" name="term_type" value="_template" id="t1" <?php if ($_REQUEST['term_type'] == "_template") { echo 'checked="checked"'; } ?> /><label for="t1"><?php echo _AT('interface_terms'); ?></label>
138 <input type="radio" name="term_type" value="_msgs" id="t2" <?php if ($_REQUEST['term_type'] == "_msgs") { echo 'checked="checked"'; } ?> /><label for="t2"><?php echo _AT('msg_terms'); ?></label>
142 <input type="submit" name="submit" value="<?php echo _AT('submit'); ?>" class="submit" />
143 <input type="submit" name="reset_filter" value="<?php echo _AT('reset_filter'); ?>" class="submit" />
147 <label for="search_phase"><?php echo _AT('or'). ",<br /><br />" . _AT('search_text'); ?></label>
151 <input size="60" type="text" name="search_phase" id="search_phase" value="<?php echo htmlspecialchars(stripslashes($_REQUEST['search_phase'])); ?>" />
155 <input type="submit" name="search" value="<?php echo _AT('search_phase'); ?>" class="submit" />
163 if (isset($_REQUEST['selected_term']))
165 $sql_english = "SELECT * FROM ".TABLE_PREFIX."language_text WHERE language_code='".DEFAULT_LANGUAGE_CODE."' AND term='".$_REQUEST["selected_term"]."'";
166 if ($_REQUEST["term_type"] <> "") $sql_english .= " AND variable='".$_REQUEST["term_type"]."' ";
168 $rows_english = $dao->execute($sql_english);
169 $row_english = $rows_english[0];
171 $rows_selected = $languageTextDAO->getByTermAndLang($_REQUEST["selected_term"], $_REQUEST["lang_code"]);
173 function trans_form() {
174 global $row_english, $rows_selected;
176 global $success_error;
180 if (!is_array($rows_selected)) // add new term
182 else // update existing one
184 $row_selected = $rows_selected[0];
189 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>#anchor">
190 <input type="hidden" name="selected_term" value="<?php echo $_REQUEST['selected_term']; ?>" />
191 <input type="hidden" name="lang_code" value="<?php echo $_REQUEST['lang_code']; ?>" />
192 <input type="hidden" name="new_or_translated" value="<?php echo $_REQUEST['new_or_translated']; ?>" />
193 <input type="hidden" name="term_type" value="<?php echo $_REQUEST['term_type']; ?>" />
194 <input type="hidden" name="search_phase" value="<?php echo htmlspecialchars(stripslashes($_REQUEST['search_phase'])); ?>" />
195 <input type="hidden" name="variable" value="<?php echo $row_english['variable']; ?>" />
196 <input type="hidden" name="term" value="<?php echo $row_english['term']; ?>" />
197 <?php if (isset($_REQUEST["submit"])) { ?>
198 <input type="hidden" name="submit" value="1" />
200 <?php if (isset($_REQUEST["search"])) { ?>
201 <input type="hidden" name="search" value="1" />
204 <table border="0" cellspacing="0" cellpadding="2" width="100%" align="left" class="box">
206 <th class="box" colspan="2">Edit</th>
209 <?php if ($row_english['context'] <> "") { ?>
211 <td align="right" style="font:bold"><?php echo _AT('english_context'); ?>:</td>
212 <td><?php echo htmlspecialchars(stripslashes($row_english['context'])); ?></td>
215 <td align="right" style="font:bold"><?php echo _AT('translated_context'); ?>:</td>
216 <td><input type="text" name="translated_context" class="input" value="<?php echo htmlspecialchars(stripslashes($row_selected['context'])); ?>" size="45" /></td>
221 <td valign="top" align="right" nowrap="nowrap" style="font:bold"><?php echo _AT('english_text'); ?>:</td>
222 <td><?php echo nl2br(htmlspecialchars(stripslashes($row_english['text']))); ?></td>
225 <td valign="top" align="right" nowrap="nowrap" style="font: bold"><label for="translated_text"><?php echo _AT('translated_text'); ?></label>:</td>
226 <td><textarea rows="4" cols="75" name="translated_text" id="translated_text" class="input2"><?php echo htmlspecialchars(stripslashes($row_selected['text']));?></textarea></td>
229 <td colspan="2" align="center"><input type="submit" name="save" value="Save ALT-S" class="submit" accesskey="s" />
239 //displaying templates
240 if ($num_results > 0)
242 echo '<h3 class="indent">'. _AT("result") .'</h3>'."\n";
243 echo '<div class="input-form">'."\n";
244 echo '<br /><ul>'."\n";
247 if (isset($_REQUEST["submit"]))
248 $submits = htmlspecialchars(SEP)."submit=1";
249 if (isset($_REQUEST["search"]))
250 $submits .= htmlspecialchars(SEP)."search=1";
252 foreach ($rows as $row)
254 if ($row['term'] == $_REQUEST["selected_term"])
255 echo '<li>'."\n".'<a name="anchor" title="anchor"></a>'."\n";
259 // if ($row['term'] == $_REQUEST["search_phase"]) {
260 echo '<a href="'.$_SERVER['PHP_SELF'].'?selected_term='.$row['term'].htmlspecialchars(SEP).'lang_code='.$_REQUEST['lang_code'].htmlspecialchars(SEP).'new_or_translated='.$_REQUEST["new_or_translated"].htmlspecialchars(SEP).'term_type='.$_REQUEST["term_type"].htmlspecialchars(SEP).'search_phase='.$_REQUEST["search_phase"].$submits.'#anchor" ';
261 if ($row['term'] == $_REQUEST["selected_term"]) echo 'class="selected"';
267 // display if the term is new or translated
268 $rows_check = $languageTextDAO->getByTermAndLang($row['term'], $_REQUEST['lang_code']);
269 $row_check = $rows_check[0];
271 // check if the term is new
272 if ($row_check['text'] == '')
273 echo ' <small>*New*</small>'."\n";
275 // compare revised_date to see if the term is updated since last translation
276 if ($row_check['revised_date'] <> '' && $row['revised_date'] > $row_check['revised_date'])
277 echo ' <small>*Updated*</small>'."\n";
280 // display translation form
281 if ($row['term'] == $_REQUEST["selected_term"]) trans_form();
290 include(TR_INCLUDE_PATH.'footer.inc.php');