<?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($qeBS4) { if (is_array($qeBS4)) { foreach ($qeBS4 as $u_jpy) { self::$uses[$u_jpy] = true; } } else { self::$uses[$qeBS4] = true; } } public static function registerBuiltinWidgets() { $gROn3 = 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 ($gROn3 as $wymYS => $ogfq7) { WidgetManager::extend($wymYS, $ogfq7); } } public static function collectWidgetAssets($pW0Nz = 'js|css|script|style') { goto D1uvL; mY7zd: foreach (static::$availableWidgets as $ZZMEd => $rZfgs) { goto M827F; UfwGI: if (!method_exists($rZfgs, 'getAssets')) { continue; } goto d17TC; M827F: if (empty(self::$uses[$rZfgs])) { continue; } goto UfwGI; d17TC: $LUeWJ->push(array_get(call_user_func(array($rZfgs, 'getAssets')), $pW0Nz)); goto JNaGZ; JNaGZ: } goto E_436; BxMe6: $LUeWJ = collect(); goto mY7zd; E_436: static::$collectedAssets[$pW0Nz] = $LUeWJ->flatten()->unique()->filter()->toArray(); goto bfzsl; bfzsl: return static::$collectedAssets[$pW0Nz]; goto h7jPA; D1uvL: if (!in_array($pW0Nz, array('js', 'css', 'script', 'style'))) { return array(); } goto KE7Ex; KE7Ex: if (isset(static::$collectedAssets[$pW0Nz])) { return static::$collectedAssets[$pW0Nz]; } goto BxMe6; h7jPA: } public static function extend($rZfgs, $ogfq7) { static::$availableWidgets[$rZfgs] = $ogfq7; } public static function findWidgetClass($pK00s) { goto EkPNC; S0TJg: if (class_exists($ogfq7)) { return $ogfq7; } goto MfV38; EkPNC: $ogfq7 = array_get(static::$availableWidgets, $pK00s); goto S0TJg; MfV38: return false; goto WqmHK; WqmHK: } public static function call($Olcky, $pK00s, $rxS2C) { if ($qlsz_ = static::findWidgetClass($pK00s)) { goto KNveA; qSUxa: $f9gHN = new $qlsz_($t_tdX, array_slice($rxS2C, 1)); goto bdkfZ; KNveA: $t_tdX = array_get($rxS2C, 0, ''); goto qSUxa; qJAZq: return $f9gHN; goto ak5YS; bdkfZ: $Olcky->pushField($f9gHN); goto qJAZq; ak5YS: } throw new \Exception('Widget [' . ucfirst($pK00s) . '] not exists or registered, available: ' . SerializeUtil::jsonEncode(array_keys(static::$availableWidgets))); } }