/// <summary>
    /// Gets the edited object.
    /// </summary>
    private object GetEditedObject()
    {
        object editedObject = null;

        if (PageTemplate != null)
        {
            int newSharedLayoutId = QueryHelper.GetInteger("newshared", -1);
            int oldSharedLayoutId = QueryHelper.GetInteger("oldshared", -1);

            // Default state - no radio buttons used
            if ((newSharedLayoutId == -1) && (oldSharedLayoutId == -1))
            {
                editedObject = PageTemplate;
            }
            else
            {
                // If new shared layout is set, than it should be used as edited object
                // This happens when switched from custom to a shared layout
                if (newSharedLayoutId > 0)
                {
                    // Standard page layout
                    editedObject = LayoutInfoProvider.GetLayoutInfo(newSharedLayoutId);
                }
                // This means user switched from shared layout to custom
                else
                {
                    var layout = LayoutInfoProvider.GetLayoutInfo(oldSharedLayoutId);

                    // We have to work with the clone, because we need to change the data of the object
                    // (copy from shared layout)
                    var pageTemplateClone = PageTemplate.Clone();

                    if (layout != null)
                    {
                        // Delete the shared layout
                        pageTemplateClone.LayoutID = 0;

                        // Copy values
                        pageTemplateClone.PageTemplateLayout     = layout.LayoutCode;
                        pageTemplateClone.PageTemplateCSS        = layout.LayoutCSS;
                        pageTemplateClone.PageTemplateLayoutType = layout.LayoutType;
                    }

                    editedObject = pageTemplateClone;
                }
            }
        }
        // Load the layout  object
        else
        {
            var layoutId = QueryHelper.GetInteger("layoutid", 0);
            if (layoutId > 0)
            {
                editedObject = LayoutInfoProvider.GetLayoutInfo(layoutId);
            }
        }

        return(editedObject);
    }
Exemplo n.º 2
0
        public void TestClone1()
        {
            var template = new PageTemplate();
            var clone    = template.Clone();

            clone.Should().NotBeNull();
            clone.Should().NotBeSameAs(template);
            clone.Layout.Should().BeNull();
            clone.Widgets.Should().BeEmpty();
        }
Exemplo n.º 3
0
        public void TestClone2()
        {
            var template = new PageTemplate();

            template.Layout = new HorizontalWidgetLayoutTemplate();

            var clone = template.Clone();

            clone.Should().NotBeNull();
            clone.Should().NotBeSameAs(template);
            clone.Layout.Should().NotBeNull();
            clone.Layout.Should().BeOfType <HorizontalWidgetLayoutTemplate>();
            clone.Layout.Should().NotBeSameAs(template.Layout);
            clone.Widgets.Should().BeEmpty();
        }
Exemplo n.º 4
0
        public void TestClone3()
        {
            var template = new PageTemplate();
            var widget   = new WidgetTemplate();

            template.Add(widget);

            var clone = template.Clone();

            clone.Should().NotBeNull();
            clone.Should().NotBeSameAs(template);
            clone.Layout.Should().BeNull();
            clone.Widgets.Should().HaveCount(1);
            clone.Widgets.ElementAt(0).Should().NotBeNull();
            clone.Widgets.ElementAt(0).Should().NotBeSameAs(widget);
        }