Ejemplo n.º 1
0
    /// <summary>
    /// Performs additional actions for the media selector.
    /// </summary>
    /// <param name="url">Base item URL</param>
    private string EnsureMediaSelector(string url)
    {
        if (ShowSizeControls)
        {
            url = CMSDialogHelper.UpdateUrl(widthHeightElem.Width, widthHeightElem.Height, DefaultWidth, DefaultHeight, url, SourceType, true);
        }

        return(EnsureExtension(txtUrl.Text, url));
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Performs additional actions for the media selector.
    /// </summary>
    /// <param name="url">Base item URL</param>
    private string EnsureMediaSelector(string url)
    {
        if (this.ShowSizeControls)
        {
            url = CMSDialogHelper.UpdateUrl(this.widthHeightElem.Width, this.widthHeightElem.Height, 0, 0, url, this.SourceType, true);
        }

        return(EnsureExtension(this.txtUrl.Text, url));
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Returns URL updated according specified properties.
    /// </summary>
    /// <param name="height">Height of the item</param>
    /// <param name="width">Width of the item</param>
    /// <param name="url">URL to update</param>
    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 and direct path to the filesystem is not used
        bool forceSizeToUrl = (IsMediaSelector && ShowSizeControls);

        return(CMSDialogHelper.UpdateUrl(width, height, DefaultWidth, DefaultHeight, url, SourceType, forceSizeToUrl));
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Returns URL updated according specified properties.
    /// </summary>
    /// <param name="height">Height of the item</param>
    /// <param name="width">Width of the item</param>
    /// <param name="url">URL to update</param>
    private string UpdateUrl(int width, int height, string url)
    {
        // WIDTH & HEIGHT isn't required in URL
        if (((this.Config.OutputFormat == OutputFormatEnum.URL) && !this.CurrentIsImage) && !(this.IsMediaSelector && this.ShowSizeControls))
        {
            return(url);
        }

        // Media selector always put dimensions in the URL when size selector is visible
        bool forceSizeToUrl = (this.IsMediaSelector && this.ShowSizeControls);

        return(CMSDialogHelper.UpdateUrl(width, height, this.DefaultWidth, this.DefaultHeight, url, this.SourceType, forceSizeToUrl));
    }
Ejemplo n.º 5
0
 /// <summary>
 /// Returns URL updated according specified properties.
 /// </summary>
 /// <param name="height">Height of the item</param>
 /// <param name="width">Width of the item</param>
 /// <param name="url">URL to update</param>
 private string UpdateUrl(int width, int height, string url)
 {
     return(CMSDialogHelper.UpdateUrl(width, height, DefaultWidth, DefaultHeight, url, SourceType));
 }
Ejemplo n.º 6
0
    /// <summary>
    /// Loads the properties into control.
    /// </summary>
    /// <param name="properties">Collection with properties</param>
    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);
            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);

                    // Restore current dimensions from URL if present
                    widthHeightElem.Width  = ValidationHelper.GetInteger(URLHelper.GetUrlParameter(url, "width"), DefaultWidth);
                    widthHeightElem.Height = ValidationHelper.GetInteger(URLHelper.GetUrlParameter(url, "height"), DefaultHeight);
                }

                // If media selector - insert dimensions to the URL
                if (IsMediaSelector && ShowSizeControls)
                {
                    url = CMSDialogHelper.UpdateUrl(widthHeightElem.Width, widthHeightElem.Height, CurrentIsImage ? DefaultWidth : 0, CurrentIsImage ? DefaultHeight : 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)
            {
                var aliasPath = SqlHelper.EscapeLikeText(properties[DialogParameters.DOC_NODEALIASPATH].ToString(""));
                if (!String.IsNullOrEmpty(aliasPath))
                {
                    txtSelectPath.Text = aliasPath;
                }

                if (IsSelectPath && !IsSelectSinglePath)
                {
                    if (NoSelectedYet)
                    {
                        chkItems.Checked = !SubItemsNotByDefault;
                        NoSelectedYet    = false;
                    }

                    if (chkItems.Checked)
                    {
                        txtSelectPath.Text = txtSelectPath.Text.TrimEnd('/') + "/%";
                    }
                }
            }

            #endregion
        }
    }
Ejemplo n.º 7
0
    /// <summary>
    /// Loads the properites into control.
    /// </summary>
    /// <param name="properties">Collection with properties</param>
    public override void LoadProperties(Hashtable properties)
    {
        if (properties != null)
        {
            // Display the properties
            this.pnlEmpty.Visible = false;
            this.pnlTabs.CssClass = "Dialog_Tabs";

            #region "Image general tab"

            // Display size selector only if required or image
            string ext = ValidationHelper.GetString(properties[DialogParameters.URL_EXT], "");
            this.CurrentIsImage   = ImageHelper.IsImage(ext);
            this.CurrentIsMedia   = !this.CurrentIsImage ? (MediaHelper.IsAudioVideo(ext) || MediaHelper.IsFlash(ext)) : false;
            this.ShowSizeControls = DisplaySizeSelector();

            if (tabImageGeneral.Visible)
            {
                string url = HttpUtility.HtmlDecode(ValidationHelper.GetString(properties[DialogParameters.URL_URL], ""));
                if (url != "")
                {
                    this.OriginalUrl = url;
                }

                if ((this.Config.SelectableContent == SelectableContentEnum.OnlyMedia) || this.IsMediaSelector)
                {
                    url = URLHelper.UpdateParameterInUrl(url, "ext", "." + ext.TrimStart('.'));
                }

                if (this.CurrentIsImage)
                {
                    int width  = ValidationHelper.GetInteger(properties[DialogParameters.IMG_WIDTH], 0);
                    int height = ValidationHelper.GetInteger(properties[DialogParameters.IMG_HEIGHT], 0);

                    this.DefaultWidth  = ValidationHelper.GetInteger(properties[DialogParameters.IMG_ORIGINALWIDTH], 0);
                    this.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 = this.DefaultWidth;
                        }
                    }
                    if (height == 0)
                    {
                        height = ValidationHelper.GetInteger(URLHelper.GetUrlParameter(url, "height"), 0);
                        if (height == 0)
                        {
                            height = this.DefaultHeight;
                        }
                    }

                    this.widthHeightElem.Width  = width;
                    this.widthHeightElem.Height = height;

                    ViewState[DialogParameters.IMG_SIZETOURL] = ValidationHelper.GetBoolean(properties[DialogParameters.IMG_SIZETOURL], false);
                }
                else
                {
                    this.DefaultWidth  = 300;
                    this.DefaultHeight = GetDefaultAVHeight(ext);

                    this.widthHeightElem.Width  = this.DefaultWidth;
                    this.widthHeightElem.Height = this.DefaultHeight;
                }

                // If media selector - insert dimensions to the URL
                if (this.IsMediaSelector && this.ShowSizeControls)
                {
                    url = CMSDialogHelper.UpdateUrl(this.widthHeightElem.Width, this.widthHeightElem.Height, 0, 0, url, this.SourceType, true);
                }
                this.txtUrl.Text = url;

                // Initialize media file URLs
                if (this.SourceType == MediaSourceEnum.MediaLibraries)
                {
                    this.OriginalUrl  = (string.IsNullOrEmpty(this.OriginalUrl) ? ValidationHelper.GetString(properties[DialogParameters.URL_DIRECT], "") : this.OriginalUrl);
                    this.PermanentUrl = (string.IsNullOrEmpty(this.PermanentUrl) ? ValidationHelper.GetString(properties[DialogParameters.URL_PERMANENT], "") : this.PermanentUrl);
                }
                else
                {
                    this.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], "");
            this.EditorClientID = ValidationHelper.GetString(properties[DialogParameters.EDITOR_CLIENTID], "");

            #endregion

            #region "Select path & Relationship items"

            if (this.IsRelationship || this.IsSelectPath)
            {
                this.txtSelectPath.Text = ValidationHelper.GetString(properties[DialogParameters.DOC_NODEALIASPATH], "");

                if (this.chkItems.Visible)
                {
                    if (this.NoSelectedYet)
                    {
                        this.chkItems.Checked = true;
                        this.NoSelectedYet    = false;
                    }

                    if (this.chkItems.Checked)
                    {
                        this.txtSelectPath.Text = this.txtSelectPath.Text.TrimEnd('/') + "/%";
                    }
                }
            }

            #endregion
        }
    }