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