国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
3.0KB

  1. <?php
  2. /**
  3. * 管理菜单函数
  4. *
  5. * @version $id:inc_menu_func.php 10:32 2010年7月21日 tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2022 DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(dirname(__FILE__)."/../config.php");
  12. require_once(DEDEINC."/dedetag.class.php");
  13. $headTemplet = '<li><div class="link"><i class="fa ~icon~"></i>~channelname~<i class="fa fa-angle-down"></i></div><ul class="submenu">';
  14. $footTemplet = "</ul></li>";
  15. $itemTemplet = "<li>~link~</li>";
  16. function GetMenus($userrank, $topos = 'main')
  17. {
  18. global $openitem, $headTemplet, $footTemplet, $itemTemplet;
  19. if ($topos == 'main') {
  20. $openitem = (empty($openitem) ? 1 : $openitem);
  21. $menus = $GLOBALS['menusMain'];
  22. } else if ($topos == 'module') {
  23. $openitem = 100;
  24. $menus = $GLOBALS['menusMoudle'];
  25. }
  26. $dtp = new DedeTagParse();
  27. $dtp->SetNameSpace('m', '<', '>');
  28. $dtp->LoadSource($menus);
  29. $dtp2 = new DedeTagParse();
  30. $dtp2->SetNameSpace('m', '<', '>');
  31. foreach ($dtp->CTags as $i => $ctag) {
  32. if ($ctag->GetName() == 'top' && ($ctag->GetAtt('rank') == '' || TestPurview($ctag->GetAtt('rank')))) {
  33. if ($openitem != 999 && !preg_match("#".$openitem.'_'."#", $ctag->GetAtt('item')) && $openitem != 100) continue;
  34. $htmp = str_replace("~channelname~", $ctag->GetAtt("name"), $headTemplet);
  35. $icon = 'fa-desktop';
  36. if ($ctag->GetAtt('icon') != '') {
  37. $icon = $ctag->GetAtt('icon');
  38. }
  39. $htmp = str_replace('~icon~', $icon, $htmp);
  40. echo $htmp;
  41. $dtp2->LoadSource($ctag->InnerText);
  42. foreach ($dtp2->CTags as $j => $ctag2) {
  43. $ischannel = trim($ctag2->GetAtt('ischannel'));
  44. if ($ctag2->GetName() == 'item' && ($ctag2->GetAtt('rank') == '' || TestPurview($ctag2->GetAtt('rank')))) {
  45. $link = "<a href='".$ctag2->GetAtt('link')."' target='".$ctag2->GetAtt('target')."'>".$ctag2->GetAtt('name')."</a>";
  46. if ($ischannel == '1') {
  47. if ($ctag2->GetAtt('addico') != '') {
  48. $addico = $ctag2->GetAtt('addico');
  49. } else {
  50. $addico = 'fa-plus-circle';
  51. }
  52. $addalt = $ctag2->GetAtt('addalt');
  53. $link = "$link<a href='".$ctag2->GetAtt('linkadd')."' class='submenu-right' target='".$ctag2->GetAtt('target')."'><span class='fa $addico' title='$addalt'></span></a>";
  54. } else {
  55. $link .= "";
  56. }
  57. $itemtmp = str_replace('~link~', $link, $itemTemplet);
  58. echo $itemtmp;
  59. }
  60. }
  61. echo $footTemplet;
  62. }
  63. }
  64. }//End Function
  65. ?>