acknowledgments update
[openemr.git] / interface / language / lang_manage.php
blobd079cab3addfa0f3cfede054160ef19808b32edd
1 <?php
2 if ($_POST['check'] || $_POST['synchronize']){
3 // set up flag if only checking for changes (ie not performing synchronization)
4 $checkOnly = 0;
5 if ($_POST['check']) {
6 $checkOnly = 1;
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 else {
14 $case_sensitive_collation = "COLLATE latin_bin";
16 $difference = 0; //flag
18 //
19 // collect and display(synchronize) new custom languages
21 $sql = "SELECT lang_description FROM lang_languages";
22 $res = SqlStatement($sql);
23 $row_main = array();
24 while ($row=SqlFetchArray($res)){
25 $row_main[] = $row['lang_description'];
27 $sql = "SELECT lang_description FROM lang_custom";
28 $res = SqlStatement($sql);
29 $row_custom = array();
30 while ($row=SqlFetchArray($res)){
31 $row_custom[] = $row['lang_description'];
33 $custom_languages = array_diff(array_unique($row_custom),array_unique($row_main));
34 foreach ($custom_languages as $var) {
35 if ($var=='') continue;
36 echo htmlspecialchars(xl('Following is a new custom language:'),ENT_NOQUOTES)." ".htmlspecialchars($var,ENT_NOQUOTES)."<BR>";
37 if (!$checkOnly) {
38 // add the new language (first collect the language code)
39 $sql = "SELECT lang_code FROM lang_custom WHERE constant_name='' AND lang_description=? ".$case_sensitive_collation." LIMIT 1";
40 $res = SqlStatement($sql, array($var) );
41 $row = SqlFetchArray($res);
42 $sql="INSERT INTO lang_languages SET lang_code=?, lang_description=?";
43 SqlStatement($sql, array($row['lang_code'], $var) );
44 echo htmlspecialchars(xl('Synchronized new custom language:'),ENT_NOQUOTES)." ".htmlspecialchars($var,ENT_NOQUOTES)."<BR><BR>";
46 $difference = 1;
49 //
50 // collect and display(synchronize) new custom constants
51 //
52 $sql = "SELECT constant_name FROM lang_constants";
53 $res = SqlStatement($sql);
54 $row_main = array();
55 while ($row=SqlFetchArray($res)){
56 $row_main[] = $row['constant_name'];
58 $sql = "SELECT constant_name FROM lang_custom";
59 $res = SqlStatement($sql);
60 $row_custom = array();
61 while ($row=SqlFetchArray($res)){
62 $row_custom[] = $row['constant_name'];
64 $custom_constants = array_diff(array_unique($row_custom),array_unique($row_main));
65 foreach ($custom_constants as $var) {
66 if ($var=='') continue;
67 echo htmlspecialchars(xl('Following is a new custom constant:'),ENT_NOQUOTES)." ".htmlspecialchars($var,ENT_NOQUOTES)."<BR>";
68 if (!$checkOnly) {
69 // add the new constant
70 $sql="INSERT INTO lang_constants SET constant_name=?";
71 SqlStatement($sql, array($var) );
72 echo htmlspecialchars(xl('Synchronized new custom constant:'),ENT_NOQUOTES)." ".htmlspecialchars($var,ENT_NOQUOTES)."<BR><BR>";
74 $difference = 1;
77 //
78 // collect and display(synchronize) custom definitions
80 $sql = "SELECT lang_description, lang_code, constant_name, definition FROM lang_custom WHERE lang_description != '' AND constant_name != ''";
81 $res = SqlStatement($sql);
82 while ($row=SqlFetchArray($res)){
84 // collect language id
85 $sql = "SELECT lang_id FROM lang_languages WHERE lang_description=? ".$case_sensitive_collation." LIMIT 1";
86 $res2 = SqlStatement($sql, array($row['lang_description']) );
87 $row2 = SqlFetchArray($res2);
88 $language_id=$row2['lang_id'];
90 // collect constant id
91 $sql = "SELECT cons_id FROM lang_constants WHERE constant_name=? ".$case_sensitive_collation." LIMIT 1";
92 $res2 = SqlStatement($sql, array($row['constant_name']) );
93 $row2 = SqlFetchArray($res2);
94 $constant_id=$row2['cons_id'];
96 // collect definition id (if it exists)
97 $sql = "SELECT def_id FROM lang_definitions WHERE cons_id=? AND lang_id=? LIMIT 1";
98 $res2 = SqlStatement($sql, array($constant_id, $language_id) );
99 $row2 = SqlFetchArray($res2);
100 $def_id=$row2['def_id'];
102 if ($def_id) {
103 //definition exist, so check to see if different
104 $sql = "SELECT * FROM lang_definitions WHERE def_id=? AND definition=? ".$case_sensitive_collation;
105 $res_test = SqlStatement($sql, array($def_id, $row['definition']) );
106 if (SqlFetchArray($res_test)) {
107 //definition not different
108 continue;
110 else {
111 //definition is different
112 echo htmlspecialchars(xl('Following is a new definition (Language, Constant, Definition):'),ENT_NOQUOTES).
113 " ".htmlspecialchars($row['lang_description'],ENT_NOQUOTES).
114 " ".htmlspecialchars($row['constant_name'],ENT_NOQUOTES).
115 " ".htmlspecialchars($row['definition'],ENT_NOQUOTES)."<BR>";
116 if (!$checkOnly) {
117 //add new definition
118 $sql = "UPDATE `lang_definitions` SET `definition`=? WHERE `def_id`=? LIMIT 1";
119 SqlStatement($sql, array($row['definition'], $def_id) );
120 echo htmlspecialchars(xl('Synchronized new definition (Language, Constant, Definition):'),ENT_NOQUOTES).
121 " ".htmlspecialchars($row['lang_description'],ENT_NOQUOTES).
122 " ".htmlspecialchars($row['constant_name'],ENT_NOQUOTES).
123 " ".htmlspecialchars($row['definition'],ENT_NOQUOTES)."<BR><BR>";
125 $difference = 1;
128 else {
129 echo htmlspecialchars(xl('Following is a new definition (Language, Constant, Definition):'),ENT_NOQUOTES).
130 " ".htmlspecialchars($row['lang_description'],ENT_NOQUOTES).
131 " ".htmlspecialchars($row['constant_name'],ENT_NOQUOTES).
132 " ".htmlspecialchars($row['definition'],ENT_NOQUOTES)."<BR>";
133 if (!$checkOnly) {
134 //add new definition
135 $sql = "INSERT INTO lang_definitions (cons_id,lang_id,definition) VALUES (?,?,?)";
136 SqlStatement($sql, array($constant_id, $language_id, $row['definition']) );
137 echo htmlspecialchars(xl('Synchronized new definition (Language, Constant, Definition):'),ENT_NOQUOTES).
138 " ".htmlspecialchars($row['lang_description'],ENT_NOQUOTES).
139 " ".htmlspecialchars($row['constant_name'],ENT_NOQUOTES).
140 " ".htmlspecialchars($row['definition'],ENT_NOQUOTES)."<BR><BR>";
142 $difference = 1;
145 if (!$difference) {
146 echo htmlspecialchars(xl('The translation tables are synchronized.'),ENT_NOQUOTES);
151 <TABLE>
152 <FORM name="manage_form" METHOD=POST ACTION="?m=manage" onsubmit="return top.restoreSession()">
153 <TR>
154 <TD><INPUT TYPE="submit" name="check" value="<?php echo htmlspecialchars(xl('Check'),ENT_QUOTES); ?>"></TD>
155 <TD class="text">(<?php echo htmlspecialchars(xl('Check for differences of translations with custom language table.'),ENT_NOQUOTES); ?>)</TD>
156 </TR>
157 <TR></TR>
158 <TR>
159 <TD><INPUT TYPE="submit" name="synchronize" value="<?php echo htmlspecialchars(xl('Synchronize'),ENT_QUOTES); ?>"></TD>
160 <TD class="text">(<?php echo htmlspecialchars(xl('Synchronize translations with custom language table.'),ENT_NOQUOTES); ?>)</TD>
161 </TR>
162 </FORM>
163 </TABLE>