<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Assets; use Illuminate\Support\Facades\Request; use Illuminate\Support\Str; use ModStart\Core\Exception\BizException; class AssetsUtil { public static function cdn() { return app('assetPathDriver')->getCDN(''); } public static function fix($YhsOb, $yAv3U = true) { goto ooIdV; ooIdV: if (empty($YhsOb)) { return $YhsOb; } goto qm2Pr; Mfa0B: if ($yAv3U) { $ik1Qg .= app('assetPathDriver')->getPathWithHash($YhsOb); } else { $ik1Qg .= $YhsOb; } goto WWroj; WWroj: return $ik1Qg; goto ho3bz; qm2Pr: if (Str::startsWith($YhsOb, 'http://') || Str::startsWith($YhsOb, 'https://') || Str::startsWith($YhsOb, '//')) { return $YhsOb; } goto JBwWB; JBwWB: if (Str::startsWith($YhsOb, '/')) { $YhsOb = substr($YhsOb, 1); } goto AhMgv; AhMgv: $ik1Qg = app('assetPathDriver')->getCDN($YhsOb); goto Mfa0B; ho3bz: } public static function fixOrDefault($YhsOb, $jDU6Q) { if (empty($YhsOb)) { return self::fix($jDU6Q); } return self::fix($YhsOb); } public static function url($ypGny) { return app('assetPathDriver')->getCDN($ypGny) . app('assetPathDriver')->getPathWithHash($ypGny); } public static function fixCurrentDomain($YhsOb) { goto pFpgH; pFpgH: if (is_array($YhsOb)) { return array_values(array_map(function ($NKf8K) { return self::fixCurrentDomain($NKf8K); }, $YhsOb)); } goto XB19a; ro_6n: if (Str::startsWith($YhsOb, '//')) { return $EqplL . ':' . $YhsOb; } goto LzMX9; LzMX9: return $EqplL . '://' . Request::server('HTTP_HOST') . $YhsOb; goto izLPv; XB19a: if (Str::startsWith($YhsOb, 'http://') || Str::startsWith($YhsOb, 'https://')) { return $YhsOb; } goto hNSnu; mgsQk: if (Request::secure()) { $EqplL = 'https'; } else { $EqplL = 'http'; } goto ro_6n; hNSnu: if (!Str::startsWith($YhsOb, '/')) { $YhsOb = '/' . $YhsOb; } goto mgsQk; izLPv: } public static function fixFullFromConfig($XW8Ro) { goto cZzrN; QA8UB: return self::fixFull($Mczr_); goto z2Vyw; CqWyI: if (empty($Mczr_)) { return null; } goto QA8UB; cZzrN: $Mczr_ = modstart_config($XW8Ro); goto CqWyI; z2Vyw: } public static function fixFull($YhsOb, $yAv3U = true) { goto JdGLg; JdGLg: if (is_array($YhsOb)) { return array_values(array_map(function ($NKf8K) use($yAv3U) { return self::fixFull($NKf8K, $yAv3U); }, $YhsOb)); } goto wWmMF; Kj8LE: $YhsOb = self::fix($YhsOb, $yAv3U); goto j5nms; wWmMF: if (empty($YhsOb)) { return $YhsOb; } goto Kj8LE; AQuFJ: if (Request::secure()) { $EqplL = 'https'; } else { $EqplL = 'http'; } goto GnGrj; GnGrj: if (Str::startsWith($YhsOb, '//')) { return $EqplL . ':' . $YhsOb; } goto ue7QO; ue7QO: return $EqplL . '://' . Request::server('HTTP_HOST') . $YhsOb; goto y0ZBi; j5nms: if (Str::startsWith($YhsOb, 'http://') || Str::startsWith($YhsOb, 'https://')) { return $YhsOb; } goto AQuFJ; y0ZBi: } public static function fixFullInJob($YhsOb, $yAv3U = true) { goto jgLO_; oY84o: return rtrim($DvMNB, '/') . '/' . ltrim($YhsOb, '/'); goto HVHeh; RyvV7: BizException::throwsIfEmpty('APP_URL Required In Job', $DvMNB); goto oY84o; CNDu2: $YhsOb = self::fix($YhsOb, $yAv3U); goto TsL5a; TsL5a: if (Str::startsWith($YhsOb, 'http://') || Str::startsWith($YhsOb, 'https://')) { return $YhsOb; } goto efth5; efth5: if (Str::startsWith($YhsOb, '//')) { return 'http:' . $YhsOb; } goto mWfrN; jgLO_: if (empty($YhsOb)) { return $YhsOb; } goto CNDu2; mWfrN: $DvMNB = config('env.APP_URL'); goto RyvV7; HVHeh: } public static function fixFullWithCdn($YhsOb, $Zw14k, $yAv3U = true) { goto uxKek; o9L1h: if (empty($YhsOb)) { return $YhsOb; } goto ICDaU; TW2fX: return $Zw14k . ltrim($YhsOb, '/'); goto ahjxG; ICDaU: if (Str::startsWith($YhsOb, 'http://') || Str::startsWith($YhsOb, 'https://')) { return $YhsOb; } goto TW2fX; uxKek: if (is_array($YhsOb)) { return array_values(array_map(function ($NKf8K) use($Zw14k, $yAv3U) { return self::fixFullWithCdn($NKf8K, $Zw14k, $yAv3U); }, $YhsOb)); } goto o9L1h; ahjxG: } public static function fixFullOrDefault($YhsOb, $jDU6Q = null) { goto NKQjv; aftB3: return self::fixFull($YhsOb); goto JFoF9; NKQjv: if (is_array($YhsOb)) { return array_values(array_map(function ($NKf8K) use($jDU6Q) { return self::fixFullOrDefault($NKf8K, $jDU6Q); }, $YhsOb)); } goto yYkPf; yYkPf: if (empty($YhsOb)) { return self::fixFull($jDU6Q); } goto aftB3; JFoF9: } public static function recordsFixFullOrDefault(&$YDsPC, $l6tBV, $jDU6Q = null) { foreach ((array) $l6tBV as $Kb6lI) { foreach ($YDsPC as $B34tD => $Xz28r) { $YDsPC[$B34tD][$Kb6lI] = self::fixFullOrDefault($Xz28r[$Kb6lI], $jDU6Q); } } } }