From ec61417e395cdc5918ce9b4d53618b69bc566b15 Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Wed, 19 Aug 2015 17:10:28 +0000 Subject: [PATCH] #1081 Customizations: adjust the dimensions of the HTML Editor (CKEditor). Also fixed an issue when specifying width/height with unit (e.g. "30em") for AttributeText/AttributeLongText SVN:trunk[3689] --- application/cmdbabstract.class.inc.php | 2 +- application/ui.htmleditorwidget.class.inc.php | 29 +++++++++++++++---- setup/compiler.class.inc.php | 4 +-- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index b7622f7968..fccda63e77 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -1841,7 +1841,7 @@ EOF break; case 'HTML': - $oWidget = new UIHTMLEditorWidget($iId, $sAttCode, $sNameSuffix, $sFieldPrefix, $sHelpText, $sValidationField, $value, $bMandatory); + $oWidget = new UIHTMLEditorWidget($iId, $oAttDef, $sNameSuffix, $sFieldPrefix, $sHelpText, $sValidationField, $value, $bMandatory); $sHTMLValue = $oWidget->Display($oPage, $aArgs); break; diff --git a/application/ui.htmleditorwidget.class.inc.php b/application/ui.htmleditorwidget.class.inc.php index 839f9245b2..6b4c986602 100644 --- a/application/ui.htmleditorwidget.class.inc.php +++ b/application/ui.htmleditorwidget.class.inc.php @@ -1,5 +1,5 @@ m_iId = $iInputId; - $this->m_sAttCode = $sAttCode; + $this->m_oAttDef = $oAttDef; + $this->m_sAttCode = $oAttDef->GetCode(); $this->m_sNameSuffix = $sNameSuffix; $this->m_sHelpText = $sHelpText; $this->m_sValidationField = $sValidationField; @@ -68,8 +71,24 @@ class UIHTMLEditorWidget // To change the default settings of the editor, // a) edit the file /js/ckeditor/config.js // b) or override some of the configuration settings, using the second parameter of ckeditor() + $aConfig = array(); $sLanguage = strtolower(trim(UserRights::GetUserLanguage())); - $oPage->add_ready_script("$('#$iId').ckeditor(function() { /* callback code */ }, { language : '$sLanguage' , contentsLanguage : '$sLanguage', extraPlugins: 'disabler' });"); // Transform $iId into a CKEdit + $aConfig['language'] = $sLanguage; + $aConfig['contentsLanguage'] = $sLanguage; + $aConfig['extraPlugins'] = 'disabler'; + $sWidthSpec = addslashes(trim($this->m_oAttDef->GetWidth())); + if ($sWidthSpec != '') + { + $aConfig['width'] = $sWidthSpec; + } + $sHeightSpec = addslashes(trim($this->m_oAttDef->GetHeight())); + if ($sHeightSpec != '') + { + $aConfig['height'] = $sHeightSpec; + } + $sConfigJS = json_encode($aConfig); + + $oPage->add_ready_script("$('#$iId').ckeditor(function() { /* callback code */ }, $sConfigJS);"); // Transform $iId into a CKEdit // Please read... // ValidateCKEditField triggers a timer... calling itself indefinitely diff --git a/setup/compiler.class.inc.php b/setup/compiler.class.inc.php index 4450d1a905..0fc403798e 100644 --- a/setup/compiler.class.inc.php +++ b/setup/compiler.class.inc.php @@ -1155,8 +1155,8 @@ EOF; // Added if present... // $aParameters['validation_pattern'] = $this->GetPropString($oField, 'validation_pattern'); - $aParameters['width'] = $this->GetPropNumber($oField, 'width'); - $aParameters['height'] = $this->GetPropNumber($oField, 'height'); + $aParameters['width'] = $this->GetPropString($oField, 'width'); + $aParameters['height'] = $this->GetPropString($oField, 'height'); $aParameters['digits'] = $this->GetPropNumber($oField, 'digits'); $aParameters['decimals'] = $this->GetPropNumber($oField, 'decimals'); $aParameters['always_load_in_tables'] = $this->GetPropBoolean($oField, 'always_load_in_tables', false);