EmailLinkBuilder extends AbstractTypolinkBuilder implements LoggerAwareInterface uses DefaultJavaScriptAssetTrait, LoggerAwareTrait
Builds a TypoLink to an email address, also takes care of additional functionality for the time being such as the infamous config.spamProtectedEmailAddresses option.
Table of Contents
Interfaces
- LoggerAwareInterface
Properties
- $contentObjectRenderer : ContentObjectRenderer
- $defaultFrontendJavaScriptFile : string
- $typoScriptFrontendController : TypoScriptFrontendController|null
Methods
- __construct() : mixed
- build() : LinkResultInterface
- Should be implemented by all subclasses to return an array with three parts: - URL - Link Text (can be modified) - Target (can be modified) - Tag Attributes (optional)
- getTypoScriptFrontendController() : TypoScriptFrontendController
-
processEmailLink()
: array{0: string, 1: string, 2: array
} - Creates a href attibute for given $mailAddress.
- addDefaultFrontendJavaScript() : void
- encodeFallbackLinkTextIfLinkTextIsEmpty() : string
- Helper method to a fallback method properly encoding HTML.
- encryptCharcode() : string
- Encryption (or decryption) of a single character.
- encryptEmail() : string
- Encryption of email addresses for <A>-tags See the spam protection setup in TS 'config.'
- forceAbsoluteUrl() : string
- Forces a given URL to be absolute.
- isLibParseFuncDefined() : bool
- Determines whether lib.parseFunc is defined.
- parseFallbackLinkTextIfLinkTextIsEmpty() : string
- Helper method to a fallback method parsing HTML out of it
- resolveTargetAttribute() : string
- Creates the value for target="..." in a typolink configuration
- shallExportDefaultFrontendJavaScript() : bool
- shallRemoveDefaultFrontendJavaScript() : bool
Properties
$contentObjectRenderer
protected
ContentObjectRenderer
$contentObjectRenderer
$defaultFrontendJavaScriptFile
protected
string
$defaultFrontendJavaScriptFile
= 'EXT:frontend/Resources/Public/JavaScript/default_frontend.js'
$typoScriptFrontendController
protected
TypoScriptFrontendController|null
$typoScriptFrontendController
= null
Methods
__construct()
public
__construct(ContentObjectRenderer $contentObjectRenderer[, TypoScriptFrontendController|null $typoScriptFrontendController = null ]) : mixed
Parameters
- $contentObjectRenderer : ContentObjectRenderer
- $typoScriptFrontendController : TypoScriptFrontendController|null = null
build()
Should be implemented by all subclasses to return an array with three parts: - URL - Link Text (can be modified) - Target (can be modified) - Tag Attributes (optional)
public
build(array<string|int, mixed> &$linkDetails, string $linkText, string $target, array<string|int, mixed> $conf) : LinkResultInterface
Parameters
- $linkDetails : array<string|int, mixed>
-
parsed link details by the LinkService
- $linkText : string
-
the link text
- $target : string
-
the target to point to
- $conf : array<string|int, mixed>
-
the TypoLink configuration array
Return values
LinkResultInterfacegetTypoScriptFrontendController()
public
getTypoScriptFrontendController() : TypoScriptFrontendController
Return values
TypoScriptFrontendControllerprocessEmailLink()
Creates a href attibute for given $mailAddress.
public
processEmailLink(string $mailAddress, string $linkText[, array<string|int, mixed> $linkDetails = [] ]) : array{0: string, 1: string, 2: array}
The function uses spamProtectEmailAddresses for encoding the mailto statement. If spamProtectEmailAddresses is disabled, it'll just return a string like "mailto:user@example.tld".
Returns an array with three items (numeric index)
#0: $mailToUrl (string), ready to be inserted into the href attribute of the tag
#1: $linkText (string), content between starting and ending <a>
tag
#2: $attributes (array<string, string>), additional attributes for <a>
tag
Parameters
- $mailAddress : string
-
Email address
- $linkText : string
-
Link text, default will be the email address.
- $linkDetails : array<string|int, mixed> = []
this method is not part of TYPO3's public API
Return values
array{0: string, 1: string, 2: arrayA numerical array with three items
addDefaultFrontendJavaScript()
protected
addDefaultFrontendJavaScript() : void
encodeFallbackLinkTextIfLinkTextIsEmpty()
Helper method to a fallback method properly encoding HTML.
protected
encodeFallbackLinkTextIfLinkTextIsEmpty(string $originalLinkText, string $fallbackLinkText) : string
Parameters
- $originalLinkText : string
-
the original string, if empty, the fallback link text
- $fallbackLinkText : string
-
the string to be used.
Return values
string —the final text
encryptCharcode()
Encryption (or decryption) of a single character.
protected
encryptCharcode(int $n, int $start, int $end, int $offset) : string
Within the given range the character is shifted with the supplied offset.
Parameters
- $n : int
-
Ordinal of input character
- $start : int
-
Start of range
- $end : int
-
End of range
- $offset : int
-
Offset
Return values
string —encoded/decoded version of character
encryptEmail()
Encryption of email addresses for <A>-tags See the spam protection setup in TS 'config.'
protected
encryptEmail(string $string, int $offset) : string
Parameters
- $string : string
-
Input string to en/decode: "mailto:some@example.com
- $offset : int
-
a number between -10 and 10, taken from config.spamProtectEmailAddresses
Return values
string —encoded version of $string
forceAbsoluteUrl()
Forces a given URL to be absolute.
protected
forceAbsoluteUrl(string $url, array<string|int, mixed> $configuration) : string
Parameters
- $url : string
-
The URL to be forced to be absolute
- $configuration : array<string|int, mixed>
-
TypoScript configuration of typolink
Return values
string —The absolute URL
isLibParseFuncDefined()
Determines whether lib.parseFunc is defined.
protected
isLibParseFuncDefined() : bool
Return values
boolparseFallbackLinkTextIfLinkTextIsEmpty()
Helper method to a fallback method parsing HTML out of it
protected
parseFallbackLinkTextIfLinkTextIsEmpty(string $originalLinkText, string $fallbackLinkText) : string
Parameters
- $originalLinkText : string
-
the original string, if empty, the fallback link text
- $fallbackLinkText : string
-
the string to be used.
Return values
string —the final text
resolveTargetAttribute()
Creates the value for target="..." in a typolink configuration
protected
resolveTargetAttribute(array<string|int, mixed> $conf, string $name) : string
Parameters
- $conf : array<string|int, mixed>
-
the typolink configuration
- $name : string
-
the key, usually "target", "extTarget" or "fileTarget"
Return values
string —the value of the target attribute, if there is one
shallExportDefaultFrontendJavaScript()
protected
shallExportDefaultFrontendJavaScript() : bool
Return values
boolshallRemoveDefaultFrontendJavaScript()
protected
shallRemoveDefaultFrontendJavaScript() : bool