#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]
This commit is contained in:
Romain Quetiez
2015-08-19 17:10:28 +00:00
parent 3ba2c3d657
commit ec61417e39
3 changed files with 27 additions and 8 deletions

View File

@@ -1841,7 +1841,7 @@ EOF
break; break;
case 'HTML': 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); $sHTMLValue = $oWidget->Display($oPage, $aArgs);
break; break;

View File

@@ -1,5 +1,5 @@
<?php <?php
// Copyright (C) 2010-2012 Combodo SARL // Copyright (C) 2010-2015 Combodo SARL
// //
// This file is part of iTop. // This file is part of iTop.
// //
@@ -21,13 +21,15 @@
* UI wdiget for displaying and editing one-way encrypted passwords * UI wdiget for displaying and editing one-way encrypted passwords
* *
* @author Phil Eddies * @author Phil Eddies
* @copyright Copyright (C) 2010-2012 Combodo SARL * @author Romain Quetiez
* @copyright Copyright (C) 2010-2015 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0 * @license http://opensource.org/licenses/AGPL-3.0
*/ */
class UIHTMLEditorWidget class UIHTMLEditorWidget
{ {
protected $m_iId; protected $m_iId;
protected $m_oAttDef;
protected $m_sAttCode; protected $m_sAttCode;
protected $m_sNameSuffix; protected $m_sNameSuffix;
protected $m_sFieldPrefix; protected $m_sFieldPrefix;
@@ -36,10 +38,11 @@ class UIHTMLEditorWidget
protected $m_sValue; protected $m_sValue;
protected $m_sMandatory; protected $m_sMandatory;
public function __construct($iInputId, $sAttCode, $sNameSuffix, $sFieldPrefix, $sHelpText, $sValidationField, $sValue, $sMandatory) public function __construct($iInputId, $oAttDef, $sNameSuffix, $sFieldPrefix, $sHelpText, $sValidationField, $sValue, $sMandatory)
{ {
$this->m_iId = $iInputId; $this->m_iId = $iInputId;
$this->m_sAttCode = $sAttCode; $this->m_oAttDef = $oAttDef;
$this->m_sAttCode = $oAttDef->GetCode();
$this->m_sNameSuffix = $sNameSuffix; $this->m_sNameSuffix = $sNameSuffix;
$this->m_sHelpText = $sHelpText; $this->m_sHelpText = $sHelpText;
$this->m_sValidationField = $sValidationField; $this->m_sValidationField = $sValidationField;
@@ -68,8 +71,24 @@ class UIHTMLEditorWidget
// To change the default settings of the editor, // To change the default settings of the editor,
// a) edit the file /js/ckeditor/config.js // a) edit the file /js/ckeditor/config.js
// b) or override some of the configuration settings, using the second parameter of ckeditor() // b) or override some of the configuration settings, using the second parameter of ckeditor()
$aConfig = array();
$sLanguage = strtolower(trim(UserRights::GetUserLanguage())); $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... // Please read...
// ValidateCKEditField triggers a timer... calling itself indefinitely // ValidateCKEditField triggers a timer... calling itself indefinitely

View File

@@ -1155,8 +1155,8 @@ EOF;
// Added if present... // Added if present...
// //
$aParameters['validation_pattern'] = $this->GetPropString($oField, 'validation_pattern'); $aParameters['validation_pattern'] = $this->GetPropString($oField, 'validation_pattern');
$aParameters['width'] = $this->GetPropNumber($oField, 'width'); $aParameters['width'] = $this->GetPropString($oField, 'width');
$aParameters['height'] = $this->GetPropNumber($oField, 'height'); $aParameters['height'] = $this->GetPropString($oField, 'height');
$aParameters['digits'] = $this->GetPropNumber($oField, 'digits'); $aParameters['digits'] = $this->GetPropNumber($oField, 'digits');
$aParameters['decimals'] = $this->GetPropNumber($oField, 'decimals'); $aParameters['decimals'] = $this->GetPropNumber($oField, 'decimals');
$aParameters['always_load_in_tables'] = $this->GetPropBoolean($oField, 'always_load_in_tables', false); $aParameters['always_load_in_tables'] = $this->GetPropBoolean($oField, 'always_load_in_tables', false);