Skip to content

Commit

Permalink
Merge pull request #510 from sebastian-meyer/fix-506
Browse files Browse the repository at this point in the history
Include fallback for TYPO3 8.7
  • Loading branch information
sebastian-meyer committed Apr 27, 2020
2 parents 6311041 + 5f1f4e7 commit a34b620
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Classes/Common/AbstractPlugin.php
Expand Up @@ -229,6 +229,11 @@ protected function parseTS($string = '')
*/
public function pi_linkTP($str, $urlParameters = [], $cache = false, $altPageId = 0)
{
// Remove when we don't need to support TYPO3 8.7 anymore.
if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getNumericTypo3Version(), '9.0.0', '<')) {
return $this->pi_linkTP_fallback($str, $urlParameters, $cache, $altPageId);
}
// -->
$conf = [];
if (!$cache) {
$conf['no_cache'] = true;
Expand All @@ -241,6 +246,34 @@ public function pi_linkTP($str, $urlParameters = [], $cache = false, $altPageId
return $this->cObj->typoLink($str, $conf);
}

/**
* Link string to the current page (fallback for TYPO3 8.7)
* @see $this->pi_linkTP()
*
* @deprecated
*
* @access public
*
* @param string $str: The content string to wrap in <a> tags
* @param array $urlParameters: Array with URL parameters as key/value pairs
* @param bool $cache: Should the "no_cache" parameter be added?
* @param int $altPageId: Alternative page ID for the link.
*
* @return string The input string wrapped in <a> tags
*/
public function pi_linkTP_fallback($str, $urlParameters = [], $cache = false, $altPageId = 0)
{
$conf = [];
$conf['useCacheHash'] = $this->pi_USER_INT_obj ? 0 : $cache;
$conf['no_cache'] = $this->pi_USER_INT_obj ? 0 : !$cache;
$conf['parameter'] = $altPageId ? $altPageId : ($this->pi_tmpPageId ? $this->pi_tmpPageId : $this->frontendController->id);
$conf['additionalParams'] = $this->conf['parent.']['addParams'] . GeneralUtility::implodeArrayForUrl('', $urlParameters, '', true) . $this->pi_moreParams;
// Add additional configuration for absolute URLs.
$conf['forceAbsoluteUrl'] = !empty($this->conf['forceAbsoluteUrl']) ? 1 : 0;
$conf['forceAbsoluteUrl.']['scheme'] = !empty($this->conf['forceAbsoluteUrl']) && !empty($this->conf['forceAbsoluteUrlHttps']) ? 'https' : 'http';
return $this->cObj->typoLink($str, $conf);
}

/**
* Wraps the input string in a <div> tag with the class attribute set to the class name
* @see \TYPO3\CMS\Frontend\Plugin\AbstractPlugin->pi_wrapInBaseClass()
Expand Down

0 comments on commit a34b620

Please sign in to comment.