[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Joomla! Content Management System 5 * 6 * @copyright (C) 2007 Open Source Matters, Inc. <https://www.joomla.org> 7 * @license GNU General Public License version 2 or later; see LICENSE.txt 8 */ 9 10 namespace Joomla\CMS\HTML\Helpers; 11 12 use Joomla\CMS\Factory; 13 use Joomla\CMS\Language\Text; 14 use Joomla\CMS\String\PunycodeHelper; 15 use Joomla\CMS\Uri\Uri; 16 17 // phpcs:disable PSR1.Files.SideEffects 18 \defined('JPATH_PLATFORM') or die; 19 // phpcs:enable PSR1.Files.SideEffects 20 21 /** 22 * Utility class for cloaking email addresses 23 * 24 * @since 1.5 25 */ 26 abstract class Email 27 { 28 /** 29 * Simple JavaScript email cloaker 30 * 31 * By default replaces an email with a mailto link with email cloaked 32 * 33 * @param string $mail The -mail address to cloak. 34 * @param boolean $mailto True if text and mailing address differ 35 * @param string $text Text for the link 36 * @param boolean $email True if text is an email address 37 * @param string $attribsBefore Any attributes before the email address 38 * @param string $attribsAfter Any attributes before the email address 39 * 40 * @return string The cloaked email. 41 * 42 * @since 1.5 43 */ 44 public static function cloak($mail, $mailto = true, $text = '', $email = true, $attribsBefore = '', $attribsAfter = '') 45 { 46 // Handle IDN addresses: punycode for href but utf-8 for text displayed. 47 if ($mailto && (empty($text) || $email)) { 48 // Use dedicated $text whereas $mail is used as href and must be punycoded. 49 $text = PunycodeHelper::emailToUTF8($text ?: $mail); 50 } elseif (!$mailto) { 51 // In that case we don't use link - so convert $mail back to utf-8. 52 $mail = PunycodeHelper::emailToUTF8($mail); 53 } 54 55 // Split email by @ symbol 56 $mail = explode('@', $mail); 57 $name = @$mail[0]; 58 $domain = @$mail[1]; 59 60 // Include the email cloaking script 61 Factory::getDocument()->getWebAssetManager() 62 ->useScript('webcomponent.hidden-mail'); 63 64 return '<joomla-hidden-mail ' 65 . $attribsBefore . ' is-link="' 66 . $mailto . '" is-email="' 67 . $email . '" first="' 68 . base64_encode($name) . '" last="' 69 . base64_encode($domain) . '" text="' 70 . base64_encode($text) . '" base="' 71 . Uri::root(true) . '" ' . $attribsAfter . '>' . Text::_('JLIB_HTML_CLOAKING') . '</joomla-hidden-mail>'; 72 } 73 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |