<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Util; use Illuminate\Support\Str; use ModStart\Core\Assets\AssetsUtil; use ModStart\Misc\Html\Purifier; class HtmlUtil { public static function replaceImageSrcToLazyLoad($BWI89, $shLJU = 'data-src', $rmyvC = false) { goto KwWDZ; C3xJO: return $BWI89; goto wLDtx; KwWDZ: preg_match_all('/(<img.*?)src="(.*?)"(.*?>)/i', $BWI89, $S8gta); goto Pw9yT; Pw9yT: if ($rmyvC) { foreach ($S8gta[0] as $pztz4 => $Q0rz2) { $BWI89 = str_replace($Q0rz2, $S8gta[1][$pztz4] . $shLJU . '="' . AssetsUtil::fix($S8gta[2][$pztz4]) . '"' . $S8gta[3][$pztz4], $BWI89); } } else { foreach ($S8gta[0] as $pztz4 => $Q0rz2) { $BWI89 = str_replace($Q0rz2, $S8gta[1][$pztz4] . $shLJU . '="' . AssetsUtil::fix($S8gta[2][$pztz4]) . '"' . $S8gta[3][$pztz4], $BWI89); } } goto C3xJO; wLDtx: } public static function replaceImageSrcToFull($BWI89, $rmyvC = false, $efw4C = null) { goto KLYHH; pvTq0: return $BWI89; goto PJr9X; KLYHH: preg_match_all('/(<img.*?)src="(.*?)"(.*?>)/i', $BWI89, $S8gta); goto Qx7Zd; Qx7Zd: foreach ($S8gta[0] as $pztz4 => $Q0rz2) { if ($efw4C) { $BWI89 = str_replace($Q0rz2, $S8gta[1][$pztz4] . 'src="' . AssetsUtil::fixFullWithCdn($S8gta[2][$pztz4], $efw4C) . '"' . $S8gta[3][$pztz4], $BWI89); } else { if ($rmyvC) { $BWI89 = str_replace($Q0rz2, $S8gta[1][$pztz4] . 'src="' . AssetsUtil::fixFull($S8gta[2][$pztz4]) . '"' . $S8gta[3][$pztz4], $BWI89); } else { $BWI89 = str_replace($Q0rz2, $S8gta[1][$pztz4] . 'src="' . AssetsUtil::fixCurrentDomain($S8gta[2][$pztz4]) . '"' . $S8gta[3][$pztz4], $BWI89); } } } goto pvTq0; PJr9X: } public static function recordsReplaceImageSrcToFull(&$lz_pk, $VFU9l, $rmyvC = false, $efw4C = null) { foreach ($lz_pk as $pztz4 => $Q0rz2) { $lz_pk[$pztz4][$VFU9l] = self::replaceImageSrcToFull($Q0rz2[$VFU9l], $rmyvC, $efw4C); } } public static function extractTextAndImages($BWI89) { goto sQ_3_; TgtHU: if (!empty($S8gta[1])) { $S6y9h['images'] = $S8gta[1]; } goto TiXUk; ZufsF: $QvR6j = preg_replace('/<[^>]+>/', '', $BWI89); goto io4W3; OScC5: preg_match_all('/<img.*?src="(.*?)".*?>/i', $BWI89, $S8gta); goto TgtHU; TiXUk: return $S6y9h; goto UagsK; sQ_3_: $S6y9h = array('text' => '', 'images' => array()); goto ZufsF; io4W3: $S6y9h['text'] = $QvR6j; goto OScC5; UagsK: } public static function cover($BWI89) { goto xMBtt; DDMCn: return null; goto G6w21; w8b15: if (!empty($S8gta[1][0])) { return $S8gta[1][0]; } goto DDMCn; xMBtt: preg_match_all('/<img.*?src="(.*?)".*?>/i', $BWI89, $S8gta); goto w8b15; G6w21: } public static function text($BWI89, $D8igw = null) { goto jZKNz; jZKNz: $QvR6j = preg_replace('/<[^>]+>/', '', $BWI89); goto msijG; msijG: if (null !== $D8igw) { $QvR6j = Str::limit($QvR6j, $D8igw); } goto H0Ray; H0Ray: return str_replace(array('&nbsp;'), array(' '), $QvR6j); goto cO_4M; cO_4M: } public static function filter($BWI89) { if (empty($BWI89)) { return $BWI89; } return Purifier::cleanHtml($BWI89); } public static function filter2($BWI89) { if (empty($BWI89)) { return $BWI89; } return Purifier::cleanHtml($BWI89); } public static function text2html($QvR6j, $mpnfv = true) { goto HXp0g; wBBf1: return '<p>' . $QvR6j . '</p>'; goto Z1_96; HQ6QS: $QvR6j = str_replace('
', '</p><p>', $QvR6j); goto xeszy; N5K7p: $QvR6j = str_replace('
', '', $QvR6j); goto HQ6QS; HXp0g: if (empty($QvR6j)) { return ''; } goto hmDcc; hmDcc: if ($mpnfv) { $QvR6j = htmlspecialchars($QvR6j, ENT_QUOTES, 'UTF-8', false); } goto N5K7p; xeszy: $QvR6j = str_replace('<p></p>', '<p>&nbsp;</p>', $QvR6j); goto wBBf1; Z1_96: } public static function text2htmlSimpleRich($QvR6j, $mpnfv = true) { goto ytwN3; Ouvp4: $BWI89 = preg_replace('|([\\w\\d]*)\\s?(https?://([\\d\\w\\.-]+\\.[\\w\\.]{2,6})[^\\s\\]\\[\\<\\>]*/?)|i', '<a href="$2" target="_blank">$0</a>', $BWI89); goto Dtte_; ytwN3: $BWI89 = self::text2html($QvR6j, $mpnfv); goto Ouvp4; Dtte_: return $BWI89; goto g9DnQ; g9DnQ: } public static function html2text($QvR6j) { return str_replace(array('</p>', '<p>'), array('
', ''), $QvR6j); } public static function workCount($BWI89) { goto C_1YF; J1LpO: $Tw6Yp = mb_strlen($BWI89, 'utf-8'); goto wi3j7; LkZeK: $SL_Zh = count($S8gta[0]); goto malc7; JmG6c: preg_match_all('/[a-z0-9]+/i', $BWI89, $S8gta); goto LkZeK; wi3j7: return $SL_Zh + $Tw6Yp; goto rCekM; C_1YF: $BWI89 = preg_replace('/<[^>]+>/', '^', $BWI89); goto JmG6c; Ipg5a: $BWI89 = preg_replace('/[^\\x{4e00}-\\x{9fa5}]+/u', '', $BWI89); goto J1LpO; malc7: $BWI89 = str_replace('^', '', $BWI89); goto Ipg5a; rCekM: } }