Exemple #1
0
    /// <summary>
    /// Overridden CreateChildControls method.
    /// </summary>
    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;
                pnlEditor.Attributes.Add("data-tracksavechanges", "true");
                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
                    Editor                       = new CMSHtmlEditor();
                    Editor.IsLiveSite            = false;
                    Editor.ID                    = "htmlValue";
                    Editor.AutoDetectLanguage    = false;
                    Editor.DefaultLanguage       = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
                    Editor.Title                 = Title;
                    Editor.UseInlineMode         = UseInlineMode;
                    Editor.ContentsLangDirection = CultureHelper.IsPreferredCultureRTL() ? LanguageDirection.RightToLeft : LanguageDirection.LeftToRight;

                    // Set the language
                    try
                    {
                        CultureInfo ci = CultureHelper.GetCultureInfo(DataHelper.GetNotEmpty(MembershipContext.AuthenticatedUser.PreferredUICultureCode, LocalizationContext.PreferredCultureCode));
                        Editor.DefaultLanguage = ci.TwoLetterISOLanguageName;
                    }
                    catch (ArgumentNullException)
                    {
                    }
                    catch (CultureNotFoundException)
                    {
                    }

                    Editor.AutoDetectLanguage = false;
                    Editor.Enabled            = IsEnabled(ViewMode);

                    if (ViewMode == ViewModeEnum.EditDisabled)
                    {
                        pnlEditor.Controls.Add(new LiteralControl("<div style=\"width: 98%\">"));
                        pnlEditor.Controls.Add(Editor);
                        pnlEditor.Controls.Add(new LiteralControl("</div>"));
                    }
                    else
                    {
                        pnlEditor.Controls.Add(Editor);
                    }
                    break;

                case CMSEditableRegionTypeEnum.TextArea:
                case CMSEditableRegionTypeEnum.TextBox:
                    // TextBox
                    txtValue          = new CMSTextBox();
                    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;
            }
        }
    }
    /// <summary>
    /// Overridden CreateChildControls method.
    /// </summary>
    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("<div style=\"width: 98%\">"));
                        pnlEditor.Controls.Add((Control)htmlValue);
                        pnlEditor.Controls.Add(new LiteralControl("</div>"));
                    }
                    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;
            }
        }
    }
Exemple #3
0
    /// <summary>
    /// Overridden CreateChildControls method.
    /// </summary>
    protected override void CreateChildControls()
    {
        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 = "EditableImageEdit EditableImage_" + ContentID;
                pnlEditor.Attributes.Add("data-tracksavechanges", "true");
                if (ImageWidth > 0)
                {
                    pnlEditor.Style.Add(HtmlTextWriterStyle.Width, ImageWidth.ToString() + "px;");
                }
                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);

                // Add image selector
                selPath                  = new ImageSelector(null, false);
                selPath.Culture          = MembershipContext.AuthenticatedUser.PreferredUICultureCode;
                selPath.EnableOpenInFull = false;
                selPath.ID               = "selPath";
                selPath.UseImagePath     = true;
                selPath.ImageCssClass    = ImageCssClass;
                selPath.ImageStyle       = ImageStyle;
                selPath.ShowTextBox      = DisplaySelectorTextBox;
                selPath.DefaultValue     = DefaultImage;
                selPath.AddCssClass("cms-bootstrap");

                // Dialog configuration
                selPath.DialogConfig.ResizeToHeight      = ResizeToHeight;
                selPath.DialogConfig.ResizeToWidth       = ResizeToWidth;
                selPath.DialogConfig.ResizeToMaxSideSize = ResizeToMaxSideSize;

                pnlEditor.Controls.Add(selPath);

                selPath.Enabled    = ViewMode.IsEdit();
                selPath.IsLiveSite = ViewMode.IsLiveSite();
            }
            break;

            default:
            {
                // Display content in non editing modes
                imgImage    = new Image();
                imgImage.ID = "imgImage";
                imgImage.GenerateEmptyAlternateText = true;
                if (ImageCssClass != "")
                {
                    imgImage.CssClass = ImageCssClass;
                }
                if (ImageStyle != "")
                {
                    imgImage.Attributes.Add("style", ImageStyle);
                }

                imgImage.AlternateText   = AlternateText;
                imgImage.ToolTip         = AlternateText;
                imgImage.EnableViewState = false;
                Controls.Add(imgImage);
            }
            break;
            }
        }
    }
Exemple #4
0
    /// <summary>
    /// Overridden CreateChildControls method.
    /// </summary>
    protected override void CreateChildControls()
    {
        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 = "EditableImageEdit EditableImage_" + ContentID;
                pnlEditor.Attributes.Add("data-tracksavechanges", "true");
                if (ImageWidth > 0)
                {
                    pnlEditor.Style.Add(HtmlTextWriterStyle.Width, ImageWidth.ToString() + "px;");
                }
                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);
            }
            break;

            default:
            {
                // Display content in non editing modes
                imgImage    = new Image();
                imgImage.ID = "imgImage";
                imgImage.GenerateEmptyAlternateText = true;
                if (ImageCssClass != "")
                {
                    imgImage.CssClass = ImageCssClass;
                }
                if (ImageStyle != "")
                {
                    imgImage.Attributes.Add("style", ImageStyle);
                }

                imgImage.AlternateText   = AlternateText;
                imgImage.ToolTip         = AlternateText;
                imgImage.EnableViewState = false;
                Controls.Add(imgImage);
            }
            break;
            }
        }
    }