PageRenderTime 25ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/NukeViet3.2/themes/admin_full/theme.php

http://nuke-viet.googlecode.com/
PHP | 262 lines | 243 code | 10 blank | 9 comment | 34 complexity | 674af5cb7f1cc303dfec0183d3200772 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1, GPL-2.0
  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 31/05/2010, 00:36
  7. */
  8. if ( ! defined( 'NV_MAINFILE' ) ) die( 'Stop!!!' );
  9. function nv_get_submenu ( $mod )
  10. {
  11. global $lang_global, $module_name;
  12. $submenu = array();
  13. if ( $mod != $module_name and file_exists( NV_ROOTDIR . "/" . NV_ADMINDIR . "/modules/" . $mod . "/functions.php" ) )
  14. {
  15. //ket noi voi file ngon ngu cua module
  16. if ( file_exists( NV_ROOTDIR . "/language/" . NV_LANG_INTERFACE . "/admin_" . $mod . ".php" ) )
  17. {
  18. include ( NV_ROOTDIR . "/language/" . NV_LANG_INTERFACE . "/admin_" . $mod . ".php" );
  19. }
  20. elseif ( file_exists( NV_ROOTDIR . "/language/" . NV_LANG_DATA . "/admin_" . $mod . ".php" ) )
  21. {
  22. include ( NV_ROOTDIR . "/language/" . NV_LANG_DATA . "/admin_" . $mod . ".php" );
  23. }
  24. elseif ( file_exists( NV_ROOTDIR . "/language/en/admin_" . $mod . ".php" ) )
  25. {
  26. include ( NV_ROOTDIR . "/language/en/admin_" . $mod . ".php" );
  27. }
  28. include ( NV_ROOTDIR . "/" . NV_ADMINDIR . "/modules/" . $mod . "/functions.php" );
  29. unset( $lang_module );
  30. }
  31. return $submenu;
  32. }
  33. function nv_admin_theme ( $contents, $head_site = 1 )
  34. {
  35. global $global_config, $lang_global, $admin_mods, $site_mods, $admin_menu_mods, $module_name, $module_file, $module_info, $admin_info, $db, $page_title, $submenu, $select_options, $op, $set_active_op, $array_lang_admin, $my_head;
  36. $dir_template = "";
  37. if ( $head_site == 1 )
  38. {
  39. $file_name_tpl = "main.tpl";
  40. if ( file_exists( NV_ROOTDIR . "/themes/" . $global_config['admin_theme'] . "/system/" . $file_name_tpl ) )
  41. {
  42. $dir_template = NV_ROOTDIR . "/themes/" . $global_config['admin_theme'] . "/system";
  43. }
  44. else
  45. {
  46. $dir_template = NV_ROOTDIR . "/themes/admin_default/system";
  47. $global_config['admin_theme'] = "admin_default";
  48. }
  49. }
  50. else
  51. {
  52. $file_name_tpl = "content.tpl";
  53. if ( file_exists( NV_ROOTDIR . "/themes/" . $global_config['admin_theme'] . "/system/" . $file_name_tpl ) )
  54. {
  55. $dir_template = NV_ROOTDIR . "/themes/" . $global_config['admin_theme'] . "/system";
  56. }
  57. else
  58. {
  59. $dir_template = NV_ROOTDIR . "/themes/admin_default/system";
  60. $global_config['admin_theme'] = "admin_default";
  61. }
  62. }
  63. $global_config['site_name'] = empty( $global_config['site_name'] ) ? NV_SERVER_NAME : $global_config['site_name'];
  64. $xtpl = new XTemplate( $file_name_tpl, $dir_template );
  65. $xtpl->assign( 'NV_SITE_COPYRIGHT', "" . $global_config['site_name'] . " [" . $global_config['site_email'] . "] " );
  66. $xtpl->assign( 'NV_SITE_NAME', $global_config['site_name'] );
  67. $xtpl->assign( 'NV_SITE_TITLE', "" . $global_config['site_name'] . " " . NV_TITLEBAR_DEFIS . " " . $lang_global['admin_page'] . " " . NV_TITLEBAR_DEFIS . " " . $module_info['custom_title'] . "" );
  68. $xtpl->assign( 'NV_ADMIN_CHECK_PASS_TIME', NV_ADMIN_CHECK_PASS_TIME );
  69. $xtpl->assign( 'NV_BASE_SITEURL', NV_BASE_SITEURL );
  70. $xtpl->assign( 'NV_ADMINDIR', NV_ADMINDIR );
  71. $xtpl->assign( 'NV_BASE_ADMINURL', NV_BASE_ADMINURL );
  72. $xtpl->assign( 'MODULE_NAME', $module_name );
  73. $xtpl->assign( 'MODULE_FILE', $module_file );
  74. $xtpl->assign( 'NV_ADMIN_THEME', $global_config['admin_theme'] );
  75. if ( file_exists( NV_ROOTDIR . "/themes/" . $global_config['admin_theme'] . "/css/" . $module_file . ".css" ) )
  76. {
  77. $xtpl->assign( 'NV_CSS_MODULE_THEME', NV_BASE_SITEURL . "themes/" . $global_config['admin_theme'] . "/css/" . $module_file . ".css" );
  78. $xtpl->parse( 'main.css_module' );
  79. }
  80. elseif ( file_exists( NV_ROOTDIR . "/themes/admin_default/css/" . $module_file . ".css" ) )
  81. {
  82. $xtpl->assign( 'NV_CSS_MODULE_THEME', NV_BASE_SITEURL . "themes/admin_default/css/" . $module_file . ".css" );
  83. $xtpl->parse( 'main.css_module' );
  84. }
  85. $xtpl->assign( 'NV_LANG_VARIABLE', NV_LANG_VARIABLE );
  86. $xtpl->assign( 'NV_LANG_INTERFACE', NV_LANG_INTERFACE );
  87. $xtpl->assign( 'NV_NAME_VARIABLE', NV_NAME_VARIABLE );
  88. $xtpl->assign( 'NV_OP_VARIABLE', NV_OP_VARIABLE );
  89. $xtpl->assign( 'NV_LANG_VARIABLE', NV_LANG_VARIABLE );
  90. $xtpl->assign( 'NV_SITE_TIMEZONE_OFFSET', round( NV_SITE_TIMEZONE_OFFSET / 3600 ) );
  91. $xtpl->assign( 'NV_CURRENTTIME', nv_date( "T", NV_CURRENTTIME ) );
  92. $xtpl->assign( 'NV_COOKIE_PREFIX', $global_config['cookie_prefix'] );
  93. if ( file_exists( NV_ROOTDIR . "/js/admin_" . $module_file . ".js" ) )
  94. {
  95. $xtpl->assign( 'NV_JS_MODULE', NV_BASE_SITEURL . "js/admin_" . $module_file . ".js" );
  96. $xtpl->parse( 'main.module_js' );
  97. }
  98. elseif ( file_exists( NV_ROOTDIR . "/modules/" . $module_file . "/js/admin.js" ) )
  99. {
  100. $xtpl->assign( 'NV_JS_MODULE', NV_BASE_SITEURL . "modules/" . $module_file . "/js/admin.js" );
  101. $xtpl->parse( 'main.module_js' );
  102. }
  103. if ( defined( 'NV_EDITOR' ) and nv_function_exists( 'nv_add_editor_js' ) )
  104. {
  105. $xtpl->assign( 'NV_ADD_EDITOR_JS', nv_add_editor_js() );
  106. $xtpl->parse( 'main.nv_add_editor_js' );
  107. }
  108. if ( ! empty( $my_head ) )
  109. {
  110. $xtpl->assign( 'NV_ADD_MY_HEAD', $my_head );
  111. $xtpl->parse( 'main.nv_add_my_head' );
  112. }
  113. if ( $head_site == 1 )
  114. {
  115. $xtpl->assign( 'NV_GO_CLIENTSECTOR', $lang_global['go_clientsector'] );
  116. $lang_site = ( ! empty( $site_mods ) ) ? NV_LANG_DATA : $global_config['site_lang'];
  117. $xtpl->assign( 'NV_GO_CLIENTSECTOR_URL', NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . $lang_site );
  118. $xtpl->assign( 'NV_LOGOUT', $lang_global['logout'] );
  119. if ( ! empty( $array_lang_admin ) )
  120. {
  121. $xtpl->assign( 'NV_LANGDATA', $lang_global['langdata'] );
  122. foreach ( $array_lang_admin as $lang_i => $lang_name )
  123. {
  124. $xtpl->assign( 'SELECTED', ( $lang_i == NV_LANG_DATA ) ? " selected=\"selected\"" : "" );
  125. $xtpl->assign( 'LANGVALUE', $lang_name );
  126. $xtpl->assign( 'LANGOP', NV_BASE_ADMINURL . "index.php?" . NV_LANG_VARIABLE . "=" . $lang_i );
  127. $xtpl->parse( 'main.langdata.option' );
  128. }
  129. $xtpl->parse( 'main.langdata' );
  130. }
  131. //Top_menu
  132. foreach ( $admin_mods as $m => $v )
  133. {
  134. if ( ! empty( $v['custom_title'] ) )
  135. {
  136. $xtpl->assign( 'TOP_MENU_CURRENT', ( ( $module_name == $m ) ? " class=\"current\"" : "" ) );
  137. $xtpl->assign( 'TOP_MENU_HREF', $m );
  138. $xtpl->assign( 'TOP_MENU_NAME', $v['custom_title'] );
  139. $array_submenu = nv_get_submenu( $m );
  140. if ( ! empty( $array_submenu ) )
  141. {
  142. foreach ( $array_submenu as $mop => $submenu_i )
  143. {
  144. $xtpl->assign( 'SUBMENULINK', NV_BASE_ADMINURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=" . $m . "&amp;" . NV_OP_VARIABLE . "=" . $mop );
  145. $xtpl->assign( 'SUBMENUTITLE', $submenu_i );
  146. $xtpl->parse( 'main.top_menu.top_menu_loop.submenu.submenu_loop' );
  147. }
  148. $xtpl->parse( 'main.top_menu.top_menu_loop.submenu' );
  149. }
  150. $xtpl->parse( 'main.top_menu.top_menu_loop' );
  151. }
  152. }
  153. $xtpl->parse( 'main.top_menu' );
  154. $xtpl->assign( 'NV_DIGCLOCK', nv_date( "H:i T l, d/m/Y", NV_CURRENTTIME ) );
  155. if ( $admin_info['current_login'] >= NV_CURRENTTIME - 60 )
  156. {
  157. if ( ! empty( $admin_info['last_login'] ) )
  158. {
  159. $temp = sprintf( $lang_global['hello_admin1'], "<strong>" . $admin_info['username'] . "</strong>", date( "H:i d/m/Y", $admin_info['last_login'] ), $admin_info['last_ip'] );
  160. $xtpl->assign( 'HELLO_ADMIN1', $temp );
  161. $xtpl->parse( 'main.hello_admin' );
  162. }
  163. else
  164. {
  165. $temp = sprintf( $lang_global['hello_admin3'], "<strong>" . $admin_info['username'] . "</strong>" );
  166. $xtpl->assign( 'HELLO_ADMIN3', $temp );
  167. $xtpl->parse( 'main.hello_admin3' );
  168. }
  169. }
  170. else
  171. {
  172. $temp = sprintf( $lang_global['hello_admin2'], "<strong>" . $admin_info['username'] . "</strong>", nv_convertfromSec( NV_CURRENTTIME - $admin_info['current_login'] ), $admin_info['current_ip'] );
  173. $xtpl->assign( 'HELLO_ADMIN2', $temp );
  174. $xtpl->parse( 'main.hello_admin2' );
  175. }
  176. if ( ! empty( $admin_menu_mods ) )
  177. {
  178. //Vertical menu
  179. foreach ( $admin_menu_mods as $m => $v )
  180. {
  181. $xtpl->assign( 'VERTICAL_MENU_CURRENT', ( ( $module_name == $m ) ? "class=\"current\"" : "" ) );
  182. $xtpl->assign( 'VERTICAL_MENU_HREF', $m );
  183. $xtpl->assign( 'VERTICAL_MENU_NAME', $v );
  184. if ( $m == $module_name and ! empty( $submenu ) )
  185. {
  186. foreach ( $submenu as $n => $l )
  187. {
  188. $xtpl->assign( 'VERTICAL_MENU_SUB_CURRENT', ( ( ( ! empty( $op ) and $op == $n ) or ( ! empty( $set_active_op ) and $set_active_op == $n ) ) ? " class=\"sub_current\"" : " class=\"sub_normal\"" ) );
  189. $xtpl->assign( 'VERTICAL_MENU_SUB_HREF', $m );
  190. $xtpl->assign( 'VERTICAL_MENU_SUB_HREF1', $n );
  191. $xtpl->assign( 'VERTICAL_MENU_SUB_NAME', $l );
  192. $xtpl->parse( 'main.vertical_menu.vertical_menu_loop.vertical_menu_sub_loop' );
  193. }
  194. }
  195. $xtpl->parse( 'main.vertical_menu.vertical_menu_loop' );
  196. }
  197. $xtpl->parse( 'main.vertical_menu' );
  198. }
  199. }
  200. if ( ! empty( $select_options ) )
  201. {
  202. $xtpl->assign( 'PLEASE_SELECT', $lang_global['please_select'] );
  203. foreach ( $select_options as $value => $link )
  204. {
  205. $xtpl->assign( 'SELECT_NAME', $link );
  206. $xtpl->assign( 'SELECT_VALUE', $value );
  207. $xtpl->parse( 'main.select_option.select_option_loop' );
  208. }
  209. $xtpl->parse( 'main.select_option' );
  210. }
  211. elseif ( ! isset( $admin_mods[$module_name] ) and isset( $site_mods[$module_name] ) )
  212. {
  213. $xtpl->assign( 'NV_GO_CLIENTMOD', $lang_global['go_clientmod'] );
  214. $xtpl->parse( 'main.site_mods' );
  215. }
  216. if ( ! empty( $page_title ) )
  217. {
  218. $xtpl->assign( 'PAGE_TITLE', $page_title );
  219. $xtpl->parse( 'main.empty_page_title' );
  220. }
  221. $xtpl->assign( 'THEME_ERROR_INFO', nv_error_info() );
  222. $xtpl->assign( 'MODULE_CONTENT', $contents );
  223. $end_time = array_sum( explode( " ", microtime() ) );
  224. $total_time = substr( ( $end_time - NV_START_TIME + $db->time ), 0, 5 );
  225. $xtpl->assign( 'NV_TOTAL_TIME', substr( ( $end_time - NV_START_TIME + $db->time ), 0, 5 ) );
  226. if ( defined( "NV_IS_SPADMIN" ) )
  227. {
  228. $xtpl->assign( 'NV_SHOW_QUERIES', $lang_global['show_queries'] );
  229. }
  230. $xtpl->assign( 'NV_DB_NUM_QUERIES', $lang_global['db_num_queries'] );
  231. $xtpl->assign( 'COUNT_QUERY_STRS', count( $db->query_strs ) );
  232. $xtpl->assign( 'NV_COPYRIGHT', sprintf( $lang_global['copyright'], $global_config['site_name'] ) );
  233. if ( defined( "NV_IS_SPADMIN" ) )
  234. {
  235. foreach ( $db->query_strs as $key => $field )
  236. {
  237. $xtpl->assign( 'NV_SHOW_QUERIES_CLASS', ( $key % 2 ) ? " class=\"second\"" : "" );
  238. $xtpl->assign( 'NV_FIELD1', ( $field[1] ? "<img alt=\"" . $lang_global['ok'] . "\" title=\"" . $lang_global['ok'] . "\" src=\"" . NV_BASE_SITEURL . "themes/" . $global_config['admin_theme'] . "/images/icons/good.png\" />" : "<img alt=\"" . $lang_global['fail'] . "\" title=\"" . $lang_global['fail'] . "\" src=\"" . NV_BASE_SITEURL . "themes/" . $global_config['admin_theme'] . "/images/icons/bad.png\" />" ) );
  239. $xtpl->assign( 'NV_FIELD', $field[0] );
  240. $xtpl->parse( 'main.nv_show_queries.nv_show_queries_loop' );
  241. }
  242. $xtpl->parse( 'main.nv_show_queries' );
  243. }
  244. if ( NV_LANG_INTERFACE == 'vi' and NV_LANG_DATA == 'vi' )
  245. {
  246. $xtpl->parse( 'main.nv_if_mudim' );
  247. }
  248. $xtpl->assign( 'NV_GENPASS', nv_genpass() );
  249. $xtpl->parse( 'main' );
  250. return $xtpl->text( 'main' );
  251. }
  252. ?>