<?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($Afv_G, $Nvjz3 = 'data-src', $G6guQ = false) { goto rb6E5; MjmVY: if ($G6guQ) { foreach ($WpF0C[0] as $RTHJ6 => $F6Fus) { $Afv_G = str_replace($F6Fus, $WpF0C[1][$RTHJ6] . $Nvjz3 . '="' . AssetsUtil::fix($WpF0C[2][$RTHJ6]) . '"' . $WpF0C[3][$RTHJ6], $Afv_G); } } else { foreach ($WpF0C[0] as $RTHJ6 => $F6Fus) { $Afv_G = str_replace($F6Fus, $WpF0C[1][$RTHJ6] . $Nvjz3 . '="' . AssetsUtil::fix($WpF0C[2][$RTHJ6]) . '"' . $WpF0C[3][$RTHJ6], $Afv_G); } } goto zQgY5; rb6E5: preg_match_all('/(<img.*?)src="(.*?)"(.*?>)/i', $Afv_G, $WpF0C); goto MjmVY; zQgY5: return $Afv_G; goto cjfeG; cjfeG: } public static function replaceImageSrcToFull($Afv_G, $G6guQ = false, $lCgLt = null) { goto QtgUz; goTXt: return $Afv_G; goto KBSYd; QtgUz: preg_match_all('/(<img.*?)src="(.*?)"(.*?>)/i', $Afv_G, $WpF0C); goto GSub2; GSub2: foreach ($WpF0C[0] as $RTHJ6 => $F6Fus) { if ($lCgLt) { $Afv_G = str_replace($F6Fus, $WpF0C[1][$RTHJ6] . 'src="' . AssetsUtil::fixFullWithCdn($WpF0C[2][$RTHJ6], $lCgLt) . '"' . $WpF0C[3][$RTHJ6], $Afv_G); } else { if ($G6guQ) { $Afv_G = str_replace($F6Fus, $WpF0C[1][$RTHJ6] . 'src="' . AssetsUtil::fixFull($WpF0C[2][$RTHJ6]) . '"' . $WpF0C[3][$RTHJ6], $Afv_G); } else { $Afv_G = str_replace($F6Fus, $WpF0C[1][$RTHJ6] . 'src="' . AssetsUtil::fixCurrentDomain($WpF0C[2][$RTHJ6]) . '"' . $WpF0C[3][$RTHJ6], $Afv_G); } } } goto goTXt; KBSYd: } public static function recordsReplaceImageSrcToFull(&$bcEDt, $jPfeB, $G6guQ = false, $lCgLt = null) { foreach ($bcEDt as $RTHJ6 => $F6Fus) { $bcEDt[$RTHJ6][$jPfeB] = self::replaceImageSrcToFull($F6Fus[$jPfeB], $G6guQ, $lCgLt); } } public static function extractTextAndImages($Afv_G) { goto V2cxB; znNZI: $XzQNg['text'] = $McuDg; goto x0vD7; c3sK9: $McuDg = preg_replace('/<[^>]+>/', '', $Afv_G); goto znNZI; V2cxB: $XzQNg = array('text' => '', 'images' => array()); goto c3sK9; nUczJ: return $XzQNg; goto o5ZYn; x0vD7: preg_match_all('/<img.*?src="(.*?)".*?>/i', $Afv_G, $WpF0C); goto g5xda; g5xda: if (!empty($WpF0C[1])) { $XzQNg['images'] = $WpF0C[1]; } goto nUczJ; o5ZYn: } public static function cover($Afv_G) { goto ZnFJZ; nd7AW: if (!empty($WpF0C[1][0])) { return $WpF0C[1][0]; } goto wQj02; ZnFJZ: preg_match_all('/<img.*?src="(.*?)".*?>/i', $Afv_G, $WpF0C); goto nd7AW; wQj02: return null; goto Hi134; Hi134: } public static function text($Afv_G, $CcreL = null) { goto r0UEn; i3lsV: return str_replace(array('&nbsp;'), array(' '), $McuDg); goto vwWDw; SXdEl: if (null !== $CcreL) { $McuDg = Str::limit($McuDg, $CcreL); } goto i3lsV; r0UEn: $McuDg = preg_replace('/<[^>]+>/', '', $Afv_G); goto SXdEl; vwWDw: } public static function filter($Afv_G) { if (empty($Afv_G)) { return $Afv_G; } return Purifier::cleanHtml($Afv_G); } public static function filter2($Afv_G) { if (empty($Afv_G)) { return $Afv_G; } return Purifier::cleanHtml($Afv_G); } public static function text2html($McuDg, $UBWtY = true) { goto TK3oV; N9yPV: $McuDg = str_replace('
', '', $McuDg); goto dxaNe; p4wOs: $McuDg = str_replace('<p></p>', '<p>&nbsp;</p>', $McuDg); goto zNKNm; dxaNe: $McuDg = str_replace('
', '</p><p>', $McuDg); goto p4wOs; weDl4: if ($UBWtY) { $McuDg = htmlspecialchars($McuDg, ENT_QUOTES, 'UTF-8', false); } goto N9yPV; zNKNm: return '<p>' . $McuDg . '</p>'; goto q0zk6; TK3oV: if (empty($McuDg)) { return ''; } goto weDl4; q0zk6: } public static function text2htmlSimpleRich($McuDg, $UBWtY = true) { goto gSpLA; YIJpa: $Afv_G = preg_replace('|([\\w\\d]*)\\s?(https?://([\\d\\w\\.-]+\\.[\\w\\.]{2,6})[^\\s\\]\\[\\<\\>]*/?)|i', '<a href="$2" target="_blank">$0</a>', $Afv_G); goto T_AkP; gSpLA: $Afv_G = self::text2html($McuDg, $UBWtY); goto YIJpa; T_AkP: return $Afv_G; goto Dp0Ea; Dp0Ea: } public static function html2text($McuDg) { return str_replace(array('</p>', '<p>'), array('
', ''), $McuDg); } public static function workCount($Afv_G) { goto tggTO; UYf1A: $s_scI = mb_strlen($Afv_G, 'utf-8'); goto YrwuH; TlRfH: preg_match_all('/[a-z0-9]+/i', $Afv_G, $WpF0C); goto hPOrN; tggTO: $Afv_G = preg_replace('/<[^>]+>/', '^', $Afv_G); goto TlRfH; IGO0W: $Afv_G = str_replace('^', '', $Afv_G); goto yd287; yd287: $Afv_G = preg_replace('/[^\\x{4e00}-\\x{9fa5}]+/u', '', $Afv_G); goto UYf1A; hPOrN: $nGxAN = count($WpF0C[0]); goto IGO0W; YrwuH: return $nGxAN + $s_scI; goto sqa9P; sqa9P: } }