Skip to content
Snippets Groups Projects
Commit 0cbda38c authored by Fabian Galinski's avatar Fabian Galinski :pouting_cat:
Browse files

[FEATURE] Adapation of the Linkbrowser for TYPO3 8

parent 8943e7ed
No related branches found
No related tags found
1 merge request!10Typo3v8compatibility
This commit is part of merge request !10. Comments created here will be created in the context of that merge request.
...@@ -15,6 +15,7 @@ namespace SGalinski\Tinymce4Rte\Controller; ...@@ -15,6 +15,7 @@ namespace SGalinski\Tinymce4Rte\Controller;
*/ */
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use SGalinski\Tinymce4Rte\Utility\VersionUtility;
use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
...@@ -210,39 +211,60 @@ class BrowseLinksController extends AbstractLinkBrowserController { ...@@ -210,39 +211,60 @@ class BrowseLinksController extends AbstractLinkBrowserController {
return; return;
} }
if (!empty($this->currentLinkParts['class'])) { if (VersionUtility::isVersion870OrHigher()) {
// remove required classes if (!empty($this->currentLinkParts['url'])) {
$currentClasses = GeneralUtility::trimExplode(' ', $this->currentLinkParts['class'], true); /** @noinspection ExceptionsAnnotatingAndHandlingInspection */
if (count($currentClasses) > 1) { /** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */
$this->currentLinkParts['class'] = end($currentClasses); $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'])) { if (!empty($this->currentLinkParts['class'])) {
// strip siteUrl prefix except for external and mail links // Only keep last class value (others are automatically added again by required option)
if (strpos($this->currentLinkParts['url'], 'mailto:') === false) { // https://review.typo3.org/#/c/29643
$paramsPosition = strpos($this->currentLinkParts['url'], '?'); $currentClasses = GeneralUtility::trimExplode(' ', $this->currentLinkParts['class'], true);
if ($paramsPosition !== false) { if (count($currentClasses) > 1) {
$this->currentLinkParts['url'] = substr($this->currentLinkParts['url'], $paramsPosition + 1); $this->currentLinkParts['class'] = end($currentClasses);
} }
} }
// special treatment for page links, remove the id= part } else {
$idPosition = strpos($this->currentLinkParts['url'], 'id='); if (!empty($this->currentLinkParts['class'])) {
if ($idPosition !== false) { // remove required classes
$this->currentLinkParts['url'] = substr($this->currentLinkParts['url'], $idPosition + 3); $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 if (empty($this->currentLinkParts['data-htmlarea-external'])) {
// we need to split this again into dedicated fields // strip siteUrl prefix except for external and mail links
$additionalParamsPosition = strpos($this->currentLinkParts['url'], '?'); if (strpos($this->currentLinkParts['url'], 'mailto:') === FALSE) {
if ($additionalParamsPosition === false) { $paramsPosition = strpos($this->currentLinkParts['url'], '?');
$additionalParamsPosition = strpos($this->currentLinkParts['url'], '&'); if ($paramsPosition !== FALSE) {
} $this->currentLinkParts['url'] = substr($this->currentLinkParts['url'], $paramsPosition + 1);
if ($additionalParamsPosition !== false) { }
$this->currentLinkParts['params'] = substr($this->currentLinkParts['url'], $additionalParamsPosition); }
$this->currentLinkParts['url'] = substr($this->currentLinkParts['url'], 0, $additionalParamsPosition); // special treatment for page links, remove the id= part
// in case the first sign was an ? override it with & $idPosition = strpos($this->currentLinkParts['url'], 'id=');
$this->currentLinkParts['params'][0] = '&'; 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 { ...@@ -589,4 +611,4 @@ class BrowseLinksController extends AbstractLinkBrowserController {
'contentTypo3Language' => $this->contentTypo3Language 'contentTypo3Language' => $this->contentTypo3Language
]; ];
} }
} }
\ No newline at end of file
...@@ -359,55 +359,56 @@ class RichTextElement extends AbstractFormElement { ...@@ -359,55 +359,56 @@ class RichTextElement extends AbstractFormElement {
* @return void * @return void
*/ */
protected function enableRegisteredPlugins() { protected function enableRegisteredPlugins() {
// $plugins = [ // @todo repair this
$plugins = [
// 'TYPO3Image' => [ // 'TYPO3Image' => [
// 'objectReference' => Typo3Image::class, // 'objectReference' => Typo3Image::class,
// ], // ],
// 'TYPO3Link' => [ 'TYPO3Link' => [
// 'objectReference' => TYPO3Link::class, 'objectReference' => TYPO3Link::class,
// ], ],
// ]; ];
// foreach ($plugins as $pluginId => $pluginObjectConfiguration) { foreach ($plugins as $pluginId => $pluginObjectConfiguration) {
// if (is_array($pluginObjectConfiguration) && isset($pluginObjectConfiguration['objectReference'])) { if (is_array($pluginObjectConfiguration) && isset($pluginObjectConfiguration['objectReference'])) {
// /** @var RteHtmlAreaApi $plugin */ /** @var RteHtmlAreaApi $plugin */
// $plugin = GeneralUtility::makeInstance($pluginObjectConfiguration['objectReference']); $plugin = GeneralUtility::makeInstance($pluginObjectConfiguration['objectReference']);
// $configuration = array( $configuration = array(
// 'language' => $this->language, 'language' => $this->language,
// 'contentTypo3Language' => $this->contentTypo3Language, 'contentTypo3Language' => $this->contentTypo3Language,
// 'contentISOLanguage' => $this->contentISOLanguage, 'contentISOLanguage' => $this->contentISOLanguage,
// 'contentLanguageUid' => $this->contentLanguageUid, 'contentLanguageUid' => $this->contentLanguageUid,
// 'RTEsetup' => $this->vanillaRteTsConfig, 'RTEsetup' => $this->vanillaRteTsConfig,
// 'client' => $this->client, 'client' => $this->client,
// 'thisConfig' => $this->processedRteConfiguration, 'thisConfig' => $this->processedRteConfiguration,
// 'specConf' => $this->defaultExtras, 'specConf' => $this->defaultExtras,
// ); );
// if ($plugin->main($configuration)) { if ($plugin->main($configuration)) {
// $this->registeredPlugins[$pluginId] = $plugin; $this->registeredPlugins[$pluginId] = $plugin;
// // Override buttons from previously registered plugins // Override buttons from previously registered plugins
// $pluginButtons = GeneralUtility::trimExplode(',', $plugin->getPluginButtons(), TRUE); $pluginButtons = GeneralUtility::trimExplode(',', $plugin->getPluginButtons(), TRUE);
// foreach ($this->pluginButton as $previousPluginId => $buttonList) { foreach ($this->pluginButton as $previousPluginId => $buttonList) {
// $this->pluginButton[$previousPluginId] = implode(',', array_diff(GeneralUtility::trimExplode(',', $this->pluginButton[$previousPluginId], TRUE), $pluginButtons)); $this->pluginButton[$previousPluginId] = implode(',', array_diff(GeneralUtility::trimExplode(',', $this->pluginButton[$previousPluginId], TRUE), $pluginButtons));
// } }
// $this->pluginButton[$pluginId] = $plugin->getPluginButtons(); $this->pluginButton[$pluginId] = $plugin->getPluginButtons();
// $pluginLabels = GeneralUtility::trimExplode(',', $plugin->getPluginLabels(), TRUE); $pluginLabels = GeneralUtility::trimExplode(',', $plugin->getPluginLabels(), TRUE);
// foreach ($this->pluginLabel as $previousPluginId => $labelList) { foreach ($this->pluginLabel as $previousPluginId => $labelList) {
// $this->pluginLabel[$previousPluginId] = implode(',', array_diff(GeneralUtility::trimExplode(',', $this->pluginLabel[$previousPluginId], TRUE), $pluginLabels)); $this->pluginLabel[$previousPluginId] = implode(',', array_diff(GeneralUtility::trimExplode(',', $this->pluginLabel[$previousPluginId], TRUE), $pluginLabels));
// } }
// $this->pluginLabel[$pluginId] = $plugin->getPluginLabels(); $this->pluginLabel[$pluginId] = $plugin->getPluginLabels();
// $this->pluginEnabledArray[] = $pluginId; $this->pluginEnabledArray[] = $pluginId;
// } }
// } }
// } }
//
// // Process overrides // Process overrides
// $hidePlugins = array(); $hidePlugins = array();
// foreach ($this->registeredPlugins as $pluginId => $plugin) { foreach ($this->registeredPlugins as $pluginId => $plugin) {
// /** @var RteHtmlAreaApi $plugin */ /** @var RteHtmlAreaApi $plugin */
// if ($plugin->addsButtons() && !$this->pluginButton[$pluginId]) { if ($plugin->addsButtons() && !$this->pluginButton[$pluginId]) {
// $hidePlugins[] = $pluginId; $hidePlugins[] = $pluginId;
// } }
// } }
// $this->pluginEnabledArray = array_unique(array_diff($this->pluginEnabledArray, $hidePlugins)); $this->pluginEnabledArray = array_unique(array_diff($this->pluginEnabledArray, $hidePlugins));
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment