PageRenderTime 41ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 1ms

/public_html/lists/admin/checki18n.php

https://github.com/samtuke/phplist
PHP | 93 lines | 76 code | 8 blank | 9 comment | 9 complexity | a30866213fb0730c6c43d4a77d05e0e0 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. require_once dirname(__FILE__).'/accesscheck.php';
  3. $_SESSION['show_translation_colours'] = 1;
  4. print '<p class="button">'.PageLink2('checki18n&amp;changedonly=yes','Show changes only').'</p>';
  5. # translation check. See that every token has a text in a file and vv
  6. function getFileI18Ntags($file) {
  7. $res = array();
  8. if (!is_file($file))
  9. return $res;
  10. $fd = fopen ($file, "r");
  11. $contents = fread ($fd, filesize ($file));
  12. fclose ($fd);
  13. preg_match_all('/\$GLOBALS\[(["|\'])I18N\1\]->get\((["|\'])([^\2]+)\2\)/Uim', $contents, $globalsi18ntags);
  14. preg_match_all('/\$I18N->get\((["|\'])([^\1]+)\1\)/Uim', $contents, $i18ntags);
  15. for ($i=0; $i< count($globalsi18ntags[0]); $i++) {
  16. array_push($res,$globalsi18ntags[3][$i]);
  17. }
  18. for ($i=0; $i< count($i18ntags[0]); $i++) {
  19. array_push($res,$i18ntags[2][$i]);
  20. }
  21. return $res;
  22. }
  23. function checkI18NDir($rootdir) {
  24. $dir = opendir($rootdir);
  25. while ($file = readdir($dir)) {
  26. $fileoutput = '';
  27. $some = 0;
  28. if (is_file($rootdir.'/'.$file)) {
  29. $fileoutput .= '<hr/><h3>'.$file."</h3><br/>";
  30. $arr = getFileI18Ntags($rootdir.'/'.$file);
  31. $lan = array();
  32. # include 'lan/en/'.$file;
  33. switch ($file) {
  34. case 'send_core.php':
  35. $_GET['page'] = 'send';break;
  36. case 'importcsv.php':
  37. $_GET['page'] = 'import2';break;
  38. default:
  39. $_GET['page'] = basename($file,'.php');
  40. }
  41. /* $page = $_GET['page'];
  42. include_once dirname(__FILE__)."/lan/".$_SESSION['adminlanguage']['iso']."/pagetitles.php";
  43. if (!strtolower($page_title) === 'phplist') {
  44. print "No page title: $page<br/>";
  45. } else {
  46. print "Page title: $page, $page_title<br/>";
  47. }
  48. */ foreach ($arr as $tag) {
  49. $translation = $GLOBALS['I18N']->get(stripslashes($tag));
  50. if (!isset($_GET['changedonly']) || ($_GET['changedonly'] === 'yes' && preg_match('/ff1717/i',$translation))) {
  51. $fileoutput .= "'".$tag.'\' =&gt; \''.$translation.'\',<br/>';
  52. $some = 1;
  53. }
  54. }
  55. if ($some) {
  56. print $fileoutput;
  57. }
  58. # print "RES: $tag<br/>";
  59. # }
  60. # if (!in_array($tag,$lan)) {
  61. # print "Missing: $tag<br/>";
  62. # } else {
  63. # print "Exists: $tag<br/>";
  64. # }
  65. # }
  66. }
  67. }
  68. }
  69. /*
  70. print '
  71. <script language="Javascript" type="text/javascript">
  72. function selectAll() {
  73. document.form.content.focus();document.form.content.select();
  74. }
  75. </script>
  76. <a href="javascript:selectAll()">Select All</a><br/>';
  77. #print '<form name="form">';
  78. print '<textarea name="content" rows="50" cols="60">';
  79. */
  80. checkI18NDir(dirname(__FILE__));
  81. checkI18NDir(dirname(__FILE__).'/commonlib/pages/');
  82. #print '</textarea>';
  83. print '</form>';