Skip to content
Snippets Groups Projects

Typo3v8compatibility

Merged Fabian Galinski requested to merge typo3v8compatibility into master
2 files
+ 97
74
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -15,6 +15,7 @@ namespace SGalinski\Tinymce4Rte\Controller;
*/
use Psr\Http\Message\ServerRequestInterface;
use SGalinski\Tinymce4Rte\Utility\VersionUtility;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -210,39 +211,60 @@ class BrowseLinksController extends AbstractLinkBrowserController {
return;
}
if (!empty($this->currentLinkParts['class'])) {
// remove required classes
$currentClasses = GeneralUtility::trimExplode(' ', $this->currentLinkParts['class'], true);
if (count($currentClasses) > 1) {
$this->currentLinkParts['class'] = end($currentClasses);
if (VersionUtility::isVersion870OrHigher()) {
if (!empty($this->currentLinkParts['url'])) {
/** @noinspection ExceptionsAnnotatingAndHandlingInspection */
/** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */
$linkService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\LinkHandling\LinkService::class);
$data = $linkService->resolve($this->currentLinkParts['url']);
$this->currentLinkParts['type'] = $data['type'];
unset($data['type']);
$this->currentLinkParts['url'] = $data;
}
}
if (empty($this->currentLinkParts['data-htmlarea-external'])) {
// strip siteUrl prefix except for external and mail links
if (strpos($this->currentLinkParts['url'], 'mailto:') === false) {
$paramsPosition = strpos($this->currentLinkParts['url'], '?');
if ($paramsPosition !== false) {
$this->currentLinkParts['url'] = substr($this->currentLinkParts['url'], $paramsPosition + 1);
if (!empty($this->currentLinkParts['class'])) {
// Only keep last class value (others are automatically added again by required option)
// https://review.typo3.org/#/c/29643
$currentClasses = GeneralUtility::trimExplode(' ', $this->currentLinkParts['class'], true);
if (count($currentClasses) > 1) {
$this->currentLinkParts['class'] = end($currentClasses);
}
}
// special treatment for page links, remove the id= part
$idPosition = strpos($this->currentLinkParts['url'], 'id=');
if ($idPosition !== false) {
$this->currentLinkParts['url'] = substr($this->currentLinkParts['url'], $idPosition + 3);
} else {
if (!empty($this->currentLinkParts['class'])) {
// remove required classes
$currentClasses = GeneralUtility::trimExplode(' ', $this->currentLinkParts['class'], TRUE);
if (count($currentClasses) > 1) {
$this->currentLinkParts['class'] = end($currentClasses);
}
}
// in RTE the additional params are encoded directly at the end of the href part
// we need to split this again into dedicated fields
$additionalParamsPosition = strpos($this->currentLinkParts['url'], '?');
if ($additionalParamsPosition === false) {
$additionalParamsPosition = strpos($this->currentLinkParts['url'], '&');
}
if ($additionalParamsPosition !== false) {
$this->currentLinkParts['params'] = substr($this->currentLinkParts['url'], $additionalParamsPosition);
$this->currentLinkParts['url'] = substr($this->currentLinkParts['url'], 0, $additionalParamsPosition);
// in case the first sign was an ? override it with &
$this->currentLinkParts['params'][0] = '&';
if (empty($this->currentLinkParts['data-htmlarea-external'])) {
// strip siteUrl prefix except for external and mail links
if (strpos($this->currentLinkParts['url'], 'mailto:') === FALSE) {
$paramsPosition = strpos($this->currentLinkParts['url'], '?');
if ($paramsPosition !== FALSE) {
$this->currentLinkParts['url'] = substr($this->currentLinkParts['url'], $paramsPosition + 1);
}
}
// special treatment for page links, remove the id= part
$idPosition = strpos($this->currentLinkParts['url'], 'id=');
if ($idPosition !== FALSE) {
$this->currentLinkParts['url'] = substr($this->currentLinkParts['url'], $idPosition + 3);
}
// in RTE the additional params are encoded directly at the end of the href part
// we need to split this again into dedicated fields
$additionalParamsPosition = strpos($this->currentLinkParts['url'], '?');
if ($additionalParamsPosition === FALSE) {
$additionalParamsPosition = strpos($this->currentLinkParts['url'], '&');
}
if ($additionalParamsPosition !== FALSE) {
$this->currentLinkParts['params'] = substr($this->currentLinkParts['url'], $additionalParamsPosition);
$this->currentLinkParts['url'] = substr($this->currentLinkParts['url'], 0, $additionalParamsPosition);
// in case the first sign was an ? override it with &
$this->currentLinkParts['params'][0] = '&';
}
}
}
@@ -589,4 +611,4 @@ class BrowseLinksController extends AbstractLinkBrowserController {
'contentTypo3Language' => $this->contentTypo3Language
];
}
}
\ No newline at end of file
}
Loading