Esempio n. 1
0
        private string PersistLayoutElementInternal(
            IList <IDictionary <string, string> > layoutData,
            TemplatedItemPart templatedItem,
            LayoutTemplatePart layout,
            IUpdateModel updater,
            string prefix)
        {
            var doc                 = XDocument.Parse("<data></data>");
            var layoutRoot          = GetDefinitions(layout, templatedItem.DataDocument);
            var elementDescriptions = layoutRoot.Elements().ToList();
            // Form field names are of the form
            // TemplatedItemData[element index][property index].Key
            // and TemplatedItemData[element index][property index].Value,
            // and get automatically bound to an IList<IDictionary<string, string>>
            // where the list is over the elements
            // and the dictionary is over the properties of that element.
            // Persist form values onto the XML description for the templated item,
            // walking the tree in the same order that the display was generated
            var docRoot = doc.Element("data");

            Debug.Assert(docRoot != null, "The document should always have a root called data.");
            var editors =
                GetLayoutElementEditors(
                    layoutRoot,
                    new XElement("data"), "").ToList();
            var context = _wca.GetContext().HttpContext;

            HtmlHelpers.ResetIndex(context, "LayoutEditorIndex");
            PersistLayoutElementPrivate(
                context, layoutData, elementDescriptions, docRoot, editors,
                updater, prefix);
            return(doc.ToString(SaveOptions.DisableFormatting));
        }
Esempio n. 2
0
 public void PersistLayoutElement(
     IList <IDictionary <string, string> > layoutData,
     TemplatedItemPart templatedItem,
     LayoutTemplatePart layout,
     IUpdateModel updater,
     string prefix)
 {
     templatedItem.Data = PersistLayoutElementInternal(layoutData, templatedItem, layout, updater, prefix);
 }
Esempio n. 3
0
        public IEnumerable <dynamic> GetLayoutElementDisplays(
            TemplatedItemPart templatedItem,
            LayoutTemplatePart layout,
            string displayType)
        {
            var contentItem = templatedItem.ContentItem;

            return(GetLayoutElementDisplays(
                       GetDefinitions(layout, templatedItem.DataDocument),
                       templatedItem.RootElement,
                       contentItem,
                       displayType));
        }
Esempio n. 4
0
        private static XElement GetDefinitions(LayoutTemplatePart layout, XDocument dataDocument)
        {
            if (layout != null)
            {
                return(layout.RootElement);
            }
            var firstElement = dataDocument == null ? null :
                               dataDocument.Root.Elements().FirstOrDefault();

            return(new XElement("layout", new XElement(
                                    firstElement == null ? "img" : firstElement.Name),
                                new XElement("link", new XAttribute("Title", "Caption"))));
        }
Esempio n. 5
0
        public IEnumerable <dynamic> GetLayoutElementEditors(TemplatedItemPart templatedItem, LayoutTemplatePart layout, string prefix)
        {
            var definitions = GetDefinitions(layout, templatedItem.DataDocument);

            return(GetLayoutElementEditors(definitions, templatedItem.RootElement, prefix));
        }