K_Reverter的网页开发记录

要么不做,要么就当作艺术品来做!

导航

添加了一个照片发布通知功能

我觉得DotText的照片发布很奇怪,发布之后,首页除了能在相册列表里面看到照片多了一张之外,什么都看不到,很不明显,我倒很欣赏ChinaRen校友录,里面的班级成员发布照片的时候,就会自动的添加一个留言,上面有照片预览什么的,非常方便,所以就移植到DotText上面来了,现在已经移植完成,主要实现代码如下:
 1///这是Dottext.Framework的Images对象的静态方法
 2///添加HttpContext context参数是为了获取图片路径

 3        public static int InsertImage(Dottext.Framework.Components.Image _image,byte[] Buffer,HttpContext context)
 4        
{
 5            if
(SaveImage(Buffer,_image.OriginalFilePath))
 6            
{
 7                MakeAlbumImages(ref
 _image);
 8                _image.ImageID=
DTOProvider.Instance().InsertImage(_image);
 9

10                if
(_image.IsActive)
11                
{
12                    Entry entry=new
 Entry(PostType.BlogPost);
13                    entry.AllowComments=true
;
14                    entry.Author=
Config.CurrentBlog().Author;
15                    entry.Email=
Config.CurrentBlog().Email;
16                    entry.BlogID=
_image.BlogID;
17                    entry.Body=String.Format(Config.Settings.GalleriesAlertFormat,Config.CurrentBlog().FullyQualifiedUrl+"gallery/image/"+_image.ImageID+".aspx",Images.HttpGalleryFilePath(context,_image.CategoryID)+
_image.ThumbNailFile,_image.Title);
18//这一语句是设置通知的内容,通知以随笔的形式添加到首页

19                    entry.DateCreated=DateTime.Now;
20                    entry.DateUpdated=
DateTime.Now;
21                    entry.Description=
_image.Title;
22                    entry.DisplayOnHomePage=true
;
23                    entry.IsActive=true
;
24                    entry.IsAggregated=true
;
25                    entry.IncludeInMainSyndication=true
;
26                    entry.Link="#"
;
27                    entry.Title="上传新照片("+_image.Title+")"
;
28                    entry.TitleUrl=Config.CurrentBlog().FullyQualifiedUrl+"gallery/image/"+_image.ImageID+".aspx"
;
29
                    DTOProvider.Instance().Create(entry);
30                }

31                return _image.ImageID;
32            }

33            return -1;
34        }

以上代码中entry就是根据照片创建的一个随笔对象,29行将此随笔添加到数据库中,

如果要设置随笔的内容格式,可以通过Web.Config中的以下格式来设置

  <GalleriesAlertFormat>&lt;a href="{0}"&gt;&lt;img src="{1}" title="{2}" style="solid 1 black" /&gt;&lt;/a&gt;</GalleriesAlertFormat>

GalleriesAlertFormat是logConfigurationSettings的一个子节点,其内容就是随笔的内容格式,{0}是图片浏览路径,{1}是图片缩略图路径,{2}是图片说明,也可以不设置这个节点,因为已经设置默认值

当前不支持这个关闭本功能的开关

posted on 2005-09-18 16:19  K_Reverter  阅读(206)  评论(0编辑  收藏  举报