2 if ($_POST['check'] ||
$_POST['synchronize']) {
3 // set up flag if only checking for changes (ie not performing synchronization)
9 // set up the mysql collation string to ensure case is sensitive in the mysql queries
10 if (!$disable_utf8_flag) {
11 $case_sensitive_collation = "COLLATE utf8_bin";
13 $case_sensitive_collation = "COLLATE latin_bin";
16 $difference = 0; //flag
19 // collect and display(synchronize) new custom languages
21 $sql = "SELECT lang_description FROM lang_languages";
22 $res = SqlStatement($sql);
24 while ($row=SqlFetchArray($res)) {
25 $row_main[] = $row['lang_description'];
28 $sql = "SELECT lang_description FROM lang_custom";
29 $res = SqlStatement($sql);
30 $row_custom = array();
31 while ($row=SqlFetchArray($res)) {
32 $row_custom[] = $row['lang_description'];
35 $custom_languages = array_diff(array_unique($row_custom), array_unique($row_main));
36 foreach ($custom_languages as $var) {
41 echo htmlspecialchars(xl('Following is a new custom language:'), ENT_NOQUOTES
)." ".htmlspecialchars($var, ENT_NOQUOTES
)."<BR>";
43 // add the new language (first collect the language code)
44 $sql = "SELECT lang_code FROM lang_custom WHERE constant_name='' AND lang_description=? ".$case_sensitive_collation." LIMIT 1";
45 $res = SqlStatement($sql, array($var));
46 $row = SqlFetchArray($res);
47 $sql="INSERT INTO lang_languages SET lang_code=?, lang_description=?";
48 SqlStatement($sql, array($row['lang_code'], $var));
49 echo htmlspecialchars(xl('Synchronized new custom language:'), ENT_NOQUOTES
)." ".htmlspecialchars($var, ENT_NOQUOTES
)."<BR><BR>";
56 // collect and display(synchronize) new custom constants
58 $sql = "SELECT constant_name FROM lang_constants";
59 $res = SqlStatement($sql);
61 while ($row=SqlFetchArray($res)) {
62 $row_main[] = $row['constant_name'];
65 $sql = "SELECT constant_name FROM lang_custom";
66 $res = SqlStatement($sql);
67 $row_custom = array();
68 while ($row=SqlFetchArray($res)) {
69 $row_custom[] = $row['constant_name'];
72 $custom_constants = array_diff(array_unique($row_custom), array_unique($row_main));
73 foreach ($custom_constants as $var) {
78 echo htmlspecialchars(xl('Following is a new custom constant:'), ENT_NOQUOTES
)." ".htmlspecialchars($var, ENT_NOQUOTES
)."<BR>";
80 // add the new constant
81 $sql="INSERT INTO lang_constants SET constant_name=?";
82 SqlStatement($sql, array($var));
83 echo htmlspecialchars(xl('Synchronized new custom constant:'), ENT_NOQUOTES
)." ".htmlspecialchars($var, ENT_NOQUOTES
)."<BR><BR>";
90 // collect and display(synchronize) custom definitions
92 $sql = "SELECT lang_description, lang_code, constant_name, definition FROM lang_custom WHERE lang_description != '' AND constant_name != ''";
93 $res = SqlStatement($sql);
94 while ($row=SqlFetchArray($res)) {
95 // collect language id
96 $sql = "SELECT lang_id FROM lang_languages WHERE lang_description=? ".$case_sensitive_collation." LIMIT 1";
97 $res2 = SqlStatement($sql, array($row['lang_description']));
98 $row2 = SqlFetchArray($res2);
99 $language_id=$row2['lang_id'];
101 // collect constant id
102 $sql = "SELECT cons_id FROM lang_constants WHERE constant_name=? ".$case_sensitive_collation." LIMIT 1";
103 $res2 = SqlStatement($sql, array($row['constant_name']));
104 $row2 = SqlFetchArray($res2);
105 $constant_id=$row2['cons_id'];
107 // collect definition id (if it exists)
108 $sql = "SELECT def_id FROM lang_definitions WHERE cons_id=? AND lang_id=? LIMIT 1";
109 $res2 = SqlStatement($sql, array($constant_id, $language_id));
110 $row2 = SqlFetchArray($res2);
111 $def_id=$row2['def_id'];
114 //definition exist, so check to see if different
115 $sql = "SELECT * FROM lang_definitions WHERE def_id=? AND definition=? ".$case_sensitive_collation;
116 $res_test = SqlStatement($sql, array($def_id, $row['definition']));
117 if (SqlFetchArray($res_test)) {
118 //definition not different
121 //definition is different
122 echo htmlspecialchars(xl('Following is a new definition (Language, Constant, Definition):'), ENT_NOQUOTES
).
123 " ".htmlspecialchars($row['lang_description'], ENT_NOQUOTES
).
124 " ".htmlspecialchars($row['constant_name'], ENT_NOQUOTES
).
125 " ".htmlspecialchars($row['definition'], ENT_NOQUOTES
)."<BR>";
128 $sql = "UPDATE `lang_definitions` SET `definition`=? WHERE `def_id`=? LIMIT 1";
129 SqlStatement($sql, array($row['definition'], $def_id));
130 echo htmlspecialchars(xl('Synchronized new definition (Language, Constant, Definition):'), ENT_NOQUOTES
).
131 " ".htmlspecialchars($row['lang_description'], ENT_NOQUOTES
).
132 " ".htmlspecialchars($row['constant_name'], ENT_NOQUOTES
).
133 " ".htmlspecialchars($row['definition'], ENT_NOQUOTES
)."<BR><BR>";
139 echo htmlspecialchars(xl('Following is a new definition (Language, Constant, Definition):'), ENT_NOQUOTES
).
140 " ".htmlspecialchars($row['lang_description'], ENT_NOQUOTES
).
141 " ".htmlspecialchars($row['constant_name'], ENT_NOQUOTES
).
142 " ".htmlspecialchars($row['definition'], ENT_NOQUOTES
)."<BR>";
145 $sql = "INSERT INTO lang_definitions (cons_id,lang_id,definition) VALUES (?,?,?)";
146 SqlStatement($sql, array($constant_id, $language_id, $row['definition']));
147 echo htmlspecialchars(xl('Synchronized new definition (Language, Constant, Definition):'), ENT_NOQUOTES
).
148 " ".htmlspecialchars($row['lang_description'], ENT_NOQUOTES
).
149 " ".htmlspecialchars($row['constant_name'], ENT_NOQUOTES
).
150 " ".htmlspecialchars($row['definition'], ENT_NOQUOTES
)."<BR><BR>";
158 echo htmlspecialchars(xl('The translation tables are synchronized.'), ENT_NOQUOTES
);
164 <FORM name
="manage_form" METHOD
=POST ACTION
="?m=manage" onsubmit
="return top.restoreSession()">
166 <TD
><INPUT TYPE
="submit" name
="check" value
="<?php echo htmlspecialchars(xl('Check'), ENT_QUOTES); ?>"></TD
>
167 <TD
class="text">(<?php
echo htmlspecialchars(xl('Check for differences of translations with custom language table.'), ENT_NOQUOTES
); ?
>)</TD
>
171 <TD
><INPUT TYPE
="submit" name
="synchronize" value
="<?php echo htmlspecialchars(xl('Synchronize'), ENT_QUOTES); ?>"></TD
>
172 <TD
class="text">(<?php
echo htmlspecialchars(xl('Synchronize translations with custom language table.'), ENT_NOQUOTES
); ?
>)</TD
>