private void BindWebpage() { Webpage webpage = WebpageDataSource.Load(PageHelper.GetWebpageId()); EditItemLink.Text = webpage.Name; EditItemLink.NavigateUrl = Page.ResolveUrl(string.Format("~/Admin/Website/ContentPages/EditContentPage.aspx?WebpageId={0}", webpage.Id)); }
private List <ListItem> GetListItems(Category category, string field) { if (!_ListItemCache.ContainsKey(field)) { // LIST ITEMS NOT CACHED, CONSTRUCT THEM // SET THE CACHE FLAG TO FALSE IF THE OPTIONS DEPEND ON THE CATEGORY bool enableCache = true; List <ListItem> listItems = new List <ListItem>(); switch (field) { case "displaypage": IList <Webpage> webpages = WebpageDataSource.LoadForWebpageType(WebpageType.CategoryDisplay); foreach (Webpage webpage in webpages) { listItems.Add(new ListItem(webpage.Name, webpage.Id.ToString())); } break; case "visibilityid": listItems.Add(new ListItem("Public", "0")); listItems.Add(new ListItem("Hidden", "1")); listItems.Add(new ListItem("Private", "2")); break; } if (!enableCache) { return(listItems); } _ListItemCache[field] = listItems; } return(_ListItemCache[field]); }
protected void Page_Load(object sender, EventArgs e) { _WebpageId = AbleCommerce.Code.PageHelper.GetWebpageId(); _Webpage = WebpageDataSource.Load(_WebpageId); if (!Page.IsPostBack) { Caption.Text = string.Format(Caption.Text, _Webpage.Name); CategoryTree.SelectedCategories = _Webpage.Categories.ToArray(); } }
protected void BindDisplayPage() { ProductsDefault.DataSource = WebpageDataSource.LoadForWebpageType(WebpageType.ProductDisplay); ProductsDefault.DataBind(); ListItem selectedItem = ProductsDefault.Items.FindByValue(_Settings.ProductWebpageId.ToString()); if (selectedItem != null) { ProductsDefault.SelectedIndex = ProductsDefault.Items.IndexOf(selectedItem); } }
protected void BindDisplayPage() { CategoriesDefault.DataSource = WebpageDataSource.LoadForWebpageType(WebpageType.CategoryDisplay); CategoriesDefault.DataBind(); ListItem selectedItem = null; selectedItem = CategoriesDefault.Items.FindByValue(_Settings.CategoryWebpageId.ToString()); if (selectedItem != null) { CategoriesDefault.SelectedIndex = CategoriesDefault.Items.IndexOf(selectedItem); } }
protected void Update_Click(object sender, EventArgs e) { List <Object> dataKeys = ProductsGrid.GetSelectedDataKeyValues(); foreach (Object dataKey in dataKeys) { int productId = AlwaysConvert.ToInt(dataKey); Product product = ProductDataSource.Load(productId); product.Webpage = WebpageDataSource.Load(AlwaysConvert.ToInt(ProductDisplayPages.SelectedValue)); product.Save(); } ProductsGrid.DataBind(); }
protected void Update_Click(object sender, EventArgs e) { List <Object> dataKeys = CategoriesGrid.GetSelectedDataKeyValues(); foreach (Object dataKey in dataKeys) { int categoryId = AlwaysConvert.ToInt(dataKey); Category category = CategoryDataSource.Load(categoryId); category.Webpage = WebpageDataSource.Load(AlwaysConvert.ToInt(CategoryDisplayPages.SelectedValue)); category.Save(); } CategoriesGrid.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.Caption)) { CaptionLabel.Text = this.Caption; } if (_WebPageId > 0) { _Webpage = WebpageDataSource.Load(_WebPageId); } if (_Webpage != null && !string.IsNullOrEmpty(_Webpage.Description)) { CustomHTMLPanel.Controls.Clear(); CustomHTMLPanel.Controls.Add(new LiteralControl(_Webpage.Description)); } }
private void UpdateDescription() { DisplayPageDescription.Text = " "; if (DisplayPage.SelectedValue != string.Empty) { Webpage page = WebpageDataSource.Load(AlwaysConvert.ToInt(DisplayPage.SelectedValue)); if (page != null) { DisplayPageDescription.Text = page.Summary; } } else { DisplayPageDescription.Text = "Uses the default display page configured for the store."; } }
public static void FindCatalogable(out ICatalogable catalogable, out CatalogNodeType catalogableType) { HttpContext context = HttpContext.Current; if (context != null) { //CHECK FOR LINK int linkId = AbleCommerce.Code.PageHelper.GetLinkId(); Link link = LinkDataSource.Load(linkId); if (link != null) { catalogable = link; catalogableType = CatalogNodeType.Link; return; } //CHECK FOR WEBPAGE int webpageId = AbleCommerce.Code.PageHelper.GetWebpageId(); Webpage webpage = WebpageDataSource.Load(webpageId); if (webpage != null) { catalogable = webpage; catalogableType = CatalogNodeType.Webpage; return; } //CHECK FOR PRODUCT int productId = AbleCommerce.Code.PageHelper.GetProductId(); Product product = ProductDataSource.Load(productId); if (product != null) { catalogable = product; catalogableType = CatalogNodeType.Product; return; } //CHECK FOR CATEGORY int categoryId = AlwaysConvert.ToInt(context.Request.QueryString["CategoryId"]); Category category = CategoryDataSource.Load(categoryId); if (category != null) { catalogable = category; catalogableType = CatalogNodeType.Category; return; } } catalogable = null; catalogableType = CatalogNodeType.Category; return; }
protected void Page_PreInIt() { _category = CategoryDataSource.Load(PageHelper.GetCategoryId()); if (_category != null) { if ((_category.Visibility == CatalogVisibility.Private) && (!AbleContext.Current.User.IsInRole(Role.CatalogAdminRoles))) { Response.Redirect(NavigationHelper.GetHomeUrl()); } } else { NavigationHelper.Trigger404(Response, "Invalid Category"); } // INITIALIZE TO DEFAULT LAYOUT string layout = AbleContext.Current.Store.Settings.CategoriesDefaultLayout; _webpage = _category.Webpage; if (_webpage == null) { _webpage = WebpageDataSource.Load(AbleContext.Current.Store.Settings.CategoryWebpageId); } if (_webpage != null) { // CHECK FOR LAYOUT OVERRIDE if (_webpage.Layout != null) { layout = _webpage.Layout.FilePath; } // CHECK FOR THEME OVERRIDE if (!string.IsNullOrEmpty(_webpage.Theme) && CommerceBuilder.UI.Theme.Exists(_webpage.Theme)) { this.Theme = _webpage.Theme; } } // SET THE LAYOUT if (!string.IsNullOrEmpty(layout)) { this.MasterPageFile = layout; } }
protected void BindDisplayPage() { DisplayPage.DataSource = WebpageDataSource.LoadForWebpageType(WebpageType.CategoryDisplay); DisplayPage.DataBind(); if (!Page.IsPostBack) { Webpage webpage = _Category.Webpage; if (webpage != null) { ListItem selectedItem = DisplayPage.Items.FindByValue(webpage.Id.ToString()); if (selectedItem != null) { DisplayPage.SelectedIndex = DisplayPage.Items.IndexOf(selectedItem); } } } }
protected void WebpagesGrid_RowCommand(object sender, GridViewCommandEventArgs e) { int webPageId = AlwaysConvert.ToInt(e.CommandArgument); if (e.CommandName.ToLower() == "dodelete") { WebpageDataSource.Delete(webPageId); WebpagesGrid.DataBind(); } else if (e.CommandName.ToLower() == "docopy") { Webpage page = Webpage.Copy(webPageId); page.Name = string.Format("Copy of {0}", page.Name); page.Save(); WebpagesGrid.DataBind(); } }
protected void UpdateButton_Click(object sender, EventArgs e) { if (_pageType == PageType.Product) { Product product = ProductDataSource.Load(PageHelper.GetProductId()); product.Webpage = WebpageDataSource.Load(AlwaysConvert.ToInt(DisplayPage.SelectedValue)); product.Save(); Response.Redirect(product.NavigateUrl); } else if (_pageType == PageType.Category) { Category category = CategoryDataSource.Load(PageHelper.GetCategoryId()); category.Webpage = WebpageDataSource.Load(AlwaysConvert.ToInt(DisplayPage.SelectedValue)); category.Save(); Response.Redirect(category.NavigateUrl); } }
protected void Page_PreInit(object sender, EventArgs e) { _webpage = WebpageDataSource.Load(PageHelper.GetWebpageId()); if (_webpage != null) { if ((_webpage.Visibility == CatalogVisibility.Private) && (!AbleContext.Current.User.IsInRole(Role.CatalogAdminRoles))) { if (!IsHomePage()) { Response.Redirect(NavigationHelper.GetHomeUrl()); } else { Server.Transfer(NavigationHelper.GetHomeUrl()); } } } else { NavigationHelper.Trigger404(Response, "Invalid Webpage"); } // INITIALIZE TO DEFAULT LAYOUT string layout = AbleContext.Current.Store.Settings.WebpagesDefaultLayout; // CHECK FOR LAYOUT OVERRIDE if (_webpage.Layout != null) { layout = _webpage.Layout.FilePath; } // CHECK FOR THEME OVERRIDE if (!string.IsNullOrEmpty(_webpage.Theme) && CommerceBuilder.UI.Theme.Exists(_webpage.Theme)) { this.Theme = _webpage.Theme; } // SET THE LAYOUT if (!string.IsNullOrEmpty(layout)) { this.MasterPageFile = layout; } }
private void SaveCategory(object sender, System.EventArgs e) { if (Page.IsValid) { _Category.Name = Name.Text; _Category.Visibility = (CatalogVisibility)Visibility.SelectedIndex; _Category.Webpage = WebpageDataSource.Load(AlwaysConvert.ToInt(DisplayPage.SelectedValue)); _Category.Title = CategoryTitle.Text.Trim(); _Category.MetaDescription = MetaDescriptionValue.Text.Trim(); _Category.MetaKeywords = MetaKeywordsValue.Text.Trim(); _Category.HtmlHead = HtmlHead.Text.Trim(); _Category.ThumbnailUrl = ThumbnailUrl.Text; _Category.ThumbnailAltText = ThumbnailAltText.Text; _Category.CustomUrl = CustomUrl.Text; CustomUrlValidator.OriginalValue = _Category.CustomUrl; _Category.Summary = StringHelper.Truncate(Summary.Text, Summary.MaxLength); _Category.Description = Description.Text; _Category.Save(); } }
protected void WebpagesGrid_RowCommand(object sender, GridViewCommandEventArgs e) { int webPageId = AlwaysConvert.ToInt(e.CommandArgument); Webpage webpage = WebpageDataSource.Load(webPageId); if (e.CommandName.ToLower() == "dodelete") { WebpageDataSource.Delete(webPageId); WebpagesGrid.DataBind(); } else if (e.CommandName.ToLower() == "docopy") { Webpage page = Webpage.Copy(webPageId); page.Name = string.Format("Copy of {0}", page.Name); page.Save(); WebpagesGrid.DataBind(); } else if (e.CommandName.ToLower() == "do_pub") { switch (webpage.Visibility) { case CatalogVisibility.Public: webpage.Visibility = CatalogVisibility.Hidden; break; case CatalogVisibility.Hidden: webpage.Visibility = CatalogVisibility.Private; break; default: webpage.Visibility = CatalogVisibility.Public; break; } webpage.Save(); WebpagesGrid.DataBind(); } }
protected void FinishButton_Click(object sender, System.EventArgs e) { if (Page.IsValid) { Category category = new Category(); category.ParentId = _ParentCategoryId; category.Name = Name.Text; category.Visibility = (CatalogVisibility)Visibility.SelectedIndex; category.Webpage = WebpageDataSource.Load(AlwaysConvert.ToInt(DisplayPage.SelectedValue)); category.ThumbnailUrl = ThumbnailUrl.Text; category.ThumbnailAltText = ThumbnailAltText.Text; category.CustomUrl = CustomUrl.Text; category.Summary = StringHelper.Truncate(Summary.Text, Summary.MaxLength); category.Description = Description.Text; category.Title = CategoryTitle.Text.Trim(); category.MetaDescription = MetaDescriptionValue.Text.Trim(); category.MetaKeywords = MetaKeywordsValue.Text.Trim(); category.HtmlHead = HtmlHead.Text.Trim(); category.Save(); Response.Redirect("~/Admin/Catalog/Browse.aspx?CategoryId=" + _ParentCategoryId.ToString()); } }
protected void Page_Load(object sender, EventArgs e) { _WebpageId = AlwaysConvert.ToInt(Request.QueryString["WebpageId"]); _Webpage = WebpageDataSource.Load(_WebpageId); if (_Webpage == null) { Response.Redirect("Default.aspx"); } if (!Page.IsPostBack) { //INITIALIZE FORM ON FIRST VISIT Name.Focus(); UpdateCaption(); Name.Text = _Webpage.Name; Summary.Text = _Webpage.Summary; SummaryCharCount.Text = (AlwaysConvert.ToInt(SummaryCharCount.Text) - Summary.Text.Length).ToString(); WebpageContent.Text = _Webpage.Description; LayoutList.DataBind(); BindThemes(); string layout = _Webpage.Layout != null ? _Webpage.Layout.FilePath : string.Empty; ListItem item = LayoutList.Items.FindByValue(layout); if (item != null) { item.Selected = true; } Name.Focus(); // SHOW SAVE CONFIRMATION NOTIFICATION IF NEEDED if (Request.UrlReferrer != null && Request.UrlReferrer.AbsolutePath.ToLowerInvariant().EndsWith("addproductpage.aspx")) { SavedMessage.Visible = true; SavedMessage.Text = string.Format(SavedMessage.Text, LocaleHelper.LocalNow); } } AbleCommerce.Code.PageHelper.SetMaxLengthCountDown(Summary, SummaryCharCount); }
protected void DoDelete(CatalogNodeType catalogNodeType, int catalogNodeId) { switch (catalogNodeType) { case CatalogNodeType.Category: Category category = CategoryDataSource.Load(catalogNodeId); if (category != null) { category.Delete(); } break; case CatalogNodeType.Product: Product product = ProductDataSource.Load(catalogNodeId); if (product != null) { product.Delete(); } break; case CatalogNodeType.Webpage: Webpage webpage = WebpageDataSource.Load(catalogNodeId); if ((webpage != null) && (webpage.Categories.Count < 2)) { webpage.Delete(); } break; case CatalogNodeType.Link: Link link = LinkDataSource.Load(catalogNodeId); if ((link != null) && (link.Categories.Count < 2)) { link.Delete(); } break; } CGrid.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { Caption.Text = this.DefaultCaption; int categoryId = this.CategoryId; if (categoryId <= 0) { categoryId = PageHelper.GetCategoryId(); } if (categoryId > 0) { IList <Webpage> webpage = WebpageDataSource.LoadForCategory(categoryId, true, true, DefaultSortOrder, MaxItems, 0); BlogRepeater.DataSource = webpage; BlogRepeater.DataBind(); } else { this.Visible = false; } NoArticlesMessage.Visible = BlogRepeater.Items.Count == 0; }
protected void Page_Load(object sender, EventArgs e) { _WebPageId = AbleCommerce.Code.PageHelper.GetWebpageId(); _Webpage = WebpageDataSource.Load(_WebPageId); if (_Webpage != null) { string durl = "~/Admin/Catalog/EditWebPage.aspx?WebpageId={0}"; durl = string.Format(durl, _WebPageId); string murl = "~/Admin/Catalog/EditWebpageCategories.aspx?WebpageId={0}"; murl = string.Format(murl, _WebPageId); WebpageDetails.NavigateUrl = durl; ManageCategories.NavigateUrl = murl; string confirmationJS = String.Format("return confirm('Are you sure you want to delete {0}');", _Webpage.Name); DeleteWebpage.Attributes.Add("onclick", confirmationJS); Preview.NavigateUrl = UrlGenerator.GetBrowseUrl(AbleCommerce.Code.PageHelper.GetCategoryId(), _WebPageId, CatalogNodeType.Webpage, _Webpage.Name); HighlightMenu(); } else { this.Controls.Clear(); } }
private void SaveProduct() { // get a reference to the loaded product // this assists in file comparions between add/edit page Product product = _Product; // basic product information pane product.Name = Name.Text; product.ManufacturerId = AlwaysConvert.ToInt(ManufacturerList.SelectedValue); product.Price = AlwaysConvert.ToDecimal(Price.Text); product.ModelNumber = ModelNumber.Text; product.MSRP = AlwaysConvert.ToDecimal(Msrp.Text); product.Weight = AlwaysConvert.ToDecimal(Weight.Text); product.CostOfGoods = AlwaysConvert.ToDecimal(CostOfGoods.Text); product.GTIN = Gtin.Text; product.Sku = Sku.Text; product.IsFeatured = IsFeatured.Checked; // descriptions product.Summary = Summary.Text; product.Description = Description.Text; product.ExtendedDescription = ExtendedDescription.Text; // shipping, tax, and inventory product.WarehouseId = AlwaysConvert.ToInt(Warehouse.SelectedValue); product.VendorId = AlwaysConvert.ToInt(Vendor.SelectedValue); product.ShippableId = (byte)AlwaysConvert.ToInt(IsShippable.SelectedValue); product.Length = AlwaysConvert.ToDecimal(Length.Text); product.Width = AlwaysConvert.ToDecimal(Width.Text); product.Height = AlwaysConvert.ToDecimal(Height.Text); product.TaxCodeId = AlwaysConvert.ToInt(TaxCode.SelectedValue); if (CurrentInventoryMode.Visible) { product.InventoryModeId = AlwaysConvert.ToByte(CurrentInventoryMode.SelectedIndex); if (product.InventoryMode == InventoryMode.Product) { product.InStock = AlwaysConvert.ToInt(InStock.Text); product.AvailabilityDate = AvailabilityDate.SelectedDate; product.InStockWarningLevel = AlwaysConvert.ToInt(LowStock.Text); product.AllowBackorder = BackOrder.Checked; } else if (product.InventoryMode == InventoryMode.Variant) { product.AllowBackorder = BackOrder.Checked; } product.EnableRestockNotifications = EnableRestockNotifications.Checked; } // advanced settings product.WrapGroupId = AlwaysConvert.ToInt(WrapGroup.SelectedValue); product.AllowReviews = AllowReviewsPanel.Visible ? AllowReviews.Checked : true; product.Visibility = (CatalogVisibility)Visibility.SelectedIndex; product.HidePrice = HidePrice.Checked; product.Webpage = WebpageDataSource.Load(AlwaysConvert.ToInt(DisplayPage.SelectedValue)); product.IsProhibited = IsProhibited.Checked; product.IsGiftCertificate = GiftCertificate.Checked; product.DisablePurchase = DisablePurchase.Checked; product.UseVariablePrice = UseVariablePrice.Checked; product.MinimumPrice = AlwaysConvert.ToDecimal(MinPrice.Text); product.MaximumPrice = AlwaysConvert.ToDecimal(MaxPrice.Text); product.HandlingCharges = AlwaysConvert.ToDecimal(HandlingCharges.Text); product.MinQuantity = AlwaysConvert.ToInt16(MinQuantity.Text); product.MaxQuantity = AlwaysConvert.ToInt16(MaxQuantity.Text); product.HtmlHead = HtmlHead.Text.Trim(); product.SearchKeywords = SearchKeywords.Text.Trim(); _Product.EnableGroups = AlwaysConvert.ToBool(EnableGroups.SelectedValue, false); _Product.ProductGroups.DeleteAll(); foreach (ListItem item in ProductGroups.Items) { if (item.Selected) { int groupId = AlwaysConvert.ToInt(item.Value); ProductGroup pg = new ProductGroup(_Product, GroupDataSource.Load(groupId)); _Product.ProductGroups.Add(pg); } } // search engines and feeds product.CustomUrl = CustomUrl.Text; CustomUrlValidator.OriginalValue = _Product.CustomUrl; product.ExcludeFromFeed = !IncludeInFeed.Checked; product.Title = ProductTitle.Text.Trim(); product.MetaDescription = MetaDescriptionValue.Text.Trim(); product.MetaKeywords = MetaKeywordsValue.Text.Trim(); product.GoogleCategory = GoogleCategory.Text; product.Condition = Condition.SelectedValue; product.Gender = Gender.SelectedValue; product.AgeGroup = AgeGroup.SelectedValue; product.Color = Color.Text; product.Size = Size.Text; product.AdwordsGrouping = AdwordsGrouping.Text; product.AdwordsLabels = AdwordsLabels.Text; product.ExcludedDestination = ExcludedDestination.SelectedValue; product.AdwordsRedirect = AdwordsRedirect.Text; product.PublishFeedAsVariants = PublishAsVariants.Checked; // TAX CLOUD PRODUCT TIC if (trTIC.Visible && !string.IsNullOrEmpty(HiddenTIC.Value)) { product.TIC = AlwaysConvert.ToInt(HiddenTIC.Value); } else { product.TIC = null; } // save product product.Save(); ModalPopupExtender.Hide(); }
protected void InitializeCatalogItems() { String items = Request.QueryString["Objects"]; if (String.IsNullOrEmpty(items)) { return; } String[] itemsArray = items.Split(','); List <String> categoryIds = new List <String>(); List <String> productIds = new List <String>(); List <String> linkIds = new List <String>(); List <String> webpageIds = new List <String>(); // Sort out items in saperate lists foreach (String item in itemsArray) { String[] itemValues = item.Split(':'); int catalogNodeId = AlwaysConvert.ToInt(itemValues[0]); CatalogNodeType catalogNodeType = (CatalogNodeType)AlwaysConvert.ToByte(itemValues[1]); switch (catalogNodeType) { case CatalogNodeType.Category: categoryIds.Add(catalogNodeId.ToString()); break; case CatalogNodeType.Product: productIds.Add(catalogNodeId.ToString()); break; case CatalogNodeType.Link: linkIds.Add(catalogNodeId.ToString()); break; case CatalogNodeType.Webpage: webpageIds.Add(catalogNodeId.ToString()); break; } } trIncludeContents.Visible = (categoryIds.Count > 0); if (categoryIds.Count > 0) { ICriteria criteria = CommerceBuilder.DomainModel.NHibernateHelper.CreateCriteria <Category>(); criteria.Add(Restrictions.In("Id", categoryIds.ToArray())); _Categories = CategoryDataSource.LoadForCriteria(criteria); if (_Categories != null && _Categories.Count > 0) { foreach (Category category in _Categories) { _CatalogItems.Add(category); } } } if (productIds.Count > 0) { ICriteria criteria = CommerceBuilder.DomainModel.NHibernateHelper.CreateCriteria <Product>(); criteria.Add(Restrictions.In("Id", productIds.ToArray())); _Products = ProductDataSource.LoadForCriteria(criteria); if (_Products != null && _Products.Count > 0) { foreach (Product product in _Products) { _CatalogItems.Add(product); } } } if (linkIds.Count > 0) { ICriteria criteria = CommerceBuilder.DomainModel.NHibernateHelper.CreateCriteria <Link>(); criteria.Add(Restrictions.In("Id", linkIds.ToArray())); _Links = LinkDataSource.LoadForCriteria(criteria); if (_Links != null && _Links.Count > 0) { foreach (Link link in _Links) { _CatalogItems.Add(link); } } } if (webpageIds.Count > 0) { ICriteria criteria = CommerceBuilder.DomainModel.NHibernateHelper.CreateCriteria <Webpage>(); criteria.Add(Restrictions.In("Id", webpageIds.ToArray())); _Webpages = WebpageDataSource.LoadForCriteria(criteria); if (_Webpages != null && _Webpages.Count > 0) { foreach (Webpage webpage in _Webpages) { _CatalogItems.Add(webpage); } } } if (!Page.IsPostBack) { if (_CatalogItems.Count == 1) { ICatalogable catalogable = _CatalogItems[0]; switch (catalogable.Visibility) { case CatalogVisibility.Public: VisPublic.Checked = true; break; case CatalogVisibility.Private: VisPrivate.Checked = true; break; case CatalogVisibility.Hidden: VisHidden.Checked = true; break; default: VisPrivate.Checked = true; break; } } else if (_CatalogItems.Count > 1) { VisPrivate.Checked = false; VisPublic.Checked = false; VisHidden.Checked = false; } } }
protected int GetWebPagesCount(object dataItem) { Theme theme = (Theme)dataItem; return(WebpageDataSource.CountForTheme(theme.Name)); }
protected void Page_Load(object sender, EventArgs e) { // SET THE DEFAULT PAGE SIZE AND ADD A NEW OPTION BASED ON MaxItems parameter value if needed if (!Page.IsPostBack) { CategoryBreadCrumbs1.Visible = this.DisplayBreadCrumbs; } InitializePageSize(); if (IsValidCategory()) { string eventTarget = Request["__EVENTTARGET"]; if (string.IsNullOrEmpty(eventTarget) || !eventTarget.EndsWith("PageSizeOptions")) { PageSizeOptions.ClearSelection(); ListItem item = PageSizeOptions.Items.FindByValue(_pageSize.ToString()); if (item != null) { item.Selected = true; } } if (string.IsNullOrEmpty(eventTarget) || !eventTarget.EndsWith("SortResults")) { string sortOption = Request.QueryString["s"]; if (!string.IsNullOrEmpty(sortOption)) { SortResults.ClearSelection(); ListItem item = SortResults.Items.OfType <ListItem>().FirstOrDefault(x => string.Compare(x.Value, sortOption, StringComparison.InvariantCultureIgnoreCase) == 0); if (item != null) { item.Selected = true; } } } if (!string.IsNullOrEmpty(eventTarget)) { if (eventTarget.EndsWith("PageSizeOptions") || eventTarget.EndsWith("SortResults")) { string url = Request.RawUrl; if (url.Contains("?")) { url = Request.RawUrl.Substring(0, Request.RawUrl.IndexOf("?")); } url += "?s=" + SortResults.SelectedValue; url += "&ps=" + _pageSize.ToString(); Response.Redirect(url); } } Caption.Text = this.DefaultCaption; if (_Category != null) { // use category name if no default name is specified if (string.IsNullOrEmpty(Caption.Text)) { Caption.Text = _Category.Name; } CategoryBreadCrumbs1.CategoryId = this.CategoryId; if (!string.IsNullOrEmpty(_Category.Summary) && ShowSummary) { CategorySummary.Text = _Category.Summary; } if (!string.IsNullOrEmpty(_Category.Description) && ShowDescription) { CategoryDescriptionPanel.Visible = true; CategoryDescription.Text = _Category.Description; } else { CategoryDescriptionPanel.Visible = false; } } else { // IT IS ROOT CATEGORY CategoryBreadCrumbs1.CategoryId = this.CategoryId; if (ShowSummary) { CategorySummary.Text = DefaultCategorySummary; } } if (_Category != null) { int count = WebpageDataSource.CountForCategory(_Category.Id, true, true); if (count > 0) { _currentPageIndex = AlwaysConvert.ToInt(Request.QueryString["p"]); if (_pageSize == 0) { _lastPageIndex = 0; } else { _lastPageIndex = ((int)Math.Ceiling(((double)count / (double)_pageSize))) - 1; } CatalogNodeList.DataSource = WebpageDataSource.LoadForCategory(_Category.Id, true, true, SortResults.SelectedValue, _pageSize, (_currentPageIndex * _pageSize)); CatalogNodeList.DataBind(); int startRowIndex = (_pageSize * _currentPageIndex); int endRowIndex = startRowIndex + _pageSize; if (endRowIndex > count || endRowIndex == 0) { endRowIndex = count; } if (count == 0) { startRowIndex = -1; } ResultIndexMessage.Text = string.Format(ResultIndexMessage.Text, (startRowIndex + 1), endRowIndex, count); ResultIndexMessage.Text = string.Format(ResultIndexMessage.Text, (startRowIndex + 1), endRowIndex, count); BindPagingControls(); } else { phEmptyCategory.Visible = true; } AbleCommerce.Code.PageVisitHelper.RegisterPageVisit(_Category.Id, CatalogNodeType.Category, _Category.Name); } } }
protected void Page_PreInit(object sender, EventArgs e) { int productId = PageHelper.GetProductId(); _product = ProductDataSource.Load(productId); if (_product != null) { // DELAYED QUERIES TO EAGER LOAD RELATED DATA FOR PERFORMANCE BOOST. var futureQuery = NHibernateHelper.QueryOver <Product>() .Where(p => p.Id == productId) .Fetch(p => p.ProductKitComponents).Eager .Future <Product>(); NHibernateHelper.QueryOver <Product>() .Where(p => p.Id == productId) .Fetch(p => p.ProductOptions).Eager .Future <Product>(); NHibernateHelper.QueryOver <Product>() .Where(p => p.Id == productId) .Fetch(p => p.ProductTemplates).Eager .Future <Product>(); NHibernateHelper.QueryOver <Product>() .Where(p => p.Id == productId) .Fetch(p => p.Specials).Eager .Future <Product>(); if (_product.IsKit) { NHibernateHelper.QueryOver <KitComponent>() .Fetch(kc => kc.KitProducts).Eager .JoinQueryOver <ProductKitComponent>(kc => kc.ProductKitComponents) .Where(pkc => pkc.ProductId == productId) .Future <KitComponent>(); NHibernateHelper.QueryOver <KitProduct>() .Fetch(kp => kp.Product).Eager .Fetch(kp => kp.Product.Specials).Eager .JoinQueryOver <KitComponent>(kp => kp.KitComponent) .JoinQueryOver <ProductKitComponent>(kc => kc.ProductKitComponents) .Where(pkc => pkc.ProductId == productId) .Future <KitProduct>(); } // TRIGGER QUEUED FUTURE QUERIES futureQuery.ToList <Product>(); if ((_product.Visibility == CatalogVisibility.Private) && (!AbleContext.Current.User.IsInRole(Role.CatalogAdminRoles))) { Response.Redirect(NavigationHelper.GetHomeUrl()); } var user = AbleContext.Current.User; if (!user.IsAdmin) { if (_product.EnableGroups) { List <int> groups = (from ug in AbleContext.Current.User.UserGroups select ug.GroupId).ToList <int>(); if (groups.Count > 0) { bool isInGroup = _product.ProductGroups.Any <ProductGroup>(pg => groups.Contains(pg.Group.Id)); if (!isInGroup) { Response.Redirect(NavigationHelper.GetHomeUrl()); } } else { Response.Redirect(NavigationHelper.GetHomeUrl()); } } } } else { NavigationHelper.Trigger404(Response, "Invalid Product"); } // INITIALIZE TO DEFAULT LAYOUT string layout = AbleContext.Current.Store.Settings.ProductsDefaultLayout; _webpage = _product.Webpage; if (_webpage == null) { _webpage = WebpageDataSource.Load(AbleContext.Current.Store.Settings.ProductWebpageId); } if (_webpage != null) { // CHECK FOR LAYOUT OVERRIDE if (_webpage.Layout != null) { layout = _webpage.Layout.FilePath; } // CHECK FOR THEME OVERRIDE if (!string.IsNullOrEmpty(_webpage.Theme) && CommerceBuilder.UI.Theme.Exists(_webpage.Theme)) { this.Theme = _webpage.Theme; } } // SET THE LAYOUT if (!string.IsNullOrEmpty(layout)) { this.MasterPageFile = layout; } }
protected void Page_Load(object sender, EventArgs e) { _WebpageId = AlwaysConvert.ToInt(Request.QueryString["WebpageId"]); _Webpage = WebpageDataSource.Load(_WebpageId); if (_Webpage == null) { Response.Redirect(Page.ResolveUrl("~/Admin/Catalog/Browse.aspx?CategoryId=" + AbleCommerce.Code.PageHelper.GetCategoryId().ToString())); } if (!Page.IsPostBack) { //INITIALIZE FORM ON FIRST VISIT Name.Focus(); UpdateCaption(); Name.Text = _Webpage.Name; CustomUrl.Text = _Webpage.CustomUrl; if (CustomUrl.Text.StartsWith("~/")) { CustomUrl.Text = CustomUrl.Text.Substring(2); } CustomUrlValidator.OriginalValue = _Webpage.CustomUrl; WebpageContent.Value = _Webpage.Description; Visibility.SelectedIndex = (int)_Webpage.Visibility; CategoryTree.SelectedCategories = _Webpage.Categories.ToArray(); PageTitle.Text = _Webpage.Title; MetaKeywordsValue.Text = _Webpage.MetaKeywords; MetaDescriptionValue.Text = _Webpage.MetaDescription; HtmlHead.Text = _Webpage.HtmlHead; ThumbnailUrl.Text = _Webpage.ThumbnailUrl; ThumbnailAltText.Text = _Webpage.ThumbnailAltText; Summary.Text = _Webpage.Summary; PublishedBy.Text = _Webpage.PublishedBy; PublishDate.SelectedDate = _Webpage.PublishDate.HasValue ? _Webpage.PublishDate.Value : DateTime.MinValue; LayoutList.DataBind(); BindThemes(); string layout = _Webpage.Layout != null ? _Webpage.Layout.FilePath : string.Empty; ListItem item = LayoutList.Items.FindByValue(layout); if (item != null) { item.Selected = true; } Name.Focus(); // SHOW SAVE CONFIRMATION NOTIFICATION IF NEEDED if (Request.UrlReferrer != null && Request.UrlReferrer.AbsolutePath.ToLowerInvariant().EndsWith("addwebpage.aspx")) { SavedMessage.Visible = true; SavedMessage.Text = string.Format(SavedMessage.Text, LocaleHelper.LocalNow); } } MetaKeywordsCharCount.Text = ((int)(MetaKeywordsValue.MaxLength - MetaKeywordsValue.Text.Length)).ToString(); MetaDescriptionCharCount.Text = ((int)(MetaDescriptionValue.MaxLength - MetaDescriptionValue.Text.Length)).ToString(); AbleCommerce.Code.PageHelper.SetPickImageButton(ThumbnailUrl, BrowseThumbnailUrl); AbleCommerce.Code.PageHelper.SetMaxLengthCountDown(MetaKeywordsValue, MetaKeywordsCharCount); AbleCommerce.Code.PageHelper.ConvertEnterToTab(Name); AbleCommerce.Code.PageHelper.SetPageDefaultButton(Page, SaveButton); AbleCommerce.Code.PageHelper.SetMaxLengthCountDown(MetaDescriptionValue, MetaDescriptionCharCount); if (!AbleContext.Current.Store.Settings.EnableWysiwygEditor) { AbleCommerce.Code.PageHelper.SetHtmlEditor(WebpageContent, ContentHtmlButton); } else { ContentHtmlButton.Visible = false; } if (!AbleContext.Current.Store.Settings.EnableWysiwygEditor) { AbleCommerce.Code.PageHelper.SetHtmlEditor(Summary, SummaryHtmlButton); } else { SummaryHtmlButton.Visible = false; } }
private void UpdateField(Category category, string field) { if (field != null) { string cleanField = field.Trim().ToLowerInvariant(); string fieldValue = GetValueFromFormPost(category.Id, cleanField); switch (cleanField) { case "customurl": bool isValid = false; string oldCustomUrl = category.CustomUrl; string newCustomUrl = fieldValue.Trim(); if (!string.IsNullOrEmpty(newCustomUrl) && string.IsNullOrEmpty(oldCustomUrl) || oldCustomUrl != newCustomUrl) { isValid = !CustomUrlDataSource.IsAlreadyUsed(newCustomUrl); } else { isValid = true; } if (isValid) { category.CustomUrl = fieldValue; } break; case "displaypage": if (IsValidListItemValue(category, field, fieldValue, true)) { category.Webpage = WebpageDataSource.Load(AlwaysConvert.ToInt(fieldValue)); } break; case "visibilityid": if (IsValidListItemValue(category, field, fieldValue, false)) { category.VisibilityId = AlwaysConvert.ToByte(fieldValue); } break; case "description": category.Description = fieldValue; break; case "metadescription": category.MetaDescription = fieldValue; break; case "metakeywords": category.MetaKeywords = fieldValue; break; case "name": if (!string.IsNullOrEmpty(fieldValue)) { category.Name = fieldValue; } break; case "summary": category.Summary = fieldValue; break; case "thumbnailalttext": category.ThumbnailAltText = fieldValue; break; case "thumbnailurl": category.ThumbnailUrl = fieldValue; break; case "pagetitle": category.Title = fieldValue; break; case "htmlhead": category.HtmlHead = fieldValue; break; } } }
protected override void CreateChildControls() { bool created = false; Scriptlet Identifier = ScriptletDataSource.Load(this.Page.Theme, this.Identifier, (ScriptletType)Enum.Parse(typeof(ScriptletType), this.ScriptletType), true); string IdentifierScriptletData = string.Empty; if (Identifier != null) { if (!string.IsNullOrEmpty(Identifier.HeaderData)) { this.Page.Header.Controls.Add(new LiteralControl(Identifier.HeaderData)); } IdentifierScriptletData = Identifier.ScriptletData; } string template = IdentifierScriptletData; //PROCESS THE MERGED NVELOCITY TEMPLATE System.Collections.Hashtable parameters = new System.Collections.Hashtable(); object store = Token.Instance.Store; object customer = Token.Instance.User; parameters.Add("store", store); parameters.Add("customer", customer); //TODO: OBSOLETE PARAMETERS, REMOVE FOR AC7.1 parameters.Add("Store", store); parameters.Add("User", customer); //CHECK FOR CATEGORY int categoryId = GetCategoryId(); Category category = CategoryDataSource.Load(categoryId); if (category != null) { parameters.Add("Category", category); } //CHECK FOR PRODUCT int productId = GetProductId(); Product product = ProductDataSource.Load(productId); if (product != null) { parameters.Add("Product", product); } //CHECK FOR WEBPAGE int webpageId = GetWebpageId(); Webpage webpage = WebpageDataSource.Load(webpageId); if (webpage != null) { parameters.Add("Webpage", webpage); } //CHECK FOR LINK int linkId = GetLinkId(); Link link = LinkDataSource.Load(linkId); if (link != null) { parameters.Add("Link", link); } string result = NVelocityEngine.Instance.Process(parameters, template); if (this.Page != null) { string baseUrl = this.Page.ResolveUrl("~"); result = result.Replace("href=\"~/", "href=\"" + baseUrl); result = result.Replace("src=\"~/", "src=\"" + baseUrl); //DISABLE THE ABILITY TO REFER TO ANY USER CONTROL //MatchCollection userControls = Regex.Matches(result, "\\[\\[(ConLib|UserControl):([^\\]]+)\\]\\]", RegexOptions.IgnoreCase); MatchCollection userControls = Regex.Matches(result, "\\[\\[(ConLib):([^\\]]+)\\]\\]", RegexOptions.IgnoreCase); if (userControls.Count > 0) { int currentIndex = 0; foreach (Match match in userControls) { //output the literal content up to the match index if (currentIndex < match.Index) { this.Controls.Add(new LiteralControl(result.Substring(currentIndex, (match.Index - currentIndex)))); currentIndex = match.Index; } string controlPath; Dictionary <string, string> attributes; ParseControlPath(match.Groups[2].Value.Trim(), out controlPath, out attributes); if (match.Groups[1].Value.ToLowerInvariant() == "conlib") { controlPath = "~/ConLib/" + controlPath + ".ascx"; } //LOAD AND OUTPUT THE CONTROL try { Control control = this.Page.LoadControl(controlPath); if (control != null) { //TRY TO SET PARAMS foreach (string propName in attributes.Keys) { //CHECK WHETHER PROPERTY EXISTS System.Reflection.PropertyInfo pi = control.GetType().GetProperty(propName); if (pi != null) { //SET THE PROPERTY WITH THE GIVEN VALUE object value = Convert.ChangeType(attributes[propName], pi.PropertyType); pi.SetValue(control, value, null); } } //ADD CONTROL TO THE COLLECTION this.Controls.Add(control); } } catch (Exception ex) { this.Controls.Add(new LiteralControl(match.Value + " " + ex.Message)); } //advance the current index currentIndex += match.Length; } //output any remaining literal content if (currentIndex < result.Length) { this.Controls.Add(new LiteralControl(result.Substring(currentIndex))); } created = true; } } if (!created) { this.Controls.Add(new LiteralControl(result)); } }