فهرست منبع

#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

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3689 a333f486-631f-4898-b8df-5754b55c2be0
romainq 9 سال پیش
والد
کامیت
26854382bc
3فایلهای تغییر یافته به همراه27 افزوده شده و 8 حذف شده
  1. 1 1
      application/cmdbabstract.class.inc.php
  2. 24 5
      application/ui.htmleditorwidget.class.inc.php
  3. 2 2
      setup/compiler.class.inc.php

+ 1 - 1
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;
 

+ 24 - 5
application/ui.htmleditorwidget.class.inc.php

@@ -1,5 +1,5 @@
 <?php
-// Copyright (C) 2010-2012 Combodo SARL
+// Copyright (C) 2010-2015 Combodo SARL
 //
 //   This file is part of iTop.
 //
@@ -21,13 +21,15 @@
  * UI wdiget for displaying and editing one-way encrypted passwords
  *
  * @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
  */
 
 class UIHTMLEditorWidget 
 {
 	protected $m_iId;
+	protected $m_oAttDef;
 	protected $m_sAttCode;
 	protected $m_sNameSuffix;
 	protected $m_sFieldPrefix;
@@ -36,10 +38,11 @@ class UIHTMLEditorWidget
 	protected $m_sValue;
 	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_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

+ 2 - 2
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);