Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include fallback for TYPO3 8.7 #510

Merged
merged 4 commits into from
Apr 27, 2020
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 33 additions & 0 deletions Classes/Common/AbstractPlugin.php
Original file line number Diff line number Diff line change
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', '<')) {
sebastian-meyer marked this conversation as resolved.
Show resolved Hide resolved
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;
sebastian-meyer marked this conversation as resolved.
Show resolved Hide resolved
// 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