-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathboot.php
More file actions
94 lines (82 loc) · 4.84 KB
/
boot.php
File metadata and controls
94 lines (82 loc) · 4.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
use FriendsOfRedaxo\TinyMce\Creator\Profiles as TinyMceProfilesCreator;
use FriendsOfRedaxo\TinyMce\Provider\Assets as TinyMceAssetsProvider;
use FriendsOfRedaxo\TinyMce\Utils\AssetUrl;
$addon = rex_addon::get('tinymce');
if (rex::isBackend() && is_object(rex::getUser())) {
rex_perm::register('tinymce_addon[]');
// Register custom plugins with rex_url::addonAssets() for correct absolute paths
$pluginBasePath = AssetUrl::getTinyPluginBaseUrl() . '/';
// Plugin registrations: plugin name, file path, button/feature names (optional)
$customPlugins = [
'link_yform' => ['link_yform/plugin.min.js', ['link_yform']],
'phonelink' => ['phonelink/plugin.min.js', ['phonelink']],
'quote' => ['quote/plugin.min.js', ['quote']],
'snippets' => ['snippets/plugin.min.js', ['snippets']],
'cleanpaste' => ['cleanpaste/plugin.min.js', []],
'mediapaste' => ['mediapaste/plugin.min.js', []],
'for_footnotes' => ['for_footnotes/plugin.min.js', ['for_footnote_insert', 'for_footnote_update']],
'for_checklist' => ['for_checklist/plugin.min.js', ['for_checklist', 'for_checklist_feature']],
'for_htmlembed' => ['for_htmlembed/plugin.min.js', ['for_htmlembed']],
'for_oembed' => ['for_oembed/plugin.min.js', ['for_oembed']],
'for_video' => ['for_video/plugin.min.js', ['for_video']],
'for_a11y' => ['for_a11y/plugin.min.js', ['for_a11y']],
'for_toc' => ['for_toc/plugin.min.js', ['for_toc_insert', 'for_toc_update']],
'for_markdown' => ['for_markdown/plugin.min.js', ['for_markdown_paste']],
'for_chars_symbols' => ['for_chars_symbols/plugin.min.js', ['for_chars_symbols']],
'for_abbr' => ['for_abbr/plugin.min.js', ['for_abbr']],
'for_images' => [
'for_images/plugin.min.js',
['imagewidthdialog', 'imagewidth', 'for_imagealignleft', 'for_imagealigncenter', 'for_imagealignright', 'for_imagealignnone', 'imageeffect', 'imagealt', 'imagecaption', 'imageshowpool', 'imageswappool'],
],
];
foreach ($customPlugins as $pluginName => $config) {
$filePath = $config[0];
$buttons = $config[1];
// If buttons are specified, register each button individually
if (!empty($buttons)) {
foreach ($buttons as $button) {
\FriendsOfRedaxo\TinyMce\PluginRegistry::addPlugin($pluginName, $pluginBasePath . $filePath, $button);
}
} else {
// No buttons specified (content-processing plugins)
\FriendsOfRedaxo\TinyMce\PluginRegistry::addPlugin($pluginName, $pluginBasePath . $filePath);
}
}
}
if (rex::isBackend() && null !== rex::getUser()) {
rex_extension::register('PACKAGES_INCLUDED', static function () {
TinyMceAssetsProvider::provideBaseAssets();
TinyMceAssetsProvider::provideDemoAssets();
TinyMceAssetsProvider::provideProfileEditData();
});
if ('tinymce' === rex_be_controller::getCurrentPagePart(1)) {
rex_extension::register(['REX_FORM_SAVED', 'REX_FORM_DELETED', 'TINY_PROFILE_CLONE', 'TINY_PROFILE_DELETE', 'TINY_PROFILE_ADD', 'TINY_PROFILE_UPDATED'], ['\FriendsOfRedaxo\TinyMce\Handler\Extension', 'createProfiles']);
}
if (str_starts_with(rex_request('page'), 'mediapool/') && ('tiny' === rex_request('addon', 'string', '') || 'REX_MEDIA_tinymce_filelink' === rex_request('opener_input_field', 'string', ''))) {
rex_extension::register('OUTPUT_FILTER', static function ($ep) {
$subject = $ep->getSubject();
$structureUrl = rex_url::backendPage('insertlink', array_filter([
'opener_input_field' => rex_request('opener_input_field', 'string', ''),
'clang' => rex_request('clang', 'string', ''),
], static fn ($value) => '' !== $value));
$subject = str_replace('</form>', '<input type="hidden" name="addon" value="tiny"></form>', $subject);
$subject = str_replace('"#rex-js-page-main">', '"#rex-js-page-main">
<ul class="nav nav-tabs tiny-nav">
<li><a href="' . rex_escape($structureUrl) . '">' . rex_escape(rex_i18n::msg('tinymce_tab_structure')) . '</a></li>
<li class="active"><a href="#">' . rex_escape(rex_i18n::msg('tinymce_tab_mediapool')) . '</a></li>
</ul>', $subject);
return str_replace('selectMedia', 'selectLink', $subject);
});
TinyMceAssetsProvider::providePopupAssets();
}
if (null !== $addon->getConfig('update_profiles', false)) {
try {
TinyMceProfilesCreator::profilesCreate();
$addon->setConfig('update_profiles', false);
} catch (rex_functional_exception $e) {
// Log generation failure to identify permission/disk issues
rex_logger::logException($e, 'tinymce_profiles_generation_failed');
}
}
}