1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
15:
16: cInclude('includes', 'functions.lang.php');
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: class cTinyMCE4Editor extends cWYSIWYGEditor {
56:
57: 58: 59: 60: 61:
62: private $_baseURL;
63:
64: 65: 66: 67: 68:
69: private $_useGZIP = false;
70:
71: 72: 73: 74: 75:
76: private $_cmsTypes = array();
77:
78: 79: 80: 81: 82:
83: protected static $_configPrefix = '[\'wysiwyg\'][\'tinymce4\']';
84:
85: 86: 87: 88: 89:
90: public function __construct($editorName, $editorContent) {
91:
92: $belang = cRegistry::getBackendLanguage();
93: $client = cRegistry::getClientId();
94: $cfgClient = cRegistry::getClientConfig();
95: $lang = cRegistry::getLanguageId();
96: $idart = cRegistry::getArticleId();
97:
98: parent::__construct($editorName, $editorContent);
99: $this->_setEditor("tinymce4");
100: $this->_aSettings = array();
101:
102:
103: $this->_aSettings = cTinymce4Configuration::get(array(), 'tinymce4');
104:
105:
106: $oTypeColl = new cApiTypeCollection();
107: $oTypeColl->select();
108: while (false !== ($typeEntry = $oTypeColl->next())) {
109:
110: $curType = $typeEntry->get('type');
111:
112: $contentTypeClassName = cTypeGenerator::getContentTypeClassName($curType);
113: if (false === class_exists($contentTypeClassName)) {
114: continue;
115: }
116: $cContentType = new $contentTypeClassName(null, 0, array());
117: if (false === $cContentType->isWysiwygCompatible()) {
118: continue;
119: }
120:
121: if (false === isset($this->_aSettings[$curType])) {
122: $this->_aSettings[$curType] = array();
123: }
124:
125: $this->_cmsTypes[$curType] = true;
126: }
127:
128:
129: foreach ($this->_aSettings as $curSettingKey => $curSetting) {
130:
131: if (false === array_key_exists($curSettingKey, $this->_cmsTypes)) {
132:
133:
134:
135: foreach ($this->_cmsTypes as $curTypeKey => $curType) {
136: if (false === isset($this->_aSettings[$curType])) {
137: $this->_aSettings[$curTypeKey][$curSettingKey] = $curSetting;
138: }
139: }
140:
141:
142: unset($this->_aSettings[$curSettingKey]);
143: }
144: }
145:
146:
147:
148: $this->_aSettings = cApiCecHook::executeAndReturn('Contenido.WYSIWYG.LoadConfiguration', $this->_aSettings, $this->_sEditor);
149:
150:
151:
152:
153:
154: foreach ($this->_aSettings as $cmsType => $setting) {
155:
156: if (false === isset($this->_cmsTypes[$cmsType])) {
157: continue;
158: }
159: $this->setSetting($cmsType, "article_url_suffix", 'front_content.php?idart=' . $idart, true);
160:
161:
162:
163:
164: $this->setSetting($cmsType, 'selector', ('.' . $cmsType), true);
165:
166: $this->setSetting($cmsType, "content_css", $cfgClient[$client]["path"]["htmlpath"] . "css/style_tiny.css");
167:
168: $this->setSetting($cmsType, "theme", "modern");
169: $this->setSetting($cmsType, "remove_script_host", false);
170:
171: $this->setSetting($cmsType, "urlconverter_callback", "Con.Tiny.customURLConverterCallback");
172:
173: $this->setSetting($cmsType, "pagebreak_separator", "<!-- my page break -->");
174:
175: $this->setSetting($cmsType, "remove_linebreaks", false);
176:
177:
178: $this->setSetting($cmsType, "convert_urls", false);
179: $this->setSetting($cmsType, "relative_urls", false);
180:
181:
182: $aLangs = i18nGetAvailableLanguages();
183: $this->setSetting($cmsType, "language", $aLangs[$belang][4]);
184: unset($aLangs);
185:
186:
187:
188: $this->setSetting($cmsType, 'document_base_url', cRegistry::getFrontendUrl(), true);
189:
190:
191:
192:
193: $this->setBaseURL($this->_getEditorPath());
194:
195:
196: if (getEffectiveSetting("generator", "xhtml", false) == "true") {
197: $this->setXHTMLMode($cmsType, true);
198: } else {
199: $this->setXHTMLMode($cmsType, false);
200: }
201:
202:
203: if (false === isset($this->_aSettings[$cmsType]["contenido_gzip"])
204: || "true" !== $this->_aSettings[$cmsType]["contenido_gzip"]) {
205: $this->setGZIPMode(false);
206: } else {
207: $this->setGZIPMode(true);
208: }
209:
210:
211: $this->setLists($cmsType);
212:
213:
214: $this->setUserDefinedStyles($cmsType);
215:
216:
217: $this->setSetting($cmsType, "width", "100%");
218: $this->setSetting($cmsType, "height", "480px");
219:
220:
221: $sDirection = langGetTextDirection($lang);
222: $this->setSetting($cmsType, "directionality", $sDirection);
223:
224:
225: $this->setSetting($cmsType, "plugin_insertdate_dateFormat", $this->convertFormat(getEffectiveSetting("dateformat", "date", "Y-m-d")));
226: $this->setSetting($cmsType, "plugin_insertdate_timeFormat", $this->convertFormat(getEffectiveSetting("dateformat", "time", "H:i:s")));
227:
228:
229: $sMode = "full";
230: if (array_key_exists("contenido_toolbar_mode", $this->_aSettings[$cmsType])) {
231: $sMode = $this->_aSettings[$cmsType]["contenido_toolbar_mode"];
232: }
233: $this->setToolbar($cmsType, trim(strtolower($sMode)));
234:
235: $autoFullElements = $this->_aSettings[$cmsType]['auto_full_elements'];
236: if (true === isset($this->_aSettings[$cmsType]['auto_full_elements'])) {
237: unset($this->_aSettings[$cmsType]['auto_full_elements']);
238: }
239:
240:
241:
242:
243: if ($autoFullElements === 'true') {
244: $this->setSetting($cmsType, 'valid_elements', '*[*]');
245: $this->setSetting($cmsType, 'extended_valid_elements', '*[*]');
246: }
247:
248:
249:
250: $validElements = "a[name|href|target|title],strong/b[class],em/i[class],strike[class],u[class],p[dir|class|style],ol,ul,li[style],br,img[class|src|border=0|alt|title|hspace|vspace|width|height|style],sub,sup,blockquote[dir|style],table[border=0|cellspacing|cellpadding|width|height|class|style],tr[class|rowspan|width|height|valign|style],td[dir|class|colspan|rowspan|width|height|valign|style],div[dir|class|style],span[class|style],pre[class|style],address[class|style],h1[dir|class|style],h2[dir|class|style],h3[dir|class|style],h4[dir|class|style],h5[dir|class|style],h6[dir|class|style],hr";
251:
252:
253: $validElements .= "iframe[src|width|height],object[data|width|height|type],audio[controls|src],source[src|type],script[src],video[width|height|poster|controls]";
254:
255:
256: $this->setSetting($cmsType, "valid_elements", $validElements);
257:
258:
259: if (!array_key_exists("extended_valid_elements", $this->_aSettings[$cmsType]) && array_key_exists("tinymce-extended-valid-elements", $this->_aSettings[$cmsType])) {
260: $this->setSetting($cmsType, "extended_valid_elements", $this->_aSettings["tinymce-extended-valid-elements"]);
261: }
262:
263: $this->setSetting($cmsType, "extended_valid_elements", "form[name|action|method],textarea[name|style|cols|rows],input[type|name|value|style|onclick],a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|style|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|style]");
264:
265:
266: $this->cleanURLs($cmsType);
267:
268:
269: unset($this->_aSettings[$cmsType]["contenido_toolbar_mode"], $this->_aSettings[$cmsType]["contenido_lists"]);
270:
271: unset($this->_aSettings[$cmsType]["tinymce-stylesheet-file"], $this->_aSettings[$cmsType]["tinymce-valid-elements"], $this->_aSettings[$cmsType]["tinymce-extended-valid-elements"], $this->_aSettings[$cmsType]["tinymce-lists"], $this->_aSettings[$cmsType]["tinymce-styles"], $this->_aSettings[$cmsType]["tinymce-toolbar-mode"], $this->_aSettings[$cmsType]["tinymce-toolbar1"], $this->_aSettings[$cmsType]["tinymce-toolbar2"], $this->_aSettings[$cmsType]["tinymce-toolbar3"], $this->_aSettings[$cmsType]["tinymce4-plugins"]);
272: }
273: }
274:
275: 276: 277: 278: 279:
280: public function convertFormat($sInput) {
281: $aFormatCodes = array(
282: "y" => "%y", "Y" => "%Y", "d" => "%d", "m" => "%m", "H" => "%H", "h" => "%I", "i" => "%M", "s" => "%S", "a" => "%P", "A" => "%P"
283: );
284:
285: foreach ($aFormatCodes as $sFormatCode => $sReplacement) {
286: $sInput = str_replace($sFormatCode, $sReplacement, $sInput);
287: }
288:
289: return $sInput;
290: }
291:
292: 293: 294: 295:
296: public function setUserDefinedStyles($sType) {
297: $sStyles = "";
298:
299:
300:
301: if(true === isset($this->_aSettings[$sType])
302: && true === isset($this->_aSettings[$sType][$sType])) {
303: if (array_key_exists('style_formats', $this->_aSettings[$sType][$sType])) {
304: $sStyles = $this->_aSettings[$sType]["style_formats"];
305: if (strlen($sStyles) > 0) {
306:
307: if (null !== json_decode($sStyles)) {
308: $this->setSetting($sType, 'style_formats', json_decode($sStyles), true);
309: }
310: }
311: }
312: }
313: }
314:
315: 316: 317: 318: 319: 320:
321: public function setLists($sType) {
322: $client = cRegistry::getClientId();
323: $lang = cRegistry::getLanguageId();
324:
325: $aLists = array();
326: if (array_key_exists("contenido_lists", $this->_aSettings[$sType])) {
327: $aLists = $this->_aSettings[$sType]["contenido_lists"];
328: }
329:
330:
331: if (true === isset($aLists['link'])) {
332: $this->setSetting($sType, 'link_list', $this->_baseURL . 'contenido/ajax/class.tinymce_list.php?mode=link&lang=' . $lang . '&client=' . $client . '#', true);
333: }
334:
335: if (true === isset($aLists['image'])) {
336: $this->setSetting($sType, 'image_list', $this->_baseURL . 'contenido/ajax/class.tinymce_list.php?mode=image&lang=' . $lang . '&client=' . $client . '#', true);
337: }
338:
339: }
340:
341: 342: 343: 344: 345: 346: 347: 348:
349: public function setXHTMLMode($sType, $bEnabled = true) {
350: if ($bEnabled) {
351: $this->setSetting($sType, 'cleanup_callback', '', true);
352: } else {
353: $this->setSetting($sType, 'cleanup_callback', 'Con.Tiny.customCleanupCallback', true);
354: }
355: }
356:
357: 358: 359: 360: 361:
362: private function setGZIPMode($bEnabled = true) {
363: if ($bEnabled) {
364: $this->_useGZIP = true;
365: } else {
366: $this->_useGZIP = false;
367: }
368: }
369:
370: 371: 372: 373: 374:
375: public function getGZIPMode() {
376: return (bool) $this->_useGZIP;
377: }
378:
379: 380: 381: 382: 383: 384: 385:
386: public function setToolbar($cmsType, $mode = "") {
387:
388: $cfgClient = cRegistry::getClientConfig();
389: $client = cRegistry::getClientId();
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405: switch ($mode) {
406: case "full":
407: if ('CMS_HTMLHEAD' === $cmsType) {
408: $defaultToolbar1 = cTinymce4Configuration::get('undo redo | consave conclose', 'tinymce4', $cmsType, 'tinymce4_full', 'toolbar1');
409: $defaultToolbar2 = cTinymce4Configuration::get('', 'tinymce4', $cmsType, 'tinymce4_full', 'toolbar2');
410: $defaultToolbar3 = cTinymce4Configuration::get('', 'tinymce4', $cmsType, 'tinymce4_full', 'toolbar3');
411: $defaultPlugins = cTinymce4Configuration::get('conclose', 'tinymce4', $cmsType, 'tinymce4_full', 'plugins');
412: $this->setSetting($cmsType, 'menubar', false, true);
413: } else {
414: $defaultToolbar1 = cTinymce4Configuration::get('cut copy paste pastetext | searchreplace | undo redo | bold italic underline strikethrough subscript superscript | insertdatetime preview | visualchars nonbreaking template pagebreak | help | fullscreen', 'tinymce4', $cmsType, 'tinymce4_full', 'toolbar1');
415: $defaultToolbar2 = cTinymce4Configuration::get('link unlink anchor image media hr | bullist numlist | outdent indent blockquote | alignleft aligncenter alignright alignfull removeformat | forecolor backcolor | ltr rtl | charmap | code', 'tinymce4', $cmsType, 'tinymce4_full', 'toolbar2');
416: $defaultToolbar3 = cTinymce4Configuration::get('table | formatselect fontselect fontsizeselect | consave conclose', 'tinymce4', $cmsType, 'tinymce4_full', 'toolbar3');
417: $defaultPlugins = cTinymce4Configuration::get('charmap code conclose table conclose hr image link pagebreak layer insertdatetime preview anchor media searchreplace print contextmenu paste directionality fullscreen visualchars nonbreaking template textcolor', 'tinymce4', $cmsType, 'tinymce4_full', 'plugins');
418: }
419: $this->setSetting($cmsType, 'inline', false, true);
420: $this->setSetting($cmsType, 'toolbar1', $defaultToolbar1, true);
421: $this->setSetting($cmsType, 'toolbar2', $defaultToolbar2, true);
422: $this->setSetting($cmsType, 'toolbar3', $defaultToolbar3, true);
423: $this->setSetting($cmsType, 'plugins', $defaultPlugins, true);
424:
425: $aCustSettings = cTinymce4Configuration::get(array(), 'tinymce4', $cmsType, 'tinymce4_full');
426: foreach ($aCustSettings as $key => $value) {
427: $this->setSetting($cmsType, $key, $value, true);
428: }
429: break;
430:
431: case "fullscreen":
432:
433: if ('CMS_HTMLHEAD' === $cmsType) {
434: $defaultToolbar1 = cTinymce4Configuration::get('undo redo | consave conclose', 'tinymce4', $cmsType, 'tinymce4_fullscreen', 'toolbar1');
435: $defaultToolbar2 = cTinymce4Configuration::get('', 'tinymce4', $cmsType, 'tinymce4_fullscreen', 'toolbar2');
436: $defaultToolbar3 = cTinymce4Configuration::get('', 'tinymce4', $cmsType, 'tinymce4_fullscreen', 'toolbar3');
437: $defaultPlugins = cTinymce4Configuration::get('conclose', 'tinymce4', $cmsType, 'tinymce4_fullscreen', 'plugins');
438: } else {
439: $defaultToolbar1 = cTinymce4Configuration::get('cut copy paste pastetext | searchreplace | undo redo | bold italic underline strikethrough subscript superscript | insertdatetime preview | visualchars nonbreaking template pagebreak | help | fullscreen', 'tinymce4', $cmsType, 'tinymce4_fullscreen', 'toolbar1');
440: $defaultToolbar2 = cTinymce4Configuration::get('link unlink anchor image media hr | bullist numlist | outdent indent blockquote | alignleft aligncenter alignright alignfull removeformat | forecolor backcolor | ltr rtl | charmap | code', 'tinymce4', $cmsType, 'tinymce4_fullscreen', 'toolbar2');
441: $defaultToolbar3 = cTinymce4Configuration::get('table | formatselect fontselect fontsizeselect | consave conclose', 'tinymce4', $cmsType, 'tinymce4_fullscreen', 'toolbar3');
442: $defaultPlugins = cTinymce4Configuration::get('charmap code table conclose hr image link pagebreak layer insertdatetime preview anchor media searchreplace print contextmenu paste directionality fullscreen visualchars nonbreaking template textcolor', 'tinymce4', $cmsType, 'tinymce4_fullscreen', 'plugins');
443: }
444: $this->setSetting($cmsType, 'inline', false, true);
445: $this->setSetting($cmsType, 'menubar', true, true);
446: $this->setSetting($cmsType, 'toolbar1', $defaultToolbar1, true);
447: $this->setSetting($cmsType, 'toolbar2', $defaultToolbar2, true);
448: $this->setSetting($cmsType, 'toolbar3', $defaultToolbar3, true);
449:
450: $this->setSetting($cmsType, 'plugins', $defaultPlugins, true);
451:
452: $aCustSettings = cTinymce4Configuration::get(array(), 'tinymce4', $cmsType, 'tinymce4_fullscreen');
453:
454: foreach ($aCustSettings as $key => $value) {
455: $this->setSetting($cmsType, $key, $value, true);
456: }
457:
458: break;
459:
460: case "simple":
461: $this->setSetting($cmsType, "toolbar1", "cut copy paste pastetext | searchreplace | undo redo | bold italic underline strikethrough subscript superscript | insertdatetime preview", true);
462: $this->setSetting($cmsType, "toolbar2", "link unlink anchor image | bullist numlist | outdent indent | alignleft aligncenter alignright alignfull removeformat | forecolor backcolor | ltr rtl | charmap | code", true);
463: $this->setSetting($cmsType, "toolbar3", "", true);
464:
465: $this->setSetting($cmsType, "plugins", "anchor charmap code insertdatetime preview searchreplace print contextmenu paste directionality textcolor", true);
466:
467: $aCustSettings = cTinymce4Configuration::get(array(), 'tinymce4', $cmsType, 'tinymce4_simple');
468: foreach ($aCustSettings as $key => $value) {
469: $this->setSetting($cmsType, $key, $value, true);
470: }
471:
472: break;
473:
474: case "mini":
475: $this->setSetting($cmsType, "toolbar1", "undo redo | bold italic underline strikethrough | link", true);
476: $this->setSetting($cmsType, "toolbar2", "", true);
477: $this->setSetting($cmsType, "toolbar3", "", true);
478:
479: $this->setSetting($cmsType, "plugins", "contextmenu", true);
480:
481: $aCustSettings = cTinymce4Configuration::get(array(), 'tinymce4', $cmsType, 'tinymce4_mini');
482: foreach ($aCustSettings as $key => $value) {
483: $this->setSetting($cmsType, $key, $value, true);
484: }
485:
486: break;
487:
488: case "custom":
489: $aCustSettings = cTinymce4Configuration::get(array(), 'tinymce4', $cmsType, 'tinymce4_custom');
490: foreach ($aCustSettings as $key => $value) {
491: $this->setSetting($cmsType, $key, $value, true);
492: }
493:
494: break;
495:
496: case "inline_edit":
497: if ('CMS_HTMLHEAD' === $cmsType) {
498: $defaultToolbar1 = cTinymce4Configuration::get('undo redo | consave conclose', 'tinymce4', $cmsType, 'tinymce4_inline', 'toolbar1');
499: $defaultToolbar2 = cTinymce4Configuration::get('', 'tinymce4', $cmsType, 'tinymce4_inline', 'toolbar2');
500: $defaultToolbar3 = cTinymce4Configuration::get('', 'tinymce4', $cmsType, 'tinymce4_inline', 'toolbar3');
501: $defaultPlugins = cTinymce4Configuration::get('conclose', 'tinymce4', $cmsType, 'tinymce4_inline', 'plugins');
502: } else {
503: $defaultToolbar1 = cTinymce4Configuration::get('bold italic underline strikethrough | undo redo | bullist numlist separator forecolor backcolor | alignleft aligncenter alignright | confullscreen | consave conclose', 'tinymce4', $cmsType, 'tinymce4_inline', 'plugins');
504: $defaultToolbar2 = cTinymce4Configuration::get('', 'tinymce4', $cmsType, 'tinymce4_inline', 'toolbar2');
505: $defaultToolbar3 = cTinymce4Configuration::get('', 'tinymce4', $cmsType, 'tinymce4_inline', 'toolbar3');
506: $defaultPlugins = cTinymce4Configuration::get('conclose confullscreen media table textcolor', 'tinymce4', $cmsType, 'tinymce4_inline', 'plugins');
507: }
508: $this->setSetting($cmsType, 'inline', true, true);
509: $this->setSetting($cmsType, 'menubar', false, true);
510: $this->setSetting($cmsType, 'toolbar1', $defaultToolbar1, true);
511: $this->setSetting($cmsType, 'toolbar2', $defaultToolbar2, true);
512: $this->setSetting($cmsType, 'toolbar3', $defaultToolbar3, true);
513:
514:
515: $this->_unsetSetting($cmsType, "width");
516: $this->setSetting($cmsType, "height", "210px", true);
517:
518:
519:
520:
521:
522: $this->setSetting($cmsType, "plugins", $defaultPlugins, true);
523:
524:
525: $this->setSetting($cmsType, 'inline', true);
526: $this->setSetting($cmsType, 'menubar', false);
527: $this->setSetting($cmsType, "content_css", $cfgClient[$client]["path"]["htmlpath"] . "css/style_tiny.css", true);
528:
529: $aCustSettings = cTinymce4Configuration::get(array(), 'tinymce4', $cmsType, 'tinymce4_inline');
530: foreach ($aCustSettings as $key => $value) {
531: $this->setSetting($cmsType, $key, $value, true);
532: }
533:
534: break;
535:
536: default:
537: $this->setSetting($cmsType, 'toolbar1', 'undo redo | bold italic underline strikethrough | link unlink anchor image | table', true);
538: $this->setSetting($cmsType, 'toolbar2', 'styleselect | bullist numlist | outdent indent | alignleft aligncenter alignright alignfull removeformat | forecolor backcolor | subscript superscript | code', true);
539: $this->setSetting($cmsType, 'toolbar3', "", true);
540: $this->setSetting($cmsType, 'plugins', "anchor code contextmenu media paste table searchreplace textcolor", true);
541:
542: $aCustSettings = cTinymce4Configuration::get(array(), 'tinymce4', $cmsType, 'tinymce_default');
543: foreach ($aCustSettings as $key => $value) {
544: $this->setSetting($cmsType, $key, $value, true);
545: }
546: }
547: }
548:
549: 550: 551: 552:
553: public function cleanURLs($cmsType) {
554:
555: $sess = cRegistry::getBackendSessionId();
556:
557:
558: $aParameters = array(
559:
560: 'content_css', 'popups_css', 'popups_css_add', 'editor_css',
561: 'plugin_preview_pageurl',
562: 'media_external_list_url',
563: 'template_external_list_url'
564: );
565:
566: foreach ($aParameters as $sParameter) {
567: if (array_key_exists($sParameter, $this->_aSettings[$cmsType])) {
568: $this->setSetting($cmsType, $sParameter, $this->addPath($this->_aSettings[$cmsType][$sParameter]), true);
569: }
570: }
571:
572:
573: $aParameters = array(
574: 'media_external_list_url',
575: 'template_external_list_url'
576: );
577:
578: foreach ($aParameters as $sParameter) {
579: if (array_key_exists($sParameter, $this->_aSettings[$cmsType]) && preg_match('/\\.php$/i', $this->_aSettings[$cmsType][$sParameter])) {
580: $this->setSetting($cmsType, $sParameter, $this->_aSettings[$cmsType][$sParameter] . '?contenido=' . $sess->id, true);
581: }
582: }
583: }
584:
585: 586: 587: 588: 589:
590: public function addPath($file) {
591:
592: $cfgClient = cRegistry::getClientConfig();
593: $client = cRegistry::getClientId();
594:
595:
596: if (!preg_match('/^(http|https):\/\/((?:[a-zA-Z0-9_-]+\.?)+):?(\d*)/', $file)) {
597: if (preg_match('/^\//', $file)) {
598: $file = "http://" . $_SERVER['HTTP_HOST'] . $file;
599: } else {
600: $file = $cfgClient[$client]["htmlpath"]["frontend"] . $file;
601: }
602: }
603:
604: return $file;
605: }
606:
607: 608: 609: 610:
611: public function setBaseURL($baseUrl) {
612: $this->_baseURL = $baseUrl;
613: }
614:
615: 616: 617: 618:
619: public function getScripts() {
620: if ($this->_useGZIP) {
621: $return = "\n<!-- tinyMCE -->\n" . '<script language="javascript" type="text/javascript" src="' . $this->_baseURL . 'tinymce/js/tinymce/tinymce.gzip.js"></script>';
622: } else {
623: $return = "\n<!-- tinyMCE -->\n" . '<script language="javascript" type="text/javascript" src="' . $this->_baseURL . 'tinymce/js/tinymce/tinymce.min.js"></script>';
624: }
625:
626: return $return;
627: }
628:
629: 630: 631: 632:
633: public function getEditor() {
634:
635: $sess = cRegistry::getBackendSessionId();
636: $cfg = cRegistry::getConfig();
637: $client = cRegistry::getClientId();
638: $cfgClient = cRegistry::getClientConfig();
639:
640:
641: $sess->register("browserparameters");
642:
643:
644:
645: $template = new cTemplate();
646:
647: $template->set('s', 'CONFIG', json_encode($this->_aSettings));
648:
649: $template->set('s', 'PATH_CONTENIDO_FULLHTML', cRegistry::getConfigValue('path', 'contenido_fullhtml'));
650: $template->set('s', 'IMAGEBROWSER', $cfg["path"]["contenido_fullhtml"] . 'frameset.php?area=upl&contenido=' . $sess->id . '&appendparameters=imagebrowser');
651: $template->set('s', 'FILEBROWSER', $cfg["path"]["contenido_fullhtml"] . 'frameset.php?area=upl&contenido=' . $sess->id . '&appendparameters=filebrowser');
652: $template->set('s', 'MEDIABROWSER', $cfg["path"]["contenido_fullhtml"] . 'frameset.php?area=upl&contenido=' . $sess->id . '&appendparameters=imagebrowser');
653: $template->set('s', 'FRONTEND_PATH', $cfgClient[$client]["path"]["htmlpath"]);
654: $template->set('s', 'CLOSE', html_entity_decode(i18n('Close editor'), ENT_COMPAT | ENT_HTML401, cRegistry::getEncoding()));
655: $template->set('s', 'SAVE', html_entity_decode(i18n('Close editor and save changes'), ENT_COMPAT | ENT_HTML401, cRegistry::getEncoding()));
656: $template->set('s', 'QUESTION', html_entity_decode(i18n('You have unsaved changes.'), ENT_COMPAT | ENT_HTML401, cRegistry::getEncoding()));
657: $template->set('s', 'BACKEND_URL', cRegistry::getBackendUrl());
658:
659: $txtEditor = new cHTMLTextarea($this->_sEditorName, $this->_sEditorContent);
660: $txtEditor->setId($this->_sEditorName);
661: $txtEditor->setClass(htmlentities($this->_sEditorName));
662:
663: $txtEditor->setStyle("width: " . $this->_aSettings['width'] . "; height: " . $this->_aSettings['height'] . ";");
664:
665: $return = $template->generate($cfg['path']['all_wysiwyg'] . $this->_sEditor . "contenido/templates/template.tinymce_tpl.html", true);
666: $return .= $txtEditor->render();
667:
668: return $return;
669: }
670:
671: 672: 673: 674: 675: 676: 677: 678: 679: 680: 681: 682: 683: 684:
685: public function setSetting($type, $key, $value, $forceSetting = false) {
686: if ($forceSetting || !array_key_exists($key, $this->_aSettings[$type])) {
687: $this->_aSettings[$type][$key] = $value;
688: }
689: }
690:
691: 692: 693: 694: 695:
696: protected function _unsetSetting($key = '') {
697: $numargs = func_num_args();
698:
699: if (0 === $numargs) {
700: return;
701: }
702:
703: $result = &$this->_aSettings;
704: for ($i = 0; $i < $numargs -1; $i++) {
705:
706: if (false === in_array(func_get_arg(1 + $i), $this->_aSettings)) {
707: return;
708: }
709:
710: $result = $result[func_get_arg(1 + $i)];
711: }
712:
713:
714: unset($result);
715: }
716:
717:
718: 719: 720: 721:
722: public function getConfigInlineEdit() {
723:
724:
725:
726: foreach ($this->_cmsTypes as $cmsType => $setting) {
727: $this->setToolbar($cmsType, 'inline_edit');
728: }
729: return $this->_aSettings;
730:
731: 732: 733: 734: 735: 736: 737: 738: 739: 740: 741: 742: 743: 744: 745: 746: 747: 748: 749: 750: 751: 752:
753: }
754:
755: 756: 757: 758:
759: public function getConfigFullscreen() {
760:
761: foreach ($this->_cmsTypes as $cmsType => $setting) {
762: $this->setToolbar($cmsType, 'fullscreen');
763: }
764:
765: return $this->_aSettings;
766:
767: }
768:
769: 770: 771: 772: 773: 774: 775:
776: public function getPlugins() {
777: return cSecurity::toString($this->_aSettings['plugins']);
778: }
779:
780: 781: 782: 783: 784: 785: 786:
787: function getThemes() {
788: return cSecurity::toString($this->_aSettings['theme']);
789: }
790:
791: 792: 793: 794: 795: 796: 797: 798: 799: 800: 801: 802: 803:
804: public static function saveConfig($config) {
805: parent::saveConfig($config['tinymce4']);
806: }
807: }
808: