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