Esempio n. 1
0
        public static SEOData GetByID(int SEODataID, IEnumerable <string> includeList = null)
        {
            SEOData obj = null;
            string  key = cacheKeyPrefix + SEODataID + GetCacheIncludeText(includeList);

            SEOData tmpClass = null;

            if (Cache.IsEnabled)
            {
                if (Cache.IsEmptyCacheItem(key))
                {
                    return(null);
                }
                tmpClass = Cache[key] as SEOData;
            }

            if (tmpClass != null)
            {
                obj = tmpClass;
            }
            else
            {
                using (Entities entity = new Entities())
                {
                    IQueryable <SEOData> itemQuery = AddIncludes(entity.SEOData, includeList);
                    obj = itemQuery.FirstOrDefault(n => n.SEODataID == SEODataID);
                }
                Cache.Store(key, obj);
            }

            return(obj);
        }
Esempio n. 2
0
 public SEOData(SEOData objectToCopy)
 {
     Approved          = objectToCopy.Approved;
     ApprovedSEODataID = objectToCopy.ApprovedSEODataID;
     DateCreated       = objectToCopy.DateCreated;
     DateLastUpdated   = objectToCopy.DateLastUpdated;
     Description       = objectToCopy.Description;
     FriendlyFilename  = objectToCopy.FriendlyFilename;
     Keywords          = objectToCopy.Keywords;
     LanguageID        = objectToCopy.LanguageID;
     PageURL           = objectToCopy.PageURL;
     SEODataID         = objectToCopy.SEODataID;
     Title             = objectToCopy.Title;
 }
Esempio n. 3
0
        /// <summary>
        /// Gets the SEO for display - either the one specified for the page (if any) or the default setup for the site (if any)
        /// </summary>
        /// <param name="urlPath">Rooted path (starts with "~/")</param>
        /// <param name="queryStringItems"></param>
        /// <returns></returns>
        public static SEOData GetSEOForSpecificPath(string urlPath, string queryStringItems)
        {
            SEOData obj;
            int     currentLanguageID = Helpers.GetCurrentLanguage().LanguageID;
            string  key = cacheKeyPrefix + "GetSEOForSpecificPath_" + urlPath + "_" + queryStringItems + "_" + currentLanguageID;

            SEOData tmpClass = null;

            if (Cache.IsEnabled)
            {
                if (Cache[key] == "NULL")
                {
                    return(null);
                }
                tmpClass = Cache[key] as SEOData;
            }

            if (tmpClass != null)
            {
                obj = tmpClass;
            }
            else
            {
                List <SEOData> setups = new List <SEOData>();
                using (Entities entity = new Entities())
                {
                    setups = entity.SEOComponent_SitePageSEOSetupForOutput((urlPath.StartsWith("~/") ? urlPath : "~/" + urlPath), queryStringItems).ToList();
                }
                //Get most recent for current language
                //If no SEO data for language, pull in for default language
                //Lastly, if still null, get most recent for no language
                obj = (setups.LastOrDefault(s => s.LanguageID == currentLanguageID) ?? setups.LastOrDefault(s => s.LanguageID == Helpers.GetDefaultLanguageID())) ?? setups.LastOrDefault(s => !s.LanguageID.HasValue);
                if (obj == null)
                {
                    Cache.Store(key, "NULL");
                }
                else
                {
                    Cache.Store(key, obj);
                }
            }
            return(obj);
        }
Esempio n. 4
0
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     if (Master != null)
     {
         SetCssAndJs();
         if (m_AdditionalJavaScriptFiles != null)
         {
             string masterPageScript = ((Literal)Master.FindControl("uxJavaScripts")).Text;
             ((Literal)Master.FindControl("uxJavaScripts")).Text = masterPageScript + (String.IsNullOrEmpty(masterPageScript) ? "" : ",") + m_AdditionalJavaScriptFiles.Text;
             m_AdditionalJavaScriptFiles.Visible = false;
         }
         if (m_AdditionalCssFiles != null)
         {
             string masterPageCss = ((HtmlLink)Master.FindControl("uxCSSFiles")).Href;
             ((HtmlLink)Master.FindControl("uxCSSFiles")).Href = masterPageCss + (String.IsNullOrEmpty(masterPageCss) ? "" : ",") + m_AdditionalCssFiles.Attributes["href"];
             m_AdditionalCssFiles.Visible = false;
         }
     }
     SetComponentInformation();
     Classes.SEOComponent.SEOData seoData = Classes.SEOComponent.SEOData.GetSEOForSpecificPath(Request.AppRelativeCurrentExecutionFilePath, Request.QueryString.ToString());
     if ((!String.IsNullOrEmpty(Request.QueryString["filename"])) || (seoData != null && !String.IsNullOrEmpty(seoData.FriendlyFilename)))
     {
         HtmlLink canon = new HtmlLink();
         canon.Attributes["rel"] = "canonical";
         if (!String.IsNullOrEmpty(Request.QueryString["filename"]))
         {
             canon.Href = Helpers.RootPath + MicrositePath + (!String.IsNullOrWhiteSpace(MicrositePath) ? "/" : "") + Request.QueryString["filename"].ToLower();
         }
         else
         {
             canon.Href = Helpers.RootPath + MicrositePath + (!String.IsNullOrWhiteSpace(MicrositePath) ? "/" : "") + seoData.FriendlyFilename;
         }
         Header.Controls.Add(canon);
     }
     ClientScript.RegisterStartupScript(Page.GetType(), "ClearFormAction", "$(\"form\").attr(\"action\", \"\");", true);
 }