private void LoadCategory(SingleCategoryViewModel model, string categoryId) { Category c = MTApp.CatalogServices.Categories.Find(categoryId); if (c != null) { if (c.Bvin != string.Empty) { string destination = UrlRewriter.BuildUrlForCategory(new CategorySnapshot(c), MTApp.CurrentRequestContext.RoutingContext); if (c.ImageUrl.StartsWith("~") | c.ImageUrl.StartsWith("http://")) { model.IconUrl = ImageHelper.SafeImage(Url.Content(c.ImageUrl)); } else { model.IconUrl = ImageHelper.SafeImage(Url.Content("~/" + c.ImageUrl)); } model.LinkUrl = destination; model.AltText = c.MetaTitle; model.Name = c.Name; if (c.SourceType == CategorySourceType.CustomLink) { model.OpenInNewWindow = c.CustomPageOpenInNewWindow; } } } }
protected void btnNew_Click(object sender, System.Web.UI.ImageClickEventArgs e) { ContentBlock b = MyPage.MTApp.ContentServices.Columns.FindBlock(this.BlockId); if (b != null) { //Inserting //SettingsManager.GetSettingList("ProductGrid"); foreach (string product in ProductPicker1.SelectedProducts) { ContentBlockSettingListItem c = new ContentBlockSettingListItem(); Product p = MyPage.MTApp.CatalogServices.Products.Find(product); c.Setting1 = product; c.Setting2 = p.Sku; c.Setting3 = p.ProductName; c.Setting4 = Page.ResolveUrl(ImageHelper.GetValidImage(p.ImageFileSmall, true)); c.Setting5 = UrlRewriter.BuildUrlForProduct(p, this.Page); c.Setting6 = p.SitePrice.ToString(); c.ListName = "ProductGrid"; b.Lists.AddItem(c); MyPage.MTApp.ContentServices.Columns.UpdateBlock(b); } LoadItems(b); } }
private CategoryMenuItemViewModel BuildItemsTree(List <CategorySnapshot> listAll, List <CategorySnapshot> catToDisplay, int currentDepth, int maximumDepth, string currentId, bool isDisplayProductsCount) { var result = new CategoryMenuItemViewModel(); foreach (var c in catToDisplay) { CategoryMenuItemViewModel item; if ((maximumDepth == 0) || (currentDepth + 1 < maximumDepth)) { item = BuildItemsTree(listAll, Category.FindChildrenInList(listAll, c.Bvin, false), currentDepth + 1, maximumDepth, currentId, isDisplayProductsCount); } else { item = new CategoryMenuItemViewModel(); } item.Title = c.Name; item.Description = c.Description; item.Url = UrlRewriter.BuildUrlForCategory(c); if (isDisplayProductsCount) { item.Bvin = c.Bvin; item.ProductsCount = HccApp.CatalogServices.FindProductCountsForCategory(c.Bvin, false); } if (c.Bvin == currentId) { item.IsCurrent = true; } result.Items.Add(item); } return(result); }
/// <summary> /// 重写Url /// </summary> /// <param name="sender">事件的源</param> /// <param name="e">包含事件数据的 EventArgs</param> private void ReUrl_BeginRequest(object sender, EventArgs e) { HttpContext context = ((HttpApplication)sender).Context; //url重写 UrlRewriter.Rewrite(context); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); ucProductPerformance.ProductId = ProductId; PageMessageBox = ucMessageBox; if (!string.IsNullOrEmpty(ReturnUrl) && ReturnUrl == "Y") { lnkBacktoAbandonedCartsReport.Visible = true; lnkBacktoAbandonedCartsReport.NavigateUrl = "~/DesktopModules/Hotcakes/Core/Admin/reports/AbandonedCarts/view.aspx"; } else { lnkBacktoAbandonedCartsReport.Visible = false; } var product = HccApp.CatalogServices.Products.FindWithCache(ProductId); lnkViewInStore.NavigateUrl = UrlRewriter.BuildUrlForProduct(product); btnCreateBundle.Visible = !product.IsBundle; }
public ActionResult GenerateUrl(string id, string mode) { var url = string.Empty; var aff = HccApp.ContactServices.Affiliates.FindByUserId(HccApp.CurrentCustomerId.ConvertTo <int>()); switch (mode) { case "Category": var cat = HccApp.CatalogServices.Categories.FindManySnapshots(new List <string> { id }).First(); url = UrlRewriter.BuildUrlForCategory(cat); url += "?" + WebAppSettings.AffiliateQueryStringName + "=" + aff.AffiliateId; break; case "Product": var prod = HccApp.CatalogServices.Products.FindWithCache(id); url = UrlRewriter.BuildUrlForProduct(prod); url += "?" + WebAppSettings.AffiliateQueryStringName + "=" + aff.AffiliateId; break; default: url = id + "?" + WebAppSettings.AffiliateQueryStringName + "=" + aff.AffiliateId; break; } return(Json(url)); }
public SingleProductViewModel(Product p, MerchantTribeApplication mtapp) { var profiler = MiniProfiler.Current; using (profiler.Step("Price Product " + p.ProductName)) { this.UserPrice = mtapp.PriceProduct(p, mtapp.CurrentCustomer, null, mtapp.CurrentlyActiveSales); } this.IsFirstItem = false; this.IsLastItem = false; this.Item = p; using (profiler.Step("Image Url Product" + p.ProductName)) { this.ImageUrl = MerchantTribe.Commerce.Storage.DiskStorage.ProductImageUrlSmall( mtapp, p.Bvin, p.ImageFileSmall, mtapp.IsCurrentRequestSecure()); } using (profiler.Step("Product Link " + p.ProductName)) { this.ProductLink = UrlRewriter.BuildUrlForProduct(p, mtapp.CurrentRequestContext.RoutingContext, string.Empty); } this.SwatchDisplay = MerchantTribe.Commerce.Utilities.ImageHelper.GenerateSwatchHtmlForProduct(p, mtapp); }
/// <summary> /// Set parameter values with provided product object /// </summary> /// <param name="p">Product information.</param> /// <param name="hccApp">An instance of the Hotcakes Application context.</param> public SingleProductViewModel(Product p, HotcakesApplication hccApp) { if (p == null) { throw new ArgumentNullException("Product"); } if (hccApp == null) { throw new ArgumentNullException("HotcakesApplication"); } UserPrice = hccApp.PriceProduct(p, hccApp.CurrentCustomer, null, hccApp.CurrentlyActiveSales); Item = p; ProductLink = UrlRewriter.BuildUrlForProduct(p); ImageUrls = new ProductImageUrls(); ImageUrls.LoadProductImageUrls(hccApp, p); SwatchDisplay = ImageHelper.GenerateSwatchHtmlForProduct(p, hccApp); #pragma warning disable 0612, 0618 ImageUrl = DiskStorage.ProductImageUrlSmall( hccApp, p.Bvin, p.ImageFileSmall, hccApp.IsCurrentRequestSecure()); OriginalImageUrl = DiskStorage.ProductImageUrlOriginal( hccApp, p.Bvin, p.ImageFileSmall, hccApp.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection); #pragma warning restore 0612, 0618 }
private void LoadCategory(SingleCategoryViewModel model, string categoryId) { var c = HccApp.CatalogServices.Categories.Find(categoryId); if (c != null) { var catSnapshot = new CategorySnapshot(c); var destination = UrlRewriter.BuildUrlForCategory(catSnapshot); var imageUrl = DiskStorage.CategoryIconUrl(HccApp, c.Bvin, c.ImageUrl, Request.IsSecureConnection); model.IconUrl = ImageHelper.SafeImage(imageUrl); model.LinkUrl = destination; model.AltText = c.MetaTitle; model.Name = c.Name; model.LocalCategory = catSnapshot; if (c.SourceType == CategorySourceType.CustomLink) { model.OpenInNewWindow = c.CustomPageOpenInNewWindow; } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!Page.IsPostBack) { if (Request.QueryString["id"] != null) { BvinField.Value = Request.QueryString["id"]; if (Request.QueryString["type"] != null) { ViewState["type"] = Request.QueryString["type"]; } lnkBack.NavigateUrl = "~/DesktopModules/Hotcakes/Core/Admin/Catalog/Categories_Edit.aspx?id=" + BvinField.Value; var category = HccApp.CatalogServices.Categories.Find(BvinField.Value); lnkViewInStore.NavigateUrl = UrlRewriter.BuildUrlForCategory(new CategorySnapshot(category)); } else { // No bvin so send back to categories page Response.Redirect("Categories.aspx"); } } LoadCategory(); CategoryBvin = BvinField.Value; }
private string BuildUrlForCategory(Category cat, string pageNumber, object addParams) { if (pageNumber != null) { return(UrlRewriter.BuildUrlForCategory(new CategorySnapshot(cat), pageNumber, addParams)); } return(UrlRewriter.BuildUrlForCategory(new CategorySnapshot(cat), addParams)); }
/// <summary> /// Edits the category. /// </summary> //[TestMethod] public void EditCategory() { //Arange var oldcatname = _irepocategory.GetEditCategoryName(); var cat = _irepocategory.GetEditCategory(); var column = _applicationDB.ContentServices.Columns.FindAll(); var col1 = column.FirstOrDefault(x => x.DisplayName.Equals(cat.PreContentColumnId)); var col2 = column.FirstOrDefault(x => x.DisplayName.Equals(cat.PostContentColumnId)); var edit = _application.CatalogServices.Categories.FindMany(oldcatname).FirstOrDefault(); { edit.PreContentColumnId = col1 == null ? string.Empty : col1.Bvin; edit.PostContentColumnId = col2 == null ? string.Empty : col2.Bvin; edit.RewriteUrl = Hotcakes.Web.Text.Slugify(cat.RewriteUrl, true); edit.Name = cat.Name; edit.MetaDescription = cat.MetaDescription; edit.MetaTitle = cat.MetaTitle; edit.MetaKeywords = cat.MetaKeywords; edit.ShowInTopMenu = cat.ShowInTopMenu; edit.Hidden = cat.Hidden; edit.TemplateName = cat.TemplateName; edit.DisplaySortOrder = cat.DisplaySortOrder; edit.ShowTitle = cat.ShowTitle; edit.Keywords = cat.Keywords; } if (UrlRewriter.IsCategorySlugInUse(edit.RewriteUrl, edit.Bvin, _application)) { Assert.Fail(); } //Act var result = _application.CatalogServices.Categories.Update(edit); if (result) { result = _application.CatalogServices.Categories.SubmitChanges(); } //TODO: Need to change EnsureJournalType function for CI if (result) { _application.ContentServices.CustomUrls.Register301(cat.RewriteUrl, edit.RewriteUrl, edit.Bvin, CustomUrlType.Category, _application.CurrentRequestContext, _application); } var resultcat = _application.CatalogServices.Categories.Find(edit.Bvin); if (resultcat == null) { Assert.Fail(); } //Assert Assert.IsTrue(result); Assert.AreEqual(edit.RewriteUrl, resultcat.RewriteUrl); }
public HtmlContentRewriter(UrlRewriter urlRewriter) { if (urlRewriter == null) { throw new ArgumentNullException("urlRewriter"); } _urlRewriter = urlRewriter; }
private BreadCrumbItem AddCategoryLink(CategorySnapshot c) { BreadCrumbItem result = new BreadCrumbItem(); result.Name = c.Name; result.Title = c.MetaTitle; result.Link = UrlRewriter.BuildUrlForCategory(c, MTApp.CurrentRequestContext.RoutingContext); return(result); }
private void PopulateStoreLink(Category c) { HyperLink m = new HyperLink(); m.ImageUrl = "~/BVAdmin/Images/Buttons/ViewInStore.png"; m.ToolTip = c.MetaTitle; m.NavigateUrl = UrlRewriter.BuildUrlForCategory(new CategorySnapshot(c), MTApp.CurrentRequestContext.RoutingContext); m.EnableViewState = false; this.inStore.Controls.Add(m); }
/// <summary> /// Set default values using parameterized constructor /// <remarks> /// This generally called from the products controller to set proper urls and product link for the bundled product /// </remarks> /// </summary> /// <param name="bp">Parameter passed for existing BundledProduct object</param> /// <param name="hccApp">An instance of the Hotcakes Application context.</param> public BundledProductViewModel(BundledProductAdv bp, HotcakesApplication hccApp) { BundledProductAdv = bp; Item = bp.BundledProduct; ProductLink = UrlRewriter.BuildUrlForProduct(BundledProductAdv.BundledProduct); ImageUrls = new ProductImageUrls(); ImageUrls.LoadProductImageUrls(hccApp, BundledProductAdv.BundledProduct); SwatchDisplay = ImageHelper.GenerateSwatchHtmlForProduct(BundledProductAdv.BundledProduct, hccApp); }
/// <summary> /// Creates the category. /// </summary> //[TestMethod] public void CreateChildCategory() { //Arange var oldcatname = _irepocategory.GetEditCategoryName(); var pcat = _application.CatalogServices.Categories.FindMany(oldcatname).FirstOrDefault(); if (pcat == null) { Assert.Fail(); } var pcatid = pcat.Bvin; var cat = _irepocategory.GetAddChildCategory(); var column = _applicationDB.ContentServices.Columns.FindAll(); var col1 = column.FirstOrDefault(x => x.DisplayName.Equals(cat.PreContentColumnId)); var col2 = column.FirstOrDefault(x => x.DisplayName.Equals(cat.PostContentColumnId)); var newcat = cat; { newcat.SourceType = CategorySourceType.Manual; newcat.PreContentColumnId = col1 == null ? string.Empty : col1.Bvin; newcat.PostContentColumnId = col2 == null ? string.Empty : col2.Bvin; newcat.RewriteUrl = Hotcakes.Web.Text.Slugify(cat.RewriteUrl, true); newcat.ParentId = pcatid; } if (UrlRewriter.IsCategorySlugInUse(newcat.RewriteUrl, newcat.Bvin, _application)) { Assert.Fail(); } //Act var result = _application.CatalogServices.Categories.Create(newcat); if (result) { result = _application.CatalogServices.Categories.SubmitChanges(); } var taxonomyTags = _irepocategory.GetCategoryTaxonomy().Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries); var resultcat = _application.CatalogServices.Categories.FindMany(newcat.Name).FirstOrDefault(); if (resultcat == null) { Assert.Fail(); } _application.SocialService.UpdateCategoryTaxonomy(newcat, taxonomyTags); var resulttex = _application.SocialService.GetTaxonomyTerms(resultcat); //TODO:Need to confirm taxonomy update functionality not implemented //Assert Assert.IsTrue(result); //Assert.AreEqual(taxonomyTags.Count(), resulttex.Count()); }
private BreadCrumbItem AddCategoryLink(CategorySnapshot c) { var result = new BreadCrumbItem { Name = c.Name, Title = c.MetaTitle, Link = UrlRewriter.BuildUrlForCategory(c) }; return(result); }
public void UrlRewriterUtilityReturnsSuccessForAnchorLinkDoubleQuote(string fromUrl, string toUrl) { // arrange string content = $"<div><a href=\"http://no-change/abcdef\">linky</a><a href=\"{fromUrl}/abcdef\"></div>"; string expectedResult = $"<div><a href=\"http://no-change/abcdef\">linky</a><a href=\"{toUrl}/abcdef\"></div>"; // act var result = UrlRewriter.Rewrite(content, new Uri(fromUrl, UriKind.RelativeOrAbsolute), new Uri(toUrl, UriKind.Absolute)); // assert A.Equals(result, expectedResult); }
public void UrlRewriterUtilityReturnsSuccessForFormActionSingleQuote(string fromUrl, string toUrl) { // arrange string content = $"<div><form action='http://no-change/abcdef' /><form action='{fromUrl}/abcdef' /></div>"; string expectedResult = $"<div><form action='http://no-change/abcdef' /><form action='{toUrl}/abcdef' /></div>"; // act var result = UrlRewriter.Rewrite(content, new Uri(fromUrl, UriKind.RelativeOrAbsolute), new Uri(toUrl, UriKind.Absolute)); // assert A.Equals(result, expectedResult); }
public static string RenderReceiptSurvey(Order o, HotcakesApplication app) { var sb = new StringBuilder(); sb.AppendLine("<!– Start Bizrate POS Code –>"); sb.AppendLine("<script language=\"JavaScript\">"); sb.AppendLine("// var passin_x =;"); sb.AppendLine("//var passin_y =500;"); sb.AppendLine("var orderId='" + o.OrderNumber + "';"); sb.AppendLine("// var z_index =; //default 9995"); sb.AppendLine("var cartTotal=" + o.TotalGrand.ToString("0.00") + ";"); sb.AppendLine("var billingZipCode='" + o.BillingAddress.PostalCode + "';"); sb.Append("var productsPurchased='"); for (var i = 0; i < 5; i++) { if (i < o.Items.Count) { var p = app.CatalogServices.Products.FindBySku(o.Items[i].ProductSku); if (p == null) { p = new Product(); } var url = UrlRewriter.BuildUrlForProduct(p); sb.Append("URL=" + url); sb.Append("^SKU=" + p.Sku); sb.Append("^GTIN="); // UPC, EIN or other global unique number sb.Append("^PRICE=" + o.Items[i].LineTotal / o.Items[i].Quantity); } else { sb.Append("URL=^SKU=^GTIN=^PRICE="); } if (i < 4) { sb.Append("|"); } } sb.AppendLine("';"); sb.AppendLine("</script>"); sb.AppendLine("<script type=\"text/javascript\" src=\"https://eval.bizrate.com/js/pos_" + app.CurrentStore.Settings.Analytics.ShopZillaId + ".js\">"); sb.AppendLine("</script>"); sb.AppendLine("<!– End Bizrate POS Code –>\n"); sb.AppendLine(RenderTracker(o, app)); return(sb.ToString()); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); var category = HccApp.CatalogServices.Categories.Find(CategoryId); lnkViewInStore.NavigateUrl = UrlRewriter.BuildUrlForCategory(new CategorySnapshot(category)); ucCategoryPerformance.CategoryId = CategoryId; PageMessageBox = ucMessageBox; }
private string RemoteUrl(Product p) { var temp = UrlRewriter.BuildUrlForProduct(p); temp = temp.Replace("\\", "/"); if (temp.ToLower().StartsWith("http://") == false) { return(Path.Combine(HccApp.CurrentStore.RootUrl(), temp.TrimStart('/'))); } return(temp); }
private string GetKeepShoppingLocation() { var category = HccApp.CatalogServices.Categories.Find(SessionManager.CategoryLastId); if (category == null) { category = new Category(); } var result = UrlRewriter.BuildUrlForCategory(new CategorySnapshot(category)); return(result); }
public SingleProductJsonModel(Product product, HotcakesApplication app) { ProductLink = UrlRewriter.BuildUrlForProduct(product); ProductName = product.ProductName; ImageSmallUrl = DiskStorage.ProductImageUrlSmall(app, product.Bvin, product.ImageFileSmall, app.IsCurrentRequestSecure()); ImageSmallAltText = product.ImageFileSmallAlternateText; ProductSku = product.Sku; Bvin = product.Bvin; var up = app.PriceProduct(product, app.CurrentCustomer, null, app.CurrentlyActiveSales); UserPrice = up.DisplayPrice(); }
public SingleProductViewModel(Product p, MerchantTribeApplication mtapp) { this.UserPrice = mtapp.PriceProduct(p, mtapp.CurrentCustomer, null); this.IsFirstItem = false; this.IsLastItem = false; this.Item = p; this.ImageUrl = MerchantTribe.Commerce.Storage.DiskStorage.ProductImageUrlSmall( mtapp, p.Bvin, p.ImageFileSmall, mtapp.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection); this.ProductLink = UrlRewriter.BuildUrlForProduct(p, mtapp.CurrentRequestContext.RoutingContext, string.Empty); }
private List <CategoryMenuItemViewModel> LoadDrillDownCategories(string catId) { var cats = HccApp.CatalogServices.Categories.FindVisibleChildren(catId); return(cats.Select(c => { var cat = new CategoryMenuItemViewModel { Title = c.Name, Description = c.Description, Url = UrlRewriter.BuildUrlForCategory(c) }; return cat; }).ToList()); }
protected void btnEdit_Click(object sender, ImageClickEventArgs e) { if (Save()) { Category c = MTApp.CatalogServices.Categories.Find(this.BvinField.Value); MTApp.IsEditMode = true; string destination = UrlRewriter.BuildUrlForCategory(new CategorySnapshot(c), MTApp.CurrentRequestContext.RoutingContext); destination = "../../" + destination; if (destination.StartsWith("http")) { destination = destination.Replace("https://", "http://"); } Response.Redirect(destination); } }
protected void Application_BeginRequest(object sender, EventArgs e) { string inputPath = Request.Url.LocalPath.ToLower(); string inputQueryString = Request.QueryString.ToString(); string siteid = ConfigurationManager.AppSettings["SiteID"]; string outputUrl = ""; bool isEditMode = (Request.QueryString["mode"] == "edit"); //Genereer het werkelijke path en controlleer of het een echt bestand is of dat het een virtueel bestand is. //string serverPath = Server.MapPath("") + inputPath; //serverPath = serverPath.Replace("/", "\\"); if (inputPath.StartsWith("/_bit") || inputPath == "/page.aspx") //|| File.Exists(serverPath)) { return; } else if (inputPath.EndsWith(".css") || inputPath.EndsWith(".js")) { if (inputPath.Contains("jquery-1.8.2.js") || inputPath.Contains("bit") || inputPath.Contains("jquery.iframe-post-form.js") || inputPath.Contains("JSON.js")) { return; } string scriptid = CmsScript.GetScriptIDByUrl(inputPath, siteid); //Geen script ID? Dan gewoon de orginele URL doorsturen. if (scriptid == "" || scriptid == null) { return; } outputUrl = "/script.handler?scriptid=" + scriptid; Context.RewritePath(outputUrl); } else { outputUrl = UrlRewriter.GetOriginalUrl(inputPath, inputQueryString, siteid, isEditMode); } //Reload bitBundler na dat een backup is terug gezet. if (Request.QueryString.AllKeys.Contains("ReloadScripts")) { BitBundler.Init(); } if (outputUrl != string.Empty) { Context.RewritePath(outputUrl); } }
private List <SingleCategoryViewModel> PrepSubCategories(List <CategorySnapshot> snaps) { List <SingleCategoryViewModel> result = new List <SingleCategoryViewModel>(); int columnCount = 1; foreach (CategorySnapshot snap in snaps) { SingleCategoryViewModel model = new SingleCategoryViewModel(); model.LinkUrl = UrlRewriter.BuildUrlForCategory(snap, MTApp.CurrentRequestContext.RoutingContext); model.IconUrl = MerchantTribe.Commerce.Storage.DiskStorage.CategoryIconUrl( MTApp, snap.Bvin, snap.ImageUrl, Request.IsSecureConnection); model.AltText = snap.Name; model.Name = snap.Name; bool isLastInRow = false; bool isFirstInRow = false; if ((columnCount == 1)) { isFirstInRow = true; } if ((columnCount == 3)) { isLastInRow = true; columnCount = 1; } else { columnCount += 1; } model.IsFirstItem = isFirstInRow; model.IsLastItem = isLastInRow; result.Add(model); } return(result); }