Exemplo n.º 1
0
        protected override void Importing(LocalizationPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            var masterContentItem = context.Attribute(part.PartDefinition.Name, "MasterContentItem");

            if (masterContentItem != null)
            {
                var contentItem = context.GetItemFromSession(masterContentItem);
                if (contentItem != null)
                {
                    part.MasterContentItem = contentItem;
                }
            }

            var culture = context.Attribute(part.PartDefinition.Name, "Culture");

            if (culture != null)
            {
                var targetCulture = _cultureManager.GetCultureByName(culture);
                // Add Culture.
                if (targetCulture == null && _cultureManager.IsValidCulture(culture))
                {
                    _cultureManager.AddCulture(culture);
                    targetCulture = _cultureManager.GetCultureByName(culture);
                }
                part.Culture = targetCulture;
            }
        }
Exemplo n.º 2
0
        protected override void Importing(MenuPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            var menuText = context.Attribute(part.PartDefinition.Name, "MenuText");

            if (menuText != null)
            {
                part.MenuText = menuText;
            }

            var position = context.Attribute(part.PartDefinition.Name, "MenuPosition");

            if (position != null)
            {
                part.MenuPosition = position;
            }

            var menuIdentity = context.Attribute(part.PartDefinition.Name, "Menu");

            if (menuIdentity != null)
            {
                var menu = context.GetItemFromSession(menuIdentity);
                if (menu != null)
                {
                    part.Menu = menu;
                }
            }
        }
        protected override void Importing(UserRolesPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            var roles = context.Attribute(part.PartDefinition.Name, "Roles");

            if (string.IsNullOrEmpty(roles))
            {
                return;
            }

            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
                });
            }
        }
Exemplo n.º 4
0
        protected override void Importing(CommentsPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            var commentsShown = context.Attribute(part.PartDefinition.Name, "CommentsShown");

            if (commentsShown != null)
            {
                part.CommentsShown = Convert.ToBoolean(commentsShown);
            }

            var commentsActive = context.Attribute(part.PartDefinition.Name, "CommentsActive");

            if (commentsActive != null)
            {
                part.CommentsActive = Convert.ToBoolean(commentsActive);
            }
        }
Exemplo n.º 5
0
        protected override void Importing(BlogPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            var description = context.Attribute(part.PartDefinition.Name, "Description");

            if (description != null)
            {
                part.Description = description;
            }

            var postCount = context.Attribute(part.PartDefinition.Name, "PostCount");

            if (postCount != null)
            {
                part.PostCount = Convert.ToInt32(postCount);
            }
        }
Exemplo n.º 6
0
        protected override void Importing(ImagePart part, ContentManagement.Handlers.ImportContentContext context)
        {
            var height = context.Attribute(part.PartDefinition.Name, "Height");

            if (height != null)
            {
                part.Height = int.Parse(height);
            }

            var width = context.Attribute(part.PartDefinition.Name, "Width");

            if (width != null)
            {
                part.Width = int.Parse(width);
            }
        }
Exemplo n.º 7
0
 protected override void Importing(UserPart part, ContentManagement.Handlers.ImportContentContext context)
 {
     part.Email = context.Attribute(part.PartDefinition.Name, "Email");
     part.EmailChallengeToken = context.Attribute(part.PartDefinition.Name, "EmailChallengeToken");
     part.EmailStatus         = (UserStatus)Enum.Parse(typeof(UserStatus), context.Attribute(part.PartDefinition.Name, "EmailStatus"));
     part.HashAlgorithm       = context.Attribute(part.PartDefinition.Name, "HashAlgorithm");
     part.NormalizedUserName  = context.Attribute(part.PartDefinition.Name, "NormalizedUserName");
     part.Password            = context.Attribute(part.PartDefinition.Name, "Password");
     part.PasswordFormat      = (MembershipPasswordFormat)Enum.Parse(typeof(MembershipPasswordFormat), context.Attribute(part.PartDefinition.Name, "PasswordFormat"));
     part.PasswordSalt        = context.Attribute(part.PartDefinition.Name, "PasswordSalt");
     part.RegistrationStatus  = (UserStatus)Enum.Parse(typeof(UserStatus), context.Attribute(part.PartDefinition.Name, "RegistrationStatus"));
     part.UserName            = context.Attribute(part.PartDefinition.Name, "UserName");
 }
Exemplo n.º 8
0
        protected override void Importing(AudioPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            var length = context.Attribute(part.PartDefinition.Name, "Length");

            if (length != null)
            {
                part.Length = int.Parse(length);
            }
        }
Exemplo n.º 9
0
        protected override void Importing(OEmbedPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            var source = context.Attribute(part.PartDefinition.Name, "Source");

            if (source != null)
            {
                part.Source = source;
            }
        }
Exemplo n.º 10
0
        protected override void Importing(MenuItemPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            var url = context.Attribute(part.PartDefinition.Name, "Url");

            if (url != null)
            {
                part.Url = url;
            }
        }
Exemplo n.º 11
0
        protected override void Importing(IdentityPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            var identity = context.Attribute(part.PartDefinition.Name, "Identifier");

            if (identity != null)
            {
                part.Identifier = identity;
            }
        }
Exemplo n.º 12
0
        protected override void Importing(BodyPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            var importedText = context.Attribute(part.PartDefinition.Name, "Text");

            if (importedText != null)
            {
                part.Text = importedText;
            }
        }
Exemplo n.º 13
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;
            }

            var title = context.Attribute(part.PartDefinition.Name, "Title");

            if (title != null)
            {
                part.Title = title;
            }

            var position = context.Attribute(part.PartDefinition.Name, "Position");

            if (position != null)
            {
                part.Position = position;
            }

            var zone = context.Attribute(part.PartDefinition.Name, "Zone");

            if (zone != null)
            {
                part.Zone = zone;
            }

            var renderTitle = context.Attribute(part.PartDefinition.Name, "RenderTitle");

            if (!string.IsNullOrWhiteSpace(renderTitle))
            {
                part.RenderTitle = Convert.ToBoolean(renderTitle);
            }

            var name = context.Attribute(part.PartDefinition.Name, "Name");

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

            part.Email = context.Attribute(part.PartDefinition.Name, "Email");
            part.EmailChallengeToken   = context.Attribute(part.PartDefinition.Name, "EmailChallengeToken");
            part.EmailStatus           = (UserStatus)Enum.Parse(typeof(UserStatus), context.Attribute(part.PartDefinition.Name, "EmailStatus"));
            part.HashAlgorithm         = context.Attribute(part.PartDefinition.Name, "HashAlgorithm");
            part.NormalizedUserName    = context.Attribute(part.PartDefinition.Name, "NormalizedUserName");
            part.Password              = context.Attribute(part.PartDefinition.Name, "Password");
            part.PasswordFormat        = (MembershipPasswordFormat)Enum.Parse(typeof(MembershipPasswordFormat), context.Attribute(part.PartDefinition.Name, "PasswordFormat"));
            part.PasswordSalt          = context.Attribute(part.PartDefinition.Name, "PasswordSalt");
            part.RegistrationStatus    = (UserStatus)Enum.Parse(typeof(UserStatus), context.Attribute(part.PartDefinition.Name, "RegistrationStatus"));
            part.UserName              = context.Attribute(part.PartDefinition.Name, "UserName");
            part.LastPasswordChangeUtc = DateTime.Parse(context.Attribute(part.PartDefinition.Name, "LastPasswordChangeUtc"));
        }
Exemplo n.º 15
0
        protected override void Importing(SiteSettingsPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            var supportedCultures = context.Attribute(part.PartDefinition.Name, "SupportedCultures");

            if (supportedCultures != null)
            {
                foreach (var culture in supportedCultures.Split(';'))
                {
                    _cultureManager.AddCulture(culture);
                }
            }
        }
Exemplo n.º 16
0
        protected override void Importing(WidgetPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            var title = context.Attribute(part.PartDefinition.Name, "Title");

            if (title != null)
            {
                part.Title = title;
            }

            var position = context.Attribute(part.PartDefinition.Name, "Position");

            if (position != null)
            {
                part.Position = position;
            }

            var zone = context.Attribute(part.PartDefinition.Name, "Zone");

            if (zone != null)
            {
                part.Zone = zone;
            }
        }
Exemplo n.º 17
0
        protected override void Importing(AutoroutePart part, ContentManagement.Handlers.ImportContentContext context)
        {
            var displayAlias = context.Attribute(part.PartDefinition.Name, "Alias");

            if (displayAlias != null)
            {
                part.DisplayAlias = displayAlias;
            }

            var customPattern = context.Attribute(part.PartDefinition.Name, "CustomPattern");

            if (customPattern != null)
            {
                part.CustomPattern = customPattern;
            }

            var useCustomPattern = context.Attribute(part.PartDefinition.Name, "UseCustomPattern");

            if (useCustomPattern != null)
            {
                part.UseCustomPattern = bool.Parse(useCustomPattern);
            }
        }
Exemplo n.º 18
0
        protected override void Importing(AdminMenuPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            var adminMenuText = context.Attribute(part.PartDefinition.Name, "AdminMenuText");

            if (adminMenuText != null)
            {
                part.AdminMenuText = adminMenuText;
            }

            var position = context.Attribute(part.PartDefinition.Name, "AdminMenuPosition");

            if (position != null)
            {
                part.AdminMenuPosition = position;
            }

            var onAdminMenu = context.Attribute(part.PartDefinition.Name, "OnAdminMenu");

            if (onAdminMenu != null)
            {
                part.OnAdminMenu = Convert.ToBoolean(onAdminMenu);
            }
        }
Exemplo n.º 19
0
        protected override void Importing(MediaPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            var mimeType = context.Attribute(part.PartDefinition.Name, "MimeType");

            if (mimeType != null)
            {
                part.MimeType = mimeType;
            }

            var caption = context.Attribute(part.PartDefinition.Name, "Caption");

            if (caption != null)
            {
                part.Caption = caption;
            }

            var alternateText = context.Attribute(part.PartDefinition.Name, "AlternateText");

            if (alternateText != null)
            {
                part.AlternateText = alternateText;
            }

            var folderPath = context.Attribute(part.PartDefinition.Name, "FolderPath");

            if (folderPath != null)
            {
                part.FolderPath = folderPath;
            }

            var fileName = context.Attribute(part.PartDefinition.Name, "FileName");

            if (fileName != null)
            {
                part.FileName = fileName;
            }
        }
Exemplo n.º 20
0
        protected override void Importing(WidgetPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            var title = context.Attribute(part.PartDefinition.Name, "Title");

            if (title != null)
            {
                part.Title = title;
            }

            var position = context.Attribute(part.PartDefinition.Name, "Position");

            if (position != null)
            {
                part.Position = position;
            }

            var zone = context.Attribute(part.PartDefinition.Name, "Zone");

            if (zone != null)
            {
                part.Zone = zone;
            }

            var renderTitle = context.Attribute(part.PartDefinition.Name, "RenderTitle");

            if (!string.IsNullOrWhiteSpace(renderTitle))
            {
                part.RenderTitle = Convert.ToBoolean(renderTitle);
            }

            var name = context.Attribute(part.PartDefinition.Name, "Name");

            if (name != null)
            {
                part.Name = name;
            }
        }
        protected override void Importing(CommentPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            var author = context.Attribute(part.PartDefinition.Name, "Author");

            if (author != null)
            {
                part.Record.Author = author;
            }

            var siteName = context.Attribute(part.PartDefinition.Name, "SiteName");

            if (siteName != null)
            {
                part.Record.SiteName = siteName;
            }

            var userName = context.Attribute(part.PartDefinition.Name, "UserName");

            if (userName != null)
            {
                part.Record.UserName = userName;
            }

            var email = context.Attribute(part.PartDefinition.Name, "Email");

            if (email != null)
            {
                part.Record.Email = email;
            }

            var position = context.Attribute(part.PartDefinition.Name, "Position");

            if (position != null)
            {
                part.Record.Position = decimal.Parse(position, CultureInfo.InvariantCulture);
            }

            var status = context.Attribute(part.PartDefinition.Name, "Status");

            if (status != null)
            {
                part.Record.Status = (CommentStatus)Enum.Parse(typeof(CommentStatus), status);
            }

            var commentDate = context.Attribute(part.PartDefinition.Name, "CommentDateUtc");

            if (commentDate != null)
            {
                part.Record.CommentDateUtc = XmlConvert.ToDateTime(commentDate, XmlDateTimeSerializationMode.Utc);
            }

            var text = context.Attribute(part.PartDefinition.Name, "CommentText");

            if (text != null)
            {
                part.Record.CommentText = text;
            }

            var commentedOn = context.Attribute(part.PartDefinition.Name, "CommentedOn");

            if (commentedOn != null)
            {
                var contentItem = context.GetItemFromSession(commentedOn);
                if (contentItem != null)
                {
                    part.Record.CommentedOn = contentItem.Id;
                }

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

            var repliedOn = context.Attribute(part.PartDefinition.Name, "RepliedOn");

            if (repliedOn != null)
            {
                var contentItem = context.GetItemFromSession(repliedOn);
                if (contentItem != null)
                {
                    part.Record.RepliedOn = contentItem.Id;
                }

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

            var commentedOnContainer = context.Attribute(part.PartDefinition.Name, "CommentedOnContainer");

            if (commentedOnContainer != null)
            {
                var container = context.GetItemFromSession(commentedOnContainer);
                if (container != null)
                {
                    part.Record.CommentedOnContainer = container.Id;
                }
            }
        }