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)); }
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 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(); }
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."; } }
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)); } }
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 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 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) { _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 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(); } }
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) { if (product.Categories.Count > 1) { product.Categories.Remove(CurrentCategory.Id); product.Categories.Save(); } else { product.Delete(); } } break; case CatalogNodeType.Webpage: Webpage webpage = WebpageDataSource.Load(catalogNodeId); if (webpage != null) { if (webpage.Categories.Count > 1) { webpage.Categories.Remove(CurrentCategory.Id); webpage.Categories.Save(); } else { webpage.Delete(); } } break; case CatalogNodeType.Link: Link link = LinkDataSource.Load(catalogNodeId); if (link != null) { if (link.Categories.Count > 1) { link.Categories.Remove(CurrentCategory.Id); link.Categories.Save(); } else { link.Delete(); } } break; } }
private void ProcessRules(BreadCrumbItem breadCrumbItem) { int id; if (breadCrumbItem.Url == "#") { return; } switch (breadCrumbItem.Url.ToLowerInvariant()) { case "~/admin/orders/shipments/editshipment.aspx": id = AlwaysConvert.ToInt(Request.QueryString["OrderShipmentId"]); breadCrumbItem.Url += "?OrderShipmentId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, id); break; case "~/admin/products/editproduct.aspx": case "~/admin/products/variants/variants.aspx": case "~/admin/products/variants/options.aspx": case "~/admin/products/digitalgoods/digitalgoods.aspx": case "~/admin/products/kits/editkit.aspx": case "~/admin/products/assets/images.aspx": case "~/admin/products/editproducttemplate.aspx": case "~/admin/products/specials/default.aspx": int categoryId = AbleCommerce.Code.PageHelper.GetCategoryId(); id = AbleCommerce.Code.PageHelper.GetProductId(); Product product = ProductDataSource.Load(id); if (categoryId > 0) { breadCrumbItem.Url += "?CategoryId=" + categoryId + "&ProductId=" + id; } else { breadCrumbItem.Url += "?ProductId=" + id; } breadCrumbItem.Title = string.Format(breadCrumbItem.Title, product.Name); break; case "~/admin/orders/vieworder.aspx": case "~/admin/orders/edit/editorderitems.aspx": case "~/admin/orders/viewdigitalgoods.aspx": case "~/admin/orders/payments/default.aspx": case "~/admin/orders/shipments/default.aspx": id = AbleCommerce.Code.PageHelper.GetOrderId(); Order order = OrderDataSource.Load(id); breadCrumbItem.Url += "?OrderNumber=" + order.OrderNumber; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, order.OrderNumber); break; case "~/admin/marketing/coupons/editcoupon.aspx": id = AlwaysConvert.ToInt(Request.QueryString["CouponId"]); Coupon coupon = CouponDataSource.Load(id); breadCrumbItem.Url += "?CouponId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, coupon.Name); break; case "~/admin/products/variants/editoption.aspx": case "~/admin/products/variants/editchoices.aspx": id = AlwaysConvert.ToInt(Request.QueryString["OptionId"]); Option option = OptionDataSource.Load(id); breadCrumbItem.Url += "?OptionId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, option.Name); break; case "~/admin/products/giftwrap/editwrapgroup.aspx": id = AlwaysConvert.ToInt(Request.QueryString["WrapGroupId"]); WrapGroup wrapGroup = WrapGroupDataSource.Load(id); breadCrumbItem.Url += "?WrapGroupId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, wrapGroup.Name); break; case "~/admin/marketing/email/managelist.aspx": id = AlwaysConvert.ToInt(Request.QueryString["EmailListId"]); EmailList emailList = EmailListDataSource.Load(id); if (emailList != null) { breadCrumbItem.Url += "?EmailListId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, emailList.Name); } break; case "~/admin/marketing/discounts/editdiscount.aspx": id = AlwaysConvert.ToInt(Request.QueryString["VolumeDiscountId"]); VolumeDiscount discount = VolumeDiscountDataSource.Load(id); breadCrumbItem.Url += "?VolumeDiscountId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, discount.Name); break; case "~/admin/catalog/editwebpage.aspx": id = AbleCommerce.Code.PageHelper.GetWebpageId(); Webpage webpage = WebpageDataSource.Load(id); breadCrumbItem.Url += "?WebpageId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, webpage.Name); break; case "~/admin/catalog/editLink.aspx": id = AbleCommerce.Code.PageHelper.GetLinkId(); Link link = LinkDataSource.Load(id); breadCrumbItem.Url += "?LinkId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, link.Name); break; case "~/admin/people/users/edituser.aspx": id = AlwaysConvert.ToInt(Request.QueryString["UserId"]); User user = UserDataSource.Load(id); breadCrumbItem.Url += "?UserId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, user.UserName); break; case "~/admin/digitalgoods/editdigitalgood.aspx": case "~/admin/digitalgoods/serialkeyproviders/defaultprovider/configure.aspx": id = AlwaysConvert.ToInt(Request.QueryString["DigitalGoodId"]); DigitalGood dg = DigitalGoodDataSource.Load(id); if (dg != null) { breadCrumbItem.Url += "?DigitalGoodId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, dg.Name); } break; case "~/admin/products/producttemplates/editproducttemplate.aspx": id = AlwaysConvert.ToInt(Request.QueryString["ProductTemplateId"]); ProductTemplate template = ProductTemplateDataSource.Load(id); if (template == null) { InputField field = InputFieldDataSource.Load(AlwaysConvert.ToInt(Request.QueryString["InputFieldId"])); if (field != null) { template = field.ProductTemplate; id = template.Id; } } if (template != null) { breadCrumbItem.Url += "?ProductTemplateId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, template.Name); } else { } break; case "~/admin/reports/dailyabandonedbaskets.aspx": id = AlwaysConvert.ToInt(Request.QueryString["BasketId"]); Basket basket = BasketDataSource.Load(id); if (basket != null) { breadCrumbItem.Url += "?ReportDate=" + basket.User.LastActivityDate.Value.ToShortDateString(); } break; } // resolve relative urls if (breadCrumbItem.Url.StartsWith("~/")) { breadCrumbItem.Url = Page.ResolveUrl(breadCrumbItem.Url); } }
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; } }
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)); } }
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 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(); }
/// <summary> /// Determines the category context for the current request. /// </summary> /// <returns>The category context for the current request.</returns> public static int GetCategoryId() { // LOOK FOR A CATEGORY IN THE QUERY STRING HttpRequest request = HttpContext.Current.Request; int categoryId = AlwaysConvert.ToInt(request.QueryString["CategoryId"]); Category category = CategoryDataSource.Load(categoryId); if (category != null) { return(categoryId); } // LOOK FOR A PRODUCT Product product = ProductDataSource.Load(GetProductId()); if (product != null) { // CHECK PRODUCT CATEGORIES int count = product.Categories.Count; if (count > 0) { if (count > 1) { // CHECK IF LAST VISITED CATEGORY IS ASSOCIATED WITH THIS OBJECT int lastCategoryId = PageVisitHelper.LastVisitedCategoryId; if (product.Categories.Contains(lastCategoryId)) { return(lastCategoryId); } } // RETURN THE FIRST CATEGORY ASSOCIATED WITH THIS OBJECT return(product.Categories[0]); } } // LOOK FOR A WEBPAGE Webpage webpage = WebpageDataSource.Load(GetWebpageId()); if (webpage != null) { int count = webpage.Categories.Count; if (count > 0) { if (count > 1) { // CHECK IF LAST VISITED CATEGORY IS ASSOCIATED WITH THIS OBJECT int lastCategoryId = PageVisitHelper.LastVisitedCategoryId; if (webpage.Categories.Contains(lastCategoryId)) { return(lastCategoryId); } } // RETURN THE FIRST CATEGORY ASSOCIATED WITH THIS OBJECT return(webpage.Categories[0]); } } // LOOK FOR A LINK Link link = LinkDataSource.Load(GetLinkId()); if (link != null) { int count = link.Categories.Count; if (count > 0) { if (count > 1) { // CHECK IF LAST VISITED CATEGORY IS ASSOCIATED WITH THIS OBJECT int lastCategoryId = PageVisitHelper.LastVisitedCategoryId; if (link.Categories.Contains(lastCategoryId)) { return(lastCategoryId); } } // RETURN THE FIRST CATEGORY ASSOCIATED WITH THIS OBJECT return(link.Categories[0]); } } // SEE IF A PARENT CATEGORY ID IS FOUND int parentCategoryId = AlwaysConvert.ToInt(request.QueryString["ParentCategoryId"]); if (parentCategoryId != 0) { return(parentCategoryId); } // NO CATEGORY CONTEXT FOUND return(0); }