3 <form name
='filterform' id
='filterform' method
='post' action
='?m=definition' onsubmit
="return top.restoreSession()">
5 <td
><?php
echo htmlspecialchars(xl('Filter for Constants','','',':'),ENT_NOQUOTES
); ?
></td
>
6 <td
><input type
='text' name
='filter_cons' size
='8' value
='<?php echo htmlspecialchars($_POST['filter_cons
'],ENT_QUOTES); ?>' />
7 <span
class="text"><?php
echo htmlspecialchars(xl('(% matches any string, _ matches any character)'),ENT_NOQUOTES
); ?
></span
></td
>
10 <td
><?php
echo htmlspecialchars(xl('Filter for Definitions','','',':'),ENT_NOQUOTES
); ?
></td
>
11 <td
><input type
='text' name
='filter_def' size
='8' value
='<?php echo htmlspecialchars($_POST['filter_def
'],ENT_QUOTES); ?>' />
12 <span
class="text"><?php
echo htmlspecialchars(xl('(% matches any string, _ matches any character)'),ENT_NOQUOTES
); ?
></span
></td
>
15 <td
><?php
echo htmlspecialchars(xl('Select Language').":",ENT_NOQUOTES
); ?
></td
>
17 <select name
='language_select'>
19 // sorting order of language titles depends on language translation options.
20 $mainLangID = empty($_SESSION['language_choice']) ?
'1' : $_SESSION['language_choice'];
21 if ($mainLangID == '1' && !empty($GLOBALS['skip_english_translation']))
23 $sql = "SELECT * FROM lang_languages ORDER BY lang_description, lang_id";
24 $res=SqlStatement($sql);
27 // Use and sort by the translated language name.
28 $sql = "SELECT ll.lang_id, " .
29 "IF(LENGTH(ld.definition),ld.definition,ll.lang_description) AS lang_description " .
30 "FROM lang_languages AS ll " .
31 "LEFT JOIN lang_constants AS lc ON lc.constant_name = ll.lang_description " .
32 "LEFT JOIN lang_definitions AS ld ON ld.cons_id = lc.cons_id AND " .
34 "ORDER BY IF(LENGTH(ld.definition),ld.definition,ll.lang_description), ll.lang_id";
35 $res=SqlStatement($sql, array($mainLangID) );
37 // collect the default selected language id, and then display list
38 $tempLangID = isset($_POST['language_select']) ?
$_POST['language_select'] : $mainLangID;
39 while ($row=SqlFetchArray($res)){
40 if ($tempLangID == $row['lang_id']) {
41 echo "<option value='" . htmlspecialchars($row['lang_id'],ENT_QUOTES
) . "' selected>" . htmlspecialchars($row['lang_description'],ENT_NOQUOTES
) . "</option>";
44 echo "<option value='" . htmlspecialchars($row['lang_id'],ENT_QUOTES
) . "'>" . htmlspecialchars($row['lang_description'],ENT_NOQUOTES
) . "</option>";
52 <td colspan
=2><INPUT TYPE
="submit" name
="edit" value
="<?php echo htmlspecialchars(xl('Search'),ENT_QUOTES); ?>"></td
>
59 // set up the mysql collation string to ensure case is sensitive (or insensitive) in the mysql queries
60 if (!$disable_utf8_flag) {
61 $case_sensitive_collation = "COLLATE utf8_bin";
62 $case_insensitive_collation = "COLLATE utf8_general_ci";
65 $case_sensitive_collation = "COLLATE latin_bin";
66 $case_insensitive_collation = "COLLATE latin1_swedish_ci";
71 // query for entering new definitions it picks the cons_id because is existant.
72 if (!empty($_POST['cons_id'])) {
73 foreach ($_POST['cons_id'] as $key => $value) {
74 $value = trim($value);
76 // do not create new blank definitions
77 if ($value == "") continue;
79 // insert into the main language tables
80 $sql = "INSERT INTO lang_definitions (`cons_id`,`lang_id`,`definition`) VALUES (?,?,?)";
81 SqlStatement($sql, array($key, $_POST['lang_id'], $value) );
83 // insert each entry into the log table - to allow persistant customizations
84 $sql = "SELECT lang_description, lang_code FROM lang_languages WHERE lang_id=? LIMIT 1";
85 $res = SqlStatement($sql, array($_POST['lang_id']) );
86 $row_l = SqlFetchArray($res);
87 $sql = "SELECT constant_name FROM lang_constants WHERE cons_id=? LIMIT 1";
88 $res = SqlStatement($sql, array($key) );
89 $row_c = SqlFetchArray($res);
90 insert_language_log($row_l['lang_description'], $row_l['lang_code'], $row_c['constant_name'], $value);
96 // query for updating preexistant definitions uses def_id because there is no def yet.
97 // echo ('<pre>'); print_r($_POST['def_id']); echo ('</pre>');
98 if (!empty($_POST['def_id'])) {
99 foreach ($_POST['def_id'] as $key => $value) {
100 $value = trim($value);
102 // only continue if the definition is new
103 $sql = "SELECT * FROM lang_definitions WHERE def_id=? AND definition=? ".$case_sensitive_collation;
104 $res_test = SqlStatement($sql, array($key, $value) );
105 if (!SqlFetchArray($res_test)) {
106 // insert into the main language tables
107 $sql = "UPDATE `lang_definitions` SET `definition`=? WHERE `def_id`=? LIMIT 1";
108 SqlStatement($sql, array($value, $key) );
110 // insert each entry into the log table - to allow persistant customizations
111 $sql = "SELECT ll.lang_description, ll.lang_code, lc.constant_name ";
112 $sql .= "FROM lang_definitions AS ld, lang_languages AS ll, lang_constants AS lc ";
113 $sql .= "WHERE ld.def_id=? ";
114 $sql .= "AND ll.lang_id = ld.lang_id AND lc.cons_id = ld.cons_id LIMIT 1";
115 $res = SqlStatement($sql, array($key) );
116 $row = SqlFetchArray($res);
117 insert_language_log($row['lang_description'], $row['lang_code'], $row['constant_name'], $value);
123 if ($go=='yes') echo htmlspecialchars(xl("New Definition set added"),ENT_NOQUOTES
);
127 if ($_POST['language_select'] == '') {
128 exit(htmlspecialchars(xl("Please select a language"),ENT_NOQUOTES
));
131 $lang_id = (int)formData('language_select');
133 $lang_filter = isset($_POST['filter_cons']) ?
$_POST['filter_cons'] : '';
135 $lang_filter_def = isset($_POST['filter_def']) ?
$_POST['filter_def'] : '';
136 $lang_filter_def .= '%';
138 $bind_sql_array = array();
139 array_push($bind_sql_array, $lang_filter);
140 $sql = "SELECT lc.cons_id, lc.constant_name, ld.def_id, ld.definition, ld.lang_id " .
141 "FROM lang_definitions AS ld " .
142 "RIGHT JOIN ( lang_constants AS lc, lang_languages AS ll ) ON " .
143 "( lc.cons_id = ld.cons_id AND ll.lang_id = ld.lang_id ) " .
144 "WHERE lc.constant_name ".$case_insensitive_collation." LIKE ? AND ( ll.lang_id = 1 ";
146 array_push($bind_sql_array, $lang_id);
147 $sql .= "OR ll.lang_id=? ";
148 $what = "SELECT * from lang_languages where lang_id=? LIMIT 1";
149 $res = SqlStatement($what, array($lang_id) );
150 $row = SqlFetchArray($res);
151 $lang_name = $row['lang_description'];
153 $sql .= ") ORDER BY lc.constant_name ".$case_insensitive_collation;
154 $res = SqlStatement($sql, array($bind_sql_array) );
156 $isResults = false; //flag to record whether there are any results
157 echo ('<table><FORM METHOD=POST ACTION="?m=definition" onsubmit="return top.restoreSession()">');
158 // only english definitions
160 while ($row=SqlFetchArray($res)){
161 $isShow = false; //flag if passes the definition filter
162 $stringTemp = '<tr><td>'.htmlspecialchars($row['constant_name'],ENT_NOQUOTES
).'</td>';
163 // if there is no definition
164 if (empty($row['def_id'])){
165 $cons_name = "cons_id[" . $row['cons_id'] . "]";
166 if ($lang_filter_def=='%') $isShow = true;
167 // if there is a previous definition
169 $cons_name = "def_id[" . $row['def_id'] . "]";
170 $sql = "SELECT definition FROM lang_definitions WHERE def_id=? AND definition LIKE ?";
171 $res2 = SqlStatement($sql, array($row['def_id'], $lang_filter_def) );
172 if (SqlFetchArray($res2)) $isShow = true;
174 $stringTemp .= '<td><INPUT TYPE="text" size="50" NAME="' . htmlspecialchars($cons_name,ENT_QUOTES
) . '" value="' . htmlspecialchars($row['definition'],ENT_QUOTES
) . '">';
175 $stringTemp .= '</td><td></td></tr>';
177 //definition filter passed, so show
182 echo ('<INPUT TYPE="hidden" name="lang_id" value="'.htmlspecialchars($lang_id,ENT_QUOTES
).'">');
183 // english plus the other
185 while ($row=SqlFetchArray($res)){
186 if (!empty($row['lang_id']) && $row['lang_id'] != '1') {
187 // This should not happen, if it does that must mean that this
188 // constant has more than one definition for the same language!
191 $isShow = false; //flag if passes the definition filter
192 $stringTemp = '<tr><td>'.htmlspecialchars($row['constant_name'],ENT_NOQUOTES
).'</td>';
193 if ($row['definition']=='' OR $row['definition']=='NULL') {
196 $def=$row['definition'];
198 $stringTemp .= '<td>'.htmlspecialchars($def,ENT_NOQUOTES
).'</td>';
199 $row=SqlFetchArray($res); // jump one to get the second language selected
200 if ($row['def_id']=='' OR $row['def_id']=='NULL'){
201 $cons_name="cons_id[".$row['cons_id']."]";
202 if ($lang_filter_def=='%') $isShow = true;
203 // if there is a previous definition
205 $cons_name="def_id[".$row['def_id']."]";;
206 $sql = "SELECT definition FROM lang_definitions WHERE def_id=? AND definition LIKE ?";
207 $res2 = SqlStatement($sql, array($row['def_id'], $lang_filter_def) );
208 if (SqlFetchArray($res2)) $isShow = true;
210 $stringTemp .= '<td><INPUT TYPE="text" size="50" NAME="'.htmlspecialchars($cons_name,ENT_QUOTES
).'" value="'.htmlspecialchars($row['definition'],ENT_QUOTES
).'">';
211 $stringTemp .='</td></tr>';
213 //definition filter passed, so show
218 echo ('<INPUT TYPE="hidden" name="lang_id" value="'.htmlspecialchars($lang_id,ENT_QUOTES
).'">');
221 echo ('<tr><td colspan=3><INPUT TYPE="submit" name="load" Value="' . htmlspecialchars(xl('Load Definitions'),ENT_NOQUOTES
) . '"></td></tr>');
223 <INPUT TYPE
="hidden" name
="filter_cons" value
="<?php echo htmlspecialchars($_POST['filter_cons'],ENT_QUOTES); ?>">
224 <INPUT TYPE
="hidden" name
="filter_def" value
="<?php echo htmlspecialchars($_POST['filter_def'],ENT_QUOTES); ?>">
225 <INPUT TYPE
="hidden" name
="language_select" value
="<?php echo htmlspecialchars($_POST['language_select'],ENT_QUOTES); ?>">
229 echo htmlspecialchars(xl('No Results Found For Search'),ENT_NOQUOTES
);
231 echo ('</FORM></table>');