public virtual bool Transform(ITransferContentData transferContentData) { var rawContent = transferContentData.RawContentData; var functionProperty = rawContent.GetProperty(ComposerProperties.ContentFunction); if (functionProperty == null) { return(true); } // Deserialize the Extension Function Struct var functionInfo = _composerSerializer.Deserialize <ComposerContentFunctionInformation>(functionProperty.Value); var isGlobalBlock = functionInfo != null && functionInfo.Type == ComposerContentFunctionCategory.Global; var guid = transferContentData.RawContentData.PageGuid(); var parent = _contentMap.GetParentPage(guid); // If a (non-global) block doesn't have a parent, it's an orphaned block and we won't import it if (parent == null && !_includeUnusedBlocks && !isGlobalBlock) { return(false); } // Move all Global and Unused blocks to the GlobalBlockFolder if (isGlobalBlock || parent == null) { rawContent.SetPropertyValue(MetaDataProperties.PageParentLink, _exportLinkResolver.GetExportableLink(ContentReference.GlobalBlockFolder)); } // Update the PageName to a more friendly name var property = rawContent.GetProperty(MetaDataProperties.PageName); if (property != null) { var friendlyName = CreateFriendlyName(rawContent, functionInfo); if (!string.IsNullOrEmpty(friendlyName)) { property.Value = friendlyName; } } // Don't change language of Global Blocks if (!isGlobalBlock && parent != null) { rawContent.Language(parent.Language); rawContent.MasterLanguage(parent.Language); } return(true); }
public virtual void TransformContainer(RawContent rawContent, IComposerPage parent) { if (rawContent == null) { throw new ArgumentNullException("rawContent"); } rawContent.SetPropertyValue(MetaDataProperties.PageParentLink, _exportLinkResolver.GetExportableLink(ContentReference.GlobalBlockFolder)); if (parent != null) { rawContent.PageName(parent.Name); rawContent.Language(parent.Language); rawContent.MasterLanguage(parent.Language); } }
public virtual void TransformFunctionPickerProperty(RawProperty functionPickerProperty) { // Change type to ContentReference functionPickerProperty.Type = PropertyDataType.ContentReference; functionPickerProperty.TypeName = null; functionPickerProperty.AssemblyName = null; var data = _composerSerializer.Deserialize <FunctionPickerData>(functionPickerProperty.Value); // Convert the Value to an ExportableLink if (data != null && data.FunctionLink != null) { functionPickerProperty.Value = _exportLinkResolver.GetExportableLink(data.FunctionLink.Guid, data.PageLanguage); functionPickerProperty.IsNull = string.IsNullOrEmpty(functionPickerProperty.Value); } else { functionPickerProperty.IsNull = true; } }