<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Member\Config; use Illuminate\Support\Str; class MemberMenu { private static $menu = array(); public static function register($jSsIt) { self::$menu[] = $jSsIt; } public static function get() { goto ILRR3; DbpAc: foreach (self::$menu as $YaV4m) { if ($YaV4m instanceof \Closure) { $YaV4m = call_user_func($YaV4m); } $jSsIt = array_merge($jSsIt, $YaV4m); } goto Koo2R; Koo2R: $jSsIt = self::mergeMenu($jSsIt); goto J7XEN; J7XEN: return $jSsIt; goto WEhx_; ILRR3: $jSsIt = array(); goto DbpAc; WEhx_: } private static function sort() { static $pPq0i = 1000; return $pPq0i++; } private static function mergeMenu($jSsIt, $aeXlE = '', $tU4nB = 1, $mHisM = null) { goto KQu1I; Xc2pz: if ($tU4nB == 1) { uasort($yyjth, function ($aVDlj, $jyPL0) { return $aVDlj['sort'] - $jyPL0['sort']; }); return self::mergeMenuTree($yyjth); } goto mdr1W; mdr1W: return $yyjth; goto azBd5; KQu1I: if (empty($jSsIt)) { return array(); } goto SY3m9; SY3m9: $yyjth = array(); goto VRBd6; VRBd6: foreach ($jSsIt as $YaV4m) { goto I_lS2; lkLbU: if (isset($YaV4m['icon'])) { if (preg_match('/^[a-zA-Z0-9\\-]+$/', $YaV4m['icon'])) { $YaV4m['icon'] = "<i class='icon iconfont icon-{$YaV4m['icon']}'></i>"; } } goto SARKD; YSqJo: if (1 == $tU4nB) { $KAKiA = $aeXlE . $YaV4m['title'] . '^' . $YaV4m['icon'] . '^' . $YaV4m['sort']; } else { $KAKiA = $aeXlE . $YaV4m['title']; } goto lkLbU; SARKD: if (!isset($yyjth[$KAKiA])) { $yyjth[$KAKiA] = $YaV4m; } goto r5WoF; ZJ2fI: if ($mHisM) { if (!call_user_func($mHisM, $YaV4m)) { continue; } } goto oMG_m; I_lS2: if (empty($YaV4m)) { continue; } goto ZJ2fI; YVzuU: if (!empty($YaV4m['children'])) { $yyjth = array_merge($yyjth, self::mergeMenu($YaV4m['children'], $KAKiA . '^^', $tU4nB + 1, $mHisM)); } goto aHTtY; oMG_m: if (!isset($YaV4m['sort'])) { $YaV4m['sort'] = self::sort(); } goto YSqJo; r5WoF: unset($yyjth[$KAKiA]['children']); goto YVzuU; aHTtY: } goto Xc2pz; azBd5: } private static function mergeMenuTree($Jomtk, $aeXlE = '') { goto KMmWB; KMmWB: $g8_Ju = array(); goto yhDPF; GHgYt: return $g8_Ju; goto Gv10Z; yhDPF: foreach ($Jomtk as $KAKiA => $Iim2u) { goto U5SXz; qhYkN: if (empty($YaV4m['children'])) { unset($YaV4m['children']); } goto Jf2R0; U5SXz: if ($KAKiA === $aeXlE) { continue; } goto EXQe1; YTTpn: $g8_Ju[] = $YaV4m; goto jnjoB; X34Yk: $YaV4m = $Iim2u; goto CnOxw; EXQe1: $w9KQq = explode('^^', $KAKiA); goto HRcFR; CnOxw: $YaV4m['children'] = self::mergeMenuTree($Jomtk, $KAKiA . '^^'); goto qhYkN; Jf2R0: if (empty($YaV4m['children']) && empty($YaV4m['url'])) { continue; } goto YTTpn; HRcFR: if ($aeXlE) { if (!Str::startsWith($KAKiA, $aeXlE)) { continue; } if (count(explode('^^', $aeXlE)) !== count(explode('^^', $KAKiA))) { continue; } } else { if (1 != count($w9KQq)) { continue; } } goto X34Yk; jnjoB: } goto GHgYt; Gv10Z: } }