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); }
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; }
protected override void TransformPage(Dynamic.Page page) { Page tcmPage = this.GetTcmPage(); StructureGroup tcmSG = (StructureGroup)tcmPage.OrganizationalItem; String mergeActionStr = Package.GetValue("MergeAction"); Dynamic.MergeAction mergeAction; if (string.IsNullOrEmpty(mergeActionStr)) { mergeAction = defaultMergeAction; } else { mergeAction = (Dynamic.MergeAction)Enum.Parse(typeof(Dynamic.MergeAction), mergeActionStr); } while (tcmSG.OrganizationalItem != null) { if (tcmSG.MetadataSchema != null) { TCM.Fields.ItemFields tcmFields = new TCM.Fields.ItemFields(tcmSG.Metadata, tcmSG.MetadataSchema); // change Builder.FieldsBuilder.AddFields(page.Metadata, tcmFields, 1, false, mergeAction, manager); } tcmSG = (StructureGroup)tcmSG.OrganizationalItem; } }
protected override void TransformPage(Dynamic.Page page) { binaryPublisher = new BinaryPublisher(Package, Engine); // call helper function to publish all relevant multimedia components // that could be: // - the current page // - any component on the current page // - any component linked to a component on the current page // - any component linked to that (the number of levels is configurable in a parameter) PublishAllBinaries(page); }
private void PublishAllBinaries(Dynamic.Page page) { foreach (Dynamic.Field field in page.Metadata.Values) { if (field.FieldType == Dynamic.FieldType.ComponentLink || field.FieldType == Dynamic.FieldType.MultiMediaLink) { foreach (Dynamic.Component linkedComponent in field.LinkedComponentValues) { PublishAllBinaries(linkedComponent); } } if (field.FieldType == Dynamic.FieldType.Xhtml) { for (int i = 0; i < field.Values.Count; i++) { string xhtml = field.Values[i]; field.Values[i] = binaryPublisher.PublishBinariesInRichTextField(xhtml); } } } // do not publish binaries in the components, because they should be handled // by the component templates! //foreach (Dynamic.ComponentPresentation cp in page.ComponentPresentations) //{ // Dynamic.Component component = cp.Component; // if (component.ComponentType.Equals(Dynamic.ComponentType.Multimedia)) // { // component.Multimedia.Url = binaryPublisher.PublishMultimediaComponent(component.Id); // } // foreach (Dynamic.Field field in component.Fields.Values) // { // if (field.FieldType == Dynamic.FieldType.ComponentLink || field.FieldType == Dynamic.FieldType.MultiMediaLink) // { // foreach (Dynamic.Component linkedComponent in field.LinkedComponentValues) // { // PublishAllBinaries(linkedComponent); // } // } // } //} }
protected override void TransformPage(Dynamic.Page page) { // do nothing, this is the basic operation }
/// <summary> /// Abstract method to be implemented by a subclass. The method takes a DynamicDelivery page and can add information to it (e.g. by searching in folders / structure groups / linked components, etc /// </summary> /// <param name="page">DynamicDelivery page</param> protected abstract void TransformPage(Dynamic.Page page);