using System;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CMS.ExtendedControls;
using CMS.GlobalHelper;
using CMS.UIControls;
using CMS.SettingsProvider;
public partial class CMSModules_Content_Controls_Dialogs_Properties_URLProperties : ItemProperties
{
#region "Private properties"
///
/// Indicates whether the properties are used for path selector form control.
///
private bool IsSelectPath
{
get
{
return (Config.CustomFormatCode == "selectpath");
}
}
///
/// Indicates whether the properties are used for single path selector form control.
///
private bool IsSelectSinglePath
{
get
{
return (QueryHelper.GetString("selectionmode", "") == "single") && IsSelectPath;
}
}
///
/// Indicates whether the properties are used for select relationship path.
///
private bool IsRelationship
{
get
{
return (Config.CustomFormatCode == "relationship");
}
}
///
/// Gets or sets the original URL (the one which come when properties are loaded).
///
private string OriginalUrl
{
get
{
return ValidationHelper.GetString(ViewState["OriginalUrl"], "");
}
set
{
ViewState["OriginalUrl"] = value;
}
}
///
/// Gets or sets the permanent URL.
///
private string PermanentUrl
{
get
{
return ValidationHelper.GetString(ViewState["PermanentUrl"], "");
}
set
{
ViewState["PermanentUrl"] = value;
}
}
///
/// Gets or sets the value which determines whether to show or hide the controls in WidthHeightSelector.
///
private bool ShowSizeControls
{
get
{
return ValidationHelper.GetBoolean(ViewState["ShowSizeControls"], false);
}
set
{
ViewState["ShowSizeControls"] = value;
}
}
///
/// Indicates whether the properties were not loaded yet.
///
private bool NoSelectedYet
{
get
{
return ValidationHelper.GetBoolean(ViewState["NoSelectedYet"], true);
}
set
{
ViewState["NoSelectedYet"] = value;
}
}
///
/// Indicates whether by default the chk box "Only subitems" is checked or not.
///
private bool SubItemsNotByDefault
{
get
{
return QueryHelper.GetBoolean("SubItemsNotByDefault", false);
}
}
///
/// Returns the default width of the width height selector.
///
private int DefaultWidth
{
get
{
return ValidationHelper.GetInteger(ViewState["DefaultHeight"], 0);
}
set
{
ViewState["DefaultHeight"] = value;
}
}
///
/// Returns the default height of the width height selector.
///
private int DefaultHeight
{
get
{
return ValidationHelper.GetInteger(ViewState["DefaultWidth"], 0);
}
set
{
ViewState["DefaultWidth"] = value;
}
}
///
/// Indicates whether the current item is image.
///
private bool CurrentIsImage
{
get
{
return ValidationHelper.GetBoolean(ViewState["CurrentIsImage"], false);
}
set
{
ViewState["CurrentIsImage"] = value;
}
}
///
/// Indicates whether the current item is audio/video/flash.
///
private bool CurrentIsMedia
{
get
{
return ValidationHelper.GetBoolean(ViewState["CurrentIsMedia"], false);
}
set
{
ViewState["CurrentIsMedia"] = value;
}
}
///
/// Indicates whether the properties are displayed for the media selector.
///
private bool IsMediaSelector
{
get
{
return ((Config.OutputFormat == OutputFormatEnum.URL) && (Config.SelectableContent == SelectableContentEnum.AllFiles));
}
}
#endregion
#region "Public properties"
///
/// Gets or sets the value which determines whether the control is displayed on the Web tab.
///
public bool IsWeb
{
get
{
return ValidationHelper.GetBoolean(ViewState["IsWeb"], false);
}
set
{
ViewState["IsWeb"] = value;
}
}
#endregion
#region "Page events"
protected void Page_Load(object sender, EventArgs e)
{
if (!StopProcessing)
{
if (Config != null)
{
if ((Config.OutputFormat == OutputFormatEnum.URL) && IsWeb)
{
plcPropContent.Visible = false;
}
if ((Config.OutputFormat == OutputFormatEnum.URL) && (Config.SelectableContent == SelectableContentEnum.AllContent))
{
DisplaySizeSelector(false);
pnlImagePreview.CssClass = "DialogPropertiesPreview DialogPropertiesPreviewFull";
pnlMediaPreview.CssClass = "DialogPropertiesPreview DialogPropertiesPreviewFull";
}
}
// Refresh button
imgRefresh.ImageUrl = GetImageUrl("Design/Controls/Dialogs/refresh.png");
imgRefresh.ToolTip = GetString("dialogs.web.refresh");
tabImageGeneral.HeaderText = GetString("general.general");
string postBackRef = ControlsHelper.GetPostBackEventReference(btnHidden, "");
string postBackKeyDownRef = "var keynum;if(window.event){keynum = event.keyCode;}else if(event.which){keynum = event.which;}if(keynum == 13){" + postBackRef + "; return false;}";
string postBackRefTxt = ControlsHelper.GetPostBackEventReference(btnTxtHidden, "");
string postBackKeyDownTxtRef = "var keynum;if(window.event){keynum = event.keyCode;}else if(event.which){keynum = event.which;}if(keynum == 13){" + postBackRefTxt + "; return false;}";
// Assign javascript change event to all fields (to refresh the preview)
widthHeightElem.TextBoxesClass = "ShortTextBox";
widthHeightElem.HeightTextBox.Attributes["onchange"] = postBackRef;
widthHeightElem.HeightTextBox.Attributes["onkeydown"] = postBackKeyDownRef;
widthHeightElem.WidthTextBox.Attributes["onchange"] = postBackRef;
widthHeightElem.WidthTextBox.Attributes["onkeydown"] = postBackKeyDownRef;
txtUrl.Attributes["onchange"] = postBackRefTxt;
txtUrl.Attributes["onkeydown"] = postBackKeyDownRef;
btnHidden.Click += new EventHandler(btnHidden_Click);
btnTxtHidden.Click += new EventHandler(btnTxtHidden_Click);
btnHiddenSize.Click += new EventHandler(btnHiddenSize_Click);
if (IsSelectPath || IsRelationship)
{
plcUrl.Visible = false;
plcSizeSelectorHeight.Visible = false;
plcPreviewArea.Visible = false;
plcSelectPath.Visible = true;
string resString = (IsSelectPath ? "dialogs.web.selectedpath" : "dialogs.web.selecteddoc");
lblSelectPah.ResourceString = resString;
lblSelectPah.DisplayColon = true;
}
if (IsSelectPath && !IsSelectSinglePath)
{
plcIncludeSubitems.Visible = true;
chkItems.Attributes.Add("onclick", "chkItemsChecked_Changed(this.checked);");
}
LoadPreview();
}
}
protected void Page_PreRender(object sender, EventArgs e)
{
if (!URLHelper.IsPostback())
{
widthHeightElem.Locked = true;
ScriptHelper.RegisterWOpenerScript(Page);
// Set alternate text
string scriptAlt = @"if (wopener) {
var hdnAlt = wopener.document.getElementById('" + QueryHelper.GetString(DialogParameters.IMG_ALT_CLIENTID, "") + @"');
var txt = document.getElementById('" + txtAlt.ClientID + @"');
if ((hdnAlt != null) && (txt != null)) {
txt.value = hdnAlt.value;
}
}";
ScriptHelper.RegisterStartupScript(Page, typeof(Page), "DialogAltImageScript", ScriptHelper.GetScript(scriptAlt));
}
widthHeightElem.CustomRefreshCode = ControlsHelper.GetPostBackEventReference(btnHiddenSize, "") + "; return false;";
widthHeightElem.ShowActions = ShowSizeControls;
bool isLink = ((Config.OutputFormat == OutputFormatEnum.BBLink) || (Config.OutputFormat == OutputFormatEnum.HTMLLink) ||
((Config.OutputFormat == OutputFormatEnum.URL) && ((Config.SelectableContent == SelectableContentEnum.AllContent) || (Config.SelectableContent == SelectableContentEnum.OnlyFlash))));
DisplaySizeSelector(ShowSizeControls && !isLink);
lblEmpty.Text = NoSelectionText;
// If size and alternate text input should not be displayed, hide them
if (Config.UseSimpleURLProperties)
{
HideComplexURLProperties();
}
}
///
/// Update parameters and preview from URL textbox.
///
private void UpdateFromUrl()
{
int width = ValidationHelper.GetInteger(URLHelper.GetUrlParameter(txtUrl.Text, "width"), 0);
int height = ValidationHelper.GetInteger(URLHelper.GetUrlParameter(txtUrl.Text, "height"), 0);
// Update WIDTH and HEIGHT information according URL
if (width > 0)
{
widthHeightElem.Width = width;
}
if (height > 0)
{
widthHeightElem.Height = height;
}
LoadPreview();
}
protected void imgRefresh_Click(object sender, ImageClickEventArgs e)
{
UpdateFromUrl();
}
protected void btnTxtHidden_Click(object sender, EventArgs e)
{
UpdateFromUrl();
}
protected void btnHiddenSize_Click(object sender, EventArgs e)
{
widthHeightElem.Width = DefaultWidth;
widthHeightElem.Height = DefaultHeight;
// Remove width & height parameters from url
string url = URLHelper.RemoveParameterFromUrl(URLHelper.RemoveParameterFromUrl(OriginalUrl, "width"), "height");
// If media selector - insert dimensions to the URL
if (IsMediaSelector)
{
url = EnsureMediaSelector(url);
}
txtUrl.Text = url;
LoadPreview();
}
protected void btnHidden_Click(object sender, EventArgs e)
{
// Update item URL
bool getPermanent = ((widthHeightElem.Width < DefaultWidth) ||
(widthHeightElem.Height < DefaultHeight)) &&
(SourceType == MediaSourceEnum.MediaLibraries);
string url = UpdateUrl(widthHeightElem.Width, widthHeightElem.Height, (getPermanent ? PermanentUrl : OriginalUrl));
// If media selector - insert dimensions to the URL
if (IsMediaSelector)
{
url = EnsureMediaSelector(url);
}
txtUrl.Text = url;
LoadPreview();
}
#endregion
#region "Private methods"
///
/// Returns URL updated according specified properties.
///
/// Height of the item
/// Width of the item
/// URL to update
private string UpdateUrl(int width, int height, string url)
{
// WIDTH & HEIGHT isn't required in URL
if (((Config.OutputFormat == OutputFormatEnum.URL) && !CurrentIsImage) && !(IsMediaSelector && ShowSizeControls))
{
return url;
}
// Media selector always put dimensions in the URL when size selector is visible
bool forceSizeToUrl = (IsMediaSelector && ShowSizeControls);
return CMSDialogHelper.UpdateUrl(width, height, DefaultWidth, DefaultHeight, url, SourceType, forceSizeToUrl);
}
///
/// Performs additional actions for the media selector.
///
/// Base item URL
private string EnsureMediaSelector(string url)
{
if (ShowSizeControls)
{
url = CMSDialogHelper.UpdateUrl(widthHeightElem.Width, widthHeightElem.Height, 0, 0, url, SourceType, true);
}
return EnsureExtension(txtUrl.Text, url);
}
///
/// Ensures that URL contains extension as required.
///
/// Original URL possibly containing extension
/// URL to ensure extension for
private string EnsureExtension(string refUrl, string updateUrl)
{
string ext = URLHelper.GetUrlParameter(refUrl, "ext");
if (!string.IsNullOrEmpty(ext))
{
updateUrl = URLHelper.UpdateParameterInUrl(updateUrl, "ext", ext);
}
return updateUrl;
}
///
/// Configures the preview control.
///
private void LoadPreview()
{
pnlImagePreview.Visible = CurrentIsImage;
pnlMediaPreview.Visible = (!CurrentIsImage && CurrentIsMedia);
if (CurrentIsImage)
{
string url = txtUrl.Text.Trim();
if (!string.IsNullOrEmpty(url))
{
url = URLHelper.UpdateParameterInUrl(url, "chset", Guid.NewGuid().ToString());
}
// Add latest version requirement for live site
if (IsLiveSite)
{
// Add requirement for latest version of files for current document
string newparams = "latestforhistoryid=" + HistoryID;
newparams += "&hash=" + ValidationHelper.GetHashString("h" + HistoryID);
url += "&" + newparams;
}
imagePreview.URL = url;
imagePreview.SizeToURL = ValidationHelper.GetBoolean(ViewState[DialogParameters.IMG_SIZETOURL], false);
imagePreview.Width = widthHeightElem.Width;
imagePreview.Height = widthHeightElem.Height;
}
else
{
string url = txtUrl.Text.Trim();
string ext = ValidationHelper.GetString(ViewState[DialogParameters.URL_EXT], "");
if (!String.IsNullOrEmpty(ext))
{
url = URLHelper.UpdateParameterInUrl(url, "ext", "." + ext.TrimStart('.'));
}
mediaPreview.Url = url;
if (CurrentIsMedia && ((widthHeightElem.Width == 0) || widthHeightElem.Height == 0))
{
widthHeightElem.Width = 300;
widthHeightElem.Height = GetDefaultAVHeight(ext);
}
if (MediaHelper.IsFlash(ext))
{
mediaPreview.AutoPlay = true;
}
else if (MediaHelper.IsAudioVideo(ext))
{
mediaPreview.AVControls = true;
}
mediaPreview.Width = widthHeightElem.Width;
mediaPreview.Height = widthHeightElem.Height;
}
// Ensure extension is at the end of URL
string urlExt = URLHelper.GetUrlParameter(txtUrl.Text, "ext");
if (!string.IsNullOrEmpty(urlExt))
{
txtUrl.Text = URLHelper.UpdateParameterInUrl(txtUrl.Text, "ext", urlExt);
}
SaveSession();
}
///
/// Save current properties into session.
///
private void SaveSession()
{
Hashtable savedProperties = SessionHelper.GetValue("DialogSelectedParameters") as Hashtable;
if (savedProperties == null)
{
savedProperties = new Hashtable();
}
Hashtable properties = GetItemProperties();
foreach (DictionaryEntry entry in properties)
{
savedProperties[entry.Key] = entry.Value;
}
SessionHelper.SetValue("DialogSelectedParameters", savedProperties);
}
///
/// Show or hide size selector.
///
/// Indicates if size selector should be displayed
private void DisplaySizeSelector(bool display)
{
if (display)
{
plcSizeSelectorWidth.Visible = true;
plcSizeSelectorHeight.Visible = true;
previewTd.Attributes["rowspan"] = "3";
previewTd.Attributes["colspan"] = "1";
}
else
{
plcSizeSelectorWidth.Visible = false;
plcSizeSelectorHeight.Visible = false;
previewTd.Attributes["rowspan"] = "1";
previewTd.Attributes["colspan"] = "3";
}
}
///
/// Hides complex URL Properties (size and Alternate text) and handles other necessary changes (setting colspans, etc.).
///
private void HideComplexURLProperties()
{
DisplaySizeSelector(false);
plcAltTextValue.Visible = false;
lblAlt.Visible = false;
previewTd.ColSpan = 2;
}
#endregion
#region "Overridden methods"
public override void LoadSelectedItems(MediaItem item, Hashtable properties)
{
if (properties == null)
{
properties = new Hashtable();
}
string url = item.Url;
OriginalUrl = item.Url;
PermanentUrl = item.PermanentUrl;
HistoryID = item.HistoryID;
switch (item.MediaType)
{
case MediaTypeEnum.Image:
properties[DialogParameters.IMG_WIDTH] = item.Width;
properties[DialogParameters.IMG_HEIGHT] = item.Height;
properties[DialogParameters.IMG_ORIGINALWIDTH] = item.Width;
properties[DialogParameters.IMG_ORIGINALHEIGHT] = item.Height;
break;
case MediaTypeEnum.AudioVideo:
properties[DialogParameters.AV_WIDTH] = 400;
properties[DialogParameters.AV_HEIGHT] = 300;
properties[DialogParameters.AV_CONTROLS] = true;
break;
case MediaTypeEnum.Flash:
properties[DialogParameters.FLASH_WIDTH] = item.Width;
properties[DialogParameters.FLASH_HEIGHT] = item.Height;
properties[DialogParameters.FLASH_AUTOPLAY] = true;
url = URLHelper.UpdateParameterInUrl(url, "ext", "." + item.Extension.TrimStart('.'));
break;
case MediaTypeEnum.Unknown:
default:
break;
}
ViewState[DialogParameters.URL_EXT] = item.Extension;
properties[DialogParameters.URL_EXT] = item.Extension;
properties[DialogParameters.URL_URL] = url;
ViewState[DialogParameters.DOC_TARGETNODEID] = item.NodeID;
properties[DialogParameters.DOC_TARGETNODEID] = item.NodeID;
properties[DialogParameters.DOC_NODEALIASPATH] = item.AliasPath;
LoadProperties(properties);
if (tabImageGeneral.Visible)
{
LoadPreview();
}
}
///
/// Loads the properites into control.
///
/// Collection with properties
public override void LoadItemProperties(Hashtable properties)
{
LoadProperties(properties);
if (tabImageGeneral.Visible)
{
LoadPreview();
}
}
///
/// Loads the properites into control.
///
/// Collection with properties
public override void LoadProperties(Hashtable properties)
{
if (properties != null)
{
// Display the properties
pnlEmpty.Visible = false;
pnlTabs.CssClass = "Dialog_Tabs";
#region "Image general tab"
// Display size selector only if required or image
string ext = ValidationHelper.GetString(properties[DialogParameters.URL_EXT], "");
CurrentIsImage = ImageHelper.IsImage(ext);
CurrentIsMedia = !CurrentIsImage ? (MediaHelper.IsAudioVideo(ext) || MediaHelper.IsFlash(ext)) : false;
ShowSizeControls = DisplaySizeSelector();
if (tabImageGeneral.Visible)
{
string url = HttpUtility.HtmlDecode(ValidationHelper.GetString(properties[DialogParameters.URL_URL], ""));
if (url != "")
{
OriginalUrl = url;
}
if ((Config.SelectableContent == SelectableContentEnum.OnlyMedia) || IsMediaSelector)
{
url = URLHelper.UpdateParameterInUrl(url, "ext", "." + ext.TrimStart('.'));
}
if (CurrentIsImage)
{
int width = ValidationHelper.GetInteger(properties[DialogParameters.IMG_WIDTH], 0);
int height = ValidationHelper.GetInteger(properties[DialogParameters.IMG_HEIGHT], 0);
DefaultWidth = ValidationHelper.GetInteger(properties[DialogParameters.IMG_ORIGINALWIDTH], 0);
DefaultHeight = ValidationHelper.GetInteger(properties[DialogParameters.IMG_ORIGINALHEIGHT], 0);
// Ensure WIDTH & HEIGHT dimensions
if (width == 0)
{
width = ValidationHelper.GetInteger(URLHelper.GetUrlParameter(url, "width"), 0);
if (width == 0)
{
width = DefaultWidth;
}
}
if (height == 0)
{
height = ValidationHelper.GetInteger(URLHelper.GetUrlParameter(url, "height"), 0);
if (height == 0)
{
height = DefaultHeight;
}
}
widthHeightElem.Width = width;
widthHeightElem.Height = height;
ViewState[DialogParameters.IMG_SIZETOURL] = ValidationHelper.GetBoolean(properties[DialogParameters.IMG_SIZETOURL], false);
}
else
{
DefaultWidth = 300;
DefaultHeight = GetDefaultAVHeight(ext);
widthHeightElem.Width = DefaultWidth;
widthHeightElem.Height = DefaultHeight;
}
// If media selector - insert dimensions to the URL
if (IsMediaSelector && ShowSizeControls)
{
url = CMSDialogHelper.UpdateUrl(widthHeightElem.Width, widthHeightElem.Height, 0, 0, url, SourceType, true);
}
txtUrl.Text = url;
// Initialize media file URLs
if (SourceType == MediaSourceEnum.MediaLibraries)
{
OriginalUrl = (string.IsNullOrEmpty(OriginalUrl) ? ValidationHelper.GetString(properties[DialogParameters.URL_DIRECT], "") : OriginalUrl);
PermanentUrl = (string.IsNullOrEmpty(PermanentUrl) ? ValidationHelper.GetString(properties[DialogParameters.URL_PERMANENT], "") : PermanentUrl);
}
else
{
OriginalUrl = url;
}
}
#endregion
#region "General items"
ViewState[DialogParameters.URL_EXT] = (properties[DialogParameters.URL_EXT] != null ? ValidationHelper.GetString(properties[DialogParameters.URL_EXT], "") : ValidationHelper.GetString(properties[DialogParameters.IMG_EXT], ""));
ViewState[DialogParameters.URL_URL] = ValidationHelper.GetString(properties[DialogParameters.URL_URL], "");
EditorClientID = ValidationHelper.GetString(properties[DialogParameters.EDITOR_CLIENTID], "");
#endregion
#region "Select path & Relationship items"
if (IsRelationship || IsSelectPath)
{
txtSelectPath.Text = ValidationHelper.GetString(properties[DialogParameters.DOC_NODEALIASPATH], "");
if (IsSelectPath && !IsSelectSinglePath)
{
if (NoSelectedYet)
{
chkItems.Checked = !SubItemsNotByDefault;
NoSelectedYet = false;
}
if (chkItems.Checked)
{
txtSelectPath.Text = txtSelectPath.Text.TrimEnd('/') + "/%";
}
}
}
#endregion
}
}
///
/// Decides whether the size selector should be displayed.
///
/// Is current file image
/// Is current file media
private bool DisplaySizeSelector()
{
bool result = false;
// Start with media selector
result = result || (IsMediaSelector && (CurrentIsImage || CurrentIsMedia));
// Is image selector ?
result = result || ((Config.OutputFormat == OutputFormatEnum.URL) && (Config.SelectableContent == SelectableContentEnum.OnlyImages));
return result;
}
///
/// Returns default height for the A/V items.
///
/// Extension of the file
private int GetDefaultAVHeight(string ext)
{
// Audio default height = 45, video = 200
return (MediaHelper.IsAudio(ext) ? 45 : 200);
}
///
/// Returns all parameters of the selected item as name – value collection.
///
public override Hashtable GetItemProperties()
{
Hashtable retval = new Hashtable();
#region "Image general tab"
string ext = ValidationHelper.GetString(ViewState[DialogParameters.URL_EXT], "");
string url = ValidationHelper.GetString(ViewState[DialogParameters.URL_URL], "");
if (!(IsRelationship || IsSelectPath))
{
bool resolveUrl = !((Config.OutputFormat == OutputFormatEnum.URL) && (Config.SelectableContent == SelectableContentEnum.OnlyMedia));
// Exception for MediaSelector control (it can't be resolved)
url = (resolveUrl ? URLHelper.ResolveUrl(url) : url);
if (MediaHelper.IsFlash(ext))
{
retval[DialogParameters.FLASH_URL] = txtUrl.Text.Trim();
}
else if (MediaHelper.IsAudioVideo(ext))
{
retval[DialogParameters.AV_URL] = txtUrl.Text.Trim();
}
else if (tabImageGeneral.Visible)
{
string imgUrl = txtUrl.Text.Trim();
bool sizeToUrl = ValidationHelper.GetBoolean(ViewState[DialogParameters.IMG_SIZETOURL], false);
if ((widthHeightElem.Width != DefaultWidth) && sizeToUrl)
{
imgUrl = URLHelper.UpdateParameterInUrl(imgUrl, "width", widthHeightElem.Width.ToString());
}
if ((widthHeightElem.Height != DefaultHeight) && sizeToUrl)
{
imgUrl = URLHelper.UpdateParameterInUrl(imgUrl, "height", widthHeightElem.Height.ToString());
}
retval[DialogParameters.IMG_HEIGHT] = widthHeightElem.Height;
retval[DialogParameters.IMG_WIDTH] = widthHeightElem.Width;
retval[DialogParameters.IMG_URL] = (resolveUrl ? URLHelper.ResolveUrl(imgUrl) : imgUrl);
retval[DialogParameters.IMG_EXT] = ValidationHelper.GetString(ViewState[DialogParameters.URL_EXT], "");
retval[DialogParameters.IMG_SIZETOURL] = sizeToUrl;
retval[DialogParameters.IMG_ALT] = txtAlt.Text.Trim();
retval[DialogParameters.IMG_ALT_CLIENTID] = QueryHelper.GetString(DialogParameters.IMG_ALT_CLIENTID, String.Empty);
}
}
#endregion
#region "General items"
retval[DialogParameters.URL_EXT] = ext;
retval[DialogParameters.URL_URL] = url;
retval[DialogParameters.EDITOR_CLIENTID] = EditorClientID;
#endregion
#region "Select path & Relationship items"
if (IsRelationship || IsSelectPath)
{
string path = txtSelectPath.Text;
if (chkItems.Checked)
{
if (!path.EndsWithCSafe("/%"))
{
path = path.TrimEnd('/') + "/%";
}
}
else if (path.EndsWithCSafe("/%"))
{
path = path.Substring(0, path.Length - 2);
}
retval[DialogParameters.DOC_NODEALIASPATH] = path;
// Fill target node id only if single path selection is enabled or in relationship dialog
if (IsSelectSinglePath || IsRelationship)
{
retval[DialogParameters.DOC_TARGETNODEID] = ViewState[DialogParameters.DOC_TARGETNODEID];
}
}
#endregion
return retval;
}
///
/// Validates all the user input.
///
public override bool Validate()
{
string errorMessage = "";
if (!widthHeightElem.Validate())
{
errorMessage += " " + GetString("dialogs.image.invalidsize");
}
errorMessage = errorMessage.Trim();
if (errorMessage != "")
{
ScriptHelper.RegisterStartupScript(Page, typeof(Page), "ImagePropertiesError", ScriptHelper.GetAlertScript(errorMessage));
return false;
}
return true;
}
///
/// Clears the properties form.
///
public override void ClearProperties(bool hideProperties)
{
// Hide the properties
pnlEmpty.Visible = hideProperties;
pnlTabs.CssClass = (hideProperties ? "DialogElementHidden" : "Dialog_Tabs");
chkItems.Checked = false;
widthHeightElem.Height = 0;
widthHeightElem.Width = 0;
imagePreview.URL = "";
txtUrl.Text = "";
txtSelectPath.Text = "";
}
#endregion
}