Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tinymce4_rte
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
TYPO3
tinymce4_rte
Commits
0cbda38c
Commit
0cbda38c
authored
7 years ago
by
Fabian Galinski
Browse files
Options
Downloads
Patches
Plain Diff
[FEATURE] Adapation of the Linkbrowser for TYPO3 8
parent
8943e7ed
No related branches found
No related tags found
1 merge request
!10
Typo3v8compatibility
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Classes/Controller/BrowseLinksController.php
+50
-28
50 additions, 28 deletions
Classes/Controller/BrowseLinksController.php
Classes/Form/Element/RichTextElement.php
+47
-46
47 additions, 46 deletions
Classes/Form/Element/RichTextElement.php
with
97 additions
and
74 deletions
Classes/Controller/BrowseLinksController.php
+
50
−
28
View file @
0cbda38c
...
...
@@ -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
}
This diff is collapsed.
Click to expand it.
Classes/Form/Element/RichTextElement.php
+
47
−
46
View file @
0cbda38c
...
...
@@ -359,55 +359,56 @@ class RichTextElement extends AbstractFormElement {
* @return void
*/
protected
function
enableRegisteredPlugins
()
{
// $plugins = [
// @todo repair this
$plugins
=
[
// 'TYPO3Image' => [
// 'objectReference' => Typo3Image::class,
// ],
//
'TYPO3Link' => [
//
'objectReference' => TYPO3Link::class,
//
],
//
];
//
foreach ($plugins as $pluginId => $pluginObjectConfiguration) {
//
if (is_array($pluginObjectConfiguration) && isset($pluginObjectConfiguration['objectReference'])) {
//
/** @var RteHtmlAreaApi $plugin */
//
$plugin = GeneralUtility::makeInstance($pluginObjectConfiguration['objectReference']);
//
$configuration = array(
//
'language' => $this->language,
//
'contentTypo3Language' => $this->contentTypo3Language,
//
'contentISOLanguage' => $this->contentISOLanguage,
//
'contentLanguageUid' => $this->contentLanguageUid,
//
'RTEsetup' => $this->vanillaRteTsConfig,
//
'client' => $this->client,
//
'thisConfig' => $this->processedRteConfiguration,
//
'specConf' => $this->defaultExtras,
//
);
//
if ($plugin->main($configuration)) {
//
$this->registeredPlugins[$pluginId] = $plugin;
//
// Override buttons from previously registered plugins
//
$pluginButtons = GeneralUtility::trimExplode(',', $plugin->getPluginButtons(), TRUE);
//
foreach ($this->pluginButton as $previousPluginId => $buttonList) {
//
$this->pluginButton[$previousPluginId] = implode(',', array_diff(GeneralUtility::trimExplode(',', $this->pluginButton[$previousPluginId], TRUE), $pluginButtons));
//
}
//
$this->pluginButton[$pluginId] = $plugin->getPluginButtons();
//
$pluginLabels = GeneralUtility::trimExplode(',', $plugin->getPluginLabels(), TRUE);
//
foreach ($this->pluginLabel as $previousPluginId => $labelList) {
//
$this->pluginLabel[$previousPluginId] = implode(',', array_diff(GeneralUtility::trimExplode(',', $this->pluginLabel[$previousPluginId], TRUE), $pluginLabels));
//
}
//
$this->pluginLabel[$pluginId] = $plugin->getPluginLabels();
//
$this->pluginEnabledArray[] = $pluginId;
//
}
//
}
//
}
//
//
// Process overrides
//
$hidePlugins = array();
//
foreach ($this->registeredPlugins as $pluginId => $plugin) {
//
/** @var RteHtmlAreaApi $plugin */
//
if ($plugin->addsButtons() && !$this->pluginButton[$pluginId]) {
//
$hidePlugins[] = $pluginId;
//
}
//
}
//
$this->pluginEnabledArray = array_unique(array_diff($this->pluginEnabledArray, $hidePlugins));
'TYPO3Link'
=>
[
'objectReference'
=>
TYPO3Link
::
class
,
],
];
foreach
(
$plugins
as
$pluginId
=>
$pluginObjectConfiguration
)
{
if
(
is_array
(
$pluginObjectConfiguration
)
&&
isset
(
$pluginObjectConfiguration
[
'objectReference'
]))
{
/** @var RteHtmlAreaApi $plugin */
$plugin
=
GeneralUtility
::
makeInstance
(
$pluginObjectConfiguration
[
'objectReference'
]);
$configuration
=
array
(
'language'
=>
$this
->
language
,
'contentTypo3Language'
=>
$this
->
contentTypo3Language
,
'contentISOLanguage'
=>
$this
->
contentISOLanguage
,
'contentLanguageUid'
=>
$this
->
contentLanguageUid
,
'RTEsetup'
=>
$this
->
vanillaRteTsConfig
,
'client'
=>
$this
->
client
,
'thisConfig'
=>
$this
->
processedRteConfiguration
,
'specConf'
=>
$this
->
defaultExtras
,
);
if
(
$plugin
->
main
(
$configuration
))
{
$this
->
registeredPlugins
[
$pluginId
]
=
$plugin
;
// Override buttons from previously registered plugins
$pluginButtons
=
GeneralUtility
::
trimExplode
(
','
,
$plugin
->
getPluginButtons
(),
TRUE
);
foreach
(
$this
->
pluginButton
as
$previousPluginId
=>
$buttonList
)
{
$this
->
pluginButton
[
$previousPluginId
]
=
implode
(
','
,
array_diff
(
GeneralUtility
::
trimExplode
(
','
,
$this
->
pluginButton
[
$previousPluginId
],
TRUE
),
$pluginButtons
));
}
$this
->
pluginButton
[
$pluginId
]
=
$plugin
->
getPluginButtons
();
$pluginLabels
=
GeneralUtility
::
trimExplode
(
','
,
$plugin
->
getPluginLabels
(),
TRUE
);
foreach
(
$this
->
pluginLabel
as
$previousPluginId
=>
$labelList
)
{
$this
->
pluginLabel
[
$previousPluginId
]
=
implode
(
','
,
array_diff
(
GeneralUtility
::
trimExplode
(
','
,
$this
->
pluginLabel
[
$previousPluginId
],
TRUE
),
$pluginLabels
));
}
$this
->
pluginLabel
[
$pluginId
]
=
$plugin
->
getPluginLabels
();
$this
->
pluginEnabledArray
[]
=
$pluginId
;
}
}
}
// Process overrides
$hidePlugins
=
array
();
foreach
(
$this
->
registeredPlugins
as
$pluginId
=>
$plugin
)
{
/** @var RteHtmlAreaApi $plugin */
if
(
$plugin
->
addsButtons
()
&&
!
$this
->
pluginButton
[
$pluginId
])
{
$hidePlugins
[]
=
$pluginId
;
}
}
$this
->
pluginEnabledArray
=
array_unique
(
array_diff
(
$this
->
pluginEnabledArray
,
$hidePlugins
));
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment