<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Assets; use Illuminate\Support\Facades\Request; use Illuminate\Support\Str; use ModStart\Core\Exception\BizException; use ModStart\Core\Util\ShellUtil; class AssetsUtil { public static function cdn() { return app('assetPathDriver')->getCDN(''); } public static function fix($QTKvb, $n0mgm = true) { goto ymvTM; m3Upe: if (Str::startsWith($QTKvb, '/')) { $QTKvb = substr($QTKvb, 1); } goto hY90x; Hdfps: return $MiLaY; goto UIa1N; q00wZ: if ($n0mgm) { $MiLaY .= app('assetPathDriver')->getPathWithHash($QTKvb); } else { $MiLaY .= $QTKvb; } goto Hdfps; hY90x: $MiLaY = app('assetPathDriver')->getCDN($QTKvb); goto q00wZ; OhsUR: if (Str::startsWith($QTKvb, 'http://') || Str::startsWith($QTKvb, 'https://') || Str::startsWith($QTKvb, '//')) { return $QTKvb; } goto m3Upe; ymvTM: if (empty($QTKvb)) { return $QTKvb; } goto OhsUR; UIa1N: } public static function fixOrDefault($QTKvb, $Rethz) { if (empty($QTKvb)) { return self::fix($Rethz); } return self::fix($QTKvb); } public static function url($WF06r) { return app('assetPathDriver')->getCDN($WF06r) . app('assetPathDriver')->getPathWithHash($WF06r); } public static function fixCurrentDomain($QTKvb) { goto ZdShi; k1qHA: if (Request::secure()) { $WX6Oy = 'https'; } else { $WX6Oy = 'http'; } goto pYqcr; J3Kb6: if (Str::startsWith($QTKvb, 'http://') || Str::startsWith($QTKvb, 'https://')) { return $QTKvb; } goto m_d_k; m_d_k: if (!Str::startsWith($QTKvb, '/')) { $QTKvb = '/' . $QTKvb; } goto k1qHA; ZdShi: if (is_array($QTKvb)) { return array_values(array_map(function ($bW0Md) { return self::fixCurrentDomain($bW0Md); }, $QTKvb)); } goto J3Kb6; pYqcr: if (Str::startsWith($QTKvb, '//')) { return $WX6Oy . ':' . $QTKvb; } goto CNmap; CNmap: return $WX6Oy . '://' . Request::server('HTTP_HOST') . $QTKvb; goto Vooo2; Vooo2: } public static function fixFullFromConfig($RsUap) { goto mMKAv; ISYKN: if (empty($cBDsM)) { return null; } goto KcTFG; mMKAv: $cBDsM = modstart_config($RsUap); goto ISYKN; KcTFG: return self::fixFull($cBDsM); goto Gy5Zs; Gy5Zs: } public static function fixFull($QTKvb, $n0mgm = true) { goto Nec3_; d4I_1: $QTKvb = self::fix($QTKvb, $n0mgm); goto Ij3Nb; PQOBi: if (ShellUtil::isCli()) { $GIgCJ = config('env.APP_URL'); if (empty($GIgCJ)) { $GIgCJ = modstart_config('siteUrl'); } } goto tTyL2; Ij3Nb: if (Str::startsWith($QTKvb, 'http://') || Str::startsWith($QTKvb, 'https://')) { return $QTKvb; } goto r33jZ; r33jZ: if (Request::secure()) { $WX6Oy = 'https'; } else { $WX6Oy = 'http'; } goto U0So7; U0So7: if (Str::startsWith($QTKvb, '//')) { return $WX6Oy . ':' . $QTKvb; } goto dlQtC; dlQtC: $GIgCJ = $WX6Oy . '://' . Request::server('HTTP_HOST'); goto PQOBi; Nec3_: if (is_array($QTKvb)) { return array_values(array_map(function ($bW0Md) use($n0mgm) { return self::fixFull($bW0Md, $n0mgm); }, $QTKvb)); } goto I153C; tTyL2: return rtrim($GIgCJ, '/') . '/' . ltrim($QTKvb, '/'); goto Ou8oF; I153C: if (empty($QTKvb)) { return $QTKvb; } goto d4I_1; Ou8oF: } public static function fixFullInJob($QTKvb, $n0mgm = true) { goto Cw3UV; fS4jq: if (Str::startsWith($QTKvb, '//')) { return 'http:' . $QTKvb; } goto VlJGI; Cw3UV: if (empty($QTKvb)) { return $QTKvb; } goto jloX5; UhZde: if (Str::startsWith($QTKvb, 'http://') || Str::startsWith($QTKvb, 'https://')) { return $QTKvb; } goto fS4jq; Xm7a5: return rtrim($syiCL, '/') . '/' . ltrim($QTKvb, '/'); goto OMvA0; VlJGI: $syiCL = config('env.APP_URL'); goto ktvKl; ktvKl: BizException::throwsIfEmpty('APP_URL Required In Job', $syiCL); goto Xm7a5; jloX5: $QTKvb = self::fix($QTKvb, $n0mgm); goto UhZde; OMvA0: } public static function fixFullWithCdn($QTKvb, $WB5Kf, $n0mgm = true) { goto tWWJt; svWmh: if (empty($QTKvb)) { return $QTKvb; } goto SFL1l; YHmAe: return $WB5Kf . ltrim($QTKvb, '/'); goto FxwKb; tWWJt: if (is_array($QTKvb)) { return array_values(array_map(function ($bW0Md) use($WB5Kf, $n0mgm) { return self::fixFullWithCdn($bW0Md, $WB5Kf, $n0mgm); }, $QTKvb)); } goto svWmh; SFL1l: if (Str::startsWith($QTKvb, 'http://') || Str::startsWith($QTKvb, 'https://')) { return $QTKvb; } goto YHmAe; FxwKb: } public static function fixFullOrDefault($QTKvb, $Rethz = null) { goto Dwm8S; Dwm8S: if (is_array($QTKvb)) { return array_values(array_map(function ($bW0Md) use($Rethz) { return self::fixFullOrDefault($bW0Md, $Rethz); }, $QTKvb)); } goto u3oqd; GS_ug: return self::fixFull($QTKvb); goto xerLV; u3oqd: if (empty($QTKvb)) { return self::fixFull($Rethz); } goto GS_ug; xerLV: } public static function recordsFixFullOrDefault(&$d5ixK, $oMJcb, $Rethz = null) { foreach ((array) $oMJcb as $PBAzK) { foreach ($d5ixK as $lxIPA => $knQyJ) { $d5ixK[$lxIPA][$PBAzK] = self::fixFullOrDefault($knQyJ[$PBAzK], $Rethz); } } } }