Beispiel #1
0
        /// <summary>
        /// Resolves the file name pattern for an export profile
        /// </summary>
        /// <param name="profile">Export profile</param>
        /// <param name="store">Store</param>
        /// <param name="fileIndex">One based file index</param>
        /// <param name="maxFileNameLength">The maximum length of the file name</param>
        /// <returns>Resolved file name pattern</returns>
        public static string ResolveFileNamePattern(this ExportProfile profile, Store store, int fileIndex, int maxFileNameLength)
        {
            var sb = new StringBuilder(profile.FileNamePattern);

            sb.Replace("%Profile.Id%", profile.Id.ToString());
            sb.Replace("%Profile.FolderName%", profile.FolderName);
            sb.Replace("%Store.Id%", store.Id.ToString());
            sb.Replace("%File.Index%", fileIndex.ToString("D4"));

            if (profile.FileNamePattern.Contains("%Profile.SeoName%"))
            {
                sb.Replace("%Profile.SeoName%", SeoHelper.GetSeName(profile.Name, true, false).Replace("/", "").Replace("-", ""));
            }
            if (profile.FileNamePattern.Contains("%Store.SeoName%"))
            {
                sb.Replace("%Store.SeoName%", profile.PerStore ? SeoHelper.GetSeName(store.Name, true, false) : "allstores");
            }
            if (profile.FileNamePattern.Contains("%Random.Number%"))
            {
                sb.Replace("%Random.Number%", CommonHelper.GenerateRandomInteger().ToString());
            }
            if (profile.FileNamePattern.Contains("%Timestamp%"))
            {
                sb.Replace("%Timestamp%", DateTime.UtcNow.ToString("s", CultureInfo.InvariantCulture));
            }

            var result = sb.ToString()
                         .ToValidFileName("")
                         .Truncate(maxFileNameLength);

            return(result);
        }
Beispiel #2
0
        public static string UploadImage(HttpPostedFileBase image, string filePathOriginal, string fileName = null)
        {
            if (image == null || image.ContentLength == 0)
            {
                return(null);
            }

            if (!IsImage(image))
            {
                return(null);
            }

            //Save image to file
            var imageExtension = Path.GetExtension(image.FileName);
            var fileNameASCII  = string.IsNullOrEmpty(fileName) ? SeoHelper.GetSeName(Path.GetFileNameWithoutExtension(image.FileName)) : SeoHelper.GetSeName(fileName);
            var newName        = fileNameASCII + imageExtension;

            string savedFileName = Path.Combine(filePathOriginal, newName);

            Directory.CreateDirectory(filePathOriginal);

            int fileCount = 0;

            while (File.Exists(savedFileName))
            {
                fileCount++;
                newName       = $"{fileNameASCII}_{fileCount}{imageExtension}";
                savedFileName = Path.Combine(filePathOriginal, newName);
            }
            image.SaveAs(savedFileName);

            return(newName);
        }
Beispiel #3
0
        /// <summary>
        /// Get bundled file name
        /// </summary>
        /// <param name="parts">Parts to bundle</param>
        /// <returns>File name</returns>
        protected virtual string GetBundleFileName(string[] parts)
        {
            if (parts == null || parts.Length == 0)
            {
                throw new ArgumentException("parts");
            }

            //calculate hash
            var hash = string.Empty;

            using (SHA256 sha = new SHA256Managed())
            {
                // string concatenation
                var hashInput = string.Empty;
                foreach (var part in parts)
                {
                    hashInput += part;
                    hashInput += ",";
                }

                var input = sha.ComputeHash(Encoding.Unicode.GetBytes(hashInput));
                hash = WebEncoders.Base64UrlEncode(input);
            }

            //ensure only valid chars
            hash = SeoHelper.GetSeName(hash);

            return(hash);
        }
 /// <summary>
 /// Get SEO friendly name
 /// </summary>
 /// <param name="name">Name</param>
 /// <param name="seoSettings">SEO settings</param>
 /// <returns>Result</returns>
 public static string GetSeName(string name, SeoSettings seoSettings)
 {
     return(SeoHelper.GetSeName(
                name,
                seoSettings == null ? false : seoSettings.ConvertNonWesternChars,
                seoSettings == null ? false : seoSettings.AllowUnicodeCharsInUrls));
 }
        /// <summary>
        /// Gets all blog posts
        /// </summary>
        /// <param name="storeId">The store identifier; pass 0 to load all records</param>
        /// <param name="languageId">Language identifier. 0 if you want to get all news</param>
        /// <param name="tag">Tag</param>
        /// <param name="pageIndex">Page index</param>
        /// <param name="pageSize">Page size</param>
        /// <param name="showHidden">A value indicating whether to show hidden records</param>
        /// <returns>Blog posts</returns>
        public virtual IPagedList <BlogPost> GetAllBlogPostsByTag(
            int storeId,
            int languageId,
            string tag,
            int pageIndex,
            int pageSize,
            bool showHidden = false)
        {
            tag = tag.Trim();

            //we laod all records and only then filter them by tag
            var blogPostsAll    = GetAllBlogPosts(storeId, languageId, null, null, 0, int.MaxValue, showHidden);
            var taggedBlogPosts = new List <BlogPost>();

            foreach (var blogPost in blogPostsAll)
            {
                var tags = blogPost.ParseTags().Select(x => SeoHelper.GetSeName(x,
                                                                                _seoSettings.ConvertNonWesternChars,
                                                                                _seoSettings.AllowUnicodeCharsInUrls,
                                                                                _seoSettings.SeoNameCharConversion));

                if (!String.IsNullOrEmpty(tags.FirstOrDefault(t => t.Equals(tag, StringComparison.InvariantCultureIgnoreCase))))
                {
                    taggedBlogPosts.Add(blogPost);
                }
            }

            //server-side paging
            var result = new PagedList <BlogPost>(taggedBlogPosts, pageIndex, pageSize);

            return(result);
        }
Beispiel #6
0
        protected void PrepareBlogPostModel(BlogPostModel model, BlogPost blogPost, bool prepareComments)
        {
            Guard.NotNull(blogPost, nameof(blogPost));
            Guard.NotNull(model, nameof(model));

            model.Id              = blogPost.Id;
            model.MetaTitle       = blogPost.MetaTitle;
            model.MetaDescription = blogPost.MetaDescription;
            model.MetaKeywords    = blogPost.MetaKeywords;
            model.SeName          = blogPost.GetSeName(blogPost.LanguageId, ensureTwoPublishedLanguages: false);
            model.Title           = blogPost.Title;
            model.Body            = blogPost.Body;
            model.CreatedOn       = _dateTimeHelper.ConvertToUserTime(blogPost.CreatedOnUtc, DateTimeKind.Utc);
            model.AddNewComment.DisplayCaptcha           = _captchaSettings.Enabled && _captchaSettings.ShowOnBlogCommentPage;
            model.Comments.AllowComments                 = blogPost.AllowComments;
            model.Comments.NumberOfComments              = blogPost.ApprovedCommentCount;
            model.Comments.AllowCustomersToUploadAvatars = _customerSettings.AllowCustomersToUploadAvatars;

            model.Tags = blogPost.ParseTags().Select(x => new BlogPostTagModel
            {
                Name   = x,
                SeName = SeoHelper.GetSeName(x,
                                             _seoSettings.ConvertNonWesternChars,
                                             _seoSettings.AllowUnicodeCharsInUrls,
                                             true,
                                             _seoSettings.SeoNameCharConversion)
            }).ToList();

            if (prepareComments)
            {
                var blogComments = blogPost.BlogComments.Where(pr => pr.IsApproved).OrderBy(pr => pr.CreatedOnUtc);
                foreach (var bc in blogComments)
                {
                    var isGuest = bc.Customer.IsGuest();

                    var commentModel = new CommentModel(model.Comments)
                    {
                        Id                   = bc.Id,
                        CustomerId           = bc.CustomerId,
                        CustomerName         = bc.Customer.FormatUserName(_customerSettings, T, false),
                        CommentText          = bc.CommentText,
                        CreatedOn            = _dateTimeHelper.ConvertToUserTime(bc.CreatedOnUtc, DateTimeKind.Utc),
                        CreatedOnPretty      = bc.CreatedOnUtc.RelativeFormat(true, "f"),
                        AllowViewingProfiles = _customerSettings.AllowViewingProfiles && !isGuest
                    };

                    commentModel.Avatar = bc.Customer.ToAvatarModel(_genericAttributeService, _pictureService, _customerSettings, _mediaSettings, Url, commentModel.CustomerName);

                    model.Comments.Comments.Add(commentModel);
                }
            }

            Services.DisplayControl.Announce(blogPost);
        }
        public void Can_convert_non_western_chars()
        {
            //german letters with diacritics
            SeoHelper.GetSeName("testäöü", true, false).ShouldEqual("testaou");
            SeoHelper.GetSeName("testäöü", false, false).ShouldEqual("test");

            var charConversions = string.Join(Environment.NewLine, new string[] { "ä;ae", "ö;oe", "ü;ue" });

            SeoHelper.GetSeName("testäöü", false, false, charConversions).ShouldEqual("testaeoeue");

            SeoHelper.ResetUserSeoCharacterTable();
        }
Beispiel #8
0
        public void Seed(SmartObjectContext context)
        {
            var allTopics = context.Set <Topic>()
                            .AsNoTracking()
                            .Select(x => new { x.Id, x.SystemName, x.Title })
                            .ToList();

            var urlRecords = context.Set <UrlRecord>();

            foreach (var topic in allTopics)
            {
                var slug     = SeoHelper.GetSeName(topic.SystemName, true, false).Truncate(400);
                int i        = 2;
                var tempSlug = slug;

                while (urlRecords.Any(x => x.Slug == tempSlug))
                {
                    tempSlug = string.Format("{0}-{1}", slug, i);
                    i++;
                }

                slug = tempSlug;

                var ur = urlRecords.FirstOrDefault(x => x.LanguageId == 0 && x.EntityName == "Topic" && x.EntityId == topic.Id);
                if (ur != null)
                {
                    ur.Slug = slug;
                }
                else
                {
                    urlRecords.Add(new UrlRecord
                    {
                        EntityId   = topic.Id,
                        EntityName = "Topic",
                        IsActive   = true,
                        LanguageId = 0,
                        Slug       = slug
                    });
                }

                context.SaveChanges();
            }
        }
Beispiel #9
0
        public virtual ExportProfile InsertExportProfile(
            string providerSystemName,
            string name,
            string fileExtension,
            ExportFeatures features,
            bool isSystemProfile     = false,
            string profileSystemName = null,
            int cloneFromProfileId   = 0)
        {
            Guard.ArgumentNotEmpty(() => providerSystemName);

            var profileCount = _exportProfileRepository.Table.Count(x => x.ProviderSystemName == providerSystemName);

            if (name.IsEmpty())
            {
                name = providerSystemName;
            }

            if (!isSystemProfile)
            {
                name = string.Concat(_localizationService.GetResource("Common.My"), " ", name);
            }

            name = string.Concat(name, " ", profileCount + 1);

            var cloneProfile = GetExportProfileById(cloneFromProfileId);

            ScheduleTask  task    = null;
            ExportProfile profile = null;

            if (cloneProfile == null)
            {
                task = new ScheduleTask
                {
                    CronExpression = "0 */6 * * *",                         // every six hours
                    Type           = typeof(DataExportTask).AssemblyQualifiedNameWithoutVersion(),
                    Enabled        = false,
                    StopOnError    = false,
                    IsHidden       = true
                };
            }
            else
            {
                task            = cloneProfile.ScheduleTask.Clone();
                task.LastEndUtc = task.LastStartUtc = task.LastSuccessUtc = null;
            }

            task.Name = string.Concat(name, " Task");

            _scheduleTaskService.InsertTask(task);

            if (cloneProfile == null)
            {
                profile = new ExportProfile
                {
                    FileNamePattern = _defaultFileNamePattern
                };

                if (isSystemProfile)
                {
                    profile.Enabled          = true;
                    profile.PerStore         = false;
                    profile.CreateZipArchive = false;
                    profile.Cleanup          = false;
                }
                else
                {
                    // what we do here is to preset typical settings for feed creation
                    // but on the other hand they may be untypical for generic data export\exchange
                    var projection = new ExportProjection
                    {
                        RemoveCriticalCharacters = true,
                        CriticalCharacters       = "¼,½,¾",
                        PriceType          = PriceDisplayType.PreSelectedPrice,
                        NoGroupedProducts  = (features.HasFlag(ExportFeatures.CanOmitGroupedProducts) ? true : false),
                        DescriptionMerging = ExportDescriptionMerging.Description
                    };

                    var filter = new ExportFilter
                    {
                        IsPublished = true
                    };

                    profile.Projection = XmlHelper.Serialize <ExportProjection>(projection);
                    profile.Filtering  = XmlHelper.Serialize <ExportFilter>(filter);
                }
            }
            else
            {
                profile = cloneProfile.Clone();
            }

            profile.IsSystemProfile    = isSystemProfile;
            profile.Name               = name;
            profile.ProviderSystemName = providerSystemName;
            profile.SchedulingTaskId   = task.Id;

            var cleanedSystemName = providerSystemName
                                    .Replace("Exports.", "")
                                    .Replace("Feeds.", "")
                                    .Replace("/", "")
                                    .Replace("-", "");

            var folderName = SeoHelper.GetSeName(cleanedSystemName, true, false)
                             .ToValidPath()
                             .Truncate(_dataExchangeSettings.MaxFileNameLength);

            profile.FolderName = "~/App_Data/ExportProfiles/" + FileSystemHelper.CreateNonExistingDirectoryName(CommonHelper.MapPath("~/App_Data/ExportProfiles"), folderName);

            if (profileSystemName.IsEmpty() && isSystemProfile)
            {
                profile.SystemName = cleanedSystemName;
            }
            else
            {
                profile.SystemName = profileSystemName;
            }

            _exportProfileRepository.Insert(profile);


            task.Alias = profile.Id.ToString();
            _scheduleTaskService.UpdateTask(task);

            if (fileExtension.HasValue() && !isSystemProfile)
            {
                if (cloneProfile == null)
                {
                    if (features.HasFlag(ExportFeatures.CreatesInitialPublicDeployment))
                    {
                        var subFolder = FileSystemHelper.CreateNonExistingDirectoryName(CommonHelper.MapPath("~/" + DataExporter.PublicFolder), folderName);

                        profile.Deployments.Add(new ExportDeployment
                        {
                            ProfileId      = profile.Id,
                            Enabled        = true,
                            DeploymentType = ExportDeploymentType.PublicFolder,
                            Name           = profile.Name,
                            SubFolder      = subFolder
                        });

                        UpdateExportProfile(profile);
                    }
                }
                else
                {
                    foreach (var deployment in cloneProfile.Deployments)
                    {
                        profile.Deployments.Add(deployment.Clone());
                    }

                    UpdateExportProfile(profile);
                }
            }

            _eventPublisher.EntityInserted(profile);

            return(profile);
        }
        protected void PrepareBlogPostModel(BlogPostModel model, BlogPost blogPost, bool prepareComments)
        {
            if (blogPost == null)
            {
                throw new ArgumentNullException("blogPost");
            }

            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            model.Id              = blogPost.Id;
            model.MetaTitle       = blogPost.MetaTitle;
            model.MetaDescription = blogPost.MetaDescription;
            model.MetaKeywords    = blogPost.MetaKeywords;
            model.SeName          = blogPost.GetSeName(blogPost.LanguageId, ensureTwoPublishedLanguages: false);
            model.Title           = blogPost.Title;
            model.Body            = blogPost.Body;
            model.CreatedOn       = _dateTimeHelper.ConvertToUserTime(blogPost.CreatedOnUtc, DateTimeKind.Utc);
            model.Tags            = blogPost.ParseTags().Select(x => new BlogPostTagModel {
                Name = x, SeName = SeoHelper.GetSeName(x,
                                                       _seoSettings.ConvertNonWesternChars,
                                                       _seoSettings.AllowUnicodeCharsInUrls,
                                                       _seoSettings.SeoNameCharConversion)
            }).ToList();
            model.AddNewComment.DisplayCaptcha           = _captchaSettings.Enabled && _captchaSettings.ShowOnBlogCommentPage;
            model.Comments.AllowComments                 = blogPost.AllowComments;
            model.Comments.AvatarPictureSize             = _mediaSettings.AvatarPictureSize;
            model.Comments.NumberOfComments              = blogPost.ApprovedCommentCount;
            model.Comments.AllowCustomersToUploadAvatars = _customerSettings.AllowCustomersToUploadAvatars;

            if (prepareComments)
            {
                var blogComments = blogPost.BlogComments.Where(pr => pr.IsApproved).OrderBy(pr => pr.CreatedOnUtc);
                foreach (var bc in blogComments)
                {
                    var commentModel = new CommentModel(model.Comments)
                    {
                        Id                   = bc.Id,
                        CustomerId           = bc.CustomerId,
                        CustomerName         = bc.Customer.FormatUserName(),
                        CommentText          = bc.CommentText,
                        CreatedOn            = _dateTimeHelper.ConvertToUserTime(bc.CreatedOnUtc, DateTimeKind.Utc),
                        CreatedOnPretty      = bc.CreatedOnUtc.RelativeFormat(true, "f"),
                        AllowViewingProfiles = _customerSettings.AllowViewingProfiles && bc.Customer != null && !bc.Customer.IsGuest()
                    };

                    if (_customerSettings.AllowCustomersToUploadAvatars)
                    {
                        var    customer  = bc.Customer;
                        string avatarUrl = _pictureService.GetPictureUrl(customer.GetAttribute <int>(SystemCustomerAttributeNames.AvatarPictureId), _mediaSettings.AvatarPictureSize, false);
                        if (String.IsNullOrEmpty(avatarUrl) && _customerSettings.DefaultAvatarEnabled)
                        {
                            avatarUrl = _pictureService.GetDefaultPictureUrl(_mediaSettings.AvatarPictureSize, PictureType.Avatar);
                        }
                        commentModel.CustomerAvatarUrl = avatarUrl;
                    }

                    model.Comments.Comments.Add(commentModel);
                }
            }

            Services.DisplayControl.Announce(blogPost);
        }
Beispiel #11
0
 public virtual string GetPictureSeName(string name)
 {
     return(SeoHelper.GetSeName(name, true, false));
 }
Beispiel #12
0
        /// <summary>
        /// Get SE name
        /// </summary>
        /// <param name="name">Name</param>
        /// <returns>Result</returns>
        public static string GetSeName(string name)
        {
            var seoSettings = EngineContext.Current.Resolve <SeoSettings>();

            return(SeoHelper.GetSeName(name, seoSettings.ConvertNonWesternChars, seoSettings.AllowUnicodeCharsInUrls));
        }
 public void Should_replace_space_with_dash()
 {
     SeoHelper.GetSeName("test test", false, false).ShouldEqual("test-test");
     SeoHelper.GetSeName("test     test", false, false).ShouldEqual("test-test");
 }
 public void Can_convert_non_western_chars()
 {
     //german letters with diacritics
     SeoHelper.GetSeName("testäöü", true, false).ShouldEqual("testaou");
     SeoHelper.GetSeName("testäöü", false, false).ShouldEqual("testaeoeue");
 }
 public void Should_allow_all_latin_chars()
 {
     SeoHelper.GetSeName("abcdefghijklmnopqrstuvwxyz1234567890", false, false).ShouldEqual("abcdefghijklmnopqrstuvwxyz1234567890");
 }
 public void Should_remove_illegal_chars()
 {
     SeoHelper.GetSeName("test!@#$%^&*()+<>?/", false, false).ShouldEqual("test");
 }
 public void Should_return_lowercase()
 {
     SeoHelper.GetSeName("tEsT", false, false).ShouldEqual("test");
 }
Beispiel #18
0
        public virtual ImportProfile InsertImportProfile(string fileName, string name, ImportEntityType entityType)
        {
            Guard.ArgumentNotEmpty(() => fileName);

            if (name.IsEmpty())
            {
                name = GetNewProfileName(entityType);
            }

            var task = new ScheduleTask
            {
                CronExpression = "0 */24 * * *",
                Type           = typeof(DataImportTask).AssemblyQualifiedNameWithoutVersion(),
                Enabled        = false,
                StopOnError    = false,
                IsHidden       = true
            };

            task.Name = string.Concat(name, " Task");

            _scheduleTaskService.InsertTask(task);

            var profile = new ImportProfile
            {
                Name             = name,
                EntityType       = entityType,
                Enabled          = true,
                SchedulingTaskId = task.Id
            };

            if (Path.GetExtension(fileName).IsCaseInsensitiveEqual(".xlsx"))
            {
                profile.FileType = ImportFileType.XLSX;
            }
            else
            {
                profile.FileType = ImportFileType.CSV;
            }

            string[] keyFieldNames = null;

            switch (entityType)
            {
            case ImportEntityType.Product:
                keyFieldNames = ProductImporter.DefaultKeyFields;
                break;

            case ImportEntityType.Category:
                keyFieldNames = CategoryImporter.DefaultKeyFields;
                break;

            case ImportEntityType.Customer:
                keyFieldNames = CustomerImporter.DefaultKeyFields;
                break;

            case ImportEntityType.NewsLetterSubscription:
                keyFieldNames = NewsLetterSubscriptionImporter.DefaultKeyFields;
                break;
            }

            profile.KeyFieldNames = string.Join(",", keyFieldNames);

            profile.FolderName = SeoHelper.GetSeName(name, true, false)
                                 .ToValidPath()
                                 .Truncate(_dataExchangeSettings.MaxFileNameLength);

            profile.FolderName = FileSystemHelper.CreateNonExistingDirectoryName(CommonHelper.MapPath("~/App_Data/ImportProfiles"), profile.FolderName);

            _importProfileRepository.Insert(profile);

            task.Alias = profile.Id.ToString();
            _scheduleTaskService.UpdateTask(task);

            _eventPublisher.EntityInserted(profile);

            return(profile);
        }
 public void Can_allow_unicode_chars()
 {
     //russian letters
     SeoHelper.GetSeName("testтест", false, true).ShouldEqual("testтест");
     SeoHelper.GetSeName("testтест", false, false).ShouldEqual("test");
 }
Beispiel #20
0
        protected void PrepareBlogPostModel(BlogPostModel model, BlogPost blogPost, bool prepareComments)
        {
            Guard.NotNull(blogPost, nameof(blogPost));
            Guard.NotNull(model, nameof(model));

            MiniMapper.Map(blogPost, model);

            model.SeName    = blogPost.GetSeName(blogPost.LanguageId, ensureTwoPublishedLanguages: false);
            model.CreatedOn = _dateTimeHelper.ConvertToUserTime(blogPost.CreatedOnUtc, DateTimeKind.Utc);
            model.AddNewComment.DisplayCaptcha           = _captchaSettings.CanDisplayCaptcha && _captchaSettings.ShowOnBlogCommentPage;
            model.Comments.AllowComments                 = blogPost.AllowComments;
            model.Comments.NumberOfComments              = blogPost.ApprovedCommentCount;
            model.Comments.AllowCustomersToUploadAvatars = _customerSettings.AllowCustomersToUploadAvatars;
            model.DisplayAdminLink = _services.Permissions.Authorize(Permissions.System.AccessBackend, _services.WorkContext.CurrentCustomer);

            model.HasBgImage = blogPost.PreviewDisplayType == PreviewDisplayType.DefaultSectionBg || blogPost.PreviewDisplayType == PreviewDisplayType.PreviewSectionBg;

            model.PictureModel = PrepareBlogPostPictureModel(blogPost, blogPost.MediaFileId);

            if (blogPost.PreviewDisplayType == PreviewDisplayType.Default || blogPost.PreviewDisplayType == PreviewDisplayType.DefaultSectionBg)
            {
                model.PreviewPictureModel = PrepareBlogPostPictureModel(blogPost, blogPost.MediaFileId);
            }
            else if (blogPost.PreviewDisplayType == PreviewDisplayType.Preview || blogPost.PreviewDisplayType == PreviewDisplayType.PreviewSectionBg)
            {
                model.PreviewPictureModel = PrepareBlogPostPictureModel(blogPost, blogPost.PreviewMediaFileId);
            }

            if (blogPost.PreviewDisplayType == PreviewDisplayType.Preview ||
                blogPost.PreviewDisplayType == PreviewDisplayType.Default ||
                blogPost.PreviewDisplayType == PreviewDisplayType.Bare)
            {
                model.SectionBg = string.Empty;
            }

            // tags
            model.Tags = blogPost.ParseTags().Select(x => new BlogPostTagModel
            {
                Name   = x,
                SeName = SeoHelper.GetSeName(x,
                                             _seoSettings.ConvertNonWesternChars,
                                             _seoSettings.AllowUnicodeCharsInUrls,
                                             true,
                                             _seoSettings.SeoNameCharConversion)
            }).ToList();

            if (prepareComments)
            {
                var blogComments = blogPost.BlogComments.Where(pr => pr.IsApproved).OrderBy(pr => pr.CreatedOnUtc);
                foreach (var bc in blogComments)
                {
                    var isGuest = bc.Customer.IsGuest();

                    var commentModel = new CommentModel(model.Comments)
                    {
                        Id                   = bc.Id,
                        CustomerId           = bc.CustomerId,
                        CustomerName         = bc.Customer.FormatUserName(_customerSettings, T, false),
                        CommentText          = bc.CommentText,
                        CreatedOn            = _dateTimeHelper.ConvertToUserTime(bc.CreatedOnUtc, DateTimeKind.Utc),
                        CreatedOnPretty      = bc.CreatedOnUtc.RelativeFormat(true, "f"),
                        AllowViewingProfiles = _customerSettings.AllowViewingProfiles && !isGuest
                    };

                    commentModel.Avatar = bc.Customer.ToAvatarModel(_genericAttributeService, _mediaService, _customerSettings, _mediaSettings, Url, commentModel.CustomerName);

                    model.Comments.Comments.Add(commentModel);
                }
            }

            Services.DisplayControl.Announce(blogPost);
        }
Beispiel #21
0
 private string GetSeName(string name)
 {
     return(SeoHelper.GetSeName(name, true, false));
 }