/** * Creates a link to a given page with a given link text * * @param array Array of arguments, [0] is the link text, [1] is the (optional) page Id to link to (otherwise TSFE->id), [2] are additional URL parameters, [3] use cache, defaults to FALSE, [4] additional A tag parameters * @return string complete anchor tag with URL and link text */ public function execute(array $arguments = array()) { $linkText = $arguments[0]; $additionalParameters = $arguments[2] ? $arguments[2] : ''; $useCache = $arguments[3] ? TRUE : FALSE; $ATagParams = $arguments[4] ? $arguments[4] : ''; // by default or if no link target is set, link to the current page $linkTarget = $GLOBALS['TSFE']->id; // if the link target is a number, interprete it as a page ID $linkArgument = trim($arguments[1]); if (is_numeric($linkArgument)) { $linkTarget = intval($linkArgument); } elseif (!empty($linkArgument) && is_string($linkArgument)) { if (Tx_Solr_Util::isValidTypoScriptPath($linkArgument)) { try { $typoscript = Tx_Solr_Util::getTypoScriptObject($linkArgument); $pathExploded = explode('.', $linkArgument); $lastPathSegment = array_pop($pathExploded); $linkTarget = intval($typoscript[$lastPathSegment]); } catch (InvalidArgumentException $e) { // ignore exceptions caused by markers, but accept the exception for wrong TS paths if (substr($linkArgument, 0, 3) != '###') { throw $e; } } } elseif (\TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($linkArgument) || \TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_HOST') . '/' . $linkArgument)) { // $linkTarget is an URL $linkTarget = filter_var($linkArgument, FILTER_SANITIZE_URL); } } $linkConfiguration = array('useCacheHash' => $useCache, 'no_cache' => FALSE, 'parameter' => $linkTarget, 'additionalParams' => $additionalParameters, 'ATagParams' => $ATagParams); return $this->contentObject->typoLink($linkText, $linkConfiguration); }