Exemplo n.º 1
0
        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 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;
            }
        }
Exemplo n.º 3
0
        public bool TryMap(RawContent rawContent, out IComposerPage composerPage)
        {
            composerPage = null;
            var sourceProperty = rawContent.GetProperty(ComposerProperties.Page);

            if (sourceProperty == null || sourceProperty.IsNull)
            {
                return(false);
            }

            // Deserialize the Extension pagestructure
            var specialized = _composerSerializer.Deserialize <ComposerPageInformation>(sourceProperty.Value);

            if (specialized == null || specialized.Page == null)
            {
                return(false);
            }

            composerPage          = specialized.Page;
            composerPage.Name     = rawContent.PageName();
            composerPage.Language = rawContent.Language();
            return(true);
        }