protected override void EnsureChildControls()
        {
            base.EnsureChildControls();

            if (!ReadOnly)
            {
                var customContent = _inlineContentLogic.GetInlineContent(InlineContentName);

                //Is the any content that is waiting to be published with a newer date, if so add an extra class
                Control[] tempCollection = new Control[Controls.Count];
                Controls.CopyTo(tempCollection, 0);
                Controls.Clear();

                HtmlGenericControl c = new HtmlGenericControl("span");
                c.ID = "content";

                c.Attributes.Add("class", "content-inline-editor");

                HtmlGenericControl ul = new HtmlGenericControl("ul");
                ul.ID = "items";
                ul.Attributes.Add("class", "content-inline-editor-buttons");

                c.Controls.Add(ul);

                //Add some button controls that are hidden
                _editItem = new HtmlGenericControl("li");
                _editItem.Attributes.Add("class", "edit");

                _editAnchor = new HtmlAnchor();
                _editAnchor.ID = "edit";
                _editAnchor.InnerHtml = "<span>Edit</span>";
                _editAnchor.HRef = "#";

                _editItem.Controls.Add(_editAnchor);
                ul.Controls.Add(_editItem);

                //Build the editor modal div
                _editor = new HtmlGenericControl("div");
                c.Controls.Add(_editor);
                _editor.Attributes.Add("style", "display:none");
                _editor.Attributes.Add("class", "fourroads-inline-content");
                _editor.ID = "editor";

                _editor.Controls.Add(new LiteralControl("<label>Default Content</Label>"));

                _editorContent = new HtmlEditorStringControl();
                _editorContent.ConfigurationData = _configurationDataBase;
                _editorContent.ContentTypeId = InlineContentPart.InlineContentContentTypeId;

                _editor.Controls.Add(_editorContent);

                _editorContent.Text = customContent != null ? customContent.Content ?? DefaultContent : DefaultContent;
                _editorContent.CssClass = "editor";
                _editorContent.ID = "editorcontent";

                _editor.Controls.Add(new LiteralControl("<label>Anonymous Content Override</Label>"));

                _editorAnonymousContent= new HtmlEditorStringControl();
                _editorAnonymousContent.ConfigurationData = _configurationDataBase;
                _editorAnonymousContent.ContentTypeId = InlineContentPart.InlineContentContentTypeId;

                _editor.Controls.Add(_editorAnonymousContent);

                _editorAnonymousContent.Text = customContent != null ? customContent.AnonymousContent ?? DefaultAnonymousContent : DefaultAnonymousContent;
                _editorAnonymousContent.CssClass = "editor";
                _editorAnonymousContent.ID = "editoranonymouscontent";

                HtmlGenericControl actions = new HtmlGenericControl("div");
                actions.Attributes.Add("style", "float:right");
                _editor.Controls.Add(actions);

                _cancelButton = new HtmlButton();
                _cancelButton.ID = "cancel";
                _cancelButton.Attributes.Add("class", "button cancel");
                _cancelButton.InnerText = "Cancel";
                actions.Controls.Add(_cancelButton);

                _updateButton = new HtmlButton();
                _updateButton.ID = "update";
                _updateButton.Attributes.Add("class", "button update");
                _updateButton.InnerText = "Update";

                actions.Controls.Add(_updateButton);

                _revertButton = new HtmlButton();
                _revertButton.ID = "revert";
                _revertButton.Attributes.Add("class", "button revert");
                _revertButton.InnerText = "Revert";

                actions.Controls.Add(_revertButton);

                Controls.Add(c);

                c.Controls.Add(new HtmlGenericControl("div") { InnerText = "click to edit" });

                foreach (Control control in tempCollection)
                {
                    c.Controls.Add(control);
                }
            }
        }
Exemplo n.º 2
0
        protected override void EnsureChildControls()
        {
            base.EnsureChildControls();

            if (!ReadOnly)
            {
                var customContent = _inlineContentLogic.GetInlineContent(InlineContentName);

                //Is the any content that is waiting to be published with a newer date, if so add an extra class
                Control[] tempCollection = new Control[Controls.Count];
                Controls.CopyTo(tempCollection, 0);
                Controls.Clear();

                HtmlGenericControl c = new HtmlGenericControl("span");
                c.ID = "content";

                c.Attributes.Add("class", "content-inline-editor");

                HtmlGenericControl ul = new HtmlGenericControl("ul");
                ul.ID = "items";
                ul.Attributes.Add("class", "content-inline-editor-buttons");

                c.Controls.Add(ul);

                //Add some button controls that are hidden
                _editItem = new HtmlGenericControl("li");
                _editItem.Attributes.Add("class", "edit");

                _editAnchor           = new HtmlAnchor();
                _editAnchor.ID        = "edit";
                _editAnchor.InnerHtml = "<span>Edit</span>";
                _editAnchor.HRef      = "#";

                _editItem.Controls.Add(_editAnchor);
                ul.Controls.Add(_editItem);

                //Build the editor modal div
                _editor = new HtmlGenericControl("div");
                c.Controls.Add(_editor);
                _editor.Attributes.Add("style", "display:none");
                _editor.Attributes.Add("class", "fourroads-inline-content");
                _editor.ID = "editor";

                _editor.Controls.Add(new LiteralControl("<label>Default Content</Label>"));

                _editorContent = new HtmlEditorStringControl();
                _editorContent.ConfigurationData = _configurationDataBase;
                _editorContent.ContentTypeId     = InlineContentPart.InlineContentContentTypeId;

                _editor.Controls.Add(_editorContent);

                _editorContent.Text     = customContent != null ? customContent.Content ?? DefaultContent : DefaultContent;
                _editorContent.CssClass = "editor";
                _editorContent.ID       = "editorcontent";

                _editor.Controls.Add(new LiteralControl("<label>Anonymous Content Override</Label>"));

                _editorAnonymousContent = new HtmlEditorStringControl();
                _editorAnonymousContent.ConfigurationData = _configurationDataBase;
                _editorAnonymousContent.ContentTypeId     = InlineContentPart.InlineContentContentTypeId;

                _editor.Controls.Add(_editorAnonymousContent);

                _editorAnonymousContent.Text     = customContent != null ? customContent.AnonymousContent ?? DefaultAnonymousContent : DefaultAnonymousContent;
                _editorAnonymousContent.CssClass = "editor";
                _editorAnonymousContent.ID       = "editoranonymouscontent";

                HtmlGenericControl actions = new HtmlGenericControl("div");
                actions.Attributes.Add("style", "float:right");
                _editor.Controls.Add(actions);

                _cancelButton    = new HtmlButton();
                _cancelButton.ID = "cancel";
                _cancelButton.Attributes.Add("class", "button cancel");
                _cancelButton.InnerText = "Cancel";
                actions.Controls.Add(_cancelButton);

                _updateButton    = new HtmlButton();
                _updateButton.ID = "update";
                _updateButton.Attributes.Add("class", "button update");
                _updateButton.InnerText = "Update";

                actions.Controls.Add(_updateButton);

                _revertButton    = new HtmlButton();
                _revertButton.ID = "revert";
                _revertButton.Attributes.Add("class", "button revert");
                _revertButton.InnerText = "Revert";

                actions.Controls.Add(_revertButton);

                Controls.Add(c);

                c.Controls.Add(new HtmlGenericControl("div")
                {
                    InnerText = "click to edit"
                });

                foreach (Control control in tempCollection)
                {
                    c.Controls.Add(control);
                }
            }
        }