index.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. if (count($_POST) > 0) {
  33. //set the variables
  34. $detect_all_languages = check_str($_POST["detect_all_languages"]);
  35. }
  36. //add multi-lingual support
  37. $language = new text;
  38. $text = $language->get();
  39. $language_totals = $language->language_totals();
  40. if($detect_all_languages){
  41. $language->detect_all_languages(true);
  42. messages::add("Detected all Languages");
  43. }
  44. //additional includes
  45. require_once "resources/header.php";
  46. require_once "resources/paging.php";
  47. function lineargradient($ra,$ga,$ba,$rz,$gz,$bz,$iterationnr) {
  48. $colorindex = array();
  49. for($iterationc=1; $iterationc<=$iterationnr; $iterationc++) {
  50. $iterationdiff = $iterationnr-$iterationc;
  51. $colorindex[] = sprintf('#%02x%02x%02x',
  52. (($ra*$iterationc)+($rz*$iterationdiff))/$iterationnr,
  53. (($ga*$iterationc)+($gz*$iterationdiff))/$iterationnr,
  54. (($ba*$iterationc)+($bz*$iterationdiff))/$iterationnr);
  55. }
  56. return $colorindex;
  57. }
  58. $colorindex = lineargradient(
  59. 0, 200, 0, // rgb of the start color
  60. 200, 0, 0, // rgb of the end color
  61. 101 // number of colors in your linear gradient
  62. );
  63. //show the content
  64. echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
  65. echo " <tr>\n";
  66. echo " <td width='50%' align='left' nowrap='nowrap'><b>".$text['title-languages']."</b></td>\n";
  67. echo " <td width='50%' align='right'>&nbsp;</td>\n";
  68. echo " </tr>\n";
  69. echo " <tr>\n";
  70. echo " <td align='left' colspan='2'>\n";
  71. echo " ".$text['description-languages']."<br /><br />\n";
  72. echo " </td>\n";
  73. echo " </tr>\n";
  74. echo "</table>\n";
  75. echo "<form method='post' name='frm' action=''>\n";
  76. echo " <button type='submit' id='organize_app' name='detect_all_languages' value='1'>Detect all languages</button>\n";
  77. echo "</form>\n";
  78. //table headers
  79. echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  80. echo "<tr>\n";
  81. echo "<th nowrap='' style='width:2em'>".$text['label-flag']."</th>\n";
  82. echo "<th nowrap='' style='width:4em'>".$text['label-culture_code']."</th>\n";
  83. echo "<th nowrap='' style='width:4em'>".$text['label-translations']."</th>\n";
  84. echo "<th nowrap='' style='width:4em'>".$text['label-menu_items']."</th>\n";
  85. echo "<th nowrap='' style='width:4em'>".$text['label-app_descriptions']."</th>\n";
  86. echo "<th nowrap='' style='width:4em'>".$text['label-overall']."</th>\n";
  87. echo "<th nowrap=''>".$text['label-name']."</th>\n";
  88. echo "</tr>\n";
  89. $c = 0;
  90. $warn_about_wrong_culture = false;
  91. foreach($language->languages as $lang_code){
  92. $complete['languages'] = sprintf("%.1f", $language_totals['languages'][$lang_code] / $language_totals['languages']['total'] * 100 );
  93. $complete['menu_items'] = sprintf("%.1f", $language_totals['menu_items'][$lang_code] / $language_totals['menu_items']['total'] * 100 );
  94. $complete['app_descriptions'] = sprintf("%.1f", $language_totals['app_descriptions'][$lang_code] / $language_totals['app_descriptions']['total'] * 100 );
  95. $complete['overall'] = sprintf("%.1f",
  96. ( $language_totals['languages'][$lang_code] + $language_totals['menu_items'][$lang_code] + $language_totals['app_descriptions'][$lang_code] )
  97. / ($language_totals['languages']['total'] + $language_totals['menu_items']['total'] + $language_totals['app_descriptions']['total'] )
  98. * 100
  99. );
  100. $tr_link = "href='languages_compare.php?target_language=$lang_code'";
  101. echo "<tr $tr_link>\n";
  102. echo "<td class='row_style".($c%2)."'>";
  103. echo "<img src='".PROJECT_PATH."/core/install/resources/images/flags/$lang_code.png' alt='$lang_code'/></td>";
  104. echo "<td class='row_style".($c%2)."'>$lang_code";
  105. if(strlen($lang_code) < 5){
  106. $warn_about_wrong_culture = true;
  107. echo "$nbsp;<sup>*1</sup>";
  108. }
  109. echo "</td>";
  110. echo "<td class='row_style".($c%2)."' style='color:".$colorindex[intval($complete['languages'])]."'>".$complete['languages']."%</td>";
  111. echo "<td class='row_style".($c%2)."' style='color:".$colorindex[intval($complete['menu_items'])]."'>".$complete['menu_items']."%</td>";
  112. echo "<td class='row_style".($c%2)."' style='color:".$colorindex[intval($complete['app_descriptions'])]."'>".$complete['app_descriptions']."%</td>";
  113. echo "<td class='row_style".($c%2)."' style='color:".$colorindex[intval($complete['overall'])]."'>".$complete['overall']."%</td>";
  114. echo "<td class='row_style".($c%2)."'>".$text["language-$lang_code"]."</td>";
  115. echo "</tr>\n";
  116. $c++;
  117. }
  118. //complete the content
  119. echo "</table>";
  120. if($warn_about_wrong_culture){
  121. $lang_code = $_SESSION['domain']['language']['code'];
  122. echo "<p><sup>*1</sup>&nbsp;".$text['warning-incorrect_language_culture_code']."<a href='https://msdn.microsoft.com/$lang_code/library/ee825488%28v=cs.20%29.aspx'>https://msdn.microsoft.com/$lang_code/library/ee825488%28v=cs.20%29.aspx</a></p>";
  123. }
  124. //include the footer
  125. require_once "resources/footer.php";
  126. ?>