|
@@ -6,54 +6,6 @@ namespace App\Services\LiquidFilters;
|
|
|
*/
|
|
|
class Filters
|
|
|
{
|
|
|
- // 获取完整的资产 URL
|
|
|
- public static function assetUrl(string $input): string
|
|
|
- {
|
|
|
- $assetBaseUrl = config('asset_base_url');
|
|
|
- return $assetBaseUrl . ltrim($input, '/');
|
|
|
- }
|
|
|
-
|
|
|
- // 获取完整的字体 URL
|
|
|
- public static function fontUrl(string $input): string
|
|
|
- {
|
|
|
- $fontBaseUrl = config('font_base_url');
|
|
|
- return $fontBaseUrl . ltrim($input, '/');
|
|
|
- }
|
|
|
-
|
|
|
- // 获取完整的图片 URL
|
|
|
- public static function imageUrl(string $input): string
|
|
|
- {
|
|
|
- $imageBaseUrl = config('image_base_url');
|
|
|
- return $imageBaseUrl . ltrim($input, '/');
|
|
|
- }
|
|
|
-
|
|
|
- // 生成 CSS 链接标签
|
|
|
- public static function stylesheetTag(string $input): string
|
|
|
- {
|
|
|
- $cssUrl = self::assetUrl($input); // 使用 assetUrl 拼接 CSS 完整 URL
|
|
|
- return '<link rel="stylesheet" href="' . htmlspecialchars($cssUrl, ENT_QUOTES) . '">';
|
|
|
- }
|
|
|
-
|
|
|
- // 生成 JavaScript 脚本标签
|
|
|
- public static function scriptTag(string $input): string
|
|
|
- {
|
|
|
- $scriptUrl = self::assetUrl($input); // 使用 assetUrl 拼接 JavaScript 完整 URL
|
|
|
- return '<script src="' . htmlspecialchars($scriptUrl, ENT_QUOTES) . '"></script>';
|
|
|
- }
|
|
|
-
|
|
|
- // 生成 img 标签
|
|
|
- public static function imageTag(string $input, string $alt = '', array $attributes = []): string
|
|
|
- {
|
|
|
- $imageUrl = self::imageUrl($input);
|
|
|
- $attrString = '';
|
|
|
-
|
|
|
- foreach ($attributes as $key => $value) {
|
|
|
- $attrString .= ' ' . htmlspecialchars($key, ENT_QUOTES) . '="' . htmlspecialchars($value, ENT_QUOTES) . '"';
|
|
|
- }
|
|
|
-
|
|
|
- return '<img src="' . htmlspecialchars($imageUrl, ENT_QUOTES) . '" alt="' . htmlspecialchars($alt, ENT_QUOTES) . '"' . $attrString . '>';
|
|
|
- }
|
|
|
-
|
|
|
public static function decode_html_entities($input) {
|
|
|
return html_entity_decode($input, ENT_QUOTES, 'UTF-8');
|
|
|
}
|