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 defines the CodeMirror editor integration class.
  4:  *
  5:  * @package    Core
  6:  * @subpackage Backend
  7:  * @author     Unknown
  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: /**
 17:  * Class for handling and displaying CodeMirror
 18:  *
 19:  * @package    Core
 20:  * @subpackage Backend
 21:  */
 22: class CodeMirror {
 23: 
 24:     /**
 25:      * Properties which were used to init CodeMirror
 26:      *
 27:      * @var array
 28:      */
 29:     private $_properties = array();
 30: 
 31:     /**
 32:      * HTML-ID of textarea which is replaced by CodeMirror
 33:      *
 34:      * @var string
 35:      */
 36:     private $_textareaId = '';
 37: 
 38:     /**
 39:      * defines if textarea is used or not (by system/client/user property)
 40:      *
 41:      * @var boolean
 42:      */
 43:     private $_activated = true;
 44: 
 45:     /**
 46:      * defines if js-script for CodeMirror is included on rendering process
 47:      *
 48:      * @var boolean
 49:      */
 50:     private $_addScript = true;
 51: 
 52:     /**
 53:      * The CONTENIDO configuration array
 54:      *
 55:      * @var array
 56:      */
 57:     private $_cfg = array();
 58: 
 59:     /**
 60:      * Language of CodeMirror
 61:      *
 62:      * @var string
 63:      */
 64:     private $_language = '';
 65: 
 66:     /**
 67:      * Syntax of CodeMirror
 68:      *
 69:      * @var string
 70:      */
 71:     private $_syntax = '';
 72: 
 73:     /**
 74:      * Constructor of CodeMirror initializes class variables
 75:      *
 76:      * @param string $id - The id of textarea which is replaced by editor
 77:      * @param string $syntax - Name of syntax highlighting which is used (html,
 78:      *        css, js, php, ...)
 79:      * @param string $lang - lang which is used into editor. Notice NOT
 80:      *        CONTENIDO language id
 81:      *        ex: de, en ... To get it from CONTENIDO language use:
 82:      *        substr(strtolower($belang), 0, 2) in backend
 83:      * @param bool $addScript - defines if CodeMirror script is included or
 84:      *        not
 85:      *        interesting when there is more than only one editor on page
 86:      * @param array $cfg - The CONTENIDO configuration array
 87:      * @param bool $editable - Optional defines if content is editable or not
 88:      */
 89:     public function __construct($id, $syntax, $lang, $addScript, $cfg, $editable = true) {
 90:         // init class variables
 91:         $this->_properties = array();
 92:         $this->_cfg = (array) $cfg;
 93:         $this->_addScript = (boolean) $addScript;
 94:         $this->_textareaId = (string) $id;
 95:         $this->_activated = true;
 96:         $this->_language = (string) $lang;
 97:         $this->_syntax = (string) $syntax;
 98: 
 99:         // make content not editable if not allowed
100:         if ($editable == false) {
101:             $this->setProperty('readOnly', 'true', true);
102:         }
103: 
104:         $this->setProperty('lineNumbers', 'true', true);
105:         $this->setProperty('lineWrapping', 'true', true);
106:         $this->setProperty('matchBrackets', 'true', true);
107:         $this->setProperty('indentUnit', 4, true);
108:         $this->setProperty('indentWithTabs', 'true', true);
109:         $this->setProperty('enterMode', 'keep', false);
110:         $this->setProperty('tabMode', 'shift', false);
111: 
112:         // internal function which appends more properties to $this->setProperty
113:         // wich where defined
114:         // by user or sysadmin in systemproperties / client settings / user
115:         // settings ...
116:         $this->_getSystemProperties();
117:     }
118: 
119:     /**
120:      * Function gets properties from CONTENIDO for CodeMirror and stores it into
121:      * $this->setProperty so user is able to overwride standard settings or
122:      * append
123:      * other settings.
124:      * Function also checks if CodeMirror is activated or deactivated
125:      * by user
126:      */
127:     private function _getSystemProperties() {
128:         // check if editor is disabled or enabled by user/admin
129:         if (getEffectiveSetting('codemirror', 'activated', 'true') == 'false') {
130:             $this->_activated = false;
131:         }
132: 
133:         $userSettings = getEffectiveSettingsByType('codemirror');
134:         foreach ($userSettings as $key => $value) {
135:             if ($key != 'activated') {
136:                 if ($value == 'true' || $value == 'false' || is_numeric($value)) {
137:                     $this->setProperty($key, $value, true);
138:                 } else {
139:                     $this->setProperty($key, $value, false);
140:                 }
141:             }
142:         }
143:     }
144: 
145:     /**
146:      * Function for setting a property for CodeMirror to $this->setProperty
147:      * existing properties were overwritten
148:      *
149:      * @param string $name - Name of CodeMirror property
150:      * @param string $value - Value of CodeMirror property
151:      * @param bool $isNumeric - Defines if value is numeric or not
152:      *        in case of a numeric value, there is no need to use
153:      *        quotes
154:      */
155:     public function setProperty($name, $value, $isNumeric = false) {
156:         // datatype check
157:         $name = (string) $name;
158:         $value = (string) $value;
159:         $isNumeric = (boolean) $isNumeric;
160: 
161:         // generate a new array for new property
162:         $record = array();
163:         $record['name'] = $name;
164:         $record['value'] = $value;
165:         $record['is_numeric'] = $isNumeric;
166: 
167:         // append it to class variable $this->aProperties
168:         // when key already exists, overwride it
169:         $this->_properties[$name] = $record;
170:     }
171: 
172:     private function _getSyntaxScripts() {
173:         $path = $this->_cfg['path']['contenido_fullhtml'] . 'external/codemirror';
174: 
175:         $js = '';
176:         $jsTemplate = '<script type="text/javascript" src="%s/mode/%s/%s.js"></script>';
177: 
178:         $modes = array();
179: 
180:         $syntax = $this->_syntax;
181:         if ($syntax == 'js' || $syntax == 'html' || $syntax == 'php') {
182:             $modes[] = 'javascript';
183:         }
184: 
185:         if ($syntax == 'css' || $syntax == 'html' || $syntax == 'php') {
186:             $modes[] = 'css';
187:         }
188: 
189:         if ($syntax == 'html' || $syntax == 'php') {
190:             $modes[] = 'xml';
191:         }
192: 
193:         if ($syntax == 'php') {
194:             $modes[] = 'php';
195:             $modes[] = 'clike';
196:         }
197: 
198:         if ($syntax == 'html') {
199:             $modes[] = 'htmlmixed';
200:         }
201: 
202:         foreach ($modes as $mode) {
203:             $js .= sprintf($jsTemplate, $path, $mode, $mode) . PHP_EOL;
204:         }
205: 
206:         return $js;
207:     }
208: 
209:     private function _getSyntaxName() {
210:         if ($this->_syntax == 'php') {
211:             return 'application/x-httpd-php';
212:         }
213: 
214:         if ($this->_syntax == 'html') {
215:             return 'text/html';
216:         }
217: 
218:         if ($this->_syntax == 'css') {
219:             return 'text/css';
220:         }
221: 
222:         if ($this->_syntax == 'js') {
223:             return 'text/javascript';
224:         }
225:     }
226: 
227:     /**
228:      * Function renders js_script for inclusion into an header of a html file
229:      *
230:      * @return string - js_script for CodeMirror
231:      */
232:     public function renderScript() {
233:         // if editor is disabled, there is no need to render this script
234:         if ($this->_activated == false) {
235:             return '';
236:         }
237: 
238:         // if external js file for editor should be included, do this here
239:         $js = '';
240:         if ($this->_addScript) {
241:             $conPath = $this->_cfg['path']['contenido_fullhtml'];
242:             $path = $conPath . 'external/codemirror/';
243: 
244:             $language = $this->_language;
245:             if (!file_exists($this->_cfg['path']['contenido'] . 'external/codemirror/lib/lang/' . $language . '.js')) {
246:                 $language = 'en';
247:             }
248: 
249:             $js .= '<script type="text/javascript" src="' . $path . 'lib/lang/' . $language . '.js"></script>' . PHP_EOL;
250:             $js .= '<script type="text/javascript" src="' . $path . 'lib/codemirror.js"></script>' . PHP_EOL;
251:             $js .= '<script type="text/javascript" src="' . $path . 'lib/util/foldcode.js"></script>' . PHP_EOL;
252:             $js .= '<script type="text/javascript" src="' . $path . 'lib/util/dialog.js"></script>' . PHP_EOL;
253:             $js .= '<script type="text/javascript" src="' . $path . 'lib/util/searchcursor.js"></script>' . PHP_EOL;
254:             $js .= '<script type="text/javascript" src="' . $path . 'lib/util/search.js"></script>' . PHP_EOL;
255:             $js .= '<script type="text/javascript" src="' . $path . 'lib/contenido_integration.js"></script>' . PHP_EOL;
256:             $js .= $this->_getSyntaxScripts();
257:             $js .= '<link rel="stylesheet" href="' . $path . 'lib/codemirror.css">' . PHP_EOL;
258:             $js .= '<link rel="stylesheet" href="' . $path . 'lib/util/dialog.css">' . PHP_EOL;
259:             $js .= '<link rel="stylesheet" href="' . $path . 'lib/contenido_integration.css">' . PHP_EOL;
260:         }
261: 
262:         // define template for CodeMirror script
263:         $js .= <<<JS
264: <script type="text/javascript">
265: (function(Con, $) {
266:     $(function() {
267:         if (!$('#{ID}')[0]) {
268:             // Node is missing, nothing to initialize here...
269:             return;
270:         }
271:         Con.CodeMirrorHelper.init('{ID}', {
272:             extraKeys: {
273:                 'F11': function() {
274:                     Con.CodeMirrorHelper.toggleFullscreenEditor('{ID}');
275:                 },
276:                 'Esc': function() {
277:                     Con.CodeMirrorHelper.toggleFullscreenEditor('{ID}');
278:                 }
279:             }
280:             {PROPERTIES}
281:         });
282:     });
283: })(Con, Con.$);
284: </script>
285: JS;
286: 
287:         $this->setProperty('mode', $this->_getSyntaxName(), false);
288:         $this->setProperty('theme', 'default ' . $this->_textareaId, false);
289: 
290:         // get all stored properties and convert it in order to insert it into
291:         // CodeMirror js template
292:         $properties = '';
293:         foreach ($this->_properties as $property) {
294:             if ($property['is_numeric'] == true) {
295:                 $properties .= ', ' . $property['name'] . ': ' . $property['value'];
296:             } else {
297:                 $properties .= ', ' . $property['name'] . ': "' . $property['value'] . '"';
298:             }
299:         }
300: 
301:         // fill js template
302:         $textareaId = $this->_textareaId;
303:         $jsResult = str_replace('{ID}', $textareaId, $js);
304:         $jsResult = str_replace('{PROPERTIES}', $properties, $jsResult);
305: 
306:         return $jsResult;
307:     }
308: 
309: }
310: 
CMS CONTENIDO 4.9.11 API documentation generated by ApiGen 2.8.0