コード例 #1
0
ファイル: ContentUtility.cs プロジェクト: zxbe/cms
        public static void PutImagePaths(SiteInfo siteInfo, ContentInfo contentInfo, NameValueCollection collection)
        {
            if (contentInfo == null)
            {
                return;
            }

            var imageUrl = contentInfo.GetString(BackgroundContentAttribute.ImageUrl);
            var videoUrl = contentInfo.GetString(BackgroundContentAttribute.VideoUrl);
            var fileUrl  = contentInfo.GetString(BackgroundContentAttribute.FileUrl);
            var content  = contentInfo.GetString(BackgroundContentAttribute.Content);

            if (!string.IsNullOrEmpty(imageUrl) && PageUtility.IsVirtualUrl(imageUrl))
            {
                collection[imageUrl] = PathUtility.MapPath(siteInfo, imageUrl);
            }
            if (!string.IsNullOrEmpty(videoUrl) && PageUtility.IsVirtualUrl(videoUrl))
            {
                collection[videoUrl] = PathUtility.MapPath(siteInfo, videoUrl);
            }
            if (!string.IsNullOrEmpty(fileUrl) && PageUtility.IsVirtualUrl(fileUrl))
            {
                collection[fileUrl] = PathUtility.MapPath(siteInfo, fileUrl);
            }

            var srcList = RegexUtils.GetOriginalImageSrcs(content);

            foreach (var src in srcList)
            {
                if (PageUtility.IsVirtualUrl(src))
                {
                    collection[src] = PathUtility.MapPath(siteInfo, src);
                }
            }
        }
コード例 #2
0
        public static void MoveFileByVirtaulUrl(SiteInfo sourceSiteInfo, SiteInfo destSiteInfo, string fileVirtaulUrl)
        {
            if (string.IsNullOrEmpty(fileVirtaulUrl) || sourceSiteInfo.Id == destSiteInfo.Id)
            {
                return;
            }

            try
            {
                if (PageUtility.IsVirtualUrl(fileVirtaulUrl))
                {
                    MoveFile(sourceSiteInfo, destSiteInfo, fileVirtaulUrl);
                }
            }
            catch
            {
                // ignored
            }
        }
コード例 #3
0
ファイル: FileUtility.cs プロジェクト: yankaics/cms-1
        public static void MoveFileByVirtaulUrl(PublishmentSystemInfo sourcePublishmentSystemInfo, PublishmentSystemInfo destPublishmentSystemInfo, string fileVirtaulUrl)
        {
            if (string.IsNullOrEmpty(fileVirtaulUrl) || sourcePublishmentSystemInfo.PublishmentSystemId == destPublishmentSystemInfo.PublishmentSystemId)
            {
                return;
            }

            try
            {
                if (PageUtility.IsVirtualUrl(fileVirtaulUrl))
                {
                    MoveFile(sourcePublishmentSystemInfo, destPublishmentSystemInfo, fileVirtaulUrl);
                }
            }
            catch
            {
                // ignored
            }
        }
コード例 #4
0
 public static void PutImagePaths(PublishmentSystemInfo publishmentSystemInfo, BackgroundContentInfo contentInfo, NameValueCollection collection)
 {
     if (contentInfo != null)
     {
         //如果是图片模型
         var nodeInfo = DataProvider.NodeDao.GetNodeInfo(contentInfo.NodeId);
         if (EContentModelTypeUtils.IsPhoto(nodeInfo.ContentModelId))
         {
             var photoInfoList = DataProvider.PhotoDao.GetPhotoInfoList(publishmentSystemInfo.PublishmentSystemId, contentInfo.Id);
             foreach (var photoInfo in photoInfoList)
             {
                 collection[photoInfo.SmallUrl]  = PathUtility.MapPath(publishmentSystemInfo, photoInfo.SmallUrl);
                 collection[photoInfo.MiddleUrl] = PathUtility.MapPath(publishmentSystemInfo, photoInfo.MiddleUrl);
                 collection[photoInfo.LargeUrl]  = PathUtility.MapPath(publishmentSystemInfo, photoInfo.LargeUrl);
             }
         }
         else
         {
             if (!string.IsNullOrEmpty(contentInfo.ImageUrl) && PageUtility.IsVirtualUrl(contentInfo.ImageUrl))
             {
                 collection[contentInfo.ImageUrl] = PathUtility.MapPath(publishmentSystemInfo, contentInfo.ImageUrl);
             }
             if (!string.IsNullOrEmpty(contentInfo.VideoUrl) && PageUtility.IsVirtualUrl(contentInfo.VideoUrl))
             {
                 collection[contentInfo.VideoUrl] = PathUtility.MapPath(publishmentSystemInfo, contentInfo.VideoUrl);
             }
             if (!string.IsNullOrEmpty(contentInfo.FileUrl) && PageUtility.IsVirtualUrl(contentInfo.FileUrl))
             {
                 collection[contentInfo.FileUrl] = PathUtility.MapPath(publishmentSystemInfo, contentInfo.FileUrl);
             }
         }
         var srcArrayList = RegexUtils.GetOriginalImageSrcs(contentInfo.Content);
         foreach (string src in srcArrayList)
         {
             if (PageUtility.IsVirtualUrl(src))
             {
                 collection[src] = PathUtility.MapPath(publishmentSystemInfo, src);
             }
         }
     }
 }
コード例 #5
0
        public static void MoveFileByContentInfo(SiteInfo sourceSiteInfo, SiteInfo destSiteInfo, ContentInfo contentInfo)
        {
            if (contentInfo == null || sourceSiteInfo.Id == destSiteInfo.Id)
            {
                return;
            }

            try
            {
                var fileUrls = new List <string>
                {
                    contentInfo.GetString(BackgroundContentAttribute.ImageUrl),
                    contentInfo.GetString(BackgroundContentAttribute.VideoUrl),
                    contentInfo.GetString(BackgroundContentAttribute.FileUrl)
                };

                foreach (var url in TranslateUtils.StringCollectionToStringList(contentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl))))
                {
                    if (!fileUrls.Contains(url))
                    {
                        fileUrls.Add(url);
                    }
                }
                foreach (var url in TranslateUtils.StringCollectionToStringList(contentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.VideoUrl))))
                {
                    if (!fileUrls.Contains(url))
                    {
                        fileUrls.Add(url);
                    }
                }
                foreach (var url in TranslateUtils.StringCollectionToStringList(contentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl))))
                {
                    if (!fileUrls.Contains(url))
                    {
                        fileUrls.Add(url);
                    }
                }
                foreach (var url in RegexUtils.GetOriginalImageSrcs(contentInfo.GetString(BackgroundContentAttribute.Content)))
                {
                    if (!fileUrls.Contains(url))
                    {
                        fileUrls.Add(url);
                    }
                }
                foreach (var url in RegexUtils.GetOriginalLinkHrefs(contentInfo.GetString(BackgroundContentAttribute.Content)))
                {
                    if (!fileUrls.Contains(url) && PageUtils.IsVirtualUrl(url))
                    {
                        fileUrls.Add(url);
                    }
                }

                foreach (var fileUrl in fileUrls)
                {
                    if (!string.IsNullOrEmpty(fileUrl) && PageUtility.IsVirtualUrl(fileUrl))
                    {
                        MoveFile(sourceSiteInfo, destSiteInfo, fileUrl);
                    }
                }
            }
            catch
            {
                // ignored
            }
        }