<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Support\Manager; use ModStart\Core\Util\SerializeUtil; use ModStart\Widget\AbstractWidget; class WidgetManager { private static $availableWidgets = array(); private static $collectedAssets = null; private static $uses = array(); public static function uses($ottBC) { if (is_array($ottBC)) { foreach ($ottBC as $xLxQi) { self::$uses[$xLxQi] = true; } } else { self::$uses[$ottBC] = true; } } public static function registerBuiltinWidgets() { $PGfuX = 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 ($PGfuX as $JY6Gz => $UfDw1) { WidgetManager::extend($JY6Gz, $UfDw1); } } public static function collectWidgetAssets($E1HRj = 'js|css|script|style') { goto Esa_5; Esa_5: if (!in_array($E1HRj, array('js', 'css', 'script', 'style'))) { return array(); } goto GnU3c; lyRsL: static::$collectedAssets[$E1HRj] = $o7ZhN->flatten()->unique()->filter()->toArray(); goto y_xQN; y_xQN: return static::$collectedAssets[$E1HRj]; goto SQE9v; GnU3c: if (isset(static::$collectedAssets[$E1HRj])) { return static::$collectedAssets[$E1HRj]; } goto H5U66; H5U66: $o7ZhN = collect(); goto obRHT; obRHT: foreach (static::$availableWidgets as $f0dxO => $E8QRJ) { goto uk8Ft; WIVnm: if (!method_exists($E8QRJ, 'getAssets')) { continue; } goto UYiEh; UYiEh: $o7ZhN->push(array_get(call_user_func(array($E8QRJ, 'getAssets')), $E1HRj)); goto Wdl2K; uk8Ft: if (empty(self::$uses[$E8QRJ])) { continue; } goto WIVnm; Wdl2K: } goto lyRsL; SQE9v: } public static function extend($E8QRJ, $UfDw1) { static::$availableWidgets[$E8QRJ] = $UfDw1; } public static function findWidgetClass($fVu6a) { goto rgiWL; rgiWL: $UfDw1 = array_get(static::$availableWidgets, $fVu6a); goto jMBu3; jMBu3: if (class_exists($UfDw1)) { return $UfDw1; } goto O89RT; O89RT: return false; goto jh2Ba; jh2Ba: } public static function call($d2dlC, $fVu6a, $RSGSj) { if ($S0esq = static::findWidgetClass($fVu6a)) { goto DHQ_0; DHQ_0: $BlfaU = array_get($RSGSj, 0, ''); goto yNA2K; yNA2K: $l05Yf = new $S0esq($BlfaU, array_slice($RSGSj, 1)); goto pGa2C; PwOkk: return $l05Yf; goto z8GgL; pGa2C: $d2dlC->pushField($l05Yf); goto PwOkk; z8GgL: } throw new \Exception('Widget [' . ucfirst($fVu6a) . '] not exists or registered, available: ' . SerializeUtil::jsonEncode(array_keys(static::$availableWidgets))); } }