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

Classes

  • cAjaxRequest
  • cAutoload
  • cBackend
  • cEffectiveSetting
  • cGuiScrollListAlltranslations
  • cHTMLValidator
  • cMailer
  • cModuleFileTranslation
  • cModuleHandler
  • cModuleSearch
  • cModuleSynchronizer
  • cModuleTemplateHandler
  • CodeMirror
  • cPasswordRequest
  • cPermission
  • cRegistry
  • cSystemPurge
  • cSystemtest
  • cTinymce4Configuration
  • cTinyMCE4Editor
  • cTinyMCEEditor
  • cWYSIWYGEditor
  • FrontendList
  • HtmlParser
  • TODOBackendList
  • TreeItem
  • UploadList
  • UploadSearchResultList

Functions

  • addArtspec
  • addSortImages
  • backToMainArea
  • buildArticleSelect
  • buildCategorySelect
  • buildCategorySelectRights
  • buildHeapTable
  • buildStackString
  • buildTree
  • buildUserOrGroupPermsFromRequest
  • callPluginStore
  • cApiCatGetLevelNode
  • cApiImageCheckCachedImageValidity
  • cApiImageCheckImageEditingPosibility
  • cApiImageGetCacheFileName
  • cApiImageGetTargetDimensions
  • cApiImageIsAnimGif
  • cApiImgScale
  • cApiImgScaleGetMD5CacheFile
  • cApiImgScaleHQ
  • cApiImgScaleImageMagick
  • cApiImgScaleLQ
  • cApiIsImageMagickAvailable
  • cApiStrCleanURLCharacters
  • cApiStrNormalizeLineEndings
  • cApiStrRecodeString
  • cApiStrReplaceDiacritics
  • cApiStrTrimAfterWord
  • cApiStrTrimHard
  • cApiStrTrimSentence
  • cDeprecated
  • cDie
  • cError
  • checkLangInClients
  • checkPathInformation
  • cInclude
  • compareUrlStrings
  • conChangeTemplateForCat
  • conCopyArticle
  • conCopyArtLang
  • conCopyContainerConf
  • conCopyContent
  • conCopyMetaTags
  • conCopyTemplateConfiguration
  • conCreateLocationString
  • conDeeperCategoriesArray
  • conDeleteart
  • conEditArt
  • conEditFirstTime
  • conFetchCategoryTree
  • conFlagOnOffline
  • conGenerateCode
  • conGenerateCodeForAllArts
  • conGenerateCodeForAllArtsInCategory
  • conGenerateCodeForAllartsUsingLayout
  • conGenerateCodeForAllartsUsingMod
  • conGenerateCodeForAllArtsUsingTemplate
  • conGenerateCodeForArtInAllCategories
  • conGenerateCodeForClient
  • conGenerateKeywords
  • conGetAvailableMetaTagTypes
  • conGetCategoryArticleId
  • conGetCategoryAssignments
  • conGetContainerConfiguration
  • conGetContentFromArticle
  • conGetHtmlTranslationTable
  • conGetMetaValue
  • conGetTemplateConfigurationIdForArticle
  • conGetTemplateConfigurationIdForCategory
  • conGetTopmostCat
  • conGetUsedModules
  • conHtmlentities
  • conHtmlEntityDecode
  • conHtmlSpecialChars
  • conIsLocked
  • conLock
  • conLockBulkEditing
  • conMakeArticleIndex
  • conMakeCatOnline
  • conMakeInlineScript
  • conMakeOnline
  • conMakeOnlineBulkEditing
  • conMakePublic
  • conMakeStart
  • conMoveArticles
  • conPhp54Check
  • conRemoveOldCategoryArticle
  • conSaveContentEntry
  • conSetCodeFlag
  • conSetCodeFlagBulkEditing
  • conSetMetaValue
  • conSyncArticle
  • copyRightsForElement
  • createBulkEditingFunction
  • createRandomName
  • createRightsForElement
  • cWarning
  • dbGetColumns
  • dbGetIndexes
  • dbGetPrimaryKeyName
  • dbTableExists
  • dbUpgradeTable
  • defineIfNotDefined
  • deleteArtspec
  • deleteRightsForElement
  • deleteSystemProperty
  • displayDatetime
  • emptyLogFile
  • endAndLogTiming
  • extractNumber
  • generateDisplayFilePath
  • generateJs
  • getAllClientsAndLanguages
  • getArtLang
  • getArtspec
  • getAvailableContentTypes
  • getCanonicalDay
  • getCanonicalMonth
  • getDirectorySize
  • getEffectiveSetting
  • getEffectiveSettingsByType
  • getEncodingByLanguage
  • getFileContents
  • getFileInformation
  • getFileType
  • getGroupOrUserName
  • getIDForArea
  • getJsHelpContext
  • getLanguageNamesByClient
  • getLanguagesByClient
  • getmicrotime
  • getNamedFrame
  • getParam
  • getParentAreaId
  • getSearchResults
  • getStrExpandCollapseButton
  • getSystemProperties
  • getSystemPropertiesByType
  • getSystemProperty
  • getTemplateSelect
  • getUplExpandCollapseButton
  • htmldecode
  • htmlentities_iso88592
  • humanReadableSize
  • includePlugins
  • insertEmptyStrRow
  • ipMatch
  • isAlphanumeric
  • isArchive
  • isArtInMultipleUse
  • isFunctionDisabled
  • isGroup
  • isIPv4
  • isRunningFromWeb
  • isStartArticle
  • isUtf8
  • isValidMail
  • langActivateDeactivateLanguage
  • langDeleteLanguage
  • langEditLanguage
  • langGetTextDirection
  • langNewLanguage
  • langRenameLanguage
  • layDeleteLayout
  • layEditLayout
  • machineReadableSize
  • mailLogBulkEditingFunctions
  • mailLogDecodeAddresses
  • markSubMenuItem
  • mask
  • modDeleteModule
  • modEditModule
  • phpInfoToHtml
  • plugin_include
  • prCreateURLNameLocationString
  • prDeleteCacheFileContent
  • prGetCacheFileContent
  • prResolvePathViaCategoryNames
  • prResolvePathViaURLNames
  • prWriteCacheFileContent
  • putFileContents
  • recursiveCopy
  • removeFileInformation
  • renderBackendBreadcrumb
  • renderLabel
  • renderSelectProperty
  • renderTextProperty
  • saveGroupRights
  • saveRights
  • scanDirectory
  • scanPlugins
  • sendEncodingHeader
  • set_magic_quotes_gpc
  • setArtspecDefault
  • setArtspecOnline
  • setSystemProperty
  • showTree
  • startTiming
  • statCreateLocationString
  • statDisplayTopChooser
  • statDisplayYearlyTopChooser
  • statGetAvailableMonths
  • statGetAvailableYears
  • statResetStatistic
  • statsArchive
  • statsDisplayInfo
  • statsOverviewAll
  • statsOverviewTop
  • statsOverviewTopYear
  • statsOverviewYear
  • strAssignTemplate
  • strBuildSqlValues
  • strCheckTreeForErrors
  • strCopyCategory
  • strCopyTree
  • strDeeperCategoriesArray
  • strDeleteCategory
  • strHasArticles
  • strHasStartArticle
  • strMakePublic
  • strMakeVisible
  • strMoveCatTargetallowed
  • strMoveDownCategory
  • strMoveSubtree
  • strMoveUpCategory
  • strNewCategory
  • strNewTree
  • strNextBackwards
  • strNextDeeper
  • strNextDeeperAll
  • strNextPost
  • strOrderedPostTreeList
  • strRemakeTreeTable
  • strRenameCategory
  • strRenameCategoryAlias
  • strSortPrePost
  • strSyncCategory
  • systemHavePerm
  • tplAutoFillModules
  • tplBrowseLayoutForContainers
  • tplcfgDuplicate
  • tplDeleteTemplate
  • tplDuplicateTemplate
  • tplEditTemplate
  • tplGetContainerDefault
  • tplGetContainerMode
  • tplGetContainerName
  • tplGetContainerNumbersInLayout
  • tplGetContainerTypes
  • tplGetInUsedData
  • tplIsTemplateInUse
  • tplPreparseLayout
  • tplProcessSendContainerConfiguration
  • updateClientCache
  • updateFileInformation
  • uplCreateFriendlyName
  • uplDirectoryListRecursive
  • uplGetDirectoriesToExclude
  • uplGetFileExtension
  • uplGetFileIcon
  • uplGetFileTypeDescription
  • uplGetThumbnail
  • uplHasFiles
  • uplHasSubdirs
  • uplmkdir
  • uplRecursiveDBDirectoryList
  • uplRecursiveDirectoryList
  • uplRenameDirectory
  • uplSearch
  • uplSyncDirectory
  • uplSyncDirectoryDBFS
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the WYSIWYG editor class for TinyMCE.
  4:  *
  5:  * @package    Core
  6:  * @subpackage Backend
  7:  * @author     Timo Hummel
  8:  * @copyright  four for business AG <www.4fb.de>
  9:  * @license    http://www.contenido.org/license/LIZENZ.txt
 10:  * @link       http://www.4fb.de
 11:  * @link       http://www.contenido.org
 12:  */
 13: 
 14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 15: 
 16: cInclude('includes', 'functions.lang.php');
 17: 
 18: /**
 19:  * The object cTinyMCEEditor is a wrapper class to the TinyMCE WYSIWYG Editor.
 20:  * Attributes can be defined to generate JavaScript options and functions to initialise the global
 21:  * tinyMCE object in file ./contenido/external/wysiwyg/tinymce3/tinymce.tpl.html.
 22:  *
 23:  * All settings accepted by tinyMCE and its plugins may be specified using system, client
 24:  * group or user property/setting.
 25:  *
 26:  * The following parameters will be always set on initialization (even, if they have been specified
 27:  * as property. They can be set using setSetting later on, if needed):
 28:  * document_base_url
 29:  * cleanup_callback (-> XHTML)
 30:  * file_browser_callback
 31:  * external_link_list_url
 32:  * external_image_list_url
 33:  *
 34:  * The following settings are only used in CONTENIDO:
 35:  * contenido_toolbar_mode: full, simple, mini, custom
 36:  * contenido_lists: link,image
 37:  * contenido_height_html
 38:  * contenido_height_head
 39:  * See backend.customizing.html for details
 40:  *
 41:  * @package    Core
 42:  * @subpackage Backend
 43:  */
 44: class cTinyMCEEditor extends cWYSIWYGEditor {
 45: 
 46:     /**
 47:      * Stores base url of page
 48:      *
 49:      * @var string
 50:      */
 51:     protected $_baseURL = '';
 52: 
 53:     /**
 54:      * Stores, if GZIP compression will be used
 55:      *
 56:      * @var bool
 57:      */
 58:     protected $_useGZIP = false;
 59: 
 60: 
 61:     /**
 62:      * cTinyMCEEditor constructor
 63:      *
 64:      * @param string $editorName
 65:      * @param string $editorContent
 66:      */
 67:     public function __construct($editorName, $editorContent) {
 68: 
 69:         $belang = cRegistry::getBackendLanguage();
 70:         $cfgClient = cRegistry::getClientConfig();
 71:         $client = cRegistry::getClientId();
 72:         $lang = cRegistry::getLanguageId();
 73:         $idart = cRegistry::getArticleId();
 74: 
 75:         parent::__construct($editorName, $editorContent);
 76: 
 77:         $this->_setEditor("tinymce3");
 78: 
 79:         // Retrieve all settings for tinymce
 80:         $this->_aSettings = getEffectiveSettingsByType("tinymce");
 81: 
 82:         // For compatibility, read settings in previous syntax also (< V4.7, type "wysiwyg" vs. "tinymce")
 83:         $this->_aSettings = array_merge(getEffectiveSettingsByType("wysiwyg"), $this->_aSettings);
 84: 
 85:         // modified 23.10.2006
 86:         $this->setSetting(null, "article_url_suffix", 'front_content.php?idart=' . $idart, true);
 87: 
 88:         // Default values
 89:         $this->setSetting(null, "mode", "exact");
 90:         $aPathFragments = explode('/', $cfgClient[$client]["path"]["htmlpath"]);
 91:         $this->setSetting(null, "content_css", $cfgClient[$client]["path"]["htmlpath"] . "css/style_tiny.css");
 92: 
 93:         $this->setSetting(null, "theme", "advanced");
 94:         $this->setSetting(null, "theme_advanced_toolbar_location", "top");
 95:         $this->setSetting(null, "theme_advanced_path_location", "bottom");
 96:         $this->setSetting(null, "remove_script_host", false);
 97:         $this->setSetting(null, "file_browser_callback", "Con.Tiny.customFileBrowserCallback", true);
 98:         //$this->_setSetting("urlconverter_callback", "Con.Tiny.customURLConverterCallback");
 99:         // New in V3.x
100:         $this->setSetting(null, "theme_advanced_resizing", true);
101:         $this->setSetting(null, "pagebreak_separator", "<!-- my page break -->"); // needs pagebreak plugin
102:         // Source formatting (ugh!)
103:         $this->setSetting(null, "apply_source_formatting", true);
104:         $this->setSetting(null, "remove_linebreaks", false); // Remove linebreaks - GREAT idea...
105: 
106:         // Convert URLs and Relative URLs default
107:         $this->setSetting(null, "convert_urls", false);
108:         $this->setSetting(null, "relative_urls", false);
109: 
110:         // Editor name (a comma separated list of instances)
111:         $this->setSetting(null, "elements", $editorName);
112: 
113:         // Editor language
114:         $langs = i18nGetAvailableLanguages();
115:         $this->setSetting(null, "language", $langs[$belang][4]);
116:         unset($langs);
117: 
118:         // Set document base URL
119:         $this->setSetting(null, 'document_base_url', cRegistry::getFrontendUrl(), true);
120: 
121:         // The following "base URL" is the URL used to reference JS script files
122:         // - it is not the base href value
123:         //$this->setBaseURL(preg_replace('/^https?:\/\/[^\/]+(.*)$/', '$1', $this->_getEditorPath()));
124:         $this->setBaseURL($this->_getEditorPath());
125: 
126:         // XHTML
127:         if (getEffectiveSetting("generator", "xhtml", false) == "true") {
128:             $this->setXHTMLMode(true);
129:         } else {
130:             $this->setXHTMLMode(false);
131:         }
132: 
133:         // GZIP
134:         if ($this->_aSettings["contenido_gzip"] == "true") {
135:             $this->setGZIPMode(true);
136:         } else {
137:             $this->setGZIPMode(false);
138:         }
139: 
140:         // Stylesheet file, for compatibility
141:         if (!array_key_exists("content_css", $this->_aSettings) && array_key_exists("tinymce-stylesheet-file", $this->_aSettings)) {
142:             $this->setSetting(null, "content_css", $this->_aSettings["tinymce-stylesheet-file"], true);
143:         }
144: 
145:         // Set lists (for links and image elements)
146:         $this->setLists();
147: 
148:         // Set user defined styles (be sure, that previous and SPAW syntax works)
149:         $this->setUserDefinedStyles();
150: 
151:         // Width and height
152:         $this->setSetting(null, "width", "100%");
153:         $this->setSetting(null, "height", "480px");
154: 
155:         // Text direction (rtl = right to left)
156:         $sDirection = langGetTextDirection($lang);
157:         $this->setSetting(null, "directionality", $sDirection);
158: 
159:         if ($sDirection == "rtl") {
160:             $this->setSetting(null, "theme_advanced_toolbar_align", "right", true);
161:         } else {
162:             $this->setSetting(null, "theme_advanced_toolbar_align", "left", true);
163:         }
164: 
165:         // Date and time formats
166:         $this->setSetting(null, "plugin_insertdate_dateFormat", $this->convertFormat(getEffectiveSetting("dateformat", "date", "Y-m-d")));
167:         $this->setSetting(null, "plugin_insertdate_timeFormat", $this->convertFormat(getEffectiveSetting("dateformat", "time", "H:i:s")));
168: 
169:         // Setting the toolbar (toolbar_mode and tinymce-toolbar-mode accepted)
170:         $mode = "full";
171:         if (array_key_exists("tinymce-toolbar-mode", $this->_aSettings)) {
172:             $mode = $this->_aSettings["tinymce-toolbar-mode"];
173:         }
174:         if (array_key_exists("contenido_toolbar_mode", $this->_aSettings)) {
175:             $mode = $this->_aSettings["contenido_toolbar_mode"];
176:         }
177:         $this->setToolbar(trim(strtolower($mode)));
178: 
179:         $autoFullElements = $this->_aSettings['auto_full_elements'];
180:         unset($this->_aSettings['auto_full_elements']);
181: 
182:         // Valid elements, for compatibility also accepts "tinymce-valid-elements"
183:         if (!array_key_exists("valid_elements", $this->_aSettings) && array_key_exists("tinymce-valid-elements", $this->_aSettings)) {
184:             $this->setSetting(null, "valid_elements", $this->_aSettings["tinymce-valid-elements"], true);
185:         }
186: 
187:         // _setSetting checks, if value is empty
188:         if ($autoFullElements === 'true') {
189:             $this->setSetting(null, 'valid_elements', '*[*]');
190:             $this->setSetting(null, 'extended_valid_elements', '*[*]');
191:         }
192: 
193:         $this->setSetting(null, "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");
194: 
195:         // Extended valid elements, for compatibility also accepts "tinymce-extended-valid-elements"
196:         if (!array_key_exists("extended_valid_elements", $this->_aSettings) && array_key_exists("tinymce-extended-valid-elements", $this->_aSettings)) {
197:             $this->setSetting(null, "extended_valid_elements", $this->_aSettings["tinymce-extended-valid-elements"]);
198:         }
199: 
200: 
201:         //print_r($this->_aSettings['valid_elements']);
202: 
203:         $this->setSetting(null, "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]");
204: 
205:         // Clean all possible URLs
206:         $this->cleanURLs();
207: 
208:         // Remove CONTENIDO specific settings
209:         unset($this->_aSettings["contenido_toolbar_mode"], $this->_aSettings["contenido_lists"]);
210:         // Remove obsolete, deprecated values
211:         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"]);
212:     }
213: 
214:     /**
215:      * Old constructor
216:      *
217:      * @param string $editorName
218:      * @param string $editorContent
219:      * @deprecated [2016-02-18]
220:      *              This method is deprecated and is not needed any longer. Please use __construct() as constructor function.
221:      * @return __construct()
222:      */
223:     public function cTinyMCEEditor($editorName, $editorContent) {
224:         cDeprecated('This method is deprecated and is not needed any longer. Please use __construct() as constructor function.');
225:         return $this->__construct($editorName, $editorContent);
226:     }
227: 
228:     /**
229:      * Convert formats
230:      *
231:      * @param string $input
232:      * @return string
233:      */
234:     public function convertFormat($input) {
235:         $aFormatCodes = array(
236:             "y" => "%y", "Y" => "%Y", "d" => "%d", "m" => "%m", "H" => "%H", "h" => "%I", "i" => "%M", "s" => "%S", "a" => "%P", "A" => "%P"
237:         );
238: 
239:         foreach ($aFormatCodes as $sFormatCode => $sReplacement) {
240:             $input = str_replace($sFormatCode, $sReplacement, $input);
241:         }
242: 
243:         return $input;
244:     }
245: 
246:     /**
247:      * Set user defined styles
248:      *
249:      */
250:     public function setUserDefinedStyles() {
251:         $styles = "";
252: 
253:         if (array_key_exists("theme_advanced_styles", $this->_aSettings)) {
254:             $styles = $this->_aSettings["theme_advanced_styles"];
255:         } else if (array_key_exists("tinymce-styles", $this->_aSettings)) {
256:             $styles = $this->_aSettings["tinymce-styles"];
257:         }
258: 
259:         if ($styles) {
260:             $this->setSetting(null, "theme_advanced_styles", preg_replace('/;$/i', '', str_replace("|", "=", trim($styles))), true);
261:         }
262:     }
263: 
264:     /**
265:      * The special name "contenido_lists", for compatibility also
266:      * accepts "tinymce-lists".
267:      *
268:      * @param string $lists
269:      *        Deprecated, for compatibility, only
270:      */
271:     public function setLists($lists = "") {
272: 
273:         $lang = cRegistry::getLanguageId();
274:         $client = cRegistry::getClientId();
275: 
276:         if ($lists == "") {
277:             if (array_key_exists("contenido_lists", $this->_aSettings)) {
278:                 $lists = $this->_aSettings["contenido_lists"];
279:             } else if (array_key_exists("tinymce-lists", $this->_aSettings)) {
280:                 $lists = $this->_aSettings["tinymce-lists"];
281:             }
282:         }
283: 
284:         $aLists = array();
285:         $aLists = explode(",", strtolower(str_replace(" ", "", $lists)));
286: 
287:         if (in_array("link", $aLists)) {
288:             $this->setSetting(null, "external_link_list_url", $this->_baseURL . "list.php?mode=link&lang=" . $lang . "&client=" . $client . "#", true);
289:         }
290:         if (in_array("image", $aLists)) {
291:             $this->setSetting(null, "external_image_list_url", $this->_baseURL . "list.php?mode=image&lang=" . $lang . "&client=" . $client . "#", true);
292:         }
293:         if (in_array("media", $aLists)) {
294:             $this->setSetting(null, "media_external_list_url", $this->_baseURL . "list.php?mode=media&lang=" . $lang . "&client=" . $client . "#", true);
295:         }
296:     }
297: 
298:     /**
299:      * Set method XHTML mode
300:      * Standard: true
301:      *
302:      * @param bool $beabled
303:      */
304:     public function setXHTMLMode($beabled = true) {
305:         if ($beabled) {
306:             $this->setSetting(null, "cleanup_callback", "", true);
307:         } else {
308:             $this->setSetting(null, "cleanup_callback", "Con.Tiny.customCleanupCallback", true);
309:         }
310:     }
311: 
312:     /**
313:      * Set method GZIP mode
314:      * Standard: true
315:      *
316:      * @param bool $enabled
317:      */
318:     public function setGZIPMode($enabled = true) {
319:         if ($enabled) {
320:             $this->_useGZIP = true;
321:         } else {
322:             $this->_useGZIP = false;
323:         }
324:     }
325: 
326:     /**
327:      * Get method for GZIP mode
328:      *
329:      * @return boolean
330:      */
331:     public function getGZIPMode() {
332:         return cSecurity::toBoolean($this->_useGZIP);
333:     }
334: 
335:     /**
336:      * For compatibility also accepts "tinymce-toolbar-mode", "tinymce-toolbar1-3" and "tinymce-plugins"
337:      *
338:      * @param string $mode
339:      */
340:     public function setToolbar($mode = "") {
341: 
342:         $cfgClient = cRegistry::getClientConfig();
343:         $client = cRegistry::getClientId();
344: 
345:         switch ($mode) {
346:             case "full": // Show all options
347:                 $this->setSetting(null, "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);
348:                 $this->setSetting(null, "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);
349:                 $this->setSetting(null, "theme_advanced_buttons3", "tablecontrols,|,formatselect,fontselect,fontsizeselect,|,styleprops,|,cite,abbr,acronym,del,ins,attribs", true);
350:                 //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
351:                 $this->setSetting(null, "plugins", "table,save,advhr,advimage,advlink,pagebreak,style,layer,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups", true);
352:                 $this->setSetting(null, "theme_advanced_toolbar_align", "left", true);
353: 
354:                 $aCustSettings = getEffectiveSettingsByType("tinymce");
355:                 foreach ($aCustSettings as $key=> $value) {
356:                     $this->setSetting(null, $key, $value, true);
357:                 }
358: 
359:                 break;
360:             case "fullscreen": // Show all options
361:                 $this->setSetting(null, "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);
362:                 $this->setSetting(null, "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);
363:                 $this->setSetting(null, "theme_advanced_buttons3", "tablecontrols,|,formatselect,fontselect,fontsizeselect,|,styleprops,|,cite,abbr,acronym,del,ins,attribs", true);
364:                 //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
365:                 $this->setSetting(null, "plugins", "table,save,advhr,advimage,advlink,pagebreak,style,layer,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups", true);
366:                 $this->setSetting(null, "theme_advanced_toolbar_align", "left", true);
367: 
368:                 $aCustSettings = getEffectiveSettingsByType("tinymce_fullscreen");
369:                 foreach ($aCustSettings as $key => $value) {
370:                     $this->setSetting(null, $key, $value, true);
371:                 }
372: 
373:                 break;
374:             case "simple": // Does not show font and table options
375:                 $this->setSetting(null, "theme_advanced_buttons1", "cut,copy,paste,pastetext,pasteword,|,search,replace,|,undo,redo,|,bold,italic,underline,strikethrough,sub,sup,|,insertdate,inserttime,preview,|,styleselect", true);
376:                 $this->setSetting(null, "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);
377:                 $this->setSetting(null, "theme_advanced_buttons3", "", true);
378:                 $this->setSetting(null, "plugins", "advhr,advimage,advlink,insertdatetime,preview,searchreplace,print,contextmenu,paste,directionality", true);
379: 
380:                 $aCustSettings = getEffectiveSettingsByType("tinymce_simple");
381:                 foreach ($aCustSettings as $key => $value) {
382:                     $this->setSetting(null, $key, $value, true);
383:                 }
384: 
385:                 break;
386:             case "mini": // Minimal toolbar
387:                 $this->setSetting(null, "theme_advanced_buttons1", "undo,redo,|,bold,italic,underline,strikethrough,|,link", true);
388:                 $this->setSetting(null, "theme_advanced_buttons2", "", true);
389:                 $this->setSetting(null, "theme_advanced_buttons3", "", true);
390: 
391:                 $aCustSettings = getEffectiveSettingsByType("tinymce_mini");
392:                 foreach ($aCustSettings as $key => $value) {
393:                     $this->setSetting(null, $key, $value, true);
394:                 }
395: 
396:                 break;
397:             case "custom": // Custom toolbar
398:                 // tinymce-toolbar1/2/3 and tinymce-plugins are only mentioned for compatibility
399:                 // They are ignored, if theme_advanced_buttons1/2/3 and plugins have been already
400:                 // specified
401:                 $this->setSetting(null, "theme_advanced_buttons1", $this->_aSettings["tinymce-toolbar1"]);
402:                 $this->setSetting(null, "theme_advanced_buttons2", $this->_aSettings["tinymce-toolbar2"]);
403:                 $this->setSetting(null, "theme_advanced_buttons3", $this->_aSettings["tinymce-toolbar3"]);
404:                 $this->setSetting(null, "plugins", $this->_aSettings["tinymce-plugins"]);
405:                 $this->setSetting(null, "theme_advanced_toolbar_location", "bottom");
406: 
407:                 $aCustSettings = getEffectiveSettingsByType("tinymce_custom");
408:                 foreach ($aCustSettings as $key => $value) {
409:                     $this->setSetting(null, $key, $value, true);
410:                 }
411: 
412:                 break;
413:             case "inline_edit":
414:                 $this->setSetting(null, "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);
415:                 $this->setSetting(null, "theme_advanced_buttons2", "", true);
416:                 $this->setSetting(null, "theme_advanced_buttons3", "", true);
417: 
418:                 $this->setSetting(null, "setupcontent_callback", "Con.Tiny.customSetupContentCallback", true);
419: 
420:                 $this->_unsetSetting("width");
421:                 $this->_unsetSetting("theme_advanced_toolbar_location");
422:                 $this->setSetting(null, "theme_advanced_toolbar_location", "external");
423:                 $this->setSetting(null, "height", "210px", true);
424:                 // close plugin not in plugins directory but still working if listed
425:                 $this->setSetting(null, "plugins", "table,inlinepopups,fullscreen,close", true);
426:                 $this->setSetting(null, "mode", "exact", true);
427:                 $this->setSetting(null, "elements", "*", true);
428:                 $this->setSetting(null, "content_css", $cfgClient[$client]["path"]["htmlpath"] . "css/style_tiny.css", true);
429: 
430:                 if (!array_key_exists("auto_resize", $this->_aSettings)) {
431:                     $this->setSetting(null, "auto_resize", "false", true);
432:                 }
433: 
434:                 if (!array_key_exists("theme_advanced_toolbar_location", $this->_aSettings)) {
435:                     $this->setSetting(null, "theme_advanced_toolbar_location", "top", true);
436:                 }
437: 
438:                 if (!array_key_exists("theme_advanced_resizing_use_cookie", $this->_aSettings)) {
439:                     $this->setSetting(null, "theme_advanced_resizing_use_cookie", "false", true);
440:                 }
441: 
442:                 if (!array_key_exists("theme_advanced_toolbar_align", $this->_aSettings)) {
443:                     $this->setSetting(null, "theme_advanced_toolbar_align", "center", true);
444:                 }
445: 
446:                 $aCustSettings = getEffectiveSettingsByType("tinymce_inline");
447:                 foreach ($aCustSettings as $key => $value) {
448:                     $this->setSetting(null, $key, $value, true);
449:                 }
450: 
451:                 break;
452:             default: // Default options
453:                 $this->setSetting(null, "theme_advanced_buttons1", "undo,redo,|,bold,italic,underline,strikethrough,|,link,unlink,anchor,image,advhr,|,tablecontrols", true);
454:                 $this->setSetting(null, "theme_advanced_buttons2", "styleselect,|,bullist,numlist,|,outdent,indent,|,justifyleft,justifycenter,justifyright,justifyfull,removeformat,|,forecolor,backcolor,|,sub,sup,|,code", true);
455:                 $this->setSetting(null, "theme_advanced_buttons3", "", true);
456:                 $this->setSetting(null, "plugins", "table,advhr,advimage,advlink,searchreplace,contextmenu,paste", true);
457: 
458:                 $aCustSettings = getEffectiveSettingsByType("tinymce_default");
459:                 foreach ($aCustSettings as $key => $value) {
460:                     $this->setSetting(null, $key, $value, true);
461:                 }
462:         }
463:     }
464: 
465:     /**
466:      * Clean urls function
467:      *
468:      */
469:     public function cleanURLs() {
470: 
471:         $sess = cRegistry::getBackendSessionId();
472: 
473:         // Add the path to the following values
474:         $aParameters = array(
475:             //builtin
476:             'content_css', 'popups_css', 'popups_css_add', 'editor_css', // plugins
477:             'plugin_preview_pageurl', //preview plugin
478:             'media_external_list_url', //media plugin
479:             'template_external_list_url' //template plugin
480:         );
481: 
482:         foreach ($aParameters as $sParameter) {
483:             if (array_key_exists($sParameter, $this->_aSettings)) {
484:                 $this->setSetting(null, $sParameter, $this->addPath($this->_aSettings[$sParameter]), true);
485:             }
486:         }
487: 
488:         // Session for template and media support files that are written in PHP
489:         $aParameters = array(
490:             'media_external_list_url', //media plugin
491:             'template_external_list_url' //template plugin
492:         );
493: 
494:         foreach ($aParameters as $sParameter) {
495:             if (array_key_exists($sParameter, $this->_aSettings) && preg_match('/\\.php$/i', $this->_aSettings[$sParameter])) {
496:                 $this->setSetting(null, $sParameter, $this->_aSettings[$sParameter] . '?contenido=' . $sess->id, true);
497:             }
498:         }
499:     }
500: 
501:     /**
502:      * Add path before filename
503:      *
504:      * @param string $file
505:      * @return string
506:      */
507:     public function addPath($file) {
508: 
509:         $cfgClient = cRegistry::getClientConfig();
510:         $client = cRegistry::getClientId();
511: 
512:         // Quick and dirty hack
513:         if (!preg_match('/^(http|https):\/\/((?:[a-zA-Z0-9_-]+\.?)+):?(\d*)/', $file)) {
514:             if (preg_match('/^\//', $file)) {
515:                 $file = "http://" . $_SERVER['HTTP_HOST'] . $file;
516:             } else {
517:                 $file = $cfgClient[$client]['htmlpath']['frontend'] . $file;
518:             }
519:         }
520: 
521:         return $file;
522:     }
523: 
524:     /**
525:      * Set method for base url
526:      *
527:      * @param string $baseUrl
528:      */
529:     public function setBaseURL($baseUrl) {
530:         $this->_baseURL = $baseUrl;
531:     }
532: 
533:     /**
534:      * Get method for scripts
535:      *
536:      * @return string
537:      */
538:     public function getScripts() {
539:         if ($this->_useGZIP) {
540:             $return = "\n<!-- tinyMCE -->\n" . '<script language="javascript" type="text/javascript" src="' . $this->_baseURL . 'jscripts/tiny_mce/tiny_mce_gzip.js"></script>';
541:         } else {
542:             $return = "\n<!-- tinyMCE -->\n" . '<script language="javascript" type="text/javascript" src="' . $this->_baseURL . 'jscripts/tiny_mce/tiny_mce.js"></script>';
543:         }
544: 
545:         return $return;
546:     }
547: 
548:     /**
549:      * Get method for editor
550:      *
551:      * @return string
552:      */
553:     public function getEditor() {
554: 
555:         $sess = cRegistry::getSession();
556:         $cfg = cRegistry::getConfig();
557:         $client = cRegistry::getClientId();
558:         $cfgClient = cRegistry::getClientConfig();
559: 
560:         // TODO: Check functionality - doesn't seem to have any effect...
561:         $sess->register("browserparameters");
562: 
563:         // Contenido-specific: Set article_url_suffix setting as it is used in plugins/advlink/jscripts/functions.js on anchor tags
564:         $this->setSetting(null, "setupcontent_callback", 'Con.Tiny.customSetupContentCallback', true);
565:         $this->setSetting(null, "save_callback", 'Con.Tiny.customSaveCallback', true);
566: 
567:         // Set browser windows
568:         // Difference between file and image browser is with (file) or without categories/articles (image)
569:         $template = new cTemplate();
570:         $template->set('s', 'IMAGEBROWSER', $cfg['path']['contenido_fullhtml'] . 'frameset.php?area=upl&contenido=' . $sess->id . '&appendparameters=imagebrowser');
571:         $template->set('s', 'FILEBROWSER', $cfg['path']['contenido_fullhtml'] . 'frameset.php?area=upl&contenido=' . $sess->id . '&appendparameters=filebrowser');
572:         $template->set('s', 'MEDIABROWSER', $cfg['path']['contenido_fullhtml'] . 'frameset.php?area=upl&contenido=' . $sess->id . '&appendparameters=imagebrowser');
573:         $template->set('s', 'FRONTEND_PATH', $cfgClient[$client]['path']['htmlpath']);
574: 
575:         // GZIP support options
576:         $GZIPScript = '';
577:         if ($this->_useGZIP) {
578:             // tinyMCE_GZ.init call must be placed in its own script tag
579:             // User defined plugins and themes should be identical in both "inits"
580:             $GZIPScript = <<<JS
581: <script type="text/javascript">
582: tinyMCE_GZ.init({
583:     plugins: '{$this->_aSettings["plugins"]}',
584:     themes: '{$this->_aSettings["theme"]}',
585:     languages: '{$this->_aSettings["language"]}',
586:     disk_cache: true,
587:     debug: false
588: });
589: </script>
590: JS;
591:         }
592:         $template->set('s', 'COMPRESSOR', $GZIPScript);
593: 
594:         // Calculate the configuration
595:         $config = '';
596: 
597:         foreach ($this->_aSettings as $key => $value) {
598:             if (is_bool($value)) {
599:                 if ($value === true) {
600:                     $value = "true";
601:                 } else {
602:                     $value = "false";
603:                 }
604:             }
605: 
606:             if ($value == "true" || $value == "false" || $key == "oninit" || $key == "onpageload" || $key == 'style_formats') {
607:                 $config .= "'$key': " . $value;
608:             } else {
609:                 $config .= "'$key': '" . $value . "'";
610:             }
611:             $config .= ",\n\t";
612:         }
613: 
614:         $config = substr($config, 0, -3);
615:         $template->set('s', 'CONFIG', $config);
616: 
617:         $oTxtEditor = new cHTMLTextarea($this->_sEditorName, $this->_sEditorContent);
618:         $oTxtEditor->setId($this->_sEditorName);
619: 
620:         $oTxtEditor->setStyle("width: " . $this->_aSettings["width"] . "; height: " . $this->_aSettings["height"] . ";");
621: 
622:         $return = $template->generate($cfg['path']['all_wysiwyg'] . $this->_sEditor . "/tinymce.tpl.html", true);
623:         $return .= $oTxtEditor->render();
624: 
625:         return $return;
626:     }
627: 
628:     /**
629:      * Get method for inline editing
630:      *
631:      * @return string
632:      */
633:     public function getConfigInlineEdit() {
634:         $config = '';
635:         $this->setToolbar('inline_edit');
636: 
637:         foreach ($this->_aSettings as $key => $value) {
638:             if (is_bool($value)) {
639:                 if ($value === true) {
640:                     $value = "true";
641:                 } else {
642:                     $value = "false";
643:                 }
644:             }
645: 
646:             if ($value == "true" || $value == "false" || $key == "oninit" || $key == "onpageload" || $key == 'style_formats') {
647:                 $config .= "'$key': " . $value;
648:             } else {
649:                 $config .= "'$key': '" . $value . "'";
650:             }
651:             $config .= ",\n\t";
652:         }
653: 
654:         $config = substr($config, 0, -3);
655: 
656:         return $config;
657:     }
658: 
659:     /**
660:      * Get method for fullscreen mode
661:      *
662:      * @return string
663:      */
664:     public function getConfigFullscreen() {
665:         $config = '';
666:         $this->setToolbar('fullscreen');
667: 
668:         $config .= "'theme_advanced_buttons1': '" . $this->_aSettings['theme_advanced_buttons1'] . "',\n";
669:         $config .= "'theme_advanced_buttons2': '" . $this->_aSettings['theme_advanced_buttons2'] . "',\n";
670:         $config .= "'theme_advanced_buttons3': '" . $this->_aSettings['theme_advanced_buttons3'] . "',\n";
671:         $config .= "'theme_advanced_toolbar_align': '" . $this->_aSettings['theme_advanced_toolbar_align'] . "',\n";
672:         $config .= "'plugins': '" . $this->_aSettings['plugins'] . "'\n";
673: 
674:         return $config;
675:     }
676: 
677:     /**
678:      * Get method for plugins
679:      *
680:      * @return array
681:      */
682:     public function getPlugins() {
683:         return $this->_aSettings['plugins'];
684:     }
685: 
686:     /**
687:      * Get method for themes
688:      *
689:      * @return array
690:      */
691:     public function getThemes() {
692:         return $this->_aSettings['theme'];
693:     }
694: 
695: }
696: 
CMS CONTENIDO 4.9.11 API documentation generated by ApiGen 2.8.0