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     Timo Hummel
 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 cTinyMCEEditor 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/tinymce3/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 cTinyMCEEditor extends cWYSIWYGEditor {
 47:     /** Stores base url of page
 48:      */
 49:     var $_sBaseURL;
 50: 
 51:     /** Stores, if GZIP compression will be used
 52:      */
 53:     var $_bUseGZIP = false;
 54: 
 55:     function cTinyMCEEditor($sEditorName, $sEditorContent) {
 56:         global $belang, $cfg, $cfgClient, $client, $lang, $idart;
 57: 
 58:         parent::__construct($sEditorName, $sEditorContent);
 59:         $this->_setEditor("tinymce3");
 60: 
 61:         // Retrieve all settings for tinymce
 62:         $this->_aSettings = getEffectiveSettingsByType("tinymce");
 63: 
 64:         // For compatibility, read settings in previous syntax also (< V4.7, type "wysiwyg" vs. "tinymce")
 65:         $this->_aSettings = array_merge(getEffectiveSettingsByType("wysiwyg"), $this->_aSettings);
 66: 
 67:         $this->_setSetting("article_url_suffix", 'front_content.php?idart=' . $idart, true); # modified 23.10.2006
 68: 
 69:         // Default values
 70:         $this->_setSetting("mode", "exact");
 71:         $aPathFragments = explode('/', $cfgClient[$client]["path"]["htmlpath"]);
 72:         $this->_setSetting("content_css", $cfgClient[$client]["path"]["htmlpath"] . "css/style_tiny.css");
 73: 
 74:         $this->_setSetting("theme", "advanced");
 75:         $this->_setSetting("theme_advanced_toolbar_location", "top");
 76:         $this->_setSetting("theme_advanced_path_location", "bottom");
 77:         $this->_setSetting("remove_script_host", false);
 78:         $this->_setSetting("file_browser_callback", "Con.Tiny.customFileBrowserCallback", true);
 79:         //$this->_setSetting("urlconverter_callback", "Con.Tiny.customURLConverterCallback");
 80:         // New in V3.x
 81:         $this->_setSetting("theme_advanced_resizing", true);
 82:         $this->_setSetting("pagebreak_separator", "<!-- my page break -->"); // needs pagebreak plugin
 83:         // Source formatting (ugh!)
 84:         $this->_setSetting("apply_source_formatting", true);
 85:         $this->_setSetting("remove_linebreaks", false); // Remove linebreaks - GREAT idea...
 86: 
 87:         // Convert URLs and Relative URLs default
 88:         $this->_setSetting("convert_urls", false);
 89:         $this->_setSetting("relative_urls", false);
 90: 
 91:         // Editor name (a comma separated list of instances)
 92:         $this->_setSetting("elements", $sEditorName);
 93: 
 94:         // Editor language
 95:         $aLangs = i18nGetAvailableLanguages();
 96:         $this->_setSetting("language", $aLangs[$belang][4]);
 97:         unset($aLangs);
 98: 
 99:         // Set document base URL
100:         $this->_setSetting('document_base_url', cRegistry::getFrontendUrl(), true);
101: 
102:         // The following "base URL" is the URL used to reference JS script files
103:         // - it is not the base href value
104:         //$this->setBaseURL(preg_replace('/^https?:\/\/[^\/]+(.*)$/', '$1', $this->_getEditorPath()));
105:         $this->setBaseURL($this->_getEditorPath());
106: 
107:         // XHTML
108:         if (getEffectiveSetting("generator", "xhtml", false) == "true") {
109:             $this->setXHTMLMode(true);
110:         } else {
111:             $this->setXHTMLMode(false);
112:         }
113: 
114:         // GZIP
115:         if ($this->_aSettings["contenido_gzip"] == "true") {
116:             $this->setGZIPMode(true);
117:         } else {
118:             $this->setGZIPMode(false);
119:         }
120: 
121:         // Stylesheet file, for compatibility
122:         if (!array_key_exists("content_css", $this->_aSettings) && array_key_exists("tinymce-stylesheet-file", $this->_aSettings)) {
123:             $this->_setSetting("content_css", $this->_aSettings["tinymce-stylesheet-file"], true);
124:         }
125: 
126:         // Set lists (for links and image elements)
127:         $this->setLists();
128: 
129:         // Set user defined styles (be sure, that previous and SPAW syntax works)
130:         $this->setUserDefinedStyles();
131: 
132:         // Width and height
133:         $this->_setSetting("width", "100%");
134:         $this->_setSetting("height", "480px");
135: 
136:         // Text direction (rtl = right to left)
137:         $sDirection = langGetTextDirection($lang);
138:         $this->_setSetting("directionality", $sDirection);
139: 
140:         if ($sDirection == "rtl") {
141:             $this->_setSetting("theme_advanced_toolbar_align", "right", true);
142:         } else {
143:             $this->_setSetting("theme_advanced_toolbar_align", "left", true);
144:         }
145: 
146:         // Date and time formats
147:         $this->_setSetting("plugin_insertdate_dateFormat", $this->convertFormat(getEffectiveSetting("dateformat", "date", "Y-m-d")));
148:         $this->_setSetting("plugin_insertdate_timeFormat", $this->convertFormat(getEffectiveSetting("dateformat", "time", "H:i:s")));
149: 
150:         // Setting the toolbar (toolbar_mode and tinymce-toolbar-mode accepted)
151:         $sMode = "full";
152:         if (array_key_exists("tinymce-toolbar-mode", $this->_aSettings)) {
153:             $sMode = $this->_aSettings["tinymce-toolbar-mode"];
154:         }
155:         if (array_key_exists("contenido_toolbar_mode", $this->_aSettings)) {
156:             $sMode = $this->_aSettings["contenido_toolbar_mode"];
157:         }
158:         $this->setToolbar(trim(strtolower($sMode)));
159: 
160:         $autoFullElements = $this->_aSettings['auto_full_elements'];
161:         unset($this->_aSettings['auto_full_elements']);
162: 
163:         // Valid elements, for compatibility also accepts "tinymce-valid-elements"
164:         if (!array_key_exists("valid_elements", $this->_aSettings) && array_key_exists("tinymce-valid-elements", $this->_aSettings)) {
165:             $this->_setSetting("valid_elements", $this->_aSettings["tinymce-valid-elements"], true);
166:         }
167: 
168:         // _setSetting checks, if value is empty
169:         if ($autoFullElements === 'true') {
170:             $this->_setSetting('valid_elements', '*[*]');
171:             $this->_setSetting('extended_valid_elements', '*[*]');
172:         }
173: 
174:         $this->_setSetting("valid_elements", "a[name|href|target|title],strong/b[class],em/i[class],strike[class],u[class],p[dir|class|align],ol,ul,li,br,img[class|src|border=0|alt|title|hspace|vspace|width|height|align],sub,sup,blockquote[dir|style],table[border=0|cellspacing|cellpadding|width|height|class|align|style],tr[class|rowspan|width|height|align|valign|style],td[dir|class|colspan|rowspan|width|height|align|valign|style],div[dir|class|align],span[class|align],pre[class|align],address[class|align],h1[dir|class|align],h2[dir|class|align],h3[dir|class|align],h4[dir|class|align],h5[dir|class|align],h6[dir|class|align],hr");
175: 
176:         // Extended valid elements, for compatibility also accepts "tinymce-extended-valid-elements"
177:         if (!array_key_exists("extended_valid_elements", $this->_aSettings) && array_key_exists("tinymce-extended-valid-elements", $this->_aSettings)) {
178:             $this->_setSetting("extended_valid_elements", $this->_aSettings["tinymce-extended-valid-elements"]);
179:         }
180: 
181: 
182:         //print_r($this->_aSettings['valid_elements']);
183: 
184:         $this->_setSetting("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|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]");
185: 
186:         // Clean all possible URLs
187:         $this->cleanURLs();
188: 
189:         // Remove CONTENIDO specific settings
190:         unset($this->_aSettings["contenido_toolbar_mode"], $this->_aSettings["contenido_lists"]);
191:         // Remove obsolete, deprecated values
192:         unset($this->_aSettings["tinymce-stylesheet-file"], $this->_aSettings["tinymce-valid-elements"], $this->_aSettings["tinymce-extended-valid-elements"], $this->_aSettings["tinymce-lists"], $this->_aSettings["tinymce-styles"], $this->_aSettings["tinymce-toolbar-mode"], $this->_aSettings["tinymce-toolbar1"], $this->_aSettings["tinymce-toolbar2"], $this->_aSettings["tinymce-toolbar3"], $this->_aSettings["tinymce-plugins"]);
193:     }
194: 
195:     function convertFormat($sInput) {
196:         $aFormatCodes = array(
197:             "y" => "%y", "Y" => "%Y", "d" => "%d", "m" => "%m", "H" => "%H", "h" => "%I", "i" => "%M", "s" => "%S", "a" => "%P", "A" => "%P"
198:         );
199: 
200:         foreach ($aFormatCodes as $sFormatCode => $sReplacement) {
201:             $sInput = str_replace($sFormatCode, $sReplacement, $sInput);
202:         }
203: 
204:         return ($sInput);
205:     }
206: 
207:     function setUserDefinedStyles() {
208:         $sStyles = "";
209: 
210:         if (array_key_exists("theme_advanced_styles", $this->_aSettings)) {
211:             $sStyles = $this->_aSettings["theme_advanced_styles"];
212:         } else if (array_key_exists("tinymce-styles", $this->_aSettings)) {
213:             $sStyles = $this->_aSettings["tinymce-styles"];
214:         }
215: 
216:         if ($sStyles) {
217:             $this->_setSetting("theme_advanced_styles", preg_replace('/;$/i', '', str_replace("|", "=", trim($sStyles))), true);
218:         }
219:     }
220: 
221:     /**
222:      * The special name "contenido_lists", for compatibility also accepts "tinymce-lists"
223:      *
224:      * @param string    sLists    Deprecated, for compatibility, only
225:      */
226:     function setLists($sLists = "") {
227:         global $lang, $client;
228: 
229:         if ($sLists == "") {
230:             if (array_key_exists("contenido_lists", $this->_aSettings)) {
231:                 $sLists = $this->_aSettings["contenido_lists"];
232:             } else if (array_key_exists("tinymce-lists", $this->_aSettings)) {
233:                 $sLists = $this->_aSettings["tinymce-lists"];
234:             }
235:         }
236: 
237:         $aLists = array();
238:         $aLists = explode(",", strtolower(str_replace(" ", "", $sLists)));
239: 
240:         if (in_array("link", $aLists)) {
241:             $this->_setSetting("external_link_list_url", $this->_sBaseURL . "list.php?mode=link&lang=" . $lang . "&client=" . $client . "#", true);
242:         }
243:         if (in_array("image", $aLists)) {
244:             $this->_setSetting("external_image_list_url", $this->_sBaseURL . "list.php?mode=image&lang=" . $lang . "&client=" . $client . "#", true);
245:         }
246:         if (in_array("media", $aLists)) {
247:             $this->_setSetting("media_external_list_url", $this->_sBaseURL . "list.php?mode=media&lang=" . $lang . "&client=" . $client . "#", true);
248:         }
249:     }
250: 
251:     function setXHTMLMode($bEnabled = true) {
252:         if ($bEnabled) {
253:             $this->_setSetting("cleanup_callback", "", true);
254:         } else {
255:             $this->_setSetting("cleanup_callback", "Con.Tiny.customCleanupCallback", true);
256:         }
257:     }
258: 
259:     function setGZIPMode($bEnabled = true) {
260:         if ($bEnabled) {
261:             $this->_bUseGZIP = true;
262:         } else {
263:             $this->_bUseGZIP = false;
264:         }
265:     }
266:     
267:     function getGZIPMode() {
268:         return (bool) $this->_bUseGZIP;
269:     }
270: 
271:     /**
272:      * For compatibility also accepts "tinymce-toolbar-mode", "tinymce-toolbar1-3" and "tinymce-plugins"
273:      */
274:     function setToolbar($sMode = "") {
275:         global $cfg, $cfgClient, $client;
276: 
277:         switch ($sMode) {
278:             case "full": // Show all options
279:                 $this->_setSetting("theme_advanced_buttons1", "cut,copy,paste,pastetext,pasteword,|,search,replace,|,undo,redo,|,bold,italic,underline,strikethrough,sub,sup,|,insertdate,inserttime,preview,|,styleselect,|,visualchars,nonbreaking,template,pagebreak,|,help,|,fullscreen", true);
280:                 $this->_setSetting("theme_advanced_buttons2", "link,unlink,anchor,image,media,advhr,|,bullist,numlist,|,outdent,indent,blockquote,|,justifyleft,justifycenter,justifyright,justifyfull,removeformat,|,forecolor,backcolor,|,ltr,rtl,|,visualaid,charmap,cleanup,|,code", true);
281:                 $this->_setSetting("theme_advanced_buttons3", "tablecontrols,|,formatselect,fontselect,fontsizeselect,|,styleprops,|,cite,abbr,acronym,del,ins,attribs", true);
282:                 //table,save,advhr,advimage,advlink,pagebreak,style,layer,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template
283:                 $this->_setSetting("plugins", "table,save,advhr,advimage,advlink,pagebreak,style,layer,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups", true);
284:                 $this->_setSetting("theme_advanced_toolbar_align", "left", true);
285: 
286:                 $aCustSettings = getEffectiveSettingsByType("tinymce");
287:                 foreach ($aCustSettings as $sKey => $sValue) {
288:                     $this->_setSetting($sKey, $sValue, true);
289:                 }
290: 
291:                 break;
292: 
293:             case "fullscreen": // Show all options
294:                 $this->_setSetting("theme_advanced_buttons1", "cut,copy,paste,pastetext,pasteword,|,search,replace,|,undo,redo,|,bold,italic,underline,strikethrough,sub,sup,|,insertdate,inserttime,preview,|,styleselect,|,visualchars,nonbreaking,template,pagebreak,|,help,|,fullscreen", true);
295:                 $this->_setSetting("theme_advanced_buttons2", "link,unlink,anchor,image,media,advhr,|,bullist,numlist,|,outdent,indent,blockquote,|,justifyleft,justifycenter,justifyright,justifyfull,removeformat,|,forecolor,backcolor,|,ltr,rtl,|,visualaid,charmap,cleanup,|,code", true);
296:                 $this->_setSetting("theme_advanced_buttons3", "tablecontrols,|,formatselect,fontselect,fontsizeselect,|,styleprops,|,cite,abbr,acronym,del,ins,attribs", true);
297:                 //table,save,advhr,advimage,advlink,pagebreak,style,layer,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template
298:                 $this->_setSetting("plugins", "table,save,advhr,advimage,advlink,pagebreak,style,layer,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups", true);
299:                 $this->_setSetting("theme_advanced_toolbar_align", "left", true);
300: 
301:                 $aCustSettings = getEffectiveSettingsByType("tinymce_fullscreen");
302:                 foreach ($aCustSettings as $sKey => $sValue) {
303:                     $this->_setSetting($sKey, $sValue, true);
304:                 }
305: 
306:                 break;
307: 
308:             case "simple": // Does not show font and table options
309:                 $this->_setSetting("theme_advanced_buttons1", "cut,copy,paste,pastetext,pasteword,|,search,replace,|,undo,redo,|,bold,italic,underline,strikethrough,sub,sup,|,insertdate,inserttime,preview,|,styleselect", true);
310:                 $this->_setSetting("theme_advanced_buttons2", "link,unlink,anchor,image,advhr,|,bullist,numlist,|,outdent,indent,|,justifyleft,justifycenter,justifyright,justifyfull,removeformat,|,forecolor,backcolor,|,ltr,rtl,|,visualaid,charmap,cleanup,|,code", true);
311:                 $this->_setSetting("theme_advanced_buttons3", "", true);
312:                 $this->_setSetting("plugins", "advhr,advimage,advlink,insertdatetime,preview,searchreplace,print,contextmenu,paste,directionality", true);
313: 
314:                 $aCustSettings = getEffectiveSettingsByType("tinymce_simple");
315:                 foreach ($aCustSettings as $sKey => $sValue) {
316:                     $this->_setSetting($sKey, $sValue, true);
317:                 }
318: 
319:                 break;
320: 
321:             case "mini": // Minimal toolbar
322:                 $this->_setSetting("theme_advanced_buttons1", "undo,redo,|,bold,italic,underline,strikethrough,|,link", true);
323:                 $this->_setSetting("theme_advanced_buttons2", "", true);
324:                 $this->_setSetting("theme_advanced_buttons3", "", true);
325: 
326:                 $aCustSettings = getEffectiveSettingsByType("tinymce_mini");
327:                 foreach ($aCustSettings as $sKey => $sValue) {
328:                     $this->_setSetting($sKey, $sValue, true);
329:                 }
330: 
331:                 break;
332: 
333:             case "custom": // Custom toolbar
334:                 // tinymce-toolbar1/2/3 and tinymce-plugins are only mentioned for compatibility
335:                 // They are ignored, if theme_advanced_buttons1/2/3 and plugins have been already
336:                 // specified
337:                 $this->_setSetting("theme_advanced_buttons1", $this->_aSettings["tinymce-toolbar1"]);
338:                 $this->_setSetting("theme_advanced_buttons2", $this->_aSettings["tinymce-toolbar2"]);
339:                 $this->_setSetting("theme_advanced_buttons3", $this->_aSettings["tinymce-toolbar3"]);
340:                 $this->_setSetting("plugins", $this->_aSettings["tinymce-plugins"]);
341:                 $this->_setSetting("theme_advanced_toolbar_location", "bottom");
342: 
343:                 $aCustSettings = getEffectiveSettingsByType("tinymce_custom");
344:                 foreach ($aCustSettings as $sKey => $sValue) {
345:                     $this->_setSetting($sKey, $sValue, true);
346:                 }
347: 
348:                 break;
349: 
350:             case "inline_edit":
351:                 $this->_setSetting("theme_advanced_buttons1", "bold,italic,underline,strikethrough,separator,undo,separator,bullist,numlist,separator,forecolor,backcolor,separator,justifyleft,justifycenter,justifyright,separator,fullscreen,separator,save,close", true);
352:                 $this->_setSetting("theme_advanced_buttons2", "", true);
353:                 $this->_setSetting("theme_advanced_buttons3", "", true);
354: 
355:                 $this->_setSetting("setupcontent_callback", "Con.Tiny.customSetupContentCallback", true);
356: 
357:                 $this->_unsetSetting("width");
358:                 $this->_unsetSetting("theme_advanced_toolbar_location");
359:                 $this->_setSetting("theme_advanced_toolbar_location", "external");
360:                 $this->_setSetting("height", "210px", true);
361:                 // close plugin not in plugins directory but still working if listed
362:                 $this->_setSetting("plugins", "table,inlinepopups,fullscreen,close", true);
363:                 $this->_setSetting("mode", "exact", true);
364:                 $this->_setSetting("elements", "*", true);
365:                 $this->_setSetting("content_css", $cfgClient[$client]["path"]["htmlpath"] . "css/style_tiny.css", true);
366: 
367:                 if (!array_key_exists("auto_resize", $this->_aSettings)) {
368:                     $this->_setSetting("auto_resize", "false", true);
369:                 }
370: 
371:                 if (!array_key_exists("theme_advanced_toolbar_location", $this->_aSettings)) {
372:                     $this->_setSetting("theme_advanced_toolbar_location", "top", true);
373:                 }
374: 
375:                 if (!array_key_exists("theme_advanced_resizing_use_cookie", $this->_aSettings)) {
376:                     $this->_setSetting("theme_advanced_resizing_use_cookie", "false", true);
377:                 }
378: 
379:                 if (!array_key_exists("theme_advanced_toolbar_align", $this->_aSettings)) {
380:                     $this->_setSetting("theme_advanced_toolbar_align", "center", true);
381:                 }
382: 
383:                 $aCustSettings = getEffectiveSettingsByType("tinymce_inline");
384:                 foreach ($aCustSettings as $sKey => $sValue) {
385:                     $this->_setSetting($sKey, $sValue, true);
386:                 }
387: 
388:                 break;
389: 
390:             default: // Default options
391:                 $this->_setSetting("theme_advanced_buttons1", "undo,redo,|,bold,italic,underline,strikethrough,|,link,unlink,anchor,image,advhr,|,tablecontrols", true);
392:                 $this->_setSetting("theme_advanced_buttons2", "styleselect,|,bullist,numlist,|,outdent,indent,|,justifyleft,justifycenter,justifyright,justifyfull,removeformat,|,forecolor,backcolor,|,sub,sup,|,code", true);
393:                 $this->_setSetting("theme_advanced_buttons3", "", true);
394:                 $this->_setSetting("plugins", "table,advhr,advimage,advlink,searchreplace,contextmenu,paste", true);
395: 
396:                 $aCustSettings = getEffectiveSettingsByType("tinymce_default");
397:                 foreach ($aCustSettings as $sKey => $sValue) {
398:                     $this->_setSetting($sKey, $sValue, true);
399:                 }
400:         }
401:     }
402: 
403:     function cleanURLs() {
404:         global $sess;
405: 
406:         // Add the path to the following values
407:         $aParameters = array(
408:             //builtin
409:             'content_css', 'popups_css', 'popups_css_add', 'editor_css', // plugins
410:             'plugin_preview_pageurl', //preview plugin
411:             'media_external_list_url', //media plugin
412:             'template_external_list_url' //template plugin
413:         );
414: 
415:         foreach ($aParameters as $sParameter) {
416:             if (array_key_exists($sParameter, $this->_aSettings)) {
417:                 $this->_setSetting($sParameter, $this->addPath($this->_aSettings[$sParameter]), true);
418:             }
419:         }
420: 
421:         // Session for template and media support files that are written in PHP
422:         $aParameters = array(
423:             'media_external_list_url', //media plugin
424:             'template_external_list_url' //template plugin
425:         );
426: 
427:         foreach ($aParameters as $sParameter) {
428:             if (array_key_exists($sParameter, $this->_aSettings) && preg_match('/\\.php$/i', $this->_aSettings[$sParameter])) {
429:                 $this->_setSetting($sParameter, $this->_aSettings[$sParameter] . '?contenido=' . $sess->id, true);
430:             }
431:         }
432:     }
433: 
434:     function addPath($sFile) {
435:         global $cfgClient, $client;
436: 
437:         // Quick and dirty hack
438:         if (!preg_match('/^(http|https):\/\/((?:[a-zA-Z0-9_-]+\.?)+):?(\d*)/', $sFile)) {
439:             if (preg_match('/^\//', $sFile)) {
440:                 $sFile = "http://" . $_SERVER['HTTP_HOST'] . $sFile;
441:             } else {
442:                 $sFile = $cfgClient[$client]["htmlpath"]["frontend"] . $sFile;
443:             }
444:         }
445: 
446:         return $sFile;
447:     }
448: 
449:     function setBaseURL($sBaseUrl) {
450:         $this->_sBaseURL = $sBaseUrl;
451:     }
452: 
453:     function _getScripts() {
454:         if ($this->_bUseGZIP) {
455:             $sReturn = "\n<!-- tinyMCE -->\n" . '<script language="javascript" type="text/javascript" src="' . $this->_sBaseURL . 'jscripts/tiny_mce/tiny_mce_gzip.js"></script>';
456:         } else {
457:             $sReturn = "\n<!-- tinyMCE -->\n" . '<script language="javascript" type="text/javascript" src="' . $this->_sBaseURL . 'jscripts/tiny_mce/tiny_mce.js"></script>';
458:         }
459: 
460:         return $sReturn;
461:     }
462: 
463:     function _getEditor() {
464:         global $sess, $cfg, $lang, $client, $idart, $cfgClient;
465: 
466:         // TODO: Check functionality - doesn't seem to have any effect...
467:         $browserparameters = array("restrict_imagebrowser" => array("jpg", "gif", "jpeg", "png"));
468:         $sess->register("browserparameters");
469: 
470:         // Contenido-specific: Set article_url_suffix setting as it is used in plugins/advlink/jscripts/functions.js on anchor tags
471:         $this->_setSetting("setupcontent_callback", 'Con.Tiny.customSetupContentCallback', true);
472:         $this->_setSetting("save_callback", 'Con.Tiny.customSaveCallback', true);
473: 
474:         // Set browser windows
475:         // Difference between file and image browser is with (file) or without categories/articles (image)
476:         $oTemplate = new cTemplate();
477:         $oTemplate->set('s', 'IMAGEBROWSER', $cfg["path"]["contenido_fullhtml"] . 'frameset.php?area=upl&contenido=' . $sess->id . '&appendparameters=imagebrowser');
478:         $oTemplate->set('s', 'FILEBROWSER', $cfg["path"]["contenido_fullhtml"] . 'frameset.php?area=upl&contenido=' . $sess->id . '&appendparameters=filebrowser');
479:         $oTemplate->set('s', 'MEDIABROWSER', $cfg["path"]["contenido_fullhtml"] . 'frameset.php?area=upl&contenido=' . $sess->id . '&appendparameters=imagebrowser');
480:         $oTemplate->set('s', 'FRONTEND_PATH', $cfgClient[$client]["path"]["htmlpath"]);
481: 
482:         // GZIP support options
483:         $sGZIPScript = '';
484:         if ($this->_bUseGZIP) {
485:             // tinyMCE_GZ.init call must be placed in its own script tag
486:             // User defined plugins and themes should be identical in both "inits"
487:             $sGZIPScript = <<<JS
488: <script type="text/javascript">
489: tinyMCE_GZ.init({
490:     plugins: '{$this->_aSettings["plugins"]}',
491:     themes: '{$this->_aSettings["theme"]}',
492:     languages: '{$this->_aSettings["language"]}',
493:     disk_cache: true,
494:     debug: false
495: });
496: </script>
497: JS;
498:         }
499:         $oTemplate->set('s', 'COMPRESSOR', $sGZIPScript);
500: 
501:         // Calculate the configuration
502:         $sConfig = '';
503: 
504:         foreach ($this->_aSettings as $sKey => $sValue) {
505:             if (is_bool($sValue)) {
506:                 if ($sValue === true) {
507:                     $sValue = "true";
508:                 } else {
509:                     $sValue = "false";
510:                 }
511:             }
512: 
513:             if ($sValue == "true" || $sValue == "false" || $sKey == "oninit" || $sKey == "onpageload" || $sKey == 'style_formats') {
514:                 $sConfig .= "'$sKey': " . $sValue;
515:             } else {
516:                 $sConfig .= "'$sKey': '" . $sValue . "'";
517:             }
518:             $sConfig .= ",\n\t";
519:         }
520: 
521:         $sConfig = substr($sConfig, 0, -3);
522:         $oTemplate->set('s', 'CONFIG', $sConfig);
523: 
524:         $oTxtEditor = new cHTMLTextarea($this->_sEditorName, $this->_sEditorContent);
525:         $oTxtEditor->setId($this->_sEditorName);
526: 
527:         $oTxtEditor->setStyle("width: " . $this->_aSettings["width"] . "; height: " . $this->_aSettings["height"] . ";");
528: 
529:         $sReturn = $oTemplate->generate($cfg['path']['all_wysiwyg'] . $this->_sEditor . "/tinymce.tpl.html", true);
530:         $sReturn .= $oTxtEditor->render();
531: 
532:         return $sReturn;
533:     }
534: 
535:     function getConfigInlineEdit() {
536:         $sConfig = '';
537:         $this->setToolbar('inline_edit');
538: 
539:         foreach ($this->_aSettings as $sKey => $sValue) {
540:             if (is_bool($sValue)) {
541:                 if ($sValue === true) {
542:                     $sValue = "true";
543:                 } else {
544:                     $sValue = "false";
545:                 }
546:             }
547: 
548:             if ($sValue == "true" || $sValue == "false" || $sKey == "oninit" || $sKey == "onpageload" || $sKey == 'style_formats') {
549:                 $sConfig .= "'$sKey': " . $sValue;
550:             } else {
551:                 $sConfig .= "'$sKey': '" . $sValue . "'";
552:             }
553:             $sConfig .= ",\n\t";
554:         }
555: 
556:         $sConfig = substr($sConfig, 0, -3);
557: 
558:         return $sConfig;
559:     }
560: 
561:     function getConfigFullscreen() {
562:         $sConfig = '';
563:         $this->setToolbar('fullscreen');
564: 
565:         $sConfig .= "'theme_advanced_buttons1': '" . $this->_aSettings['theme_advanced_buttons1'] . "',\n";
566:         $sConfig .= "'theme_advanced_buttons2': '" . $this->_aSettings['theme_advanced_buttons2'] . "',\n";
567:         $sConfig .= "'theme_advanced_buttons3': '" . $this->_aSettings['theme_advanced_buttons3'] . "',\n";
568:         $sConfig .= "'theme_advanced_toolbar_align': '" . $this->_aSettings['theme_advanced_toolbar_align'] . "',\n";
569:         $sConfig .= "'plugins': '" . $this->_aSettings['plugins'] . "'\n";
570: 
571:         return $sConfig;
572:     }
573:     
574:     function getPlugins() {
575:         return $this->_aSettings['plugins'];
576:     }
577:     function getThemes() {
578:         return $this->_aSettings['theme'];
579:     }
580: }
581: 
582: ?>
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen