Esempio n. 1
0
        protected override void Importing(LocalizationPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            // Don't do anything if the tag is not specified.
            if (context.Data.Element(part.PartDefinition.Name) == null)
            {
                return;
            }

            context.ImportAttribute(part.PartDefinition.Name, "MasterContentItem", masterContentItem => {
                var contentItem = context.GetItemFromSession(masterContentItem);
                if (contentItem != null)
                {
                    part.MasterContentItem = contentItem;
                }
            });

            context.ImportAttribute(part.PartDefinition.Name, "Culture", culture => {
                var targetCulture = _cultureManager.GetCultureByName(culture);
                // Add Culture.
                if (targetCulture == null && _cultureManager.IsValidCulture(culture))
                {
                    _cultureManager.AddCulture(culture);
                    targetCulture = _cultureManager.GetCultureByName(culture);
                }
                part.Culture = targetCulture;
            });
        }
        protected override void Importing(MediaPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            // Don't do anything if the tag is not specified.
            if (context.Data.Element(part.PartDefinition.Name) == null)
            {
                return;
            }

            context.ImportAttribute(part.PartDefinition.Name, "MimeType", mimeType =>
                                    part.MimeType = mimeType
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "Caption", caption =>
                                    part.Caption = caption
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "AlternateText", alternateText =>
                                    part.AlternateText = alternateText
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "FolderPath", folderPath =>
                                    part.FolderPath = folderPath
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "FileName", fileName =>
                                    part.FileName = fileName
                                    );
        }
        protected override void Importing(ImagePart part, ContentManagement.Handlers.ImportContentContext context)
        {
            // Don't do anything if the tag is not specified.
            if (context.Data.Element(part.PartDefinition.Name) == null)
            {
                return;
            }

            context.ImportAttribute(part.PartDefinition.Name, "Height", height =>
                                    part.Height = int.Parse(height)
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "Width", width =>
                                    part.Width = int.Parse(width)
                                    );
        }
Esempio n. 4
0
        protected override void Importing(UserRolesPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            // Don't do anything if the tag is not specified.
            if (context.Data.Element(part.PartDefinition.Name) == null)
            {
                return;
            }

            context.ImportAttribute(part.PartDefinition.Name, "Roles", roles => {
                var userRoles = roles.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                // create new roles
                foreach (var role in userRoles)
                {
                    var roleRecord = _roleService.GetRoleByName(role);

                    // create the role if it doesn't already exist
                    if (roleRecord == null)
                    {
                        _roleService.CreateRole(role);
                    }
                }

                var currentUserRoleRecords = _userRolesRepository.Fetch(x => x.UserId == part.ContentItem.Id).ToList();
                var currentRoleRecords     = currentUserRoleRecords.Select(x => x.Role).ToList();
                var targetRoleRecords      = userRoles.Select(x => _roleService.GetRoleByName(x)).ToList();
                foreach (var addingRole in targetRoleRecords.Where(x => !currentRoleRecords.Contains(x)))
                {
                    _userRolesRepository.Create(new UserRolesPartRecord {
                        UserId = part.ContentItem.Id, Role = addingRole
                    });
                }
            });
        }
Esempio n. 5
0
        protected override void Importing(WidgetPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            // Don't do anything if the tag is not specified.
            if (context.Data.Element(part.PartDefinition.Name) == null)
            {
                return;
            }

            context.ImportAttribute(part.PartDefinition.Name, "Title", x => part.Title       = x);
            context.ImportAttribute(part.PartDefinition.Name, "Position", x => part.Position = x);
            context.ImportAttribute(part.PartDefinition.Name, "Zone", x => part.Zone         = x);
            context.ImportAttribute(part.PartDefinition.Name, "RenderTitle", x => {
                if (!string.IsNullOrWhiteSpace(x))
                {
                    part.RenderTitle = Convert.ToBoolean(x);
                }
            });
            context.ImportAttribute(part.PartDefinition.Name, "Name", x => part.Name = x);
            context.ImportAttribute(part.PartDefinition.Name, "Title", x => {
                if (!String.IsNullOrWhiteSpace(x))
                {
                    part.Title = x;
                }
            });
            context.ImportAttribute(part.PartDefinition.Name, "CssClasses", x => part.CssClasses = x);
        }
        protected override void Importing(BlogPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            // Don't do anything if the tag is not specified.
            if (context.Data.Element(part.PartDefinition.Name) == null)
            {
                return;
            }

            context.ImportAttribute(part.PartDefinition.Name, "Description", description =>
                                    part.Description = description
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "PostCount", postCount =>
                                    part.PostCount = Convert.ToInt32(postCount)
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "FeedProxyUrl", feedProxyUrl =>
                                    part.FeedProxyUrl = feedProxyUrl
                                    );
        }
        protected override void Importing(AdminMenuPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            // Don't do anything if the tag is not specified.
            if (context.Data.Element(part.PartDefinition.Name) == null)
            {
                return;
            }

            context.ImportAttribute(part.PartDefinition.Name, "AdminMenuText", adminMenuText =>
                                    part.AdminMenuText = adminMenuText
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "AdminMenuPosition", position =>
                                    part.AdminMenuPosition = position
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "OnAdminMenu", onAdminMenu =>
                                    part.OnAdminMenu = Convert.ToBoolean(onAdminMenu)
                                    );
        }
        protected override void Importing(CommentsPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            // Don't do anything if the tag is not specified.
            if (context.Data.Element(part.PartDefinition.Name) == null)
            {
                return;
            }

            context.ImportAttribute(part.PartDefinition.Name, "CommentsShown", commentsShown =>
                                    part.CommentsShown = Convert.ToBoolean(commentsShown)
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "CommentsActive", commentsActive =>
                                    part.CommentsActive = Convert.ToBoolean(commentsActive)
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "ThreadedComments", threadedComments =>
                                    part.ThreadedComments = Convert.ToBoolean(threadedComments)
                                    );
        }
        protected override void Importing(AutoroutePart part, ContentManagement.Handlers.ImportContentContext context)
        {
            // Don't do anything if the tag is not specified.
            if (context.Data.Element(part.PartDefinition.Name) == null)
            {
                return;
            }

            context.ImportAttribute(part.PartDefinition.Name, "Alias", displayAlias =>
                                    part.DisplayAlias = displayAlias
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "CustomPattern", customPattern =>
                                    part.CustomPattern = customPattern
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "UseCustomPattern", useCustomPattern =>
                                    part.UseCustomPattern = bool.Parse(useCustomPattern)
                                    );
        }
        protected override void Importing(AudioPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            // Don't do anything if the tag is not specified.
            if (context.Data.Element(part.PartDefinition.Name) == null)
            {
                return;
            }

            context.ImportAttribute(part.PartDefinition.Name, "Length", length =>
                                    part.Length = int.Parse(length)
                                    );
        }
Esempio n. 11
0
        protected override void Importing(BodyPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            // Don't do anything if the tag is not specified.
            if (context.Data.Element(part.PartDefinition.Name) == null)
            {
                return;
            }

            context.ImportAttribute(part.PartDefinition.Name, "Text", importedText =>
                                    part.Text = importedText
                                    );
        }
Esempio n. 12
0
        protected override void Importing(MenuItemPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            // Don't do anything if the tag is not specified.
            if (context.Data.Element(part.PartDefinition.Name) == null)
            {
                return;
            }

            context.ImportAttribute(part.PartDefinition.Name, "Url", url =>
                                    part.Url = url
                                    );
        }
        protected override void Importing(OEmbedPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            // Don't do anything if the tag is not specified.
            if (context.Data.Element(part.PartDefinition.Name) == null)
            {
                return;
            }

            context.ImportAttribute(part.PartDefinition.Name, "Source", source =>
                                    part.Source = source
                                    );
        }
Esempio n. 14
0
        protected override void Importing(MenuPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            // Don't do anything if the tag is not specified.
            if (context.Data.Element(part.PartDefinition.Name) == null)
            {
                return;
            }

            context.ImportAttribute(part.PartDefinition.Name, "MenuText", menuText =>
                                    part.MenuText = menuText
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "MenuPosition", position =>
                                    part.MenuPosition = position
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "Menu", menuIdentity => {
                var menu = context.GetItemFromSession(menuIdentity);
                if (menu != null)
                {
                    part.Menu = menu;
                }
            });
        }
        protected override void Importing(SiteSettingsPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            // Don't do anything if the tag is not specified.
            if (context.Data.Element(part.PartDefinition.Name) == null)
            {
                return;
            }

            context.ImportAttribute(part.PartDefinition.Name, "SupportedCultures", supportedCultures => {
                foreach (var culture in supportedCultures.Split(';'))
                {
                    _cultureManager.AddCulture(culture);
                }
            });
        }
Esempio n. 16
0
        protected override void Importing(CommentPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            // Don't do anything if the tag is not specified.
            if (context.Data.Element(part.PartDefinition.Name) == null)
            {
                return;
            }

            context.ImportAttribute(part.PartDefinition.Name, "Author", author =>
                                    part.Record.Author = author
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "SiteName", siteName =>
                                    part.Record.SiteName = siteName
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "UserName", userName =>
                                    part.Record.UserName = userName
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "Email", email =>
                                    part.Record.Email = email
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "Position", position =>
                                    part.Record.Position = decimal.Parse(position, CultureInfo.InvariantCulture)
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "Status", status =>
                                    part.Record.Status = (CommentStatus)Enum.Parse(typeof(CommentStatus), status)
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "CommentDateUtc", commentDate =>
                                    part.Record.CommentDateUtc = XmlConvert.ToDateTime(commentDate, XmlDateTimeSerializationMode.Utc)
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "CommentText", text =>
                                    part.Record.CommentText = text
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "CommentedOn", commentedOn => {
                var contentItem = context.GetItemFromSession(commentedOn);
                if (contentItem != null)
                {
                    part.Record.CommentedOn = contentItem.Id;
                }

                contentItem.As <CommentsPart>().Record.CommentPartRecords.Add(part.Record);
            });

            context.ImportAttribute(part.PartDefinition.Name, "RepliedOn", repliedOn => {
                var contentItem = context.GetItemFromSession(repliedOn);
                if (contentItem != null)
                {
                    part.Record.RepliedOn = contentItem.Id;
                }
            });

            context.ImportAttribute(part.PartDefinition.Name, "CommentedOnContainer", commentedOnContainer => {
                var container = context.GetItemFromSession(commentedOnContainer);
                if (container != null)
                {
                    part.Record.CommentedOnContainer = container.Id;
                }
            });
        }