languages_compare.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <?php
  2. /*
  3. FusionPBX
  4. Version: MPL 1.1
  5. The contents of this file are subject to the Mozilla Public License Version
  6. 1.1 (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.mozilla.org/MPL/
  9. Software distributed under the License is distributed on an "AS IS" basis,
  10. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. for the specific language governing rights and limitations under the
  12. License.
  13. The Original Code is FusionPBX
  14. The Initial Developer of the Original Code is
  15. Mark J Crane <[email protected]>
  16. Portions created by the Initial Developer are Copyright (C) 2008-2012
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Matthew Vale <[email protected]>
  20. */
  21. require_once "root.php";
  22. require_once "resources/require.php";
  23. //check permissions
  24. require_once "resources/check_auth.php";
  25. if (permission_exists('languages_view')) {
  26. //access granted
  27. }
  28. else {
  29. echo "access denied";
  30. exit;
  31. }
  32. //get http post variables and set them to php variables
  33. $reference_language = $_SESSION['domain']['language']['code'];
  34. $target_language = check_str($_GET["target_language"]);
  35. $app_target = 'resources';
  36. if (count($_POST) > 0) {
  37. //set the variables
  38. $reference_language = check_str($_POST["reference_language"]);
  39. $target_language = check_str($_POST["target_language"]);
  40. $app_target = check_str($_POST["app_target"]);
  41. $organize_app = check_str($_POST["organize_app"]);
  42. $organize_all = check_str($_POST["organize_all"]);
  43. }
  44. //add multi-lingual support
  45. $language = new text;
  46. $text = $language->get();
  47. //collect languages
  48. $language_text = $language->get('all', $app_target, true);
  49. foreach ($language_text as $lang_label => $lang_codes) {
  50. $language_labels[] = $lang_label;
  51. $reference_text[$lang_label] = $lang_codes[$reference_language];
  52. $target_text[$lang_label] = $lang_codes[$target_language];
  53. }
  54. asort($language_labels);
  55. if($app_target != 'resources'){
  56. $global_text = $language->get($reference_language, 'resources', true);
  57. }
  58. unset($language_text);
  59. if($organize_app and strlen($app_target) > 0) {
  60. $language->organize_language($app_target, false);
  61. messages::add("Updated $app_target's app_languages.php");
  62. }
  63. if($organize_all) {
  64. $files = glob($_SERVER["PROJECT_ROOT"] . "/*/*/app_languages.php");
  65. foreach($files as $file) {
  66. $file = preg_replace('/\A.*(\/.*\/.*)\z/', '$1', dirname($file));
  67. $language->organize_language($file, true);
  68. }
  69. $language->organize_language('resources', true);
  70. messages::add("Updated All app_languages.php's");
  71. }
  72. //get the list of installed apps from the core and mod directories
  73. $config_list = glob($_SERVER["PROJECT_ROOT"] . "/*/*/app_config.php");
  74. $app_list;
  75. $x=0;
  76. foreach ($config_list as $config_path) {
  77. include($config_path);
  78. $dirs = explode("/", $config_path);
  79. $app_path = $dirs[(sizeof($dirs)-3)] . "/" . $dirs[(sizeof($dirs)-2)];
  80. $app_name = $apps[$x]['name'];
  81. if( strlen($app_name) == 0) { $app_name = $app_path; }
  82. $app_list[$app_name] = $app_path;
  83. $x++;
  84. }
  85. $theme_list = glob($_SERVER["PROJECT_ROOT"] . "/themes/*/app_languages.php");
  86. foreach ($theme_list as $config_path) {
  87. $dirs = explode("/", $config_path);
  88. $app_path = $dirs[(sizeof($dirs)-3)] . "/" . $dirs[(sizeof($dirs)-2)];
  89. $app_name = 'Theme - ' . $dirs[(sizeof($dirs)-2)];
  90. $app_list[$app_name] = $app_path;
  91. }
  92. unset($apps);
  93. ksort($app_list);
  94. //additional includes
  95. require_once "resources/header.php";
  96. require_once "resources/paging.php";
  97. //get variables used to control the order
  98. $order_by = $_GET["order_by"];
  99. $order = $_GET["order"];
  100. //show the content
  101. echo "<p>\n";
  102. echo "<b>".$text['title-compare_languages']."</b><br/>\n";
  103. echo $text['description-compare_languages']."\n";
  104. echo "</p>\n";
  105. //select comparison
  106. echo "<span><b>".$text['header-compare_languages']."</b><br/></span>\n";
  107. echo "<form method='post' name='frm' action=''>\n";
  108. echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  109. echo " <tr>\n";
  110. echo " <td class='vncellreq' valign='top' align='left' nowrap='nowrap' rowspan='".(count($language->languages)+1)."'width='15%'>\n";
  111. echo " ".$text['label-reference_language']."\n";
  112. echo " </td>\n";
  113. echo " <td class='vtable' align='left' width='35%'>\n";
  114. echo " ".$text['description-reference_language']."\n";
  115. echo " </td>\n";
  116. echo " <td class='vncellreq' valign='top' align='left' nowrap='nowrap' rowspan='".(count($language->languages)+1)."'width='15%'>\n";
  117. echo " ".$text['label-target_language']."\n";
  118. echo " </td>\n";
  119. echo " <td class='vtable' align='left' width='35%'>\n";
  120. echo " ".$text['description-target_language']."\n";
  121. echo " </td>\n";
  122. echo " </tr>\n";
  123. echo " <tr>\n";
  124. foreach($language->languages as $lang_code){
  125. echo " <td class='vtable' align='left'>\n";
  126. echo " <label class='radio' style='padding-left:20px;margin:0;'>";
  127. echo " <input type='radio' name='reference_language' value='$lang_code' id='reference_language_$lang_code'";
  128. if($lang_code == $reference_language)
  129. {
  130. echo " checked='checked'";
  131. }
  132. echo "/>";
  133. echo " <img src='".PROJECT_PATH."/core/install/resources/images/flags/$lang_code.png' alt='$lang_code'/>&nbsp;".$text["language-$lang_code"];
  134. echo " </label>\n";
  135. echo " </td>\n";
  136. echo " <td class='vtable' align='left'>\n";
  137. echo " <label class='radio' style='padding-left:20px;margin:0;'>";
  138. echo " <input type='radio' name='target_language' value='$lang_code' id='target_language_$lang_code'";
  139. if($lang_code == $target_language)
  140. {
  141. echo " checked='checked'";
  142. }
  143. echo "/>";
  144. echo " <img src='".PROJECT_PATH."/core/install/resources/images/flags/$lang_code.png' alt='$lang_code'/>&nbsp;".$text["language-$lang_code"];
  145. echo " </label>\n";
  146. echo " </td>\n";
  147. echo " </tr>\n";
  148. }
  149. echo "<tr>\n";
  150. echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
  151. echo " ".$text['label-app_target']."\n";
  152. echo "</td>\n";
  153. echo "<td class='vtable' align='left'>\n";
  154. echo " <select name='app_target' id='app_target' class='formfld'>\n";
  155. echo " <option value='resources'";
  156. if($app_target == 'resources') { echo " selected='selected'"; }
  157. echo ">Global</option>\n";
  158. echo " <option value=''>==========</option>";
  159. foreach($app_list as $app => $app_path ) {
  160. echo " <option value='$app_path'";
  161. if($app_target == $app_path) { echo " selected='selected'"; }
  162. echo ">".$app."</option>\n";
  163. }
  164. echo " </select>\n";
  165. echo " <br />".$text['description-app_target']."\n";
  166. echo "</td>\n";
  167. echo "</tr>\n";
  168. echo "</table>\n";
  169. echo " <div style='text-align:right'>\n";
  170. echo " <button type='button' onclick=\"history.go(-1);\">".$text['button-back']."</button>\n";
  171. echo " <button type='submit' id='next'>".$text['button-search']."</button>\n";
  172. echo " <button type='submit' id='organize_app' name='organize_app' value='1'>Organize Application's language</button>\n";
  173. echo " <button type='submit' id='organize_all' name='organize_all' value='1'>Organize All language</button>\n";
  174. echo " </div>\n";
  175. echo "</form>\n";
  176. echo "<br/>\n";
  177. //render the texts
  178. echo "<span><b>".$text['header-language_results']."</b> for '$app_target/app_languages.php'<br/></span>\n";
  179. echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  180. echo "<tr>\n";
  181. echo "<th>".$text['label-tag']."</th>";
  182. echo "<th><img src='".PROJECT_PATH."/core/install/resources/images/flags/$reference_language.png' alt='$reference_language'/>&nbsp;".$text["language-$reference_language"]."</th>\n";
  183. if(strlen($target_language) > 0) { echo "<th><img src='".PROJECT_PATH."/core/install/resources/images/flags/$target_language.png' alt='$target_language'/>&nbsp;".$text["language-$target_language"]."</th>\n"; }
  184. echo "</tr>\n";
  185. $language_count = 0;
  186. foreach ($language_labels as $lang_label){
  187. if( preg_match( '/\Alanguage-\w{2}(?:-\w{2})?\z/', $lang_label) ) { continue; }
  188. echo "<tr>\n";
  189. echo "<td class='vncellreq' valign='top' align='left' nowrap>$lang_label";
  190. if(isset($global_text[$lang_label])){
  191. echo "&nbsp;<img src='$project_path/themes/default/images/warning.png' alt='!' title=\"".$text['warning-global_already_defined']."'".$global_text[$lang_label]."'\"/>";
  192. }
  193. echo "</td>\n";
  194. echo "<td class='vtable' align='left'>";
  195. if(strlen($reference_text[$lang_label]) == 0) {
  196. echo "<b>Missing!</b>";
  197. }else{
  198. echo $reference_text[$lang_label];
  199. }
  200. echo "</td>\n";
  201. if(strlen($target_language) > 0 ) {
  202. echo "<td class='vtable' align='left'>";
  203. if(strlen($target_text[$lang_label]) == 0) {
  204. echo "<b>Missing!</b>";
  205. }else{
  206. echo $target_text[$lang_label];
  207. }
  208. echo "</td>\n";
  209. }
  210. echo "</tr>\n";
  211. $language_count++;
  212. }
  213. if($language_count == 0){
  214. echo "<tr><td colspan='3'>Sorry, this app hasn't defined any text</td></tr>\n";
  215. }
  216. echo "</table>\n";
  217. //include the footer
  218. require_once "resources/footer.php";
  219. ?>