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

https://gitlab.com/phamngsinh/baitaplon_sinhvien · PHP · 197 lines · 178 code · 13 blank · 6 comment · 25 complexity · 00118f51605290a43b54dec75e918b0d 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_smooth_navigational_menu' ) )
  10. {
  11. function nv_html_sub_menu_mod_users ( $modvalues )
  12. {
  13. if ( defined( 'NV_IS_USER' ) )
  14. {
  15. $in_submenu_users = array();
  16. $in_submenu_users[] = "changepass";
  17. if ( defined( 'NV_OPENID_ALLOWED' ) )
  18. {
  19. $in_submenu_users[] = "openid";
  20. }
  21. if ( ! defined( 'NV_IS_ADMIN' ) )
  22. {
  23. $in_submenu_users[] = "logout";
  24. }
  25. }
  26. else
  27. {
  28. $in_submenu_users = array(
  29. "login", "register", "lostpass"
  30. );
  31. }
  32. $html = "<ul>\n";
  33. foreach ( $modvalues['funcs'] as $key => $sub_item )
  34. {
  35. if ( $sub_item['in_submenu'] == 1 and in_array( $key, $in_submenu_users ) )
  36. {
  37. $html .= "<li><a title=\"" . $sub_item['func_custom_name'] . "\" href=\"" . NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=users&amp;" . NV_OP_VARIABLE . "=" . $key . "\">" . $sub_item['func_custom_name'] . "</a></li>\n";
  38. }
  39. }
  40. $html .= "</ul>\n";
  41. return $html;
  42. }
  43. function nv_submenu_html_item ( $module_array_cat, $parentid = 0 )
  44. {
  45. $array_item = array();
  46. foreach ( $module_array_cat as $cat )
  47. {
  48. if ( $cat['parentid'] == $parentid )
  49. {
  50. $array_item[] = array(
  51. 'catid' => $cat['catid'], 'title' => $cat['title'], 'link' => $cat['link']
  52. );
  53. }
  54. }
  55. if ( ! empty( $array_item ) )
  56. {
  57. $html = "<ul>\n";
  58. foreach ( $array_item as $cat )
  59. {
  60. $html .= "<li>\n";
  61. $html .= "<a title=\"" . $cat['title'] . "\" href=\"" . $cat['link'] . "\">" . $cat['title'] . "</a>\n";
  62. $html .= nv_submenu_html_item( $module_array_cat, $cat['catid'] );
  63. $html .= "</li>\n";
  64. }
  65. $html .= "</ul>\n";
  66. return $html;
  67. }
  68. return "";
  69. }
  70. function nv_smooth_navigational_menu ( $block_config )
  71. {
  72. global $db, $db_config, $global_config, $site_mods, $module_info, $module_name, $module_file, $module_data, $lang_global, $catid;
  73. if ( file_exists( NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/modules/menu/smooth_navigational_menu.tpl" ) )
  74. {
  75. $block_theme = $global_config['module_theme'];
  76. }
  77. elseif ( file_exists( NV_ROOTDIR . "/themes/" . $global_config['site_theme'] . "/modules/menu/smooth_navigational_menu.tpl" ) )
  78. {
  79. $block_theme = $global_config['site_theme'];
  80. }
  81. else
  82. {
  83. $block_theme = "default";
  84. }
  85. $xtpl = new XTemplate( "smooth_navigational_menu.tpl", NV_ROOTDIR . "/themes/" . $block_theme . "/modules/menu" );
  86. $xtpl->assign( 'LANG', $lang_global );
  87. $xtpl->assign( 'NV_BASE_SITEURL', NV_BASE_SITEURL );
  88. $xtpl->assign( 'BLOCK_THEME', $block_theme );
  89. $xtpl->assign( 'THEME_SITE_HREF', NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA );
  90. $xtpl->assign( 'THEME_RSS_INDEX_HREF', NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=rss" );
  91. foreach ( $site_mods as $modname => $modvalues )
  92. {
  93. if ( ! empty( $modvalues['in_menu'] ) )
  94. {
  95. $module_current = ( $modname == $module_name ) ? ' class="current"' : '';
  96. $array_menu = array(
  97. "title" => $modvalues['custom_title'], "class" => $modname, "current" => $module_current, "link" => NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=" . $modname, "submenu" => ""
  98. );
  99. $mod_file = $modvalues['module_file'];
  100. $array_m_html_item = array(
  101. 'news', 'shops', 'weblinks', 'download'
  102. );
  103. if ( in_array( $mod_file, $array_m_html_item ) )
  104. {
  105. if ( $mod_file == "shops" )
  106. {
  107. $sql = "SELECT `catid`, `parentid`, `" . NV_LANG_DATA . "_title` as title, `" . NV_LANG_DATA . "_alias` as alias FROM `" . NV_PREFIXLANG . "_" . $modvalues['module_data'] . "_cat` ORDER BY `order` ASC";
  108. }
  109. elseif ( $mod_file == "download" )
  110. {
  111. $sql = "SELECT `id` as catid, `parentid`, `title`, `alias` FROM `" . NV_PREFIXLANG . "_" . $modvalues['module_data'] . "_categories` ORDER BY `parentid` ASC, `weight` ASC";
  112. }
  113. elseif ( $mod_file == "weblinks" )
  114. {
  115. $sql = "SELECT `catid`, `parentid`, `title`, `alias` FROM `" . NV_PREFIXLANG . "_" . $modvalues['module_data'] . "_cat` ORDER BY `parentid` ASC, `weight` ASC";
  116. }
  117. else
  118. {
  119. $sql = "SELECT `catid`, `parentid`, `title`, `alias` FROM `" . NV_PREFIXLANG . "_" . $modvalues['module_data'] . "_cat` ORDER BY `order` ASC";
  120. }
  121. $list = nv_db_cache( $sql, 'catid', $modname );
  122. $module_array_cat = array();
  123. foreach ( $list as $l )
  124. {
  125. $module_array_cat[$l['catid']] = $l;
  126. $module_array_cat[$l['catid']]['link'] = NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=" . $modname . "&amp;" . NV_OP_VARIABLE . "=" . $l['alias'];
  127. }
  128. $array_menu['submenu'] = nv_submenu_html_item( $module_array_cat );
  129. }
  130. elseif ( $mod_file == "users" )
  131. {
  132. $array_menu['submenu'] = nv_html_sub_menu_mod_users( $modvalues );
  133. }
  134. elseif ( $mod_file == "message" )
  135. {
  136. if ( defined( 'NV_IS_USER' ) )
  137. {
  138. $sub_mess = array();
  139. $sub_mess[0] = array(
  140. 'catid' => 1,
  141. 'parentid' => 0,
  142. 'title' => $lang_global['your_account'],
  143. 'alias' => "",
  144. 'link' => NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=" . $modname . "&amp;" . NV_OP_VARIABLE . "=config"
  145. );
  146. $array_menu['submenu'] = nv_submenu_html_item( $sub_mess );
  147. }
  148. }
  149. else
  150. {
  151. $sub_nav_item = array();
  152. foreach ( $modvalues['funcs'] as $key => $sub_item )
  153. {
  154. if ( $sub_item['in_submenu'] == 1 )
  155. {
  156. $sub_nav_item[] = array(
  157. "title" => $sub_item['func_custom_name'], "link" => NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=" . $modname . "&amp;" . NV_OP_VARIABLE . "=" . $key
  158. );
  159. }
  160. }
  161. if ( ! empty( $sub_nav_item ) )
  162. {
  163. $array_menu['submenu'] = "<ul>\n";
  164. foreach ( $sub_nav_item as $item )
  165. {
  166. $array_menu['submenu'] .= "<li><a title=\"" . $item['title'] . "\" href=\"" . $item['link'] . "\">" . $item['title'] . "</a></li>\n";
  167. }
  168. $array_menu['submenu'] .= "</ul>\n";
  169. }
  170. }
  171. $xtpl->assign( 'TOP_MENU', $array_menu );
  172. $xtpl->parse( 'main.top_menu' );
  173. }
  174. }
  175. $xtpl->parse( 'main.news_cat' );
  176. $xtpl->parse( 'main' );
  177. return $xtpl->text( 'main' );
  178. }
  179. }
  180. if ( defined( 'NV_SYSTEM' ) )
  181. {
  182. $content = nv_smooth_navigational_menu( $block_config );
  183. }
  184. ?>