예제 #1
0
        /// <summary>
        /// 从设置信息中的RootUrl中取得地址,并结合发布系统和相对地址,得到能够运行动态文件的地址。
        /// </summary>
        public static string GetRootUrlByPublishmentSystemId(PublishmentSystemInfo psInfo, string requestPath)
        {
            if (psInfo == null)
            {
                var publishmentSystemId = PathUtility.GetCurrentPublishmentSystemId();
                psInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
            }
            //string url = ConfigUtils.Instance.ApplicationPath;
            var url = PageUtils.GetRootUrl(string.Empty);

            if (url.EndsWith("/"))
            {
                url = url.Substring(0, url.Length - 1);
            }
            url += "/" + psInfo.PublishmentSystemDir;

            if (requestPath != null && requestPath.Trim().Length > 0)
            {
                if (requestPath.StartsWith("/"))
                {
                    requestPath = requestPath.Substring(1);
                }
                if (requestPath.EndsWith("/"))
                {
                    requestPath = requestPath.Substring(0, requestPath.Length - 1);
                }
                url = url + "/" + requestPath;
            }
            return(url);
        }
예제 #2
0
        public static string GetPublishmentSystemVirtualUrlByAbsoluteUrl(PublishmentSystemInfo publishmentSystemInfo, string absoluteUrl)
        {
            if (publishmentSystemInfo == null)
            {
                var publishmentSystemId = PathUtility.GetCurrentPublishmentSystemId();
                publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
            }
            if (!string.IsNullOrEmpty(absoluteUrl))
            {
                if (PageUtils.IsProtocolUrl(absoluteUrl) || absoluteUrl.StartsWith("/"))
                {
                    absoluteUrl = absoluteUrl.ToLower();
                    var publishmentSystemUrl = GetPublishmentSystemUrl(publishmentSystemInfo, string.Empty).ToLower();

                    if (PageUtils.IsProtocolUrl(absoluteUrl))
                    {
                        publishmentSystemUrl = PageUtils.AddProtocolToUrl(publishmentSystemUrl);
                    }

                    absoluteUrl = StringUtils.ReplaceFirst(publishmentSystemUrl, absoluteUrl, string.Empty);
                }
                else if (absoluteUrl.StartsWith("."))
                {
                    absoluteUrl = absoluteUrl.Replace("../", string.Empty);
                    absoluteUrl = absoluteUrl.Replace("./", string.Empty);
                }
                return(PageUtils.Combine("@", absoluteUrl));
            }
            else
            {
                return(string.Empty);
            }
        }
예제 #3
0
 //level=0代表站点根目录,1代表下一级目标。。。返回代码类似../images/pic.jpg
 public static string GetPublishmentSystemUrlOfRelatedByPhysicalPath(PublishmentSystemInfo publishmentSystemInfo, string physicalPath, int level)
 {
     if (publishmentSystemInfo == null)
     {
         var publishmentSystemId = PathUtility.GetCurrentPublishmentSystemId();
         publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
     }
     if (!string.IsNullOrEmpty(physicalPath))
     {
         var publishmentSystemPath = PathUtility.GetPublishmentSystemPath(publishmentSystemInfo);
         var requestPath           = physicalPath.ToLower().Replace(publishmentSystemPath.ToLower(), string.Empty);
         requestPath = requestPath.Replace(PathUtils.SeparatorChar, PageUtils.SeparatorChar);
         requestPath = requestPath.Trim(PageUtils.SeparatorChar);
         if (level > 0)
         {
             for (var i = 0; i < level; i++)
             {
                 requestPath = "../" + requestPath;
             }
         }
         return(requestPath);
     }
     else
     {
         return(string.Empty);
     }
 }
예제 #4
0
 public static string GetPublishmentSystemVirtualUrlByPhysicalPath(PublishmentSystemInfo publishmentSystemInfo, string physicalPath)
 {
     if (publishmentSystemInfo == null)
     {
         var publishmentSystemId = PathUtility.GetCurrentPublishmentSystemId();
         publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
     }
     if (!string.IsNullOrEmpty(physicalPath))
     {
         var publishmentSystemPath = PathUtility.GetPublishmentSystemPath(publishmentSystemInfo);
         var requestPath           = physicalPath.ToLower().Replace(publishmentSystemPath.ToLower(), string.Empty);
         requestPath = requestPath.Replace(PathUtils.SeparatorChar, PageUtils.SeparatorChar);
         return(PageUtils.Combine("@", requestPath));
     }
     else
     {
         return(string.Empty);
     }
 }
예제 #5
0
 //返回代码类似/dev/site/images/pic.jpg
 public static string GetPublishmentSystemUrlByPhysicalPath(PublishmentSystemInfo publishmentSystemInfo, string physicalPath)
 {
     if (publishmentSystemInfo == null)
     {
         var publishmentSystemId = PathUtility.GetCurrentPublishmentSystemId();
         publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
     }
     if (!string.IsNullOrEmpty(physicalPath))
     {
         var    publishmentSystemPath = PathUtility.GetPublishmentSystemPath(publishmentSystemInfo);
         string requestPath;
         if (physicalPath.StartsWith(publishmentSystemPath))
         {
             requestPath = StringUtils.ReplaceStartsWith(physicalPath, publishmentSystemPath, string.Empty);
         }
         else
         {
             requestPath = physicalPath.ToLower().Replace(publishmentSystemPath.ToLower(), string.Empty);
         }
         requestPath = requestPath.Replace(PathUtils.SeparatorChar, PageUtils.SeparatorChar);
         return(GetPublishmentSystemUrl(publishmentSystemInfo, requestPath));
     }
     return(publishmentSystemInfo.PublishmentSystemUrl);
 }
예제 #6
0
        public static VisualInfo GetInstance()
        {
            var visualInfo = new VisualInfo();

            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["s"]))
            {
                visualInfo.publishmentSystemID = TranslateUtils.ToInt(HttpContext.Current.Request.QueryString["s"]);
            }
            if (visualInfo.publishmentSystemID == 0)
            {
                visualInfo.publishmentSystemID = PathUtility.GetCurrentPublishmentSystemId();
            }
            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["n"]))
            {
                visualInfo.channelID = TranslateUtils.ToInt(HttpContext.Current.Request.QueryString["n"]);
            }
            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["c"]))
            {
                visualInfo.contentID = TranslateUtils.ToInt(HttpContext.Current.Request.QueryString["c"]);
            }
            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["f"]))
            {
                visualInfo.fileTemplateID = TranslateUtils.ToInt(HttpContext.Current.Request.QueryString["f"]);
            }
            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["p"]))
            {
                visualInfo.pageIndex = TranslateUtils.ToInt(HttpContext.Current.Request.QueryString["p"]);
            }
            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["isPreview"]))
            {
                visualInfo.isPreview = TranslateUtils.ToBool(HttpContext.Current.Request.QueryString["isPreview"]);
                if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["previewID"]))
                {
                    visualInfo.contentID = TranslateUtils.ToInt(HttpContext.Current.Request.QueryString["previewID"]);//编辑界面预览
                }
            }

            if (visualInfo.channelID > 0)
            {
                visualInfo.templateType = ETemplateType.ChannelTemplate;
            }
            if (visualInfo.contentID > 0 || visualInfo.isPreview)
            {
                visualInfo.templateType = ETemplateType.ContentTemplate;
            }
            if (visualInfo.fileTemplateID > 0)
            {
                visualInfo.templateType = ETemplateType.FileTemplate;
            }

            if (visualInfo.channelID == 0)
            {
                visualInfo.channelID = visualInfo.publishmentSystemID;
            }

            var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(visualInfo.publishmentSystemID);

            if (visualInfo.templateType == ETemplateType.IndexPageTemplate)
            {
                var templateInfo   = TemplateManager.GetTemplateInfo(visualInfo.publishmentSystemID, 0, ETemplateType.IndexPageTemplate);
                var isHeadquarters = publishmentSystemInfo.IsHeadquarters;
                visualInfo.filePath = PathUtility.GetIndexPageFilePath(publishmentSystemInfo, templateInfo.CreatedFileFullName, isHeadquarters, visualInfo.pageIndex);
            }
            else if (visualInfo.templateType == ETemplateType.ChannelTemplate)
            {
                visualInfo.filePath = PathUtility.GetChannelPageFilePath(publishmentSystemInfo, visualInfo.channelID, visualInfo.pageIndex);
            }
            else if (visualInfo.templateType == ETemplateType.ContentTemplate)
            {
                visualInfo.filePath = PathUtility.GetContentPageFilePath(publishmentSystemInfo, visualInfo.channelID, visualInfo.contentID, visualInfo.pageIndex);
            }
            else if (visualInfo.templateType == ETemplateType.FileTemplate)
            {
                var templateInfo = TemplateManager.GetTemplateInfo(visualInfo.publishmentSystemID, visualInfo.fileTemplateID);
                visualInfo.filePath = PathUtility.MapPath(publishmentSystemInfo, templateInfo.CreatedFileFullName);
            }

            return(visualInfo);
        }