/// <summary> /// Sets the headers. /// </summary> private void SetHeaders() { string cacheKey = CmsCache.CreateCacheKey("page-headers", CMSContext.Current.PageId.ToString()); // check cache first object cachedObject = CmsCache.Get(cacheKey); string[] headersArray = null; if (cachedObject != null) { headersArray = (string[])cachedObject; } // Load the object if (headersArray == null) { lock (CmsCache.GetLock(cacheKey)) { cachedObject = CmsCache.Get(cacheKey); if (cachedObject != null) { headersArray = (string[])cachedObject; } else { using (IDataReader reader = PageAttributes.GetByPageId(CMSContext.Current.PageId)) { if (reader.Read()) { headersArray = new string[] { (string)reader["MetaKeys"], (string)reader["MetaDescriptions"], (string)reader["Title"] }; CmsCache.Insert(cacheKey, headersArray, CmsConfiguration.Instance.Cache.PageDocumentTimeout); } reader.Close(); } } } } if (headersArray != null) { MetaKeyWord.Attributes.Add("content", headersArray[0]); MetaKeyWord.Attributes.Add("name", "keywords"); MetaDescription.Attributes.Add("content", headersArray[1]); MetaDescription.Attributes.Add("name", "description"); Head1.Title = headersArray[2]; Page.Title = headersArray[2]; // Set footer as well PageInclude.Text = GlobalVariable.GetVariable("page_include", CMSContext.Current.SiteId); } }
/// <summary> /// Binds the form. /// </summary> private void BindForm() { bool pageExists = false; if (PageId > 0) { using (IDataReader reader = FileTreeItem.GetItemById(PageId)) { if (reader.Read()) { pageExists = true; Name.Text = reader["Name"].ToString(); IsDefault.IsSelected = (bool)reader["IsDefault"]; MasterPageText.Text = (reader["MasterPage"] != DBNull.Value) && (reader["MasterPage"] != null) ? (string)reader["MasterPage"] : String.Empty; } reader.Close(); } // Load meta attributes using (IDataReader reader = PageAttributes.GetByPageId(PageId)) { if (reader.Read()) { txtTitle.Text = (string)reader["Title"]; txtKeywords.Text = (string)reader["MetaKeys"]; txtDescription.Text = (string)reader["MetaDescriptions"]; } else { // add default site attributes PageAttributes.Add(PageId, GlobalVariable.GetVariable(_GlobalVariableTitleKey, SiteId), GlobalVariable.GetVariable(_GlobalVariableMetaKeywordsKey, SiteId), GlobalVariable.GetVariable(_GlobalVariableMetaDescriptionKey, SiteId)); txtTitle.Text = GlobalVariable.GetVariable(_GlobalVariableTitleKey, SiteId); txtKeywords.Text = GlobalVariable.GetVariable(_GlobalVariableMetaKeywordsKey, SiteId); txtDescription.Text = GlobalVariable.GetVariable(_GlobalVariableMetaDescriptionKey, SiteId); } reader.Close(); } } if (!pageExists) { // update UI for creating a new page BindParentFolderList(); ParentFolderRow.Visible = true; } // since mater page is not used anywhere for now, hide it alway MasterPageRow.Visible = false; }