コード例 #1
0
ファイル: SiteHelpers.cs プロジェクト: VladasRD/B972-Portal
 public static string GetContentLink(Models.ContentHead head)
 {            
     if (!String.IsNullOrEmpty(head.ExternalLinkUrl))
         return head.ExternalLinkUrl;
     
     return head.Location + head.CanonicalName;
 }
コード例 #2
0
        public void OnGet(Guid id)
        {
            HEAD = _siteService.GetContent(id.ToString());
            if (HEAD == null)
            {
                throw new Exception("page not found");
            }

            LogPageView();

            CONTENT_URL = Request.Scheme + "://" + Request.Host.Host + (Request.Host.Port != 80?":" + Request.Host.Port:"") + HEAD.Location + HEAD.CanonicalName;
            CONTENT     = HEAD.CONTENT;
        }
コード例 #3
0
        private bool SetThumbRedirectUrl(HttpContext context, Models.ContentHead head)
        {
            var imgUrl = head.ThumbFilePath.Replace("?asThumb=true", "");

            if (context.Request.Query.ContainsKey("asImg"))
            {
                context.Request.Path = imgUrl;
                return(true);
            }
            if (!context.Request.Query.ContainsKey("asThumb"))
            {
                return(false);
            }
            context.Request.Path        = imgUrl;
            context.Request.QueryString = new QueryString("?asThumb=true");
            return(true);
        }
コード例 #4
0
        private void SetRedirectPath(HttpContext context)
        {
            //string fullUrl = BoxLib.RemoveAppNameFromUrl(context.Request.Path);
            string url              = context.Request.Path.ToUriComponent();;
            string redirectUrl      = null;
            bool   useThumbRedirect = false;

            if (url.StartsWith("/where-is-my-db.htm") || url.StartsWith("/files/") || url.StartsWith("/box_templates/"))
            {
                return;
            }

            // if true, can see not published contents
            bool canSeeOnlyPublished = GetShowOnlyPublished(context, url);

            if (!context.Request.QueryString.HasValue)
            {
                redirectCache.TryGetValue(url, out redirectUrl);
            }

            if (redirectUrl == null)
            {
                Services.CMSService cms = context.RequestServices.GetService(typeof(Box.CMS.Services.CMSService)) as Services.CMSService;

                Models.ContentHead c = null;
                try
                {
                    c = cms.GetContentHeadByUrlAndKind(url, null, canSeeOnlyPublished);
                }
                catch (System.Exception ex)
                {
                    // var SQLexception = Box.Core.Services.SecurityService.GetSqlException(ex);
                    // if (SQLexception != null && !Box.Core.Services.SecurityService.IsDebug)
                    //     app.Context.Response.Redirect("~/where-is-my-db.htm#" + SQLexception.Number);
                    // else
                    //     throw ex;
                    throw ex;
                }

                if (c == null)
                {
                    return;
                }

                useThumbRedirect = SetThumbRedirectUrl(context, c);

                if (!useThumbRedirect)
                {
                    redirectUrl = "/box_templates/" + c.Kind + "/" + c.ContentUId;
                    // only add at cache published urls
                    if (canSeeOnlyPublished)
                    {
                        redirectCache.TryAdd(url, redirectUrl);
                    }
                }
            }

            if (!useThumbRedirect)
            {
                context.Request.Path = redirectUrl;
                // context.Request.HttpContext.Items["_boxOriginalUrl"] = url;
            }
        }
コード例 #5
0
ファイル: SiteHelpers.cs プロジェクト: VladasRD/B972-Portal
 public static IHtmlContent ContentLink(Models.ContentHead content)
 {
     return new HtmlString("<a href=\"" + BoxLib.GetContentLink(content) + "\" title=\"" + content.Name + "\">" + content.Name + "</a>");
 }