public static Dynamic.Page BuildPage(TCM.Page tcmPage, Engine engine, BuildManager manager, int linkLevels, bool resolveWidthAndHeight)
        {
            Dynamic.Page p = new Dynamic.Page();
            p.Title        = tcmPage.Title;
            p.Id           = tcmPage.Id.ToString();
            p.Filename     = tcmPage.FileName;
            p.PageTemplate = manager.BuildPageTemplate(tcmPage.PageTemplate);
            p.Schema       = manager.BuildSchema(tcmPage.MetadataSchema);
            p.Metadata     = new Dynamic.SerializableDictionary <string, Dynamic.Field>();
            if (linkLevels > 0)
            {
                try {
                    if (tcmPage.Metadata != null)
                    {
                        var tcmMetadataFields = new Tridion.ContentManager.ContentManagement.Fields.ItemFields(tcmPage.Metadata, tcmPage.MetadataSchema);
                        p.Metadata = manager.BuildFields(tcmMetadataFields, linkLevels, resolveWidthAndHeight);
                    }
                } catch (ItemDoesNotExistException) {
                    // fail silently if there is no metadata schema
                }
            }

            p.ComponentPresentations = new List <Dynamic.ComponentPresentation>();
            foreach (TCM.ComponentPresentation cp in tcmPage.ComponentPresentations)
            {
                Dynamic.ComponentPresentation dynCp = manager.BuildComponentPresentation(cp, engine, linkLevels - 1, resolveWidthAndHeight);
                p.ComponentPresentations.Add(dynCp);
            }
            p.StructureGroup = manager.BuildOrganizationalItem((TCM.StructureGroup)tcmPage.OrganizationalItem);
            p.Publication    = manager.BuildPublication(tcmPage.ContextRepository);
            p.Categories     = manager.BuildCategories(tcmPage);

            return(p);
        }
Пример #2
0
        public static List <Dynamic.Category> BuildCategories(TComm.Page page, BuildManager manager)
        {
            // note that there might be multiple fields based on the same category, so we need to combine them
            // for that purpose we use a dictionary


            if (page.Metadata == null || page.MetadataSchema == null)
            {
                return(new List <Dynamic.Category>());
            }

            Dictionary <string, Dynamic.Category> categories = new Dictionary <string, Dynamic.Category>();


            // first, add categires from the metadata
            ItemFields tcmMetadataFields = new TCM.Fields.ItemFields(page.Metadata, page.MetadataSchema);

            addFromItemFields(tcmMetadataFields, categories, manager);

            // finally, create a List from the Dictionary and return it
            List <Dynamic.Category> categoryList = new List <Dynamic.Category>();

            foreach (Dynamic.Category cat in categories.Values)
            {
                categoryList.Add(cat);
            }
            return(categoryList);
        }
Пример #3
0
        public void Transform(Engine engine, Package package)
        {
            if (package.GetByName(Package.PageName) == null)
            {
                return;
            }
            comm.Page page = (comm.Page)engine.GetObject(package.GetByName(Package.PageName));
            Dictionary <string, List <ComponentPresentation> > lists = new Dictionary <string, List <ComponentPresentation> >();
            string matchTokens = package.GetValue("ComponentTemplateTitleMatchTokens");

            if (!String.IsNullOrEmpty(matchTokens))
            {
                foreach (string token in matchTokens.Split(','))
                {
                    _matchTokens.Add(token.Trim());
                }
            }

            foreach (comm.ComponentPresentation cp in page.ComponentPresentations)
            {
                string ct = GetPresentationType(cp.ComponentTemplate.Title);
                if (!lists.ContainsKey(ct))
                {
                    lists.Add(ct, new List <ComponentPresentation>());
                }
                lists[ct].Add(new ComponentPresentation(cp.Component.Id, cp.ComponentTemplate.Id));
            }

            foreach (string token in lists.Keys)
            {
                Item item = package.CreateStringItem(ContentType.ComponentArray, ComponentPresentationList.ToXml(lists[token]));
                package.PushItem(token + "Components", item);
            }
        }
Пример #4
0
        public static Dynamic.Page BuildPage(TCM.Page tcmPage, Engine engine, BuildManager manager, int linkLevels, bool resolveWidthAndHeight, bool publishEmptyFields)
        {
            Dynamic.Page p = new Dynamic.Page
            {
                Title          = tcmPage.Title,
                Id             = tcmPage.Id.ToString(),
                Filename       = tcmPage.FileName,
                PageTemplate   = manager.BuildPageTemplate(tcmPage.PageTemplate),
                Schema         = manager.BuildSchema(tcmPage.MetadataSchema),
                Version        = tcmPage.Version,
                RevisionDate   = tcmPage.RevisionDate,
                MetadataFields = new Dynamic.FieldSet()
            };
            if (linkLevels > 0)
            {
                try
                {
                    if (tcmPage.Metadata != null && tcmPage.MetadataSchema != null)
                    {
                        var tcmMetadataFields = new Tridion.ContentManager.ContentManagement.Fields.ItemFields(tcmPage.Metadata, tcmPage.MetadataSchema);
                        p.MetadataFields = manager.BuildFields(tcmMetadataFields);
                    }
                }
                catch (Exception)
                {
                    // fail silently if there is no metadata schema
                }
            }

            p.ComponentPresentations = new List <Dynamic.ComponentPresentation>();
            foreach (TCM.ComponentPresentation cp in tcmPage.ComponentPresentations)
            {
                Dynamic.ComponentPresentation dynCp = manager.BuildComponentPresentation(cp, engine, linkLevels - 1, resolveWidthAndHeight);
                p.ComponentPresentations.Add(dynCp);
            }
            p.StructureGroup = manager.BuildOrganizationalItem((TCM.StructureGroup)tcmPage.OrganizationalItem);

            if (!manager.BuildProperties.OmitContextPublications)
            {
                p.Publication = manager.BuildPublication(tcmPage.ContextRepository);
            }
            if (!manager.BuildProperties.OmitOwningPublications)
            {
                p.OwningPublication = manager.BuildPublication(tcmPage.OwningRepository);
            }
            if (!manager.BuildProperties.OmitCategories)
            {
                p.Categories = manager.BuildCategories(tcmPage);
            }
            manager.AddXpathToFields(p.MetadataFields, "Metadata");
            return(p);
        }
Пример #5
0
 public virtual List <Dynamic.Category> BuildCategories(TComm.Page page)
 {
     return(CategoriesBuilder.BuildCategories(page, this));
 }
Пример #6
0
 public virtual Dynamic.Page BuildPage(TComm.Page tcmPage, Engine engine)
 {
     return(PageBuilder.BuildPage(tcmPage, engine, this));
 }
Пример #7
0
 public virtual Dynamic.Page BuildPage(TComm.Page tcmPage, Engine engine, int linkLevels, bool resolveWidthAndHeight, bool publishEmptyFields)
 {
     return(PageBuilder.BuildPage(tcmPage, engine, this, linkLevels, resolveWidthAndHeight, publishEmptyFields));
 }
 public static Dynamic.Page BuildPage(TCM.Page tcmPage, Engine engine, BuildManager manager)
 {
     return(BuildPage(tcmPage, engine, manager, 1, false, false));
 }