2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2009 */
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 /****************************************************************/
16 * BEWARE OF THE HACKS USED TO IMPLEMENT THIS FEATURE:
18 * this page is to allow admins to edit/customize their language
19 * and save the changes made in a way that allows the upgrading of
20 * ATutor without the loss of that language. It also allows customized
21 * language to be reverted back to its original form.
23 * since we couldn't change the database as it would break backwards
24 * compatability, none of the fields could be changed which means
25 * that the only way to store the extra language would be by reusing
26 * the `variable` field, which is part of the PK.
28 * reusing the `variable` is a huge hack and doesn't correctly support
29 * module language as there is nothing enfocing storing module language
30 * in an independant way. ideally there would be another field in the
31 * database designating custom or not and the `variable` field would
32 * be removed completely since it doesn't have much effect any more.
34 * custom language is stored as `_c_template` and `_c_msgs` for template
35 * and feedback messages, respectively. Why use "_c" as the prefix?
36 * because it comes before "_t" and _m" in the alphabet. This lets us
37 * sort the language by `variable` and limit it to one result. That is
38 * how the custom language terms are retrieved in place of default
41 * another oddity is that although custom language text isn't deleted
42 * upon upgrades, the language definitions are, which means those terms
43 * cannot be edited until after the language pack is reinstalled.
44 * this also means that if a term has changed the system might be unaware
45 * of new replacement tokens and could break.
49 define('AT_INCLUDE_PATH', '../../../include/');
50 require(AT_INCLUDE_PATH.'vitals.inc.php');
51 admin_authenticate(AT_ADMIN_PRIV_LANGUAGES);
53 if (defined('AT_DEVEL_TRANSLATE') && AT_DEVEL_TRANSLATE) {
54 $msg->addWarning('TRANSLATE_ON');
55 require(AT_INCLUDE_PATH.'header.inc.php');
56 require(AT_INCLUDE_PATH.'footer.inc.php');
60 require(AT_INCLUDE_PATH.'header.inc.php');
62 $_variables = array('template' => '_template', 'feedback' => '_msgs');
63 $_c_variables = array('template' => '_c_template', 'feedback' => '_c_msgs');
66 if (isset($_GET['filter'], $_GET['search'])) {
67 $_GET['search'] = trim($addslashes($_GET['search']));
68 $words = explode(' ', $_GET['search']);
69 foreach ($words as $key => $word) {
70 // search `term` and `text` only
71 if ($strlen($word) > 1) {
72 $word = str_replace(array('%','_'), array('\%', '\_'), $word);
73 $words[$key] = "(CAST(`term` AS CHAR) LIKE '%$word%' OR CAST(`text` AS CHAR) LIKE '%$word%')";
79 $sql_search = ' AND (' . implode(' OR ', $words).')';
81 } else if ($_GET['reset_filter']) {
84 if (!isset($_GET['type']) || !isset($_variables[$_GET['type']])) {
85 $_GET['type'] = 'template';
88 if (isset($_GET['custom'])) {
89 $variable = $_c_variables[$_GET['type']];
91 $variable = $_variables[$_GET['type']];
94 $sql = "SELECT * FROM ".TABLE_PREFIX."language_text WHERE language_code='$_SESSION[lang]' AND `variable`='$variable' $sql_search ORDER BY text";
95 $result = mysql_query($sql, $db);
96 $num_results = mysql_num_rows($result);
99 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
100 <div class="input-form">
102 <h3><?php echo _AT('results_found', $num_results); ?></h3>
106 <?php echo _AT('type'); ?><br />
107 <input type="radio" name="type" value="template" id="tyte" <?php if ($_GET['type'] == 'template') { echo 'checked="checked"'; } ?> /><label for="tyte"><?php echo _AT('template'); ?></label>
108 <input type="radio" name="type" value="feedback" id="tyfe" <?php if ($_GET['type'] == 'feedback') { echo 'checked="checked"'; } ?> /><label for="tyfe"><?php echo _AT('feedback'); ?></label>
112 <input type="checkbox" name="custom" value="1" id="cus" <?php if (isset($_GET['custom'])) { echo 'checked="checked"'; } ?> /><label for="cus"><?php echo _AT('only_show_edited_terms'); ?></label>
116 <label for="search"><?php echo _AT('search'); ?></label><br />
117 <input type="text" name="search" id="search" size="40" value="<?php echo htmlspecialchars($_GET['search']); ?>" />
120 <div class="row buttons">
121 <input type="submit" name="filter" value="<?php echo _AT('filter'); ?>" />
122 <input type="submit" name="reset_filter" value="<?php echo _AT('reset_filter'); ?>" />
127 <form name="form" method="post">
128 <div class="input-form">
129 <table cellspacing="0" cellpadding="0">
132 <?php if ($num_results): ?>
133 <select size="<?php echo min(max($num_results,2), 25); ?>" name="terms" id="terms" onchange="javascript:showtext(this);">
135 while ($row = mysql_fetch_assoc($result)):
136 if ($strlen($row['text']) > 30) {
137 $row['text'] = $substr($row['text'], 0, 28) . '...';
140 <option value="<?php echo $row['term']; ?>"><?php echo htmlspecialchars($row['text']); ?></option>
144 <p><?php echo _AT('none_found'); ?></p>
150 <iframe src="mods/_core/languages/language_term.php" frameborder="0" height="430" width="450" marginheight="0" marginwidth="0" name="tran" id="tran"></iframe>
158 <script language="javascript" type="text/javascript">
160 function showtext(obj) {
161 frames['tran'].location.href = "<?php echo AT_BASE_HREF; ?>mods/_core/languages/language_term.php?type=<?php echo $_variables[$_GET['type']].SEP; ?>term=" + obj.value;
166 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>