示例#1
0
        public override void Write(ContentItem item, string propertyName, TextWriter writer)
        {
            string url = item[propertyName] as string;

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

            string extension = VirtualPathUtility.GetExtension(url);

            switch (ImagesUtility.GetExtensionGroup(extension))
            {
            case ImagesUtility.ExtensionGroups.Images:
                base.Write(item, propertyName, writer);
                return;

            case ImagesUtility.ExtensionGroups.Flash:
                WriteFlash(url, writer);
                return;

            case ImagesUtility.ExtensionGroups.Video:
                WriteMovie(url, writer);
                return;

            case ImagesUtility.ExtensionGroups.Audio:
                WriteAudio(url, writer);
                return;
            }
        }
        public override void Write(ContentItem item, string propertyName, TextWriter writer)
        {
            var filePath = item[propertyName] as string;

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

            string url = Context.Current.Container.Resolve <IExternalWebLinkResolver>().GetPublicUrl(filePath);

            if (string.IsNullOrWhiteSpace(url))
            {
                return;
            }

            var extension = VirtualPathUtility.GetExtension(url);

            switch (ImagesUtility.GetExtensionGroup(extension))
            {
            case ImagesUtility.ExtensionGroups.Images:
                writer.Write("<img src=\"{0}\" alt=\"{1}\"  />", url, Alt);
                return;

            default:
                writer.Write("<a href=\"{0}\">{1}</a>", url, VirtualPathUtility.GetFileName(url));
                return;
            }
        }
示例#3
0
        public virtual void Write(ContentItem item, string propertyName, TextWriter writer)
        {
            string url = item[propertyName] as string;

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

            string extension = VirtualPathUtility.GetExtension(url);

            switch (ImagesUtility.GetExtensionGroup(extension))
            {
            case ImagesUtility.ExtensionGroups.Images:
                var sizes = DisplayableImageAttribute.GetSizes(PreferredSize);
                DisplayableImageAttribute.WriteImage(item, propertyName, sizes, alt, CssClass, writer);
                return;

            case ImagesUtility.ExtensionGroups.Flash:
                WriteFlash(url, writer);
                return;

            case ImagesUtility.ExtensionGroups.Video:
                WriteMovie(url, writer);
                return;

            case ImagesUtility.ExtensionGroups.Audio:
                WriteAudio(url, writer);
                return;

            default:
                WriteUrl(item, propertyName, cssClass, writer, url);
                return;
            }
        }
示例#4
0
        public virtual void Write(ContentItem item, string propertyName, TextWriter writer)
        {
            string url = item[propertyName] as string;

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

            switch (ExtensionGroup ?? ImagesUtility.GetExtensionGroup(VirtualPathUtility.GetExtension(url)))
            {
            case ImagesUtility.ExtensionGroups.Flash:
                WriteFlash(url, writer);
                return;

            case ImagesUtility.ExtensionGroups.Video:
                WriteMovie(url, writer);
                return;

            case ImagesUtility.ExtensionGroups.Audio:
                WriteAudio(url, writer);
                return;

            case ImagesUtility.ExtensionGroups.ClientCode:
            case ImagesUtility.ExtensionGroups.Compressed:
            case ImagesUtility.ExtensionGroups.Excel:
            case ImagesUtility.ExtensionGroups.Pdf:
            case ImagesUtility.ExtensionGroups.ServerCode:
            case ImagesUtility.ExtensionGroups.Text:
            case ImagesUtility.ExtensionGroups.Word:
                WriteUrl(item, propertyName, CssClass, writer, url);
                return;

            case ImagesUtility.ExtensionGroups.Images:
            default:
                var sizes = DisplayableImageAttribute.GetSizes(PreferredSize);
                DisplayableImageAttribute.WriteImage(item, propertyName, sizes, (AltSource != null ? item[AltSource] as string : null) ?? alt, CssClass, writer);
                return;
            }
        }
        public virtual void Write(ContentItem item, string propertyName, TextWriter writer)
        {
            string url = item[propertyName] as string;

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

            string extension = VirtualPathUtility.GetExtension(url);

            switch (ImagesUtility.GetExtensionGroup(extension))
            {
            case ImagesUtility.ExtensionGroups.Images:
                DisplayableImageAttribute.WriteImage(item, propertyName, PreferredSize, alt, CssClass, writer);
                return;

            default:
                WriteUrl(item, propertyName, cssClass, writer, url);
                return;
            }
        }
        private ImageViewModel FileToImageViewModel(FileData file)
        {
            string url       = null;
            var    extension = VirtualPathUtility.GetExtension(file.Name);
            string path      = file.VirtualPath;

            if (!String.IsNullOrEmpty(path))
            {
                if (path.Substring(0, 1) != "/")
                {
                    path = "/" + path;
                }
                path = "~" + path;
            }
            if (ImagesUtility.GetExtensionGroup(extension) == ImagesUtility.ExtensionGroups.Images)
            {
                url = DependencyResolver.Current.Get <IExternalWebLinkResolver>().GetPublicUrl(path);
            }
            return(new ImageViewModel(file.Name, path, "f")
            {
                ImageUrl = url, FileDate = file.Created, FileDateStr = file.Created.ToShortDateString()
            });
        }