PageRenderTime 43ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/01.Source/01.CORE/admincp/modules/language/setting.php

http://creative-portal.googlecode.com/
PHP | 199 lines | 172 code | 21 blank | 6 comment | 18 complexity | 247d8c28cb1ab3569df5436a0166b5d2 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /**
  3. * @Project NUKEVIET 3.0
  4. * @Author VINADES.,JSC (contact@vinades.vn)
  5. * @Copyright (C) 2010 VINADES.,JSC. All rights reserved
  6. * @Createdate 2-9-2010 14:43
  7. */
  8. if ( ! defined( 'NV_IS_FILE_LANG' ) ) die( 'Stop!!!' );
  9. $a = 1;
  10. $page_title = $lang_module['nv_lang_setting'];
  11. $array_type = array(
  12. $lang_module['nv_setting_type_0'], $lang_module['nv_setting_type_1'], $lang_module['nv_setting_type_2']
  13. );
  14. if ( $nv_Request->get_string( 'checksessseting', 'post' ) == md5( session_id() . "seting" ) )
  15. {
  16. $read_type = $nv_Request->get_int( 'read_type', 'post', 0 );
  17. $query = "UPDATE `" . NV_CONFIG_GLOBALTABLE . "` SET `config_value` = '" . $read_type . "' WHERE `lang`='sys' AND `module` = 'global' AND `config_name` = 'read_type'";
  18. $result = $db->sql_query( $query );
  19. nv_save_file_config_global();
  20. $contents = "<br><br><br><p align=\"center\">" . $lang_module['nv_setting_save'] . "</p>";
  21. $contents .= "<META HTTP-EQUIV=\"refresh\" content=\"2;URL=" . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=setting\">";
  22. include ( NV_ROOTDIR . "/includes/header.php" );
  23. echo nv_admin_theme( $contents );
  24. include ( NV_ROOTDIR . "/includes/footer.php" );
  25. exit();
  26. }
  27. if ( $nv_Request->get_string( 'checksessshow', 'post' ) == md5( session_id() . "show" ) )
  28. {
  29. $allow_sitelangs = $nv_Request->get_array( 'allow_sitelangs', 'post', array() );
  30. $allow_adminlangs = $nv_Request->get_array( 'allow_adminlangs', 'post', array() );
  31. $allow_adminlangs[] = NV_LANG_INTERFACE;
  32. $allow_adminlangs[] = NV_LANG_DATA;
  33. $allow_adminlangs[] = $global_config['site_lang'];
  34. foreach ( $allow_sitelangs as $lang_temp )
  35. {
  36. $allow_adminlangs[] = $lang_temp;
  37. }
  38. $allow_sitelangs[] = $global_config['site_lang'];
  39. $allow_adminlangs = array_unique( $allow_adminlangs );
  40. $allow_sitelangs_temp = array_unique( $allow_sitelangs );
  41. $allow_sitelangs = array();
  42. foreach ( $allow_sitelangs_temp as $lang_temp )
  43. {
  44. if ( file_exists( NV_ROOTDIR . "/language/" . $lang_temp . "/global.php" ) )
  45. {
  46. $allow_sitelangs[] = $lang_temp;
  47. }
  48. }
  49. $allow_sitelangs_temp = array_unique( $allow_adminlangs );
  50. $allow_adminlangs = array();
  51. foreach ( $allow_sitelangs_temp as $lang_temp )
  52. {
  53. if ( file_exists( NV_ROOTDIR . "/language/" . $lang_temp . "/global.php" ) )
  54. {
  55. $allow_adminlangs[] = $lang_temp;
  56. }
  57. }
  58. $global_config['allow_sitelangs'] = $allow_sitelangs;
  59. $global_config['allow_adminlangs'] = $allow_adminlangs;
  60. $allow_sitelangs = implode( ",", $global_config['allow_sitelangs'] );
  61. $allow_adminlangs = implode( ",", $global_config['allow_adminlangs'] );
  62. $query = "UPDATE `" . NV_CONFIG_GLOBALTABLE . "` SET `config_value` = " . $db->dbescape( $allow_sitelangs ) . " WHERE `lang`='sys' AND `module` = 'global' AND `config_name` = 'allow_sitelangs'";
  63. $result = $db->sql_query( $query );
  64. $query = "UPDATE `" . NV_CONFIG_GLOBALTABLE . "` SET `config_value` = " . $db->dbescape( $allow_adminlangs ) . " WHERE `lang`='sys' AND `module` = 'global' AND `config_name` = 'allow_adminlangs'";
  65. $result = $db->sql_query( $query );
  66. nv_save_file_config_global();
  67. $contents = "<br><br><br><p align=\"center\">" . $lang_module['nv_setting_save'] . "</p>";
  68. $contents .= "<META HTTP-EQUIV=\"refresh\" content=\"2;URL=" . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=setting\">";
  69. include ( NV_ROOTDIR . "/includes/header.php" );
  70. echo nv_admin_theme( $contents );
  71. include ( NV_ROOTDIR . "/includes/footer.php" );
  72. exit();
  73. }
  74. $lang_array_exit = nv_scandir( NV_ROOTDIR . "/language", "/^[a-z]{2}+$/" );
  75. $result = $db->sql_query( "SHOW COLUMNS FROM `" . NV_LANGUAGE_GLOBALTABLE . "_file`" );
  76. $lang_array_data_exit = array();
  77. while ( $row = $db->sql_fetch_assoc( $result ) )
  78. {
  79. if ( substr( $row['Field'], 0, 7 ) == "author_" )
  80. {
  81. $lang_array_data_exit[] = substr( $row['Field'], 7, 2 );
  82. }
  83. }
  84. $sql = "SELECT lang FROM `" . $db_config['prefix'] . "_setup_language` WHERE `setup`=1";
  85. $result = $db->sql_query( $sql );
  86. $array_lang_setup = array();
  87. while ( $row = $db->sql_fetchrow( $result ) )
  88. {
  89. $array_lang_setup[] = trim( $row['lang'] );
  90. }
  91. $contents .= "<form action=\"" . NV_BASE_ADMINURL . "index.php\" method=\"post\">";
  92. $contents .= "<table summary=\"\" class=\"tab1\">\n";
  93. $contents .= " <caption>" . $lang_module['nv_lang_show'] . "</caption>";
  94. $contents .= " <thead>\n";
  95. $contents .= " <tr>";
  96. $contents .= " <td style=\"width: 50px\">" . $lang_module['nv_lang_key'] . "</td>";
  97. $contents .= " <td style=\"width: 180px\">" . $lang_module['nv_lang_name'] . "</td>";
  98. $contents .= " <td style=\"width: 120px\">" . $lang_module['nv_lang_slsite'] . "</td>";
  99. $contents .= " <td style=\"width: 120px\">" . $lang_module['nv_lang_sladm'] . "</td>";
  100. $contents .= " <td></td>";
  101. $contents .= " </thead>";
  102. $contents .= " </tr>";
  103. $contents .= " </table>";
  104. $a = 0;
  105. $contents .= "<div style=\"height: 350px; overflow: auto; margin-bottom: 5px;\">";
  106. $contents .= "<table summary=\"\" class=\"tab1\" style=\"width:810px;\">\n";
  107. while ( list( $key, $value ) = each( $language_array ) )
  108. {
  109. $arr_lang_func = array();
  110. $check_lang_exit = false;
  111. if ( file_exists( NV_ROOTDIR . "/language/" . $key . "/global.php" ) )
  112. {
  113. $check_lang_exit = true;
  114. $arr_lang_func[] = "<a href=\"" . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=read&dirlang=" . $key . "&amp;checksess=" . md5( "readallfile" . session_id() ) . "\">" . $lang_module['nv_admin_read_all'] . "</a>";
  115. }
  116. if ( in_array( $key, $lang_array_data_exit ) )
  117. {
  118. $arr_lang_func[] = "<a href=\"" . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=write&dirlang=" . $key . "&amp;checksess=" . md5( "writeallfile" . session_id() ) . "\">" . $lang_module['nv_admin_write'] . "</a>";
  119. $arr_lang_func[] = "<a href=\"" . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=download&dirlang=" . $key . "&amp;checksess=" . md5( "downloadallfile" . session_id() ) . "\">" . $lang_module['nv_admin_download'] . "</a>";
  120. }
  121. $class = ( $a % 2 ) ? " class=\"second\"" : "";
  122. $contents .= "<tbody" . $class . ">\n";
  123. $contents .= " <tr>";
  124. $contents .= " <td style=\"width: 50px; text-align: center\">" . $key . "</td>";
  125. $contents .= " <td style=\"width: 180px\">" . $value['name'] . "</td>";
  126. if ( $check_lang_exit and in_array( $key, $array_lang_setup ) )
  127. {
  128. $contents .= "<td style=\"width: 120px; text-align: center\"><input name=\"allow_sitelangs[]\" value=\"" . $key . "\" type=\"checkbox\" " . ( in_array( $key, $global_config['allow_sitelangs'] ) ? " checked=\"checked\"" : "" ) . "></td>";
  129. }
  130. else
  131. {
  132. $contents .= "<td style=\"width: 120px; text-align: center\"><input name=\"allow_sitelangs[]\" value=\"" . $key . "\" type=\"checkbox\" disabled></td>";
  133. }
  134. if ( $check_lang_exit )
  135. {
  136. $contents .= "<td style=\"width: 120px; text-align: center\"><input name=\"allow_adminlangs[]\" value=\"" . $key . "\" type=\"checkbox\" " . ( in_array( $key, $global_config['allow_adminlangs'] ) ? " checked=\"checked\"" : "" ) . "></td>";
  137. }
  138. else
  139. {
  140. $contents .= "<td style=\"width: 120px; text-align: center\"><input name=\"allow_adminlangs[]\" value=\"" . $key . "\" type=\"checkbox\" disabled></td>";
  141. }
  142. if ( ! empty( $arr_lang_func ) and ! in_array( $key, $global_config['allow_adminlangs'] ) )
  143. {
  144. $arr_lang_func[] = "<a href=\"" . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=delete&dirlang=" . $key . "&amp;checksess=" . md5( "deleteallfile" . session_id() ) . "\">" . $lang_module['nv_admin_delete'] . "</a>";
  145. }
  146. $contents .= "<td style=\"text-align: center\">" . implode( " - ", $arr_lang_func ) . "</td>";
  147. $contents .= "</tr>";
  148. $contents .= "</tbody>";
  149. $a ++;
  150. }
  151. $contents .= "</table>";
  152. $contents .= "</div>";
  153. $contents .= "<input type=\"hidden\" name =\"" . NV_NAME_VARIABLE . "\" value=\"" . $module_name . "\" />";
  154. $contents .= "<input type=\"hidden\" name =\"" . NV_OP_VARIABLE . "\" value=\"" . $op . "\" />";
  155. $contents .= "<input type=\"hidden\" name =\"checksessshow\" value=\"" . md5( session_id() . "show" ) . "\" />";
  156. $contents .= "<center><input type=\"submit\" value=\"" . $lang_module['nv_admin_edit_save'] . "\" /><center>";
  157. $contents .= "</form>";
  158. $contents .= "<form action=\"" . NV_BASE_ADMINURL . "index.php\" method=\"post\">";
  159. $contents .= "<table summary=\"\" class=\"tab1\">\n";
  160. $contents .= " <caption>" . $lang_module['nv_setting_read'] . "</caption>";
  161. foreach ( $array_type as $key => $value )
  162. {
  163. $contents .= " <tr>";
  164. $contents .= " <td></td>";
  165. $contents .= " <td><input name=\"read_type\" value=\"" . $key . "\" type=\"radio\" " . ( $global_config['read_type'] == $key ? " checked=\"checked\"" : "" ) . "> " . $value . "</td>";
  166. $contents .= " </tr>";
  167. }
  168. $contents .= "</table>";
  169. $contents .= "<br>";
  170. $contents .= "<input type=\"hidden\" name =\"" . NV_NAME_VARIABLE . "\" value=\"" . $module_name . "\" />";
  171. $contents .= "<input type=\"hidden\" name =\"" . NV_OP_VARIABLE . "\" value=\"" . $op . "\" />";
  172. $contents .= "<input type=\"hidden\" name =\"checksessseting\" value=\"" . md5( session_id() . "seting" ) . "\" />";
  173. $contents .= "<center><input type=\"submit\" value=\"" . $lang_module['nv_admin_edit_save'] . "\" /><center>";
  174. $contents .= "</form>";
  175. include ( NV_ROOTDIR . "/includes/header.php" );
  176. echo nv_admin_theme( $contents );
  177. include ( NV_ROOTDIR . "/includes/footer.php" );
  178. ?>