2 namespace TYPO3\CMS\Rtehtmlarea\Controller;
57 $GLOBALS[
'LANG']->includeLLFile(
'EXT:rtehtmlarea/Resources/Private/Language/locallang_userelementscontroller.xlf');
58 $GLOBALS[
'LANG']->includeLLFile(
'EXT:rtehtmlarea/Resources/Private/Language/locallang_dialogs.xlf');
68 $this->editorNo = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP(
'editorNo');
69 $this->siteUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv(
'TYPO3_SITE_URL');
70 $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
71 $this->doc->bodyTagAdditions =
'onload="Init();"';
73 <form action="" id="process" name="process" method="post">
74 <input type="hidden" name="processContent" value="" />
75 <input type="hidden" name="returnUrl" value="' . htmlspecialchars(\TYPO3\CMS\Core\Utility\
GeneralUtility::getIndpEnv(
'REQUEST_URI')) .
'" />
78 var plugin = window.parent.RTEarea["' . $this->editorNo .
'"].editor.getPlugin("UserElements");
79 var HTMLArea = window.parent.HTMLArea;
80 var editor = plugin.editor;
84 function insertHTML(content,noHide) {
85 plugin.restoreSelection();
86 editor.getSelection().insertHtml(content);
87 if(!noHide) plugin.close();
89 function wrapHTML(wrap1,wrap2,noHide) {
90 plugin.restoreSelection();
91 if(!editor.getSelection().isEmpty()) {
92 editor.getSelection().surroundHtml(wrap1,wrap2);
96 if(!noHide) plugin.close();
98 function processSelection(script) {
99 plugin.restoreSelection();
100 document.process.action = script;
101 document.process.processContent.value = editor.getSelection().getHtml();
102 document.process.submit();
104 function jumpToUrl(URL) {
105 var RTEtsConfigParams = "&RTEtsConfigParams=' . rawurlencode(\TYPO3\CMS\Core\Utility\
GeneralUtility::_GP(
'RTEtsConfigParams')) .
'";
106 var editorNo = "&editorNo=' . rawurlencode($this->editorNo) .
'";
107 theLocation = URL+RTEtsConfigParams+editorNo;
108 window.location.href = theLocation;
113 unset($this->doc->JScodeArray[
'jumpToUrl']);
115 $this->doc->JScode = $this->doc->wrapScriptTags($JScode);
116 $this->modData =
$GLOBALS[
'BE_USER']->getModuleData(
'user.php',
'ses');
119 $this->modData[
'openKeys'][$parts[1]] = $parts[0] ==
'O' ? 1 : 0;
120 $GLOBALS[
'BE_USER']->pushModuleData(
'user.php', $this->modData);
149 $this->content .= $this->
main_user($this->modData[
'openKeys']);
175 public function calcWH($imgInfo, $maxW = 380, $maxH = 500)
180 $IH = ceil($IH / $IW * $maxW);
184 $IW = ceil($IW / $IH * $maxH);
187 $imgInfo[3] =
'width="' . $IW .
'" height="' . $IH .
'"';
200 $content = $this->doc->startPage(
$GLOBALS[
'LANG']->getLL(
'Insert Custom Element',
true));
201 $RTEtsConfigParts = explode(
':', \TYPO3\CMS\Core\Utility\
GeneralUtility::_GP(
'RTEtsConfigParams'));
203 $thisConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::RTEsetup($RTEsetup[
'properties'], $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
204 if (is_array($thisConfig[
'userElements.'])) {
205 $categories = array();
206 foreach ($thisConfig[
'userElements.'] as $k => $value) {
208 $v = $thisConfig[
'userElements.'][$ki .
'.'];
209 if (substr($k, -1) ==
'.' && is_array($v)) {
212 if ($openKeys[$openK]) {
214 if ($v[
'load'] ===
'images_from_folder') {
216 if ($v[
'path'] && @is_dir((PATH_site . $v[
'path']))) {
217 $files = \TYPO3\CMS\Core\Utility\GeneralUtility::getFilesInDir(PATH_site . $v[
'path'],
'gif,jpg,jpeg,png', 0,
'');
218 if (is_array($files)) {
221 $iInfo = @getimagesize((PATH_site . $v[
'path'] . $filename));
222 $iInfo = $this->
calcWH($iInfo, 50, 100);
223 $ks = (string)(100 + $c);
225 $mArray[$ks .
'.'] = array(
226 'content' =>
'<img src="' . $this->siteUrl . $v[
'path'] . $filename .
'" />',
227 '_icon' =>
'<img src="' . $this->siteUrl . $v[
'path'] . $filename .
'" ' . $iInfo[3] .
' />',
228 'description' =>
$GLOBALS[
'LANG']->getLL(
'filesize') .
': ' . str_replace(
' ',
' ', \TYPO3\CMS\Core\Utility\
GeneralUtility::formatSize(@filesize((PATH_site . $v[
'path'] . $filename)))) .
', ' .
$GLOBALS[
'LANG']->getLL(
'pixels', 1) .
': ' . $iInfo[0] .
'x' . $iInfo[1]
235 if (is_array($mArray)) {
237 \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($mArray, $v);
243 foreach ($v as $k2 => $dummyValue) {
245 if (substr($k2, -1) ==
'.' && is_array($v[$k2i .
'.'])) {
246 $title = trim($v[$k2i]);
248 $title =
'[' .
$GLOBALS[
'LANG']->getLL(
'noTitle',
true) .
']';
250 $title =
$GLOBALS[
'LANG']->sL($title,
true);
252 $description =
$GLOBALS[
'LANG']->sL($v[($k2i .
'.')][
'description'],
true) .
'<br />';
253 if (!$v[($k2i .
'.')][
'dontInsertSiteUrl']) {
254 $v[$k2i .
'.'][
'content'] = str_replace(
'###_URL###', $this->siteUrl, $v[$k2i .
'.'][
'content']);
256 $logo = $v[$k2i .
'.'][
'_icon'] ?:
'';
258 switch ((
string)$v[($k2i .
'.')][
'mode']) {
260 $wrap = explode(
'|', $v[$k2i .
'.'][
'content']);
264 $script = trim($v[$k2i .
'.'][
'submitToScript']);
265 if (substr($script, 0, 4) !=
'http') {
266 $script = $this->siteUrl . $script;
277 $A = array(
'<a href="#" onClick="' . $onClickEvent .
'return false;">',
'</a>');
278 $subcats[$k2i] =
'<tr>
280 <td class="bgColor4" valign="top">' . $A[0] . $logo . $A[1] .
'</td>
281 <td class="bgColor4" valign="top">' . $A[0] .
'<strong>' . $title .
'</strong><br />' . $description . $A[1] .
'</td>
287 $categories[$ki] = implode(
'', $subcats);
293 foreach ($categories as $k => $v) {
294 $title = trim($thisConfig[
'userElements.'][$k]);
297 $title =
'[' .
$GLOBALS[
'LANG']->getLL(
'noTitle',
true) .
']';
299 $title =
$GLOBALS[
'LANG']->sL($title,
true);
303 $url = (string)$uriBuilder->buildUriFromRoute(
'rtehtmlarea_wizard_user_elements', array(
'OC_key' => ($openKeys[$openK] ?
'C|' :
'O|') . $openK));
305 $lines[] =
'<tr><td colspan="3" class="bgColor5"><a href="#" title="' .
$GLOBALS[
'LANG']->getLL(
'expand',
true) .
'" onClick="jumpToUrl(' .
GeneralUtility::quoteJSvalue(
$url) .
');return false;"><i class="fa fa-caret-square-o-' . ($openKeys[$openK] ?
'left' :
'right') .
'" title="' .
$GLOBALS[
'LANG']->getLL(
'expand',
true) .
'"></i><strong>' . $title .
'</strong></a></td></tr>';
308 $content .=
'<table border="0" cellpadding="1" cellspacing="1">' . implode(
'', $lines) .
'</table>';