<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Support\Manager; use ModStart\Widget\AbstractWidget; class WidgetManager { private static $availableWidgets = array(); private static $collectedAssets = null; private static $uses = array(); public static function uses($fUMA5) { if (is_array($fUMA5)) { foreach ($fUMA5 as $PlI87) { self::$uses[$PlI87] = true; } } else { self::$uses[$fUMA5] = true; } } public static function registerBuiltinWidgets() { $yNqI3 = array('statusText' => \ModStart\Widget\StatusText::class, 'textAjaxRequest' => \ModStart\Widget\TextAjaxRequest::class, 'textDialogRequest' => \ModStart\Widget\TextDialogRequest::class, 'textAction' => \ModStart\Widget\TextAction::class, 'textLink' => \ModStart\Widget\TextLink::class, 'buttonAjaxRequest' => \ModStart\Widget\ButtonAjaxRequest::class, 'buttonDialogRequest' => \ModStart\Widget\ButtonDialogRequest::class); foreach ($yNqI3 as $KYdg3 => $GgiJ8) { WidgetManager::extend($KYdg3, $GgiJ8); } } public static function collectWidgetAssets($F28aA = 'js|css|script|style') { goto DrW3h; NJHTG: foreach (static::$availableWidgets as $c6VKG => $Mk6lP) { goto Snvv3; JNTL3: if (!method_exists($Mk6lP, 'getAssets')) { continue; } goto BXwHs; BXwHs: $WTDv6->push(array_get(call_user_func(array($Mk6lP, 'getAssets')), $F28aA)); goto jV7tX; Snvv3: if (empty(self::$uses[$Mk6lP])) { continue; } goto JNTL3; jV7tX: } goto cmtJt; DrW3h: if (!in_array($F28aA, array('js', 'css', 'script', 'style'))) { return array(); } goto IQa3f; cmtJt: static::$collectedAssets[$F28aA] = $WTDv6->flatten()->unique()->filter()->toArray(); goto eH1LN; IQa3f: if (isset(static::$collectedAssets[$F28aA])) { return static::$collectedAssets[$F28aA]; } goto rRNNm; eH1LN: return static::$collectedAssets[$F28aA]; goto EXinX; rRNNm: $WTDv6 = collect(); goto NJHTG; EXinX: } public static function extend($Mk6lP, $GgiJ8) { static::$availableWidgets[$Mk6lP] = $GgiJ8; } public static function findWidgetClass($hiFdg) { goto NUPWW; J6Nlb: return false; goto nWxl3; NUPWW: $GgiJ8 = array_get(static::$availableWidgets, $hiFdg); goto ok3l_; ok3l_: if (class_exists($GgiJ8)) { return $GgiJ8; } goto J6Nlb; nWxl3: } public static function call($DEp9z, $hiFdg, $lLyBI) { if ($QMs0F = static::findWidgetClass($hiFdg)) { goto VtElM; r8b5k: $NK5jE = new $QMs0F($mSZnY, array_slice($lLyBI, 1)); goto GoDR9; VtElM: $mSZnY = array_get($lLyBI, 0, ''); goto r8b5k; eJTTY: return $NK5jE; goto SFfDn; GoDR9: $DEp9z->pushField($NK5jE); goto eJTTY; SFfDn: } throw new \Exception('Widget [' . ucfirst($hiFdg) . '] not exists or registered, available: ' . json_encode(array_keys(static::$availableWidgets))); } }