();
switch (RegionType)
{
case CMSEditableRegionTypeEnum.HtmlEditor:
// HTML editor
if (htmlValue != null)
{
result.Add(htmlValue.ClientID);
}
break;
case CMSEditableRegionTypeEnum.TextArea:
case CMSEditableRegionTypeEnum.TextBox:
// TextBox
if (txtValue != null)
{
result.Add(txtValue.ClientID);
}
break;
}
return result;
}
return null;
}
protected void ApplySettings()
{
EnsureChildControls();
if (!StopProcessing)
{
// Create controls by actual page mode
switch (ViewMode)
{
case ViewModeEnum.Edit:
case ViewModeEnum.EditDisabled:
{
// Edit mode
if (DialogWidth > 0)
{
pnlEditor.Style.Add(HtmlTextWriterStyle.Width, DialogWidth.ToString() + "px;");
}
// Display the region control based on the region type
switch (RegionType)
{
case CMSEditableRegionTypeEnum.HtmlEditor:
// HTML Editor
if (IsDialogEdit)
{
htmlValue.Width = new Unit(100, UnitType.Percentage);
htmlValue.Height = new Unit(100, UnitType.Percentage);
htmlValue.ToolbarLocation = "out:CKToolbar";
// Maximize editor to fill entire dialog
((CMS.CKEditor.CKEditorControl)htmlValue).RemoveButton("maximize");
if (!CMSContext.CurrentDevice.IsMobile)
{
// Desktop browsers
htmlValue.Config["on"] = "{ 'instanceReady' : function(e) { e.editor.execCommand( 'maximize' ); } }";
}
}
else
{
if (DialogWidth > 0)
{
htmlValue.Width = new Unit(DialogWidth);
}
if (DialogHeight > 0)
{
htmlValue.Height = new Unit(DialogHeight);
}
}
// Set toolbar location
if (HtmlAreaToolbarLocation != "")
{
// Show the toolbar
if (HtmlAreaToolbarLocation.ToLowerCSafe() == "out:cktoolbar")
{
mShowToolbar = true;
}
htmlValue.ToolbarLocation = HtmlAreaToolbarLocation;
}
// Set the visual appearance
if (HtmlAreaToolbar != "")
{
htmlValue.ToolbarSet = HtmlAreaToolbar;
}
// Get editor area css file
if (HTMLEditorCssStylesheet != "")
{
htmlValue.EditorAreaCSS = CSSHelper.GetStylesheetUrl(HTMLEditorCssStylesheet);
}
else if (CMSContext.CurrentSite != null)
{
htmlValue.EditorAreaCSS = FormHelper.GetHtmlEditorAreaCss(CMSContext.CurrentSiteName);
}
// Set "Insert image or media" dialog configuration
htmlValue.MediaDialogConfig.ResizeToHeight = ResizeToHeight;
htmlValue.MediaDialogConfig.ResizeToWidth = ResizeToWidth;
htmlValue.MediaDialogConfig.ResizeToMaxSideSize = ResizeToMaxSideSize;
// Set "Insert link" dialog configuration
htmlValue.LinkDialogConfig.ResizeToHeight = ResizeToHeight;
htmlValue.LinkDialogConfig.ResizeToWidth = ResizeToWidth;
htmlValue.LinkDialogConfig.ResizeToMaxSideSize = ResizeToMaxSideSize;
// Set "Quickly insert image" configuration
htmlValue.QuickInsertConfig.ResizeToHeight = ResizeToHeight;
htmlValue.QuickInsertConfig.ResizeToWidth = ResizeToWidth;
htmlValue.QuickInsertConfig.ResizeToMaxSideSize = ResizeToMaxSideSize;
break;
case CMSEditableRegionTypeEnum.TextArea:
case CMSEditableRegionTypeEnum.TextBox:
// TextBox
if (RegionType == CMSEditableRegionTypeEnum.TextArea)
{
txtValue.TextMode = TextBoxMode.MultiLine;
}
else
{
txtValue.TextMode = TextBoxMode.SingleLine;
}
if (DialogWidth > 0)
{
txtValue.Width = new Unit(DialogWidth - 8);
}
else
{
// Default width is 100%
txtValue.Width = new Unit(100, UnitType.Percentage);
}
if (DialogHeight > 0)
{
txtValue.Height = new Unit(DialogHeight);
}
txtValue.Wrap = WordWrap;
break;
}
}
break;
}
}
}
///
/// Initializes the control properties.
///
public void SetupControl()
{
// Do not hide for roles in edit or preview mode
switch (ViewMode)
{
case ViewModeEnum.Edit:
case ViewModeEnum.EditLive:
case ViewModeEnum.EditDisabled:
case ViewModeEnum.Design:
case ViewModeEnum.DesignDisabled:
case ViewModeEnum.EditNotCurrent:
case ViewModeEnum.Preview:
SetValue("DisplayToRoles", String.Empty);
break;
}
if (!StopProcessing)
{
// Load the properties
RegionTitle = DataHelper.GetNotEmpty(GetValue("RegionTitle"), RegionTitle);
RegionType = CMSEditableRegionTypeEnumFunctions.GetRegionTypeEnum(DataHelper.GetNotEmpty(GetValue("RegionType"), CMSEditableRegionTypeEnumFunctions.GetRegionTypeString(RegionType)));
DialogWidth = DataHelper.GetNotZero(GetValue("DialogWidth"), DialogWidth);
DialogHeight = DataHelper.GetNotZero(GetValue("DialogHeight"), DialogHeight);
HTMLEditorCssStylesheet = ValidationHelper.GetString(GetValue("HtmlEditorCssStylesheet"), HTMLEditorCssStylesheet);
WordWrap = ValidationHelper.GetBoolean(GetValue("WordWrap"), WordWrap);
MinLength = DataHelper.GetNotZero(GetValue("MinLength"), MinLength);
MaxLength = DataHelper.GetNotZero(GetValue("MaxLength"), MaxLength);
HtmlAreaToolbar = DataHelper.GetNotEmpty(GetValue("HtmlAreaToolbar"), HtmlAreaToolbar);
HtmlAreaToolbarLocation = DataHelper.GetNotEmpty(GetValue("HtmlAreaToolbarLocation"), HtmlAreaToolbarLocation);
}
}
///
/// Overridden CreateChildControls method.
///
protected override void CreateChildControls()
{
SetupControl();
Controls.Clear();
base.CreateChildControls();
if (!StopProcessing)
{
if (!CMSAbstractEditableControl.RequestEditViewMode(ViewMode, ContentID))
{
ViewMode = ViewModeEnum.Preview;
}
// Create controls by actual page mode
switch (ViewMode)
{
case ViewModeEnum.Edit:
case ViewModeEnum.EditDisabled:
// Main editor panel
pnlEditor = new Panel();
pnlEditor.ID = "pnlEditor";
pnlEditor.CssClass = "EditableTextEdit EditableText_" + ContentID;
Controls.Add(pnlEditor);
// Title label
lblTitle = new Label();
lblTitle.EnableViewState = false;
lblTitle.CssClass = "EditableTextTitle";
pnlEditor.Controls.Add(lblTitle);
// Error label
lblError = new Label();
lblError.EnableViewState = false;
lblError.CssClass = "EditableTextError";
pnlEditor.Controls.Add(lblError);
// Display the region control based on the region type
switch (RegionType)
{
case CMSEditableRegionTypeEnum.HtmlEditor:
// HTML Editor
htmlValue = new CMSHtmlEditor();
htmlValue.IsLiveSite = false;
htmlValue.ID = "htmlValue";
htmlValue.AutoDetectLanguage = false;
htmlValue.DefaultLanguage = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
// Set direction
htmlValue.Config["ContentsLangDirection"] = "ltr";
if (CultureHelper.IsPreferredCultureRTL())
{
htmlValue.Config["ContentsLangDirection"] = "rtl";
}
// Set the language
try
{
CultureInfo ci = new CultureInfo(DataHelper.GetNotEmpty(CMSContext.CurrentUser.PreferredUICultureCode, CMSContext.PreferredCultureCode));
htmlValue.DefaultLanguage = ci.TwoLetterISOLanguageName;
}
catch
{
}
htmlValue.AutoDetectLanguage = false;
htmlValue.Enabled = IsEnabled(ViewMode);
if (ViewMode == ViewModeEnum.EditDisabled)
{
pnlEditor.Controls.Add(new LiteralControl(""));
pnlEditor.Controls.Add((Control)htmlValue);
pnlEditor.Controls.Add(new LiteralControl("
"));
}
else
{
pnlEditor.Controls.Add((Control)htmlValue);
}
break;
case CMSEditableRegionTypeEnum.TextArea:
case CMSEditableRegionTypeEnum.TextBox:
// TextBox
txtValue = new TextBox();
txtValue.ID = "txtValue";
txtValue.CssClass = "EditableTextTextBox";
txtValue.Enabled = IsEnabled(ViewMode);
pnlEditor.Controls.Add(txtValue);
break;
}
break;
default:
// Display content in non editing modes
ltlContent = new Literal();
ltlContent.ID = "ltlContent";
ltlContent.EnableViewState = false;
Controls.Add(ltlContent);
break;
}
}
}
///
/// Returns the value of the given web part property property.
///
/// Property name
public override object GetValue(string propertyName)
{
if (DataControl != null)
{
return DataControl.GetValue(propertyName);
}
return base.GetValue(propertyName);
}
///
/// Sets the property value of the control, setting the value affects only local property value.
///
/// Property name to set
/// New property value
public override void SetValue(string propertyName, object value)
{
if (DataControl != null)
{
DataControl.SetValue(propertyName, value);
}
base.SetValue(propertyName, value);
}
#endregion
#region "Private methods"
///
/// Indicates whether this control should be enabled and editing allowed.
///
/// The view mode.
private bool IsEnabled(ViewModeEnum viewMode)
{
return (viewMode == ViewModeEnum.Edit) && DocumentManager.AllowSave;
}
#endregion
}