2 declare(strict_types = 1);
66 abstract public function build(array &$linkDetails,
string $linkText,
string $target, array $conf): array;
77 if (!empty($url) && !empty($configuration[
'forceAbsoluteUrl']) && preg_match(
'#^(?:([a-z]+)(://)([^/]*)/?)?(.*)$#', $url, $matches)) {
79 'scheme' => $matches[1],
81 'host' => $matches[3],
84 $isUrlModified =
false;
86 if (empty($urlParts[
'host'])) {
87 $urlParts[
'scheme'] = GeneralUtility::getIndpEnv(
'TYPO3_SSL') ?
'https' :
'http';
88 $urlParts[
'host'] = GeneralUtility::getIndpEnv(
'HTTP_HOST');
89 $urlParts[
'path'] =
'/' . ltrim($urlParts[
'path'],
'/');
94 $urlParts[
'path'] = GeneralUtility::getIndpEnv(
'TYPO3_SITE_PATH') . ltrim($urlParts[
'path'],
'/');
96 $isUrlModified =
true;
99 $forceAbsoluteUrl = &$configuration[
'forceAbsoluteUrl.'][
'scheme'];
100 if (!empty($forceAbsoluteUrl) && $urlParts[
'scheme'] !== $forceAbsoluteUrl) {
101 $urlParts[
'scheme'] = $forceAbsoluteUrl;
102 $isUrlModified =
true;
105 if ($isUrlModified) {
106 $url = implode(
'', $urlParts);
119 $configuration = $this->contentObjectRenderer->mergeTSRef(
120 [
'parseFunc' =>
'< lib.parseFunc'],
123 return !empty($configuration[
'parseFunc.']) && is_array($configuration[
'parseFunc.']);
135 if ($originalLinkText !==
'') {
136 return $originalLinkText;
139 return $this->contentObjectRenderer->parseFunc($fallbackLinkText, [
'makelinks' => 0],
'< lib.parseFunc');
154 if ($originalLinkText !==
'') {
155 return $originalLinkText;
157 return htmlspecialchars($fallbackLinkText, ENT_QUOTES);
169 protected function resolveTargetAttribute(array $conf,
string $name,
bool $respectFrameSetOption =
false,
string $fallbackTarget =
''):
string
172 $targetAttributeAllowed = !$respectFrameSetOption
173 || (!isset($tsfe->config[
'config'][
'doctype']) || !$tsfe->config[
'config'][
'doctype'])
174 || in_array((
string)$tsfe->config[
'config'][
'doctype'], [
'xhtml_trans',
'xhtml_basic',
'html5'],
true);
177 if (isset($conf[$name])) {
178 $target = $conf[$name];
179 } elseif ($targetAttributeAllowed && !$conf[
'directImageLink']) {
180 $target = $fallbackTarget;
182 if (isset($conf[$name .
'.']) && $conf[$name .
'.']) {
183 $target = (string)$this->contentObjectRenderer->stdWrap($target, $conf[$name .
'.'] ?? []);
197 protected function processUrl(
string $context,
string $url, array $typolinkConfiguration = [])
199 $urlProcessors =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'urlProcessing'][
'urlProcessors'] ??
false;
200 if (!$urlProcessors) {
204 foreach ($urlProcessors as $identifier => $configuration) {
205 if (empty($configuration) || !is_array($configuration)) {
206 throw new \RuntimeException(
'Missing configuration for URI processor "' . $identifier .
'".', 1491130459);
208 if (!is_string($configuration[
'processor']) || empty($configuration[
'processor']) || !class_exists($configuration[
'processor']) || !is_subclass_of($configuration[
'processor'], UrlProcessorInterface::class)) {
209 throw new \RuntimeException(
'The URI processor "' . $identifier .
'" defines an invalid provider. Ensure the class exists and implements the "' . UrlProcessorInterface::class .
'".', 1491130460);
213 $orderedProcessors = GeneralUtility::makeInstance(DependencyOrderingService::class)->orderByDependencies($urlProcessors);
214 $keepProcessing =
true;
216 foreach ($orderedProcessors as $configuration) {
218 $urlProcessor = GeneralUtility::makeInstance($configuration[
'processor']);
219 $url = $urlProcessor->process($context, $url, $typolinkConfiguration, $this->contentObjectRenderer, $keepProcessing);
220 if (!$keepProcessing) {
241 $this->typoScriptFrontendController = GeneralUtility::makeInstance(
242 TypoScriptFrontendController::class,
244 GeneralUtility::_GP(
'id'),
245 (
int)GeneralUtility::_GP(
'type')
247 $this->typoScriptFrontendController->sys_page = GeneralUtility::makeInstance(PageRepository::class);
248 $this->typoScriptFrontendController->tmpl = GeneralUtility::makeInstance(TemplateService::class);