Exemplo n.º 1
0
        public string GetFormattedBodyContent(GetPropertyData getPropertyData, Controller controller)
        {
            ContentInfo content = GetContent(getPropertyData);

            object entity = content.Entity;

            if (entity is Webpage)
            {
                CurrentRequestData.CurrentPage = entity as Webpage;
            }
            HtmlHelper htmlHelper = MrCMSHtmlHelper.GetHtmlHelper(controller);

            return(htmlHelper.ParseShortcodes(content.Content).ToHtmlString());
        }
Exemplo n.º 2
0
        private MvcHtmlString ReturnTag(ImageInfo imageInfo, string alt, string title, object attributes)
        {
            var tagBuilder = new TagBuilder("img");

            tagBuilder.Attributes.Add("src", imageInfo.ImageUrl);
            tagBuilder.Attributes.Add("alt", alt ?? imageInfo.Title);
            tagBuilder.Attributes.Add("title", title ?? imageInfo.Description);
            if (attributes != null)
            {
                var routeValueDictionary = MrCMSHtmlHelper.AnonymousObjectToHtmlAttributes(attributes);
                foreach (var kvp in routeValueDictionary)
                {
                    tagBuilder.Attributes.Add(kvp.Key, kvp.Value.ToString());
                }
            }
            return(MvcHtmlString.Create(tagBuilder.ToString(TagRenderMode.SelfClosing)));
        }
Exemplo n.º 3
0
        public MvcHtmlString RenderImage(HtmlHelper helper, string imageUrl, Size targetSize = new Size(), string alt = null,
                                         string title = null, object attributes = null)
        {
            var cachingInfo = _mediaSettings.GetCachingInfo(imageUrl, targetSize, alt, title, attributes);

            return(helper.GetCached(cachingInfo, htmlHelper =>
            {
                using (new SiteFilterDisabler(_session))
                {
                    if (string.IsNullOrWhiteSpace(imageUrl))
                    {
                        return MvcHtmlString.Empty;
                    }

                    var image = _imageProcessor.GetImage(imageUrl);
                    if (image == null)
                    {
                        return MvcHtmlString.Empty;
                    }

                    if (targetSize != default(Size) && ImageProcessor.RequiresResize(image.Size, targetSize))
                    {
                        var location = _fileService.GetFileLocation(image, targetSize);
                        if (!string.IsNullOrWhiteSpace(location))
                        {
                            imageUrl = location;
                        }
                    }

                    var tagBuilder = new TagBuilder("img");
                    tagBuilder.Attributes.Add("src", imageUrl);
                    tagBuilder.Attributes.Add("alt", alt ?? image.Title);
                    tagBuilder.Attributes.Add("title", title ?? image.Description);
                    if (attributes != null)
                    {
                        var routeValueDictionary = MrCMSHtmlHelper.AnonymousObjectToHtmlAttributes(attributes);
                        foreach (var kvp in routeValueDictionary)
                        {
                            tagBuilder.Attributes.Add(kvp.Key, kvp.Value.ToString());
                        }
                    }
                    return MvcHtmlString.Create(tagBuilder.ToString(TagRenderMode.SelfClosing));
                }
            }));
        }
Exemplo n.º 4
0
        private static void CreateInfo(ExcelPackage excelFile)
        {
            var wsInfo = excelFile.Workbook.Worksheets.Add("Info");

            wsInfo.Cells["A1:D1"].Style.Font.Bold         = true;
            wsInfo.Cells["A:D"].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
            wsInfo.Cells["A1"].Value = "MrCMS Version";
            wsInfo.Cells["B1"].Value = "Entity Type for Export";
            wsInfo.Cells["C1"].Value = "Export Date";
            wsInfo.Cells["D1"].Value = "Export Source";

            wsInfo.Cells["A2"].Value = MrCMSHtmlHelper.AssemblyVersion(null);
            wsInfo.Cells["B2"].Value = "Product";
            wsInfo.Cells["C2"].Style.Numberformat.Format = "YYYY-MM-DD hh:mm:ss";
            wsInfo.Cells["C2"].Value = DateTime.UtcNow;
            wsInfo.Cells["D2"].Value = "MrCMS " + MrCMSHtmlHelper.AssemblyVersion(null);

            wsInfo.Cells["A:D"].AutoFitColumns();
            wsInfo.Cells["A4"].Style.HorizontalAlignment = ExcelHorizontalAlignment.Left;
            wsInfo.Cells["A4"].Value = "Please do not change any values inside this file.";
        }