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