Exemple #1
0
        public Entities.Page GetPage(Entities.Page root, string value)
        {
            var component = new PageComponent(Context);
            var content   = new ContentComponent(Context);
            var page      = component.GetPage(root, value);

            page.Contents = content.GetPageContent(page);

            return(page);
        }
Exemple #2
0
        public List <ContentModel> GetContent(string url)
        {
            var contentComponent = new ContentComponent(Context);
            var pageService      = new PageService(Context);
            var page             = pageService.GetPage(Context.Root, url);
            var content          = contentComponent.GetPageContent(page);

            var contentModels = content.Select(x => ContentModel(x)).ToList();

            return(contentModels);
        }
        public Entities.Site GetSite()
        {
            var component        = new SiteComponent(Context);
            var contentComponent = new ContentComponent(Context);
            var site             = component.GetSite();

            var contents = contentComponent.GetSiteContent(site);

            site.Contents = contents;

            return(site);
        }
        private void AddDefaultContent(Entities.Page page)
        {
            var pageDefinitionStore = new PageDefinitionStore(Context.FileSystem);
            var contentComponent    = new ContentComponent(Context);
            var definition          = pageDefinitionStore.FindAll(x => x.Name == page.Template).FirstOrDefault();

            if (definition == null)
            {
                definition = CreateDefinition(pageDefinitionStore, page.Template);
            }

            foreach (var content in definition.Items)
            {
                contentComponent.SaveContentTree(page, content, null);
            }
        }
Exemple #5
0
        public static List <ContentComponent> GetContentsFromFeed(SyndicationFeed feed)
        {
            //TODO: The code to extract the content is a bit ugly due to the handling of extensions.

            List <ContentComponent> components = new List <ContentComponent>();

            foreach (SyndicationItem item in feed.Items)
            {
                ContentComponent       cc = new ContentComponent();
                TextSyndicationContent content;

                cc.Title = item.Title.Text;

                if (null != item.Content)
                {
                    content = (TextSyndicationContent)item.Content;
                }
                else
                {
                    string contentString = "";

                    foreach (string encodedContent in (item.ElementExtensions.ReadElementExtensions <string>("encoded", "http://purl.org/rss/1.0/modules/content/")))
                    {
                        contentString = encodedContent;
                    }

                    if (contentString != "")
                    {
                        content = new TextSyndicationContent(contentString);
                    }
                    else
                    {
                        content = (TextSyndicationContent)item.Summary;
                    }
                }

                cc.Content       = "<h2>" + item.Title.Text + "</h2>";
                cc.Content      += content.Text;
                cc.MediaMimeType = "application/xhtml+xml";
                cc.ItemId        = "part-" + components.Count.ToString();
                cc.UriString     = cc.ItemId + ".html";

                components.Add(cc);
            }

            return(components);
        }
Exemple #6
0
        public void AddToPage(string url, List <ContentModel> model)
        {
            var contentComponent = new ContentComponent(Context);
            var pageComponent    = new PageService(Context);

            var page = pageComponent.GetPage(Context.Root, url);

            if (page == null)
            {
                throw new Exception("Page does not exist!");
            }

            contentComponent.DeleteContent(page);

            foreach (var content in model)
            {
                var contentTree = GetContentTreeFromModel(content);

                contentComponent.AddContent(page, contentTree);
            }
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue,
                                        JsonSerializer serializer)
        {
            var   target = serializer.Deserialize <Newtonsoft.Json.Linq.JObject>(reader);
            IItem item   = null;

            if (target != null)
            {
                if (typeof(IContentComponent) == objectType)
                {
                    var contentComponent = new ContentComponent();
                    serializer.Populate(target.CreateReader(), contentComponent);
                    return(contentComponent);
                }

                try
                {
                    var     expConverter = new ExpandoObjectConverter();
                    dynamic obj          = JsonConvert.DeserializeObject <ExpandoObject>(target.ToString(), expConverter);

                    int itemType = (int)obj.itemType;
                    switch (itemType)
                    {
                    case (int)ItemType.Publication:
                        item = new Publication();
                        break;

                    case (int)ItemType.Component:
                        item = new Component();
                        break;

                    case (int)ItemType.Category:
                    case (int)ItemType.Keyword:
                        item = new Keyword();
                        break;

                    case (int)ItemType.Page:
                        item = new Page();
                        break;

                    case (int)ItemType.StructureGroup:
                        item = new StructureGroup();
                        break;

                    case (int)ItemType.ComponentTemplate:
                        item = new Template();
                        break;

                    case 2048:     // ?? huh?
                        item = new ComponentPresentation();
                        break;
                    }
                }
                catch (Exception)
                {
                    return(null);
                }
            }
            if (item == null)
            {
                return(null);
            }
            serializer.Populate(target.CreateReader(), item);
            return(item);
        }
Exemple #8
0
        public void AddContentToPage(Entities.Page page, Entities.Content content)
        {
            var component = new ContentComponent(Context);

            component.AddContent(page, content);
        }