PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/Quản lý website trường trung học phổ thông PHP/lc1/modules/menu/blocks/global.menu_theme_modern.php

https://gitlab.com/phamngsinh/baitaplon_sinhvien
PHP | 204 lines | 185 code | 12 blank | 7 comment | 41 complexity | 5d652084188e19c3eab49110acf0ba91 MD5 | raw file
  1. <?php
  2. /**
  3. * @Project NUKEVIET 3.0
  4. * @Author VINADES., JSC (contact@vinades.vn)
  5. * @Copyright (C) 2011 VINADES ., JSC. All rights reserved
  6. * @Createdate Jan 17, 2011 11:34:27 AM
  7. */
  8. if ( ! defined( 'NV_MAINFILE' ) ) die( 'Stop!!!' );
  9. if ( ! nv_function_exists( 'nv_menu_theme_modern' ) )
  10. {
  11. function nv_menu_theme_modern ( $block_config )
  12. {
  13. global $db, $db_config, $global_config, $site_mods, $module_info, $module_name, $module_file, $module_data, $op, $lang_module, $catid, $lang_global;
  14. if ( file_exists( NV_ROOTDIR . "/themes/" . $global_config['site_theme'] . "/modules/menu/menu_theme_modern.tpl" ) )
  15. {
  16. $block_theme = $global_config['site_theme'];
  17. }
  18. else
  19. {
  20. $block_theme = "default";
  21. }
  22. $xtpl = new XTemplate( "menu_theme_modern.tpl", NV_ROOTDIR . "/themes/" . $block_theme . "/modules/menu" );
  23. $xtpl->assign( 'LANG', $lang_module );
  24. $xtpl->assign( 'NV_BASE_SITEURL', NV_BASE_SITEURL );
  25. $xtpl->assign( 'BLOCK_THEME', $block_theme );
  26. $catid = empty( $catid ) ? 1 : $catid;
  27. $array_cat_menu = array();
  28. if ( $module_name == 'users' )
  29. {
  30. if ( defined( 'NV_IS_USER' ) )
  31. {
  32. $in_submenu_users = array();
  33. $in_submenu_users[] = "changepass";
  34. if ( defined( 'NV_OPENID_ALLOWED' ) )
  35. {
  36. $in_submenu_users[] = "openid";
  37. }
  38. if ( ! defined( 'NV_IS_ADMIN' ) )
  39. {
  40. $in_submenu_users[] = "logout";
  41. }
  42. }
  43. else
  44. {
  45. $in_submenu_users = array(
  46. "login", "register", "lostpass"
  47. );
  48. }
  49. $modvalues = $site_mods['users'];
  50. $array_cat_menu[] = array(
  51. "catid" => 1, "parentid" => 0, "title" => $modvalues['custom_title'], "alias" => '', "link" => "" . NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=users"
  52. );
  53. foreach ( $modvalues['funcs'] as $key => $sub_item )
  54. {
  55. if ( $sub_item['in_submenu'] == 1 and in_array( $key, $in_submenu_users ) )
  56. {
  57. $array_cat_menu[] = array(
  58. "catid" => 1, "parentid" => 1, "title" => $sub_item['func_custom_name'], "alias" => '', "link" => "" . NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=users&amp;" . NV_OP_VARIABLE . "=" . $key
  59. );
  60. }
  61. }
  62. }
  63. elseif ( $module_file == "news" )
  64. {
  65. $sql = "SELECT catid, parentid, title, alias FROM `" . NV_PREFIXLANG . "_" . $module_data . "_cat` ORDER BY `order` ASC";
  66. $result = $db->sql_query( $sql );
  67. while ( list( $catid_i, $parentid_i, $title_i, $alias_i ) = $db->sql_fetchrow( $result ) )
  68. {
  69. $link_i = NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=" . $alias_i;
  70. $array_cat_menu[$catid_i] = array(
  71. "catid" => $catid_i, "parentid" => $parentid_i, "title" => $title_i, "alias" => $alias_i, "link" => $link_i
  72. );
  73. }
  74. }
  75. elseif ( $module_file == "shops" )
  76. {
  77. $sql = "SELECT catid, parentid, " . NV_LANG_DATA . "_title, " . NV_LANG_DATA . "_alias FROM `" . $db_config['prefix'] . "_" . $module_data . "_catalogs` ORDER BY `order` ASC";
  78. $result = $db->sql_query( $sql );
  79. while ( list( $catid_i, $parentid_i, $title_i, $alias_i ) = $db->sql_fetchrow( $result ) )
  80. {
  81. $link_i = NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=" . $alias_i;
  82. $array_cat_menu[$catid_i] = array(
  83. "catid" => $catid_i, "parentid" => $parentid_i, "title" => $title_i, "alias" => $alias_i, "link" => $link_i
  84. );
  85. }
  86. }
  87. elseif ( $module_file == "message" )
  88. {
  89. if ( defined( 'NV_IS_USER' ) )
  90. {
  91. $array_cat_menu[1] = array(
  92. 'catid' => 1,
  93. 'parentid' => 0,
  94. 'title' => $lang_global['your_account'],
  95. 'alias' => "",
  96. 'link' => NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=config"
  97. );
  98. }
  99. }
  100. elseif ( $module_file == "weblinks" )
  101. {
  102. $sql = "SELECT catid, parentid, title, alias FROM `" . NV_PREFIXLANG . "_" . $module_data . "_cat` ORDER BY `parentid` ASC, `weight` ASC";
  103. $result = $db->sql_query( $sql );
  104. while ( list( $catid_i, $parentid_i, $title_i, $alias_i ) = $db->sql_fetchrow( $result ) )
  105. {
  106. $link_i = NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=" . $alias_i;
  107. $array_cat_menu[$catid_i] = array(
  108. "catid" => $catid_i, "parentid" => $parentid_i, "title" => $title_i, "alias" => $alias_i, "link" => $link_i
  109. );
  110. }
  111. }
  112. elseif ( $module_file == "download" )
  113. {
  114. $sql = "SELECT id, parentid, title, alias FROM `" . NV_PREFIXLANG . "_" . $module_data . "_categories` ORDER BY `weight` ASC";
  115. $result = $db->sql_query( $sql );
  116. while ( list( $catid_i, $parentid_i, $title_i, $alias_i ) = $db->sql_fetchrow( $result ) )
  117. {
  118. $link_i = NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=" . $alias_i;
  119. $array_cat_menu[$catid_i] = array(
  120. "catid" => $catid_i, "parentid" => $parentid_i, "title" => $title_i, "alias" => $alias_i, "link" => $link_i
  121. );
  122. }
  123. }
  124. else
  125. {
  126. foreach ( $module_info['funcs'] as $key => $sub_item )
  127. {
  128. if ( $sub_item['in_submenu'] == 1 )
  129. {
  130. $array_cat_menu[] = array(
  131. "catid" => ( $op == $key ) ? 1 : 0, "parentid" => 1, "title" => $sub_item['func_custom_name'], "alias" => '', "link" => "" . NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=" . $key
  132. );
  133. }
  134. }
  135. if ( ! empty( $array_cat_menu ) )
  136. {
  137. $array_cat_menu[] = array(
  138. "catid" => 1, "parentid" => 0, "title" => $module_info['custom_title'], "alias" => '', "link" => "" . NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=" . $module_name
  139. );
  140. }
  141. }
  142. if ( $module_name != "news" and empty( $array_cat_menu ) )
  143. {
  144. $sql = "SELECT catid, parentid, title, alias FROM `" . NV_PREFIXLANG . "_news_cat` ORDER BY `order` ASC";
  145. $result = $db->sql_query( $sql );
  146. while ( list( $catid_i, $parentid_i, $title_i, $alias_i ) = $db->sql_fetchrow( $result ) )
  147. {
  148. $link_i = NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=news&amp;" . NV_OP_VARIABLE . "=" . $alias_i;
  149. $array_cat_menu[$catid_i] = array(
  150. "catid" => $catid_i, "parentid" => $parentid_i, "title" => $title_i, "alias" => $alias_i, "link" => $link_i
  151. );
  152. }
  153. }
  154. # process cat module
  155. $i = 1;
  156. foreach ( $array_cat_menu as $catvalue )
  157. {
  158. if ( ! empty( $catvalue['catid'] ) && empty( $catvalue['parentid'] ) )
  159. {
  160. if ( ( $catvalue['catid'] == $catid ) || ( $array_cat_menu[$catid]['parentid'] == $catvalue['catid'] ) || ( empty( $catid ) && $i == 1 ) )
  161. {
  162. $catvalue['current'] = ( $i == 1 ) ? 'class="current first"' : 'class="current"';
  163. $i = 0;
  164. }
  165. $xtpl->assign( 'mainloop', $catvalue );
  166. foreach ( $array_cat_menu as $subcatvalue )
  167. {
  168. if ( $subcatvalue['parentid'] == $catvalue['catid'] )
  169. {
  170. $subcatvalue['current'] = ( $subcatvalue['catid'] == $catid ) ? 'class="current"' : '';
  171. $xtpl->assign( 'loop', $subcatvalue );
  172. $xtpl->parse( 'main.news_cat.mainloop.sub.loop' );
  173. }
  174. else
  175. {
  176. $xtpl->parse( 'main.news_cat.mainloop.sub.null' );
  177. }
  178. }
  179. $xtpl->parse( 'main.news_cat.mainloop.sub' );
  180. $xtpl->parse( 'main.news_cat.mainloop' );
  181. }
  182. }
  183. $xtpl->parse( 'main.news_cat' );
  184. $xtpl->parse( 'main' );
  185. return $xtpl->text( 'main' );
  186. }
  187. }
  188. if ( defined( 'NV_SYSTEM' ) )
  189. {
  190. $content = nv_menu_theme_modern( $block_config );
  191. }
  192. ?>