Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  1: <?php
  2: /**
  3:  * This file contains the WYSIWYG editor class for TinyMCE.
  4:  *
  5:  * @package    Core
  6:  * @subpackage Backend
  7:  * @version    SVN Revision $Rev:$
  8:  *
  9:  * @author     Thomas Stauer
 10:  * @copyright  four for business AG <www.4fb.de>
 11:  * @license    http://www.contenido.org/license/LIZENZ.txt
 12:  * @link       http://www.4fb.de
 13:  * @link       http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: cInclude('includes', 'functions.lang.php');
 19: 
 20: /**
 21:  * The object cTinyMCE4Editor is a wrapper class to the TinyMCE WYSIWYG Editor.
 22:  * Attributes can be defined to generate JavaScript options and functions to initialise the global
 23:  * tinymce object in file ./contenido/external/wysiwyg/tinymce4/contenido/templates/template.tinymce_tpl.html.
 24:  *
 25:  * All settings accepted by tinyMCE and its plugins may be specified using system, client
 26:  * group or user property/setting.
 27:  *
 28:  * The following parameters will be always set on initialization (even, if they have been specified
 29:  * as property. They can be set using setSetting later on, if needed):
 30:  * document_base_url
 31:  * cleanup_callback (-> XHTML)
 32:  * file_browser_callback
 33:  * external_link_list_url
 34:  * external_image_list_url
 35:  *
 36:  * The following settings are only used in CONTENIDO:
 37:  * contenido_toolbar_mode: full, simple, mini, custom
 38:  * contenido_lists: link,image
 39:  * contenido_height_html
 40:  * contenido_height_head
 41:  * See backend.customizing.html for details
 42:  *
 43:  * @package    Core
 44:  * @subpackage Backend
 45:  */
 46: class cTinyMCE4Editor extends cWYSIWYGEditor {
 47:     /**
 48:      * Stores base url of page
 49:      */
 50:     private $_sBaseURL;
 51: 
 52:     /**
 53:      * Stores, if GZIP compression will be used
 54:      */
 55:     private $_bUseGZIP = false;
 56: 
 57:     /**
 58:      * Access key under which the wysiwyg editor settings will be stored
 59:      * @var string
 60:      */
 61:     protected static $_sConfigPrefix = '[\'wysiwyg\'][\'tinymce4\']';
 62: 
 63:     public function __construct($sEditorName, $sEditorContent) {
 64:         global $idart;
 65:         
 66:         $belang = cRegistry::getBackendLanguage();
 67:         $cfg = cRegistry::getConfig();
 68:         $client = cRegistry::getClientId();
 69:         $cfgClient = cRegistry::getClientConfig();
 70:         $lang = cRegistry::getLanguageId();
 71: 
 72:         parent::__construct($sEditorName, $sEditorContent);
 73:         $this->_setEditor("tinymce4");
 74:         $this->_aSettings = array();
 75: 
 76:         // Retrieve all settings for tinymce 4, depending on CMS types
 77:         // define empty arrays for all CMS types that can be edited using a WYSIWYG editor
 78:         $oTypeColl = new cApiTypeCollection();
 79:         $oTypeColl->select();
 80:         while (false !== ($typeEntry = $oTypeColl->next())) {
 81:             // specify a shortcut for type field
 82:             $curType = $typeEntry->get('type');
 83: 
 84:             $contentTypeClassName = cTypeGenerator::getContentTypeClassName($curType);
 85:             if (false === class_exists($contentTypeClassName)) {
 86:                 continue;
 87:             }
 88:             $cContentType = new $contentTypeClassName(null, 0, array());
 89:             if (false === $cContentType->isWysiwygCompatible()) {
 90:                 continue;
 91:             }
 92:             $this->_aSettings[$curType] = cTinymce4Configuration::get(array(), 'tinymce4');
 93:         }
 94: 
 95:         // CEC for template pre processing
 96:         $this->_aSettings = cApiCecHook::executeAndReturn('Contenido.WYSIWYG.LoadConfiguration', $this->_aSettings, $this->_sEditor);
 97: 
 98:         // encode data to json when doing output instead of doing this here
 99:         // this way we can manipulate data easier in PHP
100: 
101:         // process settings for each cms type
102:         foreach ($this->_aSettings as $cmsType => $setting) {
103:             $this->_setSetting($cmsType, "article_url_suffix", 'front_content.php?idart=' . $idart, true);
104: 
105:             // Default values
106: 
107:             // apply editor to any cms type provided in preferences
108:             $this->_setSetting($cmsType, 'selector', ('.' . $cmsType), true);
109: 
110:             $this->_setSetting($cmsType, "content_css", $cfgClient[$client]["path"]["htmlpath"] . "css/style_tiny.css");
111: 
112:             $this->_setSetting($cmsType, "theme", "modern");
113:             $this->_setSetting($cmsType, "remove_script_host", false);
114: 
115:             $this->_setSetting($cmsType, "urlconverter_callback", "Con.Tiny.customURLConverterCallback");
116:             // New in V3.x
117:             $this->_setSetting($cmsType, "pagebreak_separator", "<!-- my page break -->"); // needs pagebreak plugin
118:             // Source formatting (ugh!)
119:             $this->_setSetting($cmsType, "remove_linebreaks", false); // Remove linebreaks - GREAT idea...
120: 
121:             // Convert URLs and Relative URLs default
122:             $this->_setSetting($cmsType, "convert_urls", false);
123:             $this->_setSetting($cmsType, "relative_urls", false);
124: 
125:             // Editor language
126:             $aLangs = i18nGetAvailableLanguages();
127:             $this->_setSetting($cmsType, "language", $aLangs[$belang][4]);
128:             unset($aLangs);
129: 
130:             // Set document base URL for all relative URLs
131:             // http://www.tinymce.com/wiki.php/Configuration:document_base_url
132:             $this->_setSetting($cmsType, 'document_base_url', cRegistry::getFrontendUrl(), true);
133: 
134:             // The following "base URL" is the URL used to reference JS script files
135:             // - it is not the base href value
136:             //$this->setBaseURL(preg_replace('/^https?:\/\/[^\/]+(.*)$/', '$1', $this->_getEditorPath()));
137:             $this->setBaseURL($this->_getEditorPath());
138: 
139:             // XHTML
140:             if (getEffectiveSetting("generator", "xhtml", false) == "true") {
141:                 $this->setXHTMLMode($cmsType, true);
142:             } else {
143:                 $this->setXHTMLMode($cmsType, false);
144:             }
145: 
146:             // GZIP
147:             if (false === isset($this->_aSettings[$cmsType]["contenido_gzip"])
148:             || "true" !== $this->_aSettings[$cmsType]["contenido_gzip"]) {
149:                 $this->setGZIPMode(false);
150:             } else {
151:                 $this->setGZIPMode(true);
152:             }
153: 
154:             // Set lists (for links and image elements)
155:             $this->setLists($cmsType);
156: 
157:             // Set user defined styles (be sure, that previous and SPAW syntax works)
158:             $this->setUserDefinedStyles($cmsType);
159: 
160:             // Width and height
161:             $this->_setSetting($cmsType, "width", "100%");
162:             $this->_setSetting($cmsType, "height", "480px");
163: 
164:             // Text direction (rtl = right to left)
165:             $sDirection = langGetTextDirection($lang);
166:             $this->_setSetting($cmsType, "directionality", $sDirection);
167: 
168:             // Date and time formats
169:             $this->_setSetting($cmsType, "plugin_insertdate_dateFormat", $this->convertFormat(getEffectiveSetting("dateformat", "date", "Y-m-d")));
170:             $this->_setSetting($cmsType, "plugin_insertdate_timeFormat", $this->convertFormat(getEffectiveSetting("dateformat", "time", "H:i:s")));
171: 
172:             // Setting the toolbar (toolbar_mode and tinymce-toolbar-mode accepted)
173:             $sMode = "full";
174:             if (array_key_exists("contenido_toolbar_mode", $this->_aSettings[$cmsType])) {
175:                 $sMode = $this->_aSettings[$cmsType]["contenido_toolbar_mode"];
176:             }
177:             $this->setToolbar($cmsType, trim(strtolower($sMode)));
178: 
179:             $autoFullElements = $this->_aSettings[$cmsType]['auto_full_elements'];
180:             if (true === isset($this->_aSettings[$cmsType]['auto_full_elements'])) {
181:                 unset($this->_aSettings[$cmsType]['auto_full_elements']);
182:             }
183: 
184:             // Specify valid elements that tinymce 4 is allowed to write
185: 
186:             // allow any element
187:             if ($autoFullElements === 'true') {
188:                 $this->_setSetting($cmsType, 'valid_elements', '*[*]');
189:                 $this->_setSetting($cmsType, 'extended_valid_elements', '*[*]');
190:             }
191: 
192:             // default valid elements that tinymce is allowed to write
193:             // http://www.tinymce.com/wiki.php/Configuration:valid_elements
194:             $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";
195: 
196:             // media plugin
197:             $validElements .= "iframe[src|width|height],object[data|width|height|type],audio[controls|src],source[src|type],script[src],video[width|height|poster|controls]";
198: 
199:             // pass valid elements to tinymce
200:             $this->_setSetting($cmsType, "valid_elements", $validElements); 
201: 
202:             // Extended valid elements, for compatibility also accepts "tinymce-extended-valid-elements"
203:             if (!array_key_exists("extended_valid_elements", $this->_aSettings[$cmsType]) && array_key_exists("tinymce-extended-valid-elements", $this->_aSettings[$cmsType])) {
204:                 $this->_setSetting($cmsType, "extended_valid_elements", $this->_aSettings["tinymce-extended-valid-elements"]);
205:             }
206: 
207:             $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]");
208: 
209:             // Clean all possible URLs
210:             $this->cleanURLs($cmsType);
211: 
212:             // Remove CONTENIDO specific settings
213:             unset($this->_aSettings[$cmsType]["contenido_toolbar_mode"], $this->_aSettings[$cmsType]["contenido_lists"]);
214:             // Remove obsolete, deprecated values
215:             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"]);
216:         }
217:     }
218: 
219:     function convertFormat($sInput) {
220:         $aFormatCodes = array(
221:             "y" => "%y", "Y" => "%Y", "d" => "%d", "m" => "%m", "H" => "%H", "h" => "%I", "i" => "%M", "s" => "%S", "a" => "%P", "A" => "%P"
222:         );
223: 
224:         foreach ($aFormatCodes as $sFormatCode => $sReplacement) {
225:             $sInput = str_replace($sFormatCode, $sReplacement, $sInput);
226:         }
227: 
228:         return ($sInput);
229:     }
230: 
231:     function setUserDefinedStyles($sType) {
232:         $sStyles = "";
233: 
234:         // convert tinymce's style formats from string to required JSON value
235:         // http://www.tinymce.com/wiki.php/Configuration:style_formats
236:         if(true === isset($this->_aSettings[$sType])
237:         && true === isset($this->_aSettings[$sType][$sType])) {
238:             if (array_key_exists('style_formats', $this->_aSettings[$sType][$sType])) {
239:                 $sStyles = $this->_aSettings[$sType]["style_formats"];
240:                 if (strlen($sStyles) > 0) {
241:                     // if json can be decoded
242:                     if (null !== json_decode($sStyles)) {
243:                         $this->_setSetting($sType, 'style_formats', json_decode($sStyles), true);
244:                     }
245:                 }
246:             }
247:         }
248:     }
249: 
250:     /**
251:      * The special name "contenido_lists"
252:      *
253:      * @param string $sType CMS type where XHTML mode setting wil be applies
254:      */
255:     function setLists($sType) {
256:         $client = cRegistry::getClientId();
257:         $lang = cRegistry::getLanguageId();
258: 
259:         $aLists = array();
260:         if (array_key_exists("contenido_lists", $this->_aSettings[$sType])) {
261:             $aLists = json_decode($this->_aSettings[$sType]["contenido_lists"], true);
262:         }
263: 
264:         // check if link list is activated
265:         if (true === isset($aLists['link'])) {
266:             $this->_setSetting($sType, 'link_list', $this->_sBaseURL . 'contenido/ajax/class.tinymce_list.php?mode=link&lang=' . $lang . '&client=' . $client . '#', true);
267:         }
268:         // check if image list is activated
269:         if (true === isset($aLists['image'])) {
270:             $this->_setSetting($sType, 'image_list', $this->_sBaseURL . 'contenido/ajax/class.tinymce_list.php?mode=image&lang=' . $lang . '&client=' . $client . '#', true);
271:         }
272:         // media list does not exist in tinymce 4, media plugin still available though
273:     }
274: 
275:     /**
276:      * Turn XHTML mode on or off
277:      * @param string $sType CMS type where XHTML mode setting wil be applies
278:      * @param string $bEnabled Whether to turn on XHTML mode
279:      */
280:     function setXHTMLMode($sType, $bEnabled = true) {
281:         if ($bEnabled) {
282:             $this->_setSetting($sType, 'cleanup_callback', '', true);
283:         } else {
284:             $this->_setSetting($sType, 'cleanup_callback', 'Con.Tiny.customCleanupCallback', true);
285:         }
286:     }
287: 
288:     /**
289:      * Set if editor should be loaded using tinymce4's gzip compression
290:      * @param string $bEnabled
291:      */
292:     private function setGZIPMode($bEnabled = true) {
293:         if ($bEnabled) {
294:             $this->_bUseGZIP = true;
295:         } else {
296:             $this->_bUseGZIP = false;
297:         }
298:     }
299: 
300:     /**
301:      * 
302:      * @return boolean if editor is loaded using gzip compression
303:      */
304:     public function getGZIPMode() {
305:         return (bool) $this->_bUseGZIP;
306:     }
307: 
308:     /**
309:      * For compatibility also accepts "tinymce-toolbar-mode", "tinymce-toolbar1-3" and "tinymce4-plugins"
310:      */
311:     public function setToolbar($cmsType, $sMode = "") {
312:         $cfg = cRegistry::getConfig();
313:         $cfgClient = cRegistry::getClientConfig();
314:         $client = cRegistry::getClientId();
315: 
316:         // hide visualaid button because it has no icon
317:         // http://www.tinymce.com/develop/bugtracker_view.php?id=6003
318: 
319:         // Overview of available controls and their required plugins:
320:         // http://www.tinymce.com/wiki.php/Controls
321: 
322:         // TODO:
323:         // Consider using
324:         // http://www.tinymce.com/wiki.php/Configuration:toolbar
325:         // instead of
326:         // http://www.tinymce.com/wiki.php/Configuration:toolbar%3CN%3E
327:         // 
328:         // This would allow users to specify more than just 3 toolbars in total
329: 
330:         switch ($sMode) {
331:             case "full": // Show all options
332:                 if ('CMS_HTMLHEAD' === $cmsType) {
333:                     $defaultToolbar1 = cTinymce4Configuration::get('undo redo | consave conclose', 'tinymce4', $cmsType, 'tinymce4_full', 'toolbar1');
334:                     $defaultToolbar2 = cTinymce4Configuration::get('', 'tinymce4', $cmsType, 'tinymce4_full', 'toolbar2');
335:                     $defaultToolbar3 = cTinymce4Configuration::get('', 'tinymce4', $cmsType, 'tinymce4_full', 'toolbar3');
336:                     $defaultPlugins = cTinymce4Configuration::get('conclose', 'tinymce4', $cmsType, 'tinymce4_full', 'plugins');
337:                     $this->_setSetting($cmsType, 'menubar', false, true);
338:                 } else {
339:                     $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');
340:                     $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');
341:                     $defaultToolbar3 = cTinymce4Configuration::get('table | formatselect fontselect fontsizeselect | consave conclose', 'tinymce4', $cmsType, 'tinymce4_full', 'toolbar3');
342:                     $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');
343:                 }
344:                 $this->_setSetting($cmsType, 'inline', false, true);
345:                 $this->_setSetting($cmsType, 'toolbar1', $defaultToolbar1, true);
346:                 $this->_setSetting($cmsType, 'toolbar2', $defaultToolbar2, true);
347:                 $this->_setSetting($cmsType, 'toolbar3', $defaultToolbar3, true);
348:                 $this->_setSetting($cmsType, 'plugins',  $defaultPlugins,  true);
349: 
350:                 $aCustSettings = cTinymce4Configuration::get(array(), 'tinymce4', $cmsType, 'tinymce4_full');
351:                 foreach ($aCustSettings as $sKey => $sValue) {
352:                     $this->_setSetting($cmsType, $sKey, $sValue, true);
353:                 }
354:                 break;
355: 
356:             case "fullscreen": // Show all options
357:                 // fullscreen of inline-editor
358:                 if ('CMS_HTMLHEAD' === $cmsType) {
359:                     $defaultToolbar1 = cTinymce4Configuration::get('undo redo | consave conclose', 'tinymce4', $cmsType, 'tinymce4_fullscreen', 'toolbar1');
360:                     $defaultToolbar2 = cTinymce4Configuration::get('', 'tinymce4',$cmsType, 'tinymce4_fullscreen', 'toolbar2');
361:                     $defaultToolbar3 = cTinymce4Configuration::get('', 'tinymce4', $cmsType, 'tinymce4_fullscreen', 'toolbar3');
362:                     $defaultPlugins = cTinymce4Configuration::get('conclose', 'tinymce4', $cmsType, 'tinymce4_fullscreen', 'plugins');
363:                 } else {
364:                     $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');
365:                     $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');
366:                     $defaultToolbar3 = cTinymce4Configuration::get('table | formatselect fontselect fontsizeselect | consave conclose', 'tinymce4', $cmsType, 'tinymce4_fullscreen', 'toolbar3');
367:                     $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');
368:                 }
369:                 $this->_setSetting($cmsType, 'inline', false, true);
370:                 $this->_setSetting($cmsType, 'menubar', true, true);
371:                 $this->_setSetting($cmsType, 'toolbar1', $defaultToolbar1, true);
372:                 $this->_setSetting($cmsType, 'toolbar2', $defaultToolbar2, true);
373:                 $this->_setSetting($cmsType, 'toolbar3', $defaultToolbar3, true);
374:                 // load some plugins
375:                 $this->_setSetting($cmsType, 'plugins', $defaultPlugins, true);
376: 
377:                 $aCustSettings = cTinymce4Configuration::get(array(), 'tinymce4', $cmsType, 'tinymce4_fullscreen');
378:                 foreach ($aCustSettings as $sKey => $sValue) {
379:                     $this->_setSetting($cmsType, $sKey, $sValue, true);
380:                 }
381: 
382:                 break;
383: 
384:             case "simple": // Does not show font and table options
385:                 $this->_setSetting($cmsType, "toolbar1", "cut copy paste pastetext | searchreplace | undo redo | bold italic underline strikethrough subscript superscript | insertdatetime preview", true);
386:                 $this->_setSetting($cmsType, "toolbar2", "link unlink anchor image | bullist numlist | outdent indent | alignleft aligncenter alignright alignfull removeformat | forecolor backcolor | ltr rtl | charmap | code", true);
387:                 $this->_setSetting($cmsType, "toolbar3", "", true);
388: 
389:                 $this->_setSetting($cmsType, "plugins", "anchor charmap code insertdatetime preview searchreplace print contextmenu paste directionality textcolor", true);
390: 
391:                 $aCustSettings = cTinymce4Configuration::get(array(), 'tinymce4', $cmsType, 'tinymce4_simple');
392:                 foreach ($aCustSettings as $sKey => $sValue) {
393:                     $this->_setSetting($cmsType, $sKey, $sValue, true);
394:                 }
395: 
396:                 break;
397: 
398:             case "mini": // Minimal toolbar
399:                 $this->_setSetting($cmsType, "toolbar1", "undo redo | bold italic underline strikethrough | link", true);
400:                 $this->_setSetting($cmsType, "toolbar2", "", true);
401:                 $this->_setSetting($cmsType, "toolbar3", "", true);
402: 
403:                 $this->_setSetting($cmsType, "plugins", "contextmenu", true);
404: 
405:                 $aCustSettings = cTinymce4Configuration::get(array(), 'tinymce4', $cmsType, 'tinymce4_mini');
406:                 foreach ($aCustSettings as $sKey => $sValue) {
407:                     $this->_setSetting($cmsType, $sKey, $sValue, true);
408:                 }
409: 
410:                 break;
411: 
412:             case "custom": // Custom toolbar
413:                 $aCustSettings = cTinymce4Configuration::get(array(), 'tinymce4', $cmsType, 'tinymce4_custom');
414:                 foreach ($aCustSettings as $sKey => $sValue) {
415:                     $this->_setSetting($cmsType, $sKey, $sValue, true);
416:                 }
417: 
418:                 break;
419: 
420:             case "inline_edit":
421:                 if ('CMS_HTMLHEAD' === $cmsType) {
422:                     $defaultToolbar1 = cTinymce4Configuration::get('undo redo | consave conclose', 'tinymce4', $cmsType, 'tinymce4_inline', 'toolbar1');
423:                     $defaultToolbar2 = cTinymce4Configuration::get('', 'tinymce4', $cmsType, 'tinymce4_inline', 'toolbar2');
424:                     $defaultToolbar3 = cTinymce4Configuration::get('', 'tinymce4', $cmsType, 'tinymce4_inline', 'toolbar3');
425:                     $defaultPlugins = cTinymce4Configuration::get('conclose', 'tinymce4', $cmsType, 'tinymce4_inline', 'plugins');
426:                 } else {
427:                     $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');
428:                     $defaultToolbar2 = cTinymce4Configuration::get('', 'tinymce4', $cmsType, 'tinymce4_inline', 'toolbar2');
429:                     $defaultToolbar3 = cTinymce4Configuration::get('', 'tinymce4', $cmsType, 'tinymce4_inline', 'toolbar3');
430:                     $defaultPlugins = cTinymce4Configuration::get('conclose confullscreen media table textcolor', 'tinymce4', $cmsType, 'tinymce4_inline', 'plugins');
431:                 }
432:                 $this->_setSetting($cmsType, 'inline', true, true);
433:                 $this->_setSetting($cmsType, 'menubar', false, true);
434:                 $this->_setSetting($cmsType, 'toolbar1', $defaultToolbar1, true);
435:                 $this->_setSetting($cmsType, 'toolbar2', $defaultToolbar2, true);
436:                 $this->_setSetting($cmsType, 'toolbar3', $defaultToolbar3, true);
437: 
438: 
439:                 $this->_unsetSetting($cmsType, "width");
440:                 $this->_setSetting($cmsType, "height", "210px", true);
441: 
442:                 // use custom plugins
443:                 // they are specified in con_tiny.js
444:                 // close plugin: save and close button
445:                 // confullscreen plugin: switches inline mode to off and adjusts toolbar in fullscreen mode
446:                 $this->_setSetting($cmsType, "plugins", $defaultPlugins, true);
447: 
448:                 // fullscreen plugin does not work with inline turned on, custom plugin confullscreen required for this
449:                 $this->_setSetting($cmsType, 'inline', true);
450:                 $this->_setSetting($cmsType, 'menubar', false);
451:                 $this->_setSetting($cmsType, "content_css", $cfgClient[$client]["path"]["htmlpath"] . "css/style_tiny.css", true);
452: 
453:                 $aCustSettings = cTinymce4Configuration::get(array(), 'tinymce4', $cmsType, 'tinymce4_inline');
454:                 foreach ($aCustSettings as $sKey => $sValue) {
455:                     $this->_setSetting($cmsType, $sKey, $sValue, true);
456:                 }
457: 
458:                 break;
459: 
460:             default: // Default options
461:                 $this->_setSetting($cmsType, 'toolbar1', 'undo redo | bold italic underline strikethrough | link unlink anchor image | table', true);
462:                 $this->_setSetting($cmsType, 'toolbar2', 'styleselect | bullist numlist | outdent indent | alignleft aligncenter alignright alignfull removeformat | forecolor backcolor | subscript superscript | code', true);
463:                 $this->_setSetting($cmsType, 'toolbar3', "", true);
464:                 $this->_setSetting($cmsType, 'plugins', "anchor code contextmenu media paste table searchreplace textcolor", true);
465: 
466:                 $aCustSettings = cTinymce4Configuration::get(array(), 'tinymce4', $cmsType, 'tinymce_default');
467:                 foreach ($aCustSettings as $sKey => $sValue) {
468:                     $this->_setSetting($cmsType, $sKey, $sValue, true);
469:                 }
470:         }
471:     }
472: 
473:     function cleanURLs($cmsType) {
474:         global $sess;
475: 
476:         // Add the path to the following values
477:         $aParameters = array(
478:             //builtin
479:             'content_css', 'popups_css', 'popups_css_add', 'editor_css', // plugins
480:             'plugin_preview_pageurl', //preview plugin
481:             'media_external_list_url', //media plugin
482:             'template_external_list_url' //template plugin
483:         );
484: 
485:         foreach ($aParameters as $sParameter) {
486:             if (array_key_exists($sParameter, $this->_aSettings[$cmsType])) {
487:                 $this->_setSetting($cmsType, $sParameter, $this->addPath($this->_aSettings[$cmsType][$sParameter]), true);
488:             }
489:         }
490: 
491:         // Session for template and media support files that are written in PHP
492:         $aParameters = array(
493:             'media_external_list_url', //media plugin
494:             'template_external_list_url' //template plugin
495:         );
496: 
497:         foreach ($aParameters as $sParameter) {
498:             if (array_key_exists($sParameter, $this->_aSettings[$cmsType]) && preg_match('/\\.php$/i', $this->_aSettings[$cmsType][$sParameter])) {
499:                 $this->_setSetting($cmsType, $sParameter, $this->_aSettings[$cmsType][$sParameter] . '?contenido=' . $sess->id, true);
500:             }
501:         }
502:     }
503: 
504:     function addPath($sFile) {
505:         global $cfgClient, $client;
506: 
507:         // Quick and dirty hack
508:         if (!preg_match('/^(http|https):\/\/((?:[a-zA-Z0-9_-]+\.?)+):?(\d*)/', $sFile)) {
509:             if (preg_match('/^\//', $sFile)) {
510:                 $sFile = "http://" . $_SERVER['HTTP_HOST'] . $sFile;
511:             } else {
512:                 $sFile = $cfgClient[$client]["htmlpath"]["frontend"] . $sFile;
513:             }
514:         }
515: 
516:         return $sFile;
517:     }
518: 
519:     function setBaseURL($sBaseUrl) {
520:         $this->_sBaseURL = $sBaseUrl;
521:     }
522: 
523:     public function _getScripts() {
524:         if ($this->_bUseGZIP) {
525:             $sReturn = "\n<!-- tinyMCE -->\n" . '<script language="javascript" type="text/javascript" src="' . $this->_sBaseURL . 'tinymce/js/tinymce/tinymce.gzip.js"></script>';
526:         } else {
527:             $sReturn = "\n<!-- tinyMCE -->\n" . '<script language="javascript" type="text/javascript" src="' . $this->_sBaseURL . 'tinymce/js/tinymce/tinymce.min.js"></script>';
528:         }
529: 
530:         return $sReturn;
531:     }
532: 
533:     public function _getEditor() {
534:         global $sess, $cfg, $lang, $client, $idart, $cfgClient;
535: 
536:         // TODO: Check functionality - doesn't seem to have any effect...
537:         $browserparameters = array("restrict_imagebrowser" => array("jpg", "gif", "jpeg", "png"));
538:         $sess->register("browserparameters");
539: 
540: 
541:         // Set browser windows
542:         // Difference between file and image browser is with (file) or without categories/articles (image)
543:         $oTemplate = new cTemplate();
544: 
545:         $oTemplate->set('s', 'CONFIG', json_encode($this->_aSettings));
546: 
547:         $oTemplate->set('s', 'PATH_CONTENIDO_FULLHTML', cRegistry::getConfigValue('path', 'contenido_fullhtml'));
548:         $oTemplate->set('s', 'IMAGEBROWSER', $cfg["path"]["contenido_fullhtml"] . 'frameset.php?area=upl&contenido=' . $sess->id . '&appendparameters=imagebrowser');
549:         $oTemplate->set('s', 'FILEBROWSER', $cfg["path"]["contenido_fullhtml"] . 'frameset.php?area=upl&contenido=' . $sess->id . '&appendparameters=filebrowser');
550:         $oTemplate->set('s', 'MEDIABROWSER', $cfg["path"]["contenido_fullhtml"] . 'frameset.php?area=upl&contenido=' . $sess->id . '&appendparameters=imagebrowser');
551:         $oTemplate->set('s', 'FRONTEND_PATH', $cfgClient[$client]["path"]["htmlpath"]);
552:         $oTemplate->set('s', 'CLOSE', html_entity_decode(i18n('Close editor'), ENT_COMPAT | ENT_HTML401, cRegistry::getEncoding()));
553:         $oTemplate->set('s', 'SAVE', html_entity_decode(i18n('Close editor and save changes'), ENT_COMPAT | ENT_HTML401, cRegistry::getEncoding()));
554:         $oTemplate->set('s', 'QUESTION', html_entity_decode(i18n('You have unsaved changes.'), ENT_COMPAT | ENT_HTML401, cRegistry::getEncoding()));
555:         $oTemplate->set('s', 'BACKEND_URL', cRegistry::getBackendUrl());
556: 
557:         $oTxtEditor = new cHTMLTextarea($this->_sEditorName, $this->_sEditorContent);
558:         $oTxtEditor->setId($this->_sEditorName);
559:         $oTxtEditor->setClass(htmlentities($this->_sEditorName));
560: 
561:         $oTxtEditor->setStyle("width: " . $this->_aSettings["width"] . "; height: " . $this->_aSettings["height"] . ";");
562: 
563:         $sReturn = $oTemplate->generate($cfg['path']['all_wysiwyg'] . $this->_sEditor . "contenido/templates/template.tinymce_tpl.html", true);
564:         $sReturn .= $oTxtEditor->render();
565: 
566:         return $sReturn;
567:     }
568: 
569:     /**
570:      * Sets given setting if setting was not yet defined.
571:      * Overwriting defined setting can be achieved with $bForceSetting = true.
572:      * 
573:      * @param string $sType CMS type where setting should apply
574:      * @param string $sKey of setting to set
575:      * @param string $sValue of setting to set
576:      * @param bool $bForceSetting to overwrite defined setting
577:      */
578:     protected function _setSetting($sType, $sKey, $sValue, $bForceSetting = false) {
579:         if ($bForceSetting || !array_key_exists($sKey, $this->_aSettings[$sType])) {
580:             $this->_aSettings[$sType][$sKey] = $sValue;
581:         }
582:     }
583: 
584:     /**
585:      * Variadic function to unset a setting using multiple key values
586:      * @param string $sKey
587:      */
588:     protected function _unsetSetting() {
589:         $numargs = func_num_args();
590:         // if no args passed there is nothing to do
591:         if (0 === $numargs) {
592:             return;
593:         }
594: 
595:         $result = &$this->_aSettings;
596:         for ($i = 0; $i < $numargs -1; $i++) {
597:             // if key does not exist there is nothing to unset
598:             if (false === in_array(func_get_arg(1 + $i), $this->_aSettings)) {
599:                 return;
600:             }
601:             // jump one array level deeper into the result
602:             $result = $result[func_get_arg(1 + $i)];
603:         }
604: 
605:         // remove key from array
606:         unset($result);
607:     }
608:     
609: 
610:     public function getConfigInlineEdit() {
611:         $sConfig = '';
612: 
613:         foreach($this->_aSettings as $cmsType => $setting) {
614:             $this->setToolbar($cmsType, 'inline_edit');
615:         }
616: 
617:         return $this->_aSettings;
618: 
619:         foreach ($this->_aSettings as $sKey => $sValue) {
620:             if (is_bool($sValue)) {
621:                 if ($sValue === true) {
622:                     $sValue = 'true';
623:                 } else {
624:                     $sValue = 'false';
625:                 }
626:             }
627: 
628:             if ($sValue == "true" || $sValue == "false" || $sKey == "oninit" || $sKey == "onpageload" || $sKey == 'style_formats') {
629:                 $sConfig .= "'$sKey': " . $sValue;
630:             } else {
631:                 $sConfig .= "'$sKey': '" . $sValue . "'";
632:             }
633:             $sConfig .= ",\n\t";
634:         }
635: 
636:         $sConfig = substr($sConfig, 0, -3);
637:         return $sConfig;
638:     }
639: 
640:     public function getConfigFullscreen() {
641:         $sConfig = '';
642:         foreach($this->_aSettings as $cmsType => $setting) {
643:             $this->setToolbar($cmsType, 'fullscreen');
644:         }
645: 
646:         return $this->_aSettings;
647: 
648:     }
649: 
650:     /**
651:      * function to obtain a comma separated list of plugins that are tried to be loaded 
652:      * @return string plugins the plugins
653:      */
654:     public function getPlugins() {
655:         return (string) $this->_aSettings['plugins'];
656:     }
657: 
658:     /**
659:      * function to obtain a comma separated list of themes that are tried to be loaded
660:      * @return string themes the themes
661:      */
662:     function getThemes() {
663:         return (string) $this->_aSettings['theme'];
664:     }
665: 
666:     /**
667:      * Saves configuration of WYSIWYG editor into a file
668:      * This function does not validate input! This has to be done by classes that extend cWYSIWYGEditor
669:      * because this class does not know what each WYSIWYG editor expects.
670:      * @param array Array with configuration values for the current WYSIWYG editor to save
671:      * @return array Array with values that were not accepted
672:      */
673:     public static function safeConfig($config) {
674:         parent::safeConfig($config['tinymce4']);
675:     }
676: }
677: 
678: ?>
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen