public string Process(MerchantTribeApplication app, Dictionary <string, ITagHandler> handlers, ParsedTag tag, string contents) { string fileUrl = string.Empty; bool secure = app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection; ThemeManager tm = app.ThemeManager(); string mode = tag.GetSafeAttribute("mode"); if (mode == "legacy") { fileUrl = tm.CurrentStyleSheet(app, secure); } else if (mode == "system") { string cssFile = tag.GetSafeAttribute("file"); fileUrl = app.StoreUrl(secure, false) + cssFile.TrimStart('/'); } else { string fileName = tag.GetSafeAttribute("file"); fileUrl = tm.ThemeFileUrl(fileName, app); } string result = string.Empty; result = "<link href=\"" + fileUrl + "\" rel=\"stylesheet\" type=\"text/css\" />"; return(result); }
public void Process(StringBuilder output, MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string innerContents) { MiniPagerViewModel model = new MiniPagerViewModel(); model.TotalPages = tag.GetSafeAttributeAsInteger("totalpages"); if (model.TotalPages >= 1) { // manual load model.CurrentPage = tag.GetSafeAttributeAsInteger("currentpage"); model.PagerUrlFormat = tag.GetSafeAttribute("urlformat"); model.PagerUrlFormatFirst = tag.GetSafeAttribute("urlformatfirst"); if (model.CurrentPage < 1) { model.CurrentPage = GetPageFromRequest(app); } } else { // find everything from current category model = FindModelForCurrentCategory(app, viewBag, tag); } Render(output, model); }
public void Process(StringBuilder output, MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string innerContents) { MiniPagerViewModel model = new MiniPagerViewModel(); model.TotalPages = tag.GetSafeAttributeAsInteger("totalpages"); if (model.TotalPages >= 1) { // manual load model.CurrentPage = tag.GetSafeAttributeAsInteger("currentpage"); model.PagerUrlFormat = tag.GetSafeAttribute("urlformat"); model.PagerUrlFormatFirst = tag.GetSafeAttribute("urlformatfirst"); if (model.CurrentPage < 1) model.CurrentPage = GetPageFromRequest(app); } else { // find everything from current category model = FindModelForCurrentCategory(app, viewBag, tag); } Render(output, model); }
public string Process(MerchantTribeApplication app, Dictionary<string, ITagHandler> handlers, ParsedTag tag, string contents) { string fileUrl = string.Empty; bool secure = app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection; ThemeManager tm = app.ThemeManager(); string mode = tag.GetSafeAttribute("mode"); if (mode == "legacy") { fileUrl = tm.CurrentStyleSheet(app, secure); } else if (mode == "system") { string cssFile = tag.GetSafeAttribute("file"); fileUrl = app.StoreUrl(secure, false) + cssFile.TrimStart('/'); } else { string fileName = tag.GetSafeAttribute("file"); fileUrl = tm.ThemeFileUrl(fileName, app); } string result = string.Empty; result = "<link href=\"" + fileUrl + "\" rel=\"stylesheet\" type=\"text/css\" />"; return result; }
public string Process(MerchantTribeApplication app, Dictionary<string, ITagHandler> handlers, ParsedTag tag, string contents) { this.App = app; this.Url = new System.Web.Mvc.UrlHelper(app.CurrentRequestContext.RoutingContext); CurrentCategory = app.CurrentRequestContext.CurrentCategory; if (CurrentCategory == null) { CurrentCategory = new Category(); CurrentCategory.Bvin = "0"; } StringBuilder sb = new StringBuilder(); sb.Append("<div class=\"categorymenu\">"); sb.Append("<div class=\"decoratedblock\">"); string title = tag.GetSafeAttribute("title"); if (title.Trim().Length > 0) { sb.Append("<h4>" + title + "</h4>"); } sb.Append("<ul>"); int maxDepth = 5; string mode = tag.GetSafeAttribute("mode"); switch (mode.Trim().ToUpperInvariant()) { case "ROOT": case "ROOTS": // Root Categories Only LoadRoots(sb); break; case "ALL": // All Categories LoadAllCategories(sb, maxDepth); break; case "": case "PEERS": // Peers, Children and Parents LoadPeersAndChildren(sb); break; case "ROOTPLUS": // Show root and expanded children LoadRootPlusExpandedChildren(sb); break; default: // All Categories LoadPeersAndChildren(sb); break; } sb.Append("</ul>"); sb.Append("</div>"); sb.Append("</div>"); return sb.ToString(); }
public void Process(List<ITemplateAction> actions, MerchantTribe.Commerce.MerchantTribeApplication app, ITagProvider tagProvider, ParsedTag tag, string innerContents) { string fileUrl = string.Empty; bool secure = app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection; var tm = app.ThemeManager(); string mode = tag.GetSafeAttribute("mode"); if (mode == "legacy") { fileUrl = tm.CurrentStyleSheet(app, secure); } else if (mode == "system") { string cssFile = tag.GetSafeAttribute("file"); fileUrl = app.StoreUrl(secure, false) + cssFile.TrimStart('/'); } else { string fileName = tag.GetSafeAttribute("file"); fileUrl = tm.ThemeFileUrl(fileName, app); } string result = string.Empty; result = "<link href=\"" + fileUrl + "\" rel=\"stylesheet\" type=\"text/css\" />"; actions.Add(new Actions.LiteralText(result)); }
public string Process(MerchantTribeApplication app, Dictionary <string, ITagHandler> handlers, ParsedTag tag, string contents) { StringBuilder sb = new StringBuilder(); bool secure = app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection; string mode = tag.GetSafeAttribute("mode"); if (mode == "system") { string baseScriptFolder = app.CurrentStore.RootUrl(); if (secure) { baseScriptFolder = app.CurrentStore.RootUrlSecure(); } if (baseScriptFolder.EndsWith("/") == false) { baseScriptFolder += "/"; } baseScriptFolder += "scripts/"; bool useCDN = false; string cdn = tag.GetSafeAttribute("cdn"); if (cdn == "1" || cdn == "true" || cdn == "y" || cdn == "Y") { useCDN = true; } if (useCDN) { // CDN JQuery if (secure) { sb.Append("<script src='https://ajax.microsoft.com/ajax/jQuery/jquery-1.5.1.min.js' type=\"text/javascript\"></script>"); } else { sb.Append("<script src='http://ajax.microsoft.com/ajax/jQuery/jquery-1.5.1.min.js' type=\"text/javascript\"></script>"); } } else { // Local JQuery sb.Append("<script src='" + baseScriptFolder + "jquery-1.5.1.min.js' type=\"text/javascript\"></script>"); } sb.Append(System.Environment.NewLine); sb.Append("<script src='" + baseScriptFolder + "jquery-ui-1.8.7.custom/js/jquery-ui-1.8.7.custom.min.js' type=\"text/javascript\"></script>"); sb.Append("<script src='" + baseScriptFolder + "jquery.form.js' type=\"text/javascript\"></script>"); sb.Append(System.Environment.NewLine); } else { ThemeManager tm = app.ThemeManager(); string fileName = tag.GetSafeAttribute("file"); string url = tm.ThemeFileUrl(fileName, app); sb.Append("<script src=\"" + url + "\" type=\"text/javascript\"></script>"); } return(sb.ToString()); }
public void Process(StringBuilder output, MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string innerContents) { bool secure = app.IsCurrentRequestSecure(); string mode = tag.GetSafeAttribute("mode"); if (mode == "system") { string baseScriptFolder = app.CurrentStore.RootUrl(); if (secure) baseScriptFolder = app.CurrentStore.RootUrlSecure(); if (baseScriptFolder.EndsWith("/") == false) { baseScriptFolder += "/"; } baseScriptFolder += "scripts/"; bool useCDN = false; string cdn = tag.GetSafeAttribute("cdn"); if (cdn == "1" || cdn == "true" || cdn == "y" || cdn == "Y") useCDN = true; if (useCDN) { // CDN JQuery if (secure) { output.Append("<script src='https://ajax.microsoft.com/ajax/jQuery/jquery-1.5.1.min.js' type=\"text/javascript\"></script>"); } else { output.Append("<script src='http://ajax.microsoft.com/ajax/jQuery/jquery-1.5.1.min.js' type=\"text/javascript\"></script>"); } } else { // Local JQuery output.Append("<script src='" + baseScriptFolder + "jquery-1.5.1.min.js' type=\"text/javascript\"></script>"); } output.Append(System.Environment.NewLine); output.Append("<script src='" + baseScriptFolder + "jquery-ui-1.8.7.custom/js/jquery-ui-1.8.7.custom.min.js' type=\"text/javascript\"></script>"); output.Append("<script src='" + baseScriptFolder + "jquery.form.js' type=\"text/javascript\"></script>"); output.Append(System.Environment.NewLine); } else { string src = tag.GetSafeAttribute("src"); string fileName = tag.GetSafeAttribute("file"); if (fileName.Trim().Length > 0) { var tm = app.ThemeManager(); src = tm.ThemeFileUrl(fileName, app); } output.Append("<script src=\"" + src + "\" type=\"text/javascript\"></script>"); } }
public void Process(StringBuilder output, MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string innerContents) { int linksPerRow = 9; string tryLinksPerRow = tag.GetSafeAttribute("linksperrow"); int temp1 = -1; if (int.TryParse(tryLinksPerRow, out temp1)) linksPerRow = temp1; if (linksPerRow < 1) linksPerRow = 1; int maxLinks = 9; int temp2 = -1; string tryMaxLinks = tag.GetSafeAttribute("maxlinks"); if (int.TryParse(tryMaxLinks, out temp2)) maxLinks = temp2; if (maxLinks < 1) maxLinks = 1; int tabIndex = 0; string tryTabIndex = tag.GetSafeAttribute("tabindex"); int.TryParse(tryTabIndex, out tabIndex); if (tabIndex < 0) tabIndex = 0; MainMenuViewModel model = new MainMenuViewModel(); model.LinksPerRow = linksPerRow; model.MaxLinks = maxLinks; //Find Categories to Display in Menu List<MerchantTribe.Commerce.Catalog.CategorySnapshot> categories = app.CatalogServices.Categories.FindForMainMenu(); int tempTabIndex = 0; foreach (var c in categories) { var l = new MainMenuViewModelLink(); l.AltText = c.MetaTitle; l.DisplayName = c.Name; l.TabIndex = tempTabIndex; l.Target = string.Empty; l.IsActive = false; l.Url = MerchantTribe.Commerce.Utilities.UrlRewriter.BuildUrlForCategory(c, app.CurrentRequestContext.RoutingContext); if (c.Bvin == SessionManager.CategoryLastId) l.IsActive = true; if (c.SourceType == MerchantTribe.Commerce.Catalog.CategorySourceType.CustomLink || c.SourceType == MerchantTribe.Commerce.Catalog.CategorySourceType.CustomPage) { if (c.CustomPageOpenInNewWindow) l.Target = "_blank"; } model.Links.Add(l); tempTabIndex += 1; } Render(output, model); }
public string Process(MerchantTribeApplication app, Dictionary<string, ITagHandler> handlers, ParsedTag tag, string contents) { StringBuilder sb = new StringBuilder(); bool secure = app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection; string mode = tag.GetSafeAttribute("mode"); if (mode == "system") { string baseScriptFolder = app.CurrentStore.RootUrl(); if (secure) baseScriptFolder = app.CurrentStore.RootUrlSecure(); if (baseScriptFolder.EndsWith("/") == false) { baseScriptFolder += "/"; } baseScriptFolder += "scripts/"; bool useCDN = false; string cdn = tag.GetSafeAttribute("cdn"); if (cdn == "1" || cdn == "true" || cdn == "y" || cdn == "Y") useCDN = true; if (useCDN) { // CDN JQuery if (secure) { sb.Append("<script src='https://ajax.microsoft.com/ajax/jQuery/jquery-1.5.1.min.js' type=\"text/javascript\"></script>"); } else { sb.Append("<script src='http://ajax.microsoft.com/ajax/jQuery/jquery-1.5.1.min.js' type=\"text/javascript\"></script>"); } } else { // Local JQuery sb.Append("<script src='" + baseScriptFolder + "jquery-1.5.1.min.js' type=\"text/javascript\"></script>"); } sb.Append(System.Environment.NewLine); sb.Append("<script src='" + baseScriptFolder + "jquery-ui-1.8.7.custom/js/jquery-ui-1.8.7.custom.min.js' type=\"text/javascript\"></script>"); sb.Append("<script src='" + baseScriptFolder + "jquery.form.js' type=\"text/javascript\"></script>"); sb.Append(System.Environment.NewLine); } else { string src = tag.GetSafeAttribute("src"); string fileName = tag.GetSafeAttribute("file"); if (fileName.Trim().Length > 0) { ThemeManager tm = app.ThemeManager(); src = tm.ThemeFileUrl(fileName, app); } sb.Append("<script src=\"" + src + "\" type=\"text/javascript\"></script>"); } return sb.ToString(); }
public void Process(StringBuilder output, MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string innerContents) { var profiler = MiniProfiler.Current; var model = new List <SingleCategoryViewModel>(); int columns = tag.GetSafeAttributeAsInteger("columns"); if (columns < 1) { columns = 3; } string source = tag.GetSafeAttribute("source"); switch (source.Trim().ToLowerInvariant()) { case "manual": string manualBvins = tag.GetSafeAttribute("categories"); List <string> bvins = manualBvins.Split(',').ToList(); model = PrepSubCategories(app.CatalogServices.Categories.FindManySnapshots(bvins), app); break; default: using (profiler.Step("Pull Products for Category")) { var cat = app.CurrentRequestContext.CurrentCategory; string categoryId = tag.GetSafeAttribute("categories"); using (profiler.Step("Checking for non-current category on grid")) { if (categoryId.Trim().Length < 1 || categoryId.Trim().ToLowerInvariant() == "current") { if (app.CurrentRequestContext.CurrentCategory != null) { categoryId = app.CurrentRequestContext.CurrentCategory.Bvin; cat = app.CatalogServices.Categories.Find(categoryId); } } } model = PrepSubCategories(app.CatalogServices.Categories.FindVisibleChildren(cat.Bvin), app); } break; } Render(output, app, viewBag, model, columns); }
public void Process(StringBuilder output, MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string innerContents) { var profiler = MiniProfiler.Current; var model = new List<SingleCategoryViewModel>(); int columns = tag.GetSafeAttributeAsInteger("columns"); if (columns < 1) columns = 3; string source = tag.GetSafeAttribute("source"); switch (source.Trim().ToLowerInvariant()) { case "manual": string manualBvins = tag.GetSafeAttribute("categories"); List<string> bvins = manualBvins.Split(',').ToList(); model = PrepSubCategories(app.CatalogServices.Categories.FindManySnapshots(bvins), app); break; default: using (profiler.Step("Pull Products for Category")) { var cat = app.CurrentRequestContext.CurrentCategory; string categoryId = tag.GetSafeAttribute("categories"); using (profiler.Step("Checking for non-current category on grid")) { if (categoryId.Trim().Length < 1 || categoryId.Trim().ToLowerInvariant() == "current") { if (app.CurrentRequestContext.CurrentCategory != null) { categoryId = app.CurrentRequestContext.CurrentCategory.Bvin; cat = app.CatalogServices.Categories.Find(categoryId); } } } model = PrepSubCategories(app.CatalogServices.Categories.FindVisibleChildren(cat.Bvin), app); } break; } Render(output, app, viewBag, model, columns); }
public void Process(StringBuilder output, MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string innerContents) { bool isSecureRequest = app.IsCurrentRequestSecure(); bool textOnly = !app.CurrentStore.Settings.UseLogoImage; string textOnlyTag = tag.GetSafeAttribute("textonly").Trim().ToLowerInvariant(); if (textOnlyTag == "1" || textOnlyTag == "y" || textOnlyTag == "yes" || textOnlyTag == "true") textOnly = true; string storeRootUrl = app.CurrentStore.RootUrl(); string storeName = app.CurrentStore.Settings.FriendlyName; string logoImage = app.CurrentStore.Settings.LogoImageFullUrl(app, isSecureRequest); string logoText = app.CurrentStore.Settings.LogoText; LogoViewModel model = new LogoViewModel(); model.InnerContent = innerContents.Trim(); model.LinkUrl = storeRootUrl; model.LogoImageUrl = logoImage; model.LogoText = logoText; model.StoreName = storeName; model.UseTextOnly = textOnly; Render(output, model); }
public string Process(MerchantTribeApplication app, Dictionary<string, ITagHandler> handlers, ParsedTag tag, string contents) { string areaName = tag.GetSafeAttribute("name"); string result = contents; // Get area data from the category if it exists, otherwise use the default area content if (app.CurrentRequestContext.CurrentCategory != null) { CategoryPageVersion v = app.CurrentRequestContext.CurrentCategory.GetCurrentVersion(); if (v != null) { string fromCat = v.Areas.GetAreaContent(areaName); if (fromCat.Trim().Length > 0) { result = fromCat; } } } // do replacements for legacy tags here result = MerchantTribe.Commerce.Utilities.TagReplacer.ReplaceContentTags(result, app, "", app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection); return result; }
public void Process(List<ITemplateAction> actions, MerchantTribeApplication app, ITagProvider tagProvider, ParsedTag tag, string contents) { string areaName = tag.GetSafeAttribute("name"); string result = contents; // Get area data from the category if it exists, otherwise use the default area content if (app.CurrentRequestContext.CurrentCategory != null) { CategoryPageVersion v = app.CurrentRequestContext.CurrentCategory.GetCurrentVersion(); if (v != null) { string fromCat = v.Areas.GetAreaContent(areaName); if (fromCat.Trim().Length > 0) { result = fromCat; } } } // do replacements for legacy tags here result = MerchantTribe.Commerce.Utilities.TagReplacer.ReplaceContentTags(result, app, "", app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection); actions.Add(new Actions.LiteralText(result)); }
public string Process(MerchantTribeApplication app, Dictionary <string, ITagHandler> handlers, ParsedTag tag, string contents) { string areaName = tag.GetSafeAttribute("name"); string result = contents; // Get area data from the category if it exists, otherwise use the default area content if (app.CurrentRequestContext.CurrentCategory != null) { CategoryPageVersion v = app.CurrentRequestContext.CurrentCategory.GetCurrentVersion(); if (v != null) { string fromCat = v.Areas.GetAreaContent(areaName); if (fromCat.Trim().Length > 0) { result = fromCat; } } } // do replacements for legacy tags here result = MerchantTribe.Commerce.Utilities.TagReplacer.ReplaceContentTags(result, app, "", app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection); return(result); }
public void Process(StringBuilder output, MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string contents) { string areaName = tag.GetSafeAttribute("name"); string result = contents; // Get area data from the category if it exists, otherwise use the default area content if (app.CurrentRequestContext.CurrentCategory != null) { CategoryPageVersion v = app.CurrentRequestContext.CurrentCategory.GetCurrentVersion(); if (v != null) { string fromCat = v.Areas.GetAreaContent(areaName); if (fromCat.Trim().Length > 0) { result = fromCat; } } } // do replacements for legacy tags here //result = MerchantTribe.Commerce.Utilities.TagReplacer.ReplaceContentTags(result, // app, // "", // app.IsCurrentRequestSecure()); output.Append(result); }
public void Process(StringBuilder output, MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string innerContents) { bool isSecureRequest = app.IsCurrentRequestSecure(); bool textOnly = !app.CurrentStore.Settings.UseLogoImage; string textOnlyTag = tag.GetSafeAttribute("textonly").Trim().ToLowerInvariant(); if (textOnlyTag == "1" || textOnlyTag == "y" || textOnlyTag == "yes" || textOnlyTag == "true") { textOnly = true; } string storeRootUrl = app.CurrentStore.RootUrl(); string storeName = app.CurrentStore.Settings.FriendlyName; string logoImage = app.CurrentStore.Settings.LogoImageFullUrl(app, isSecureRequest); string logoText = app.CurrentStore.Settings.LogoText; LogoViewModel model = new LogoViewModel(); model.InnerContent = innerContents.Trim(); model.LinkUrl = storeRootUrl; model.LogoImageUrl = logoImage; model.LogoText = logoText; model.StoreName = storeName; model.UseTextOnly = textOnly; Render(output, model); }
public string Process(MerchantTribeApplication app, Dictionary<string, ITagHandler> handlers, ParsedTag tag, string contents) { StringBuilder sb = new StringBuilder(); bool isSecureRequest = app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection; bool textOnly = false; string textOnlyTag = tag.GetSafeAttribute("textonly").Trim().ToLowerInvariant(); if (textOnlyTag == "1" || textOnlyTag == "y" || textOnlyTag == "yes" || textOnlyTag == "true") textOnly = true; string storeRootUrl = app.CurrentStore.RootUrl(); string storeName = app.CurrentStore.Settings.FriendlyName; string logoImage = app.CurrentStore.Settings.LogoImageFullUrl(app, isSecureRequest); string logoText = app.CurrentStore.Settings.LogoText; sb.Append("<a href=\"" + storeRootUrl + "\" title=\"" + storeName + "\""); if (contents.Trim().Length > 0) { sb.Append(">"); sb.Append(contents); } else if (app.CurrentStore.Settings.UseLogoImage && textOnly == false) { sb.Append("><img src=\"" + logoImage + "\" alt=\"" + storeName + "\" />"); } else { sb.Append(" class=\"logo\">"); sb.Append(System.Web.HttpUtility.HtmlEncode(logoText)); } sb.Append("</a>"); return sb.ToString(); }
public void Process(List<ITemplateAction> actions, MerchantTribe.Commerce.MerchantTribeApplication app, ITagProvider tagProvider, ParsedTag tag, string innerContents) { string byParam = tag.GetSafeAttribute("by"); dynamic model = new ExpandoObject(); model.By = byParam; actions.Add(new Actions.PartialView("~/views/shared/_copyright.cshtml", model)); }
public void Process(StringBuilder output, MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string innerContents) { string bvin = tag.GetSafeAttribute("bvin"); string sku = tag.GetSafeAttribute("sku"); var product = app.CatalogServices.Products.Find(bvin); if (product == null) { product = app.CatalogServices.Products.FindBySku(sku); } Render(output, product, app); }
public void Process(StringBuilder output, MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string innerContents) { PagerViewModel model = new PagerViewModel(); //model.TotalPages = tag.GetSafeAttributeAsInteger("totalpages"); model.TotalItems = tag.GetSafeAttributeAsInteger("totalitems"); model.PageSize = tag.GetSafeAttributeAsInteger("pagesize"); if (model.PageSize < 1) model.PageSize = 1; model.CurrentPage = tag.GetSafeAttributeAsInteger("currentpage"); model.PagerUrlFormat = tag.GetSafeAttribute("urlformat"); model.PagerUrlFormatFirst = tag.GetSafeAttribute("urlformatfirst"); Render(output, model); }
private void PassAttribute(ref StringBuilder sb, ParsedTag tag, string name) { string value = tag.GetSafeAttribute(name); if (value.Length > 0) { sb.Append(" " + name + "=\"" + value + "\""); } }
void ITagHandler.Process(List<ITemplateAction> actions, MerchantTribeApplication app, ITagProvider tagProvider, ParsedTag tag, string innerContents) { string partName = tag.GetSafeAttribute("part"); ThemeManager tm = app.ThemeManager(); string result = tm.GetTemplatePartFromCurrentTheme(partName); Processor proc = new Processor(app, result, tagProvider); var subActions = proc.RenderForDisplay(); actions.AddRange(subActions); }
public string Process(MerchantTribeApplication app, Dictionary<string, ITagHandler> handlers, ParsedTag tag, string contents) { string partName = tag.GetSafeAttribute("part"); ThemeManager tm = app.ThemeManager(); string result = tm.GetTemplatePartFromCurrentTheme(partName); TemplateProcessor proc = new TemplateProcessor(app, result, handlers); string processed = proc.RenderForDisplay(); return processed; }
public void Process(StringBuilder output, MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string innerContents) { string colId = tag.GetSafeAttribute("columnid"); if (string.IsNullOrEmpty(colId)) { colId = tag.GetSafeAttribute("id"); } if (string.IsNullOrEmpty(colId)) { colId = tag.GetSafeAttribute("columnname"); } RenderColumn(output, colId, app, viewBag); }
public void Process(StringBuilder output, MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string innerContents) { List <BreadCrumbItem> extras = new List <BreadCrumbItem>(); string[] parts = innerContents.Split(','); if (parts.Length > 0) { foreach (string p in parts) { string[] linkParts = p.Split('|'); if (linkParts.Length > 0) { string name = linkParts[0].Trim(); if (name.Length > 0) { BreadCrumbItem item = new BreadCrumbItem(); item.Name = linkParts[0].Trim(); item.Link = ""; if (linkParts.Length > 1) { item.Link = linkParts[1].Trim(); } extras.Add(item); } } } } string mode = tag.GetSafeAttribute("mode"); if (mode == "manual") { output.Append(RenderManual(app, extras)); } else { if (app.CurrentRequestContext.CurrentProduct != null) { output.Append(RenderProduct(app, extras)); } else if (app.CurrentRequestContext.CurrentCategory != null) { output.Append(RenderCategory(app, extras)); } else { output.Append(RenderManual(app, extras)); } } }
public string Process(MerchantTribeApplication app, Dictionary <string, ITagHandler> handlers, ParsedTag tag, string contents) { string partName = tag.GetSafeAttribute("part"); ThemeManager tm = app.ThemeManager(); string result = tm.GetTemplatePartFromCurrentTheme(partName); TemplateProcessor proc = new TemplateProcessor(app, result, handlers); string processed = proc.RenderForDisplay(); return(processed); }
public void Process(StringBuilder output, MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string innerContents) { List<BreadCrumbItem> extras = new List<BreadCrumbItem>(); string[] parts = innerContents.Split(','); if (parts.Length > 0) { foreach (string p in parts) { string[] linkParts = p.Split('|'); if (linkParts.Length > 0) { string name = linkParts[0].Trim(); if (name.Length > 0) { BreadCrumbItem item = new BreadCrumbItem(); item.Name = linkParts[0].Trim(); item.Link = ""; if (linkParts.Length > 1) { item.Link = linkParts[1].Trim(); } extras.Add(item); } } } } string mode = tag.GetSafeAttribute("mode"); if (mode == "manual") { output.Append(RenderManual(app, extras)); } else { if (app.CurrentRequestContext.CurrentProduct != null) { output.Append(RenderProduct(app, extras)); } else if (app.CurrentRequestContext.CurrentCategory != null) { output.Append(RenderCategory(app, extras)); } else { output.Append(RenderManual(app, extras)); } } }
public void Process(List<ITemplateAction> actions, MerchantTribe.Commerce.MerchantTribeApplication app, ITagProvider tagProvider, ParsedTag tag, string innerContents) { List<BreadCrumbItem> extras = new List<BreadCrumbItem>(); string[] parts = innerContents.Split(','); if (parts.Length > 0) { foreach (string p in parts) { string[] linkParts = p.Split('|'); if (linkParts.Length > 0) { string name = linkParts[0].Trim(); if (name.Length > 0) { BreadCrumbItem item = new BreadCrumbItem(); item.Name = linkParts[0].Trim(); item.Link = ""; if (linkParts.Length > 1) { item.Link = linkParts[1].Trim(); } extras.Add(item); } } } } string mode = tag.GetSafeAttribute("mode"); if (mode == "manual") { actions.Add(new Actions.CallAction("BreadCrumb", "ManualTrail", new { extras = extras })); } else { if (app.CurrentRequestContext.CurrentProduct != null) { actions.Add(new Actions.CallAction("BreadCrumb", "ProductTrail", new { product = app.CurrentRequestContext.CurrentProduct, extras = extras })); } else if (app.CurrentRequestContext.CurrentCategory != null) { actions.Add(new Actions.CallAction("BreadCrumb", "CategoryTrail", new { cat = app.CurrentRequestContext.CurrentCategory, extras = extras })); } else { actions.Add(new Actions.CallAction("BreadCrumb", "ManualTrail", new { extras = extras })); } } }
public void Process(StringBuilder output, MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string innerContents) { PagerViewModel model = new PagerViewModel(); //model.TotalPages = tag.GetSafeAttributeAsInteger("totalpages"); model.TotalItems = tag.GetSafeAttributeAsInteger("totalitems"); model.PageSize = tag.GetSafeAttributeAsInteger("pagesize"); if (model.PageSize < 1) { model.PageSize = 1; } model.CurrentPage = tag.GetSafeAttributeAsInteger("currentpage"); model.PagerUrlFormat = tag.GetSafeAttribute("urlformat"); model.PagerUrlFormatFirst = tag.GetSafeAttribute("urlformatfirst"); Render(output, model); }
public void Process(StringBuilder output, MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string innerContents) { string fileUrl = string.Empty; bool secure = app.IsCurrentRequestSecure(); var tm = app.ThemeManager(); string mode = tag.GetSafeAttribute("mode"); if (mode == "legacy") { fileUrl = tm.CurrentStyleSheet(app, secure); } else if (mode == "system") { string cssFile = tag.GetSafeAttribute("file"); fileUrl = app.StoreUrl(secure, false) + cssFile.TrimStart('/'); } else { string fileName = tag.GetSafeAttribute("file"); fileUrl = tm.ThemeFileUrl(fileName, app); } if (fileUrl.StartsWith("http://")) { fileUrl = fileUrl.Replace("http://", "//"); } string result = string.Empty; result = "<link href=\"" + fileUrl + "\" rel=\"stylesheet\" type=\"text/css\" />"; output.Append(result); }
public void Process(StringBuilder output, MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string innerContents) { string id = tag.GetSafeAttribute("id"); if (!string.IsNullOrEmpty((string)viewBag.BodyClass)) { id = viewBag.BodyClass; } output.Append("<body id=\"" + id + "\">"); }
public void Process(StringBuilder output, MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string innerContents) { string byParam = tag.GetSafeAttribute("by"); dynamic model = new ExpandoObject(); model.By = byParam; output.Append(Render(model)); }
void ITagHandler.Process(StringBuilder output, MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string innerContents) { string partName = tag.GetSafeAttribute("part"); ThemeManager tm = app.ThemeManager(); string result = tm.GetTemplatePartFromCurrentTheme(partName); Processor proc = new Processor(app, viewBag, result, tagProvider); proc.RenderForDisplay(output); }
public string Process(MerchantTribeApplication app, Dictionary <string, ITagHandler> handlers, ParsedTag tag, string contents) { string by = contents; string byParam = tag.GetSafeAttribute("by"); if (byParam.Trim().Length > 0) { by = byParam; } string result = "<span class=\"copyright\">Copyright © "; result += DateTime.Now.Year.ToString(); result += "</span>"; if (by.Trim().Length > 0) { result += by; } return(result); }
public string Process(MerchantTribeApplication app, Dictionary <string, ITagHandler> handlers, ParsedTag tag, string contents) { StringBuilder sb = new StringBuilder(); bool isSecureRequest = app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection; bool textOnly = false; string textOnlyTag = tag.GetSafeAttribute("textonly").Trim().ToLowerInvariant(); if (textOnlyTag == "1" || textOnlyTag == "y" || textOnlyTag == "yes" || textOnlyTag == "true") { textOnly = true; } string storeRootUrl = app.CurrentStore.RootUrl(); string storeName = app.CurrentStore.Settings.FriendlyName; string logoImage = app.CurrentStore.Settings.LogoImageFullUrl(app, isSecureRequest); string logoText = app.CurrentStore.Settings.LogoText; sb.Append("<a href=\"" + storeRootUrl + "\" title=\"" + storeName + "\""); if (contents.Trim().Length > 0) { sb.Append(">"); sb.Append(contents); } else if (app.CurrentStore.Settings.UseLogoImage && textOnly == false) { sb.Append("><img src=\"" + logoImage + "\" alt=\"" + storeName + "\" />"); } else { sb.Append(" class=\"logo\">"); sb.Append(System.Web.HttpUtility.HtmlEncode(logoText)); } sb.Append("</a>"); return(sb.ToString()); }
public void Process(List<ITemplateAction> actions, MerchantTribe.Commerce.MerchantTribeApplication app, ITagProvider tagProvider, ParsedTag tag, string innerContents) { StringBuilder sb = new StringBuilder(); bool isSecureRequest = app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection; bool textOnly = !app.CurrentStore.Settings.UseLogoImage; string textOnlyTag = tag.GetSafeAttribute("textonly").Trim().ToLowerInvariant(); if (textOnlyTag == "1" || textOnlyTag == "y" || textOnlyTag == "yes" || textOnlyTag == "true") textOnly = true; string storeRootUrl = app.CurrentStore.RootUrl(); string storeName = app.CurrentStore.Settings.FriendlyName; string logoImage = app.CurrentStore.Settings.LogoImageFullUrl(app, isSecureRequest); string logoText = app.CurrentStore.Settings.LogoText; LogoViewModel model = new LogoViewModel(); model.InnerContent = innerContents.Trim(); model.LinkUrl = storeRootUrl; model.LogoImageUrl = logoImage; model.LogoText = logoText; model.StoreName = storeName; model.UseTextOnly = textOnly; actions.Add(new Actions.PartialView("~/views/shared/_Logo.cshtml", model)); }
public void Process(StringBuilder output, MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string innerContents) { var profiler = MiniProfiler.Current; bool showPagers = false; int columns = 3; var model = new ProductListViewModel(); using (profiler.Step("Attribute Gathering")) { model.PagerData.PageSize = tag.GetSafeAttributeAsInteger("pagesize"); if (model.PagerData.PageSize < 1) { model.PagerData.PageSize = 9; } columns = tag.GetSafeAttributeAsInteger("columns"); if (columns < 1) { columns = 3; } if (tag.GetSafeAttribute("page") == "all") { model.PagerData.CurrentPage = WebAppSettings.ViewAllPagesConstant; } else { model.PagerData.CurrentPage = tag.GetSafeAttributeAsInteger("page"); } if (model.PagerData.CurrentPage < 1 && model.PagerData.CurrentPage != WebAppSettings.ViewAllPagesConstant) { model.PagerData.CurrentPage = GetPageFromRequest(app); } model.PagerData.TotalItems = 0; showPagers = tag.GetSafeAttributeAsBoolean("showpager"); } string source = tag.GetSafeAttribute("source"); switch (source.Trim().ToLowerInvariant()) { case "featured": model.Items = app.CatalogServices.Products.FindFeatured(1, model.PagerData.PageSize); showPagers = false; break; case "manual": string manualProducts = tag.GetSafeAttribute("products"); List <string> bvins = manualProducts.Split(',').ToList(); model.Items = app.CatalogServices.Products.FindMany(bvins); string manualSkus = tag.GetSafeAttribute("skus"); List <string> skus = manualSkus.Split(',').ToList(); model.Items.AddRange(app.CatalogServices.Products.FindManySkus(skus)); showPagers = false; break; default: using (profiler.Step("Pull Products for Category")) { var cat = app.CurrentRequestContext.CurrentCategory; string categoryId = tag.GetSafeAttribute("categoryid"); using (profiler.Step("Checking for non-current category on grid")) { if (categoryId.Trim().Length < 1 || categoryId.Trim().ToLowerInvariant() == "current") { if (app.CurrentRequestContext.CurrentCategory != null) { categoryId = app.CurrentRequestContext.CurrentCategory.Bvin; cat = app.CatalogServices.Categories.Find(categoryId); } } } using (profiler.Step("Build Data for Render")) { int totalItems = 0; using (profiler.Step("Get the Products")) { // View All Support if (model.PagerData.CurrentPage == WebAppSettings.ViewAllPagesConstant) { model.PagerData.CurrentPage = 1; model.PagerData.PageSize = 250; // int.MaxValue; - Use a reasonable limit here instead of max int. } model.Items = app.CatalogServices.FindProductForCategoryWithSort( categoryId, CategorySortOrder.ManualOrder, false, model.PagerData.CurrentPage, model.PagerData.PageSize, ref totalItems); model.PagerData.TotalItems = totalItems; } using (profiler.Step("Build the Pager Urls")) { model.PagerData.PagerUrlFormat = UrlRewriter.BuildUrlForCategory(new CategorySnapshot(cat), app.CurrentRequestContext.RoutingContext, "{0}"); model.PagerData.PagerUrlFormatFirst = UrlRewriter.BuildUrlForCategory(new CategorySnapshot(cat), app.CurrentRequestContext.RoutingContext); } } } break; } Render(output, app, viewBag, model, showPagers, columns); }
public void Process(StringBuilder output, MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string innerContents) { var profiler = MiniProfiler.Current; bool showPagers = false; int columns = 3; var model = new ProductListViewModel(); using (profiler.Step("Attribute Gathering")) { model.PagerData.PageSize = tag.GetSafeAttributeAsInteger("pagesize"); if (model.PagerData.PageSize < 1) model.PagerData.PageSize = 9; columns = tag.GetSafeAttributeAsInteger("columns"); if (columns < 1) columns = 3; if (tag.GetSafeAttribute("page") == "all") { model.PagerData.CurrentPage = WebAppSettings.ViewAllPagesConstant; } else { model.PagerData.CurrentPage = tag.GetSafeAttributeAsInteger("page"); } if (model.PagerData.CurrentPage < 1 && model.PagerData.CurrentPage != WebAppSettings.ViewAllPagesConstant) { model.PagerData.CurrentPage = GetPageFromRequest(app); } model.PagerData.TotalItems = 0; showPagers = tag.GetSafeAttributeAsBoolean("showpager"); } string source = tag.GetSafeAttribute("source"); switch (source.Trim().ToLowerInvariant()) { case "featured": model.Items = app.CatalogServices.Products.FindFeatured(1, model.PagerData.PageSize); showPagers = false; break; case "manual": string manualProducts = tag.GetSafeAttribute("products"); List<string> bvins = manualProducts.Split(',').ToList(); model.Items = app.CatalogServices.Products.FindMany(bvins); string manualSkus = tag.GetSafeAttribute("skus"); List<string> skus = manualSkus.Split(',').ToList(); model.Items.AddRange(app.CatalogServices.Products.FindManySkus(skus)); showPagers = false; break; default: using (profiler.Step("Pull Products for Category")) { var cat = app.CurrentRequestContext.CurrentCategory; string categoryId = tag.GetSafeAttribute("categoryid"); using (profiler.Step("Checking for non-current category on grid")) { if (categoryId.Trim().Length < 1 || categoryId.Trim().ToLowerInvariant() == "current") { if (app.CurrentRequestContext.CurrentCategory != null) { categoryId = app.CurrentRequestContext.CurrentCategory.Bvin; cat = app.CatalogServices.Categories.Find(categoryId); } } } using (profiler.Step("Build Data for Render")) { int totalItems = 0; using (profiler.Step("Get the Products")) { // View All Support if (model.PagerData.CurrentPage == WebAppSettings.ViewAllPagesConstant) { model.PagerData.CurrentPage = 1; model.PagerData.PageSize = 250; // int.MaxValue; - Use a reasonable limit here instead of max int. } model.Items = app.CatalogServices.FindProductForCategoryWithSort( categoryId, CategorySortOrder.ManualOrder, false, model.PagerData.CurrentPage, model.PagerData.PageSize, ref totalItems); model.PagerData.TotalItems = totalItems; } using (profiler.Step("Build the Pager Urls")) { model.PagerData.PagerUrlFormat = UrlRewriter.BuildUrlForCategory(new CategorySnapshot(cat), app.CurrentRequestContext.RoutingContext, "{0}"); model.PagerData.PagerUrlFormatFirst = UrlRewriter.BuildUrlForCategory(new CategorySnapshot(cat), app.CurrentRequestContext.RoutingContext); } } } break; } Render(output, app, viewBag, model, showPagers, columns); }
public void Process(StringBuilder output, MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string innerContents) { this.App = app; this.Url = new System.Web.Mvc.UrlHelper(app.CurrentRequestContext.RoutingContext); CurrentCategory = app.CurrentRequestContext.CurrentCategory; if (CurrentCategory == null) { CurrentCategory = new Category(); CurrentCategory.Bvin = "0"; } output.Append("<div class=\"categorymenu\">"); output.Append("<div class=\"decoratedblock\">"); string title = tag.GetSafeAttribute("title"); if (title.Trim().Length > 0) { output.Append("<h4>" + title + "</h4>"); } output.Append("<ul>"); int maxDepth = 5; string mode = tag.GetSafeAttribute("mode"); switch (mode.Trim().ToUpperInvariant()) { case "ROOT": case "ROOTS": // Root Categories Only LoadRoots(output); break; case "ALL": // All Categories LoadAllCategories(output, maxDepth); break; case "": case "PEERS": // Peers, Children and Parents LoadPeersAndChildren(output); break; case "ROOTPLUS": // Show root and expanded children LoadRootPlusExpandedChildren(output); break; default: // All Categories LoadPeersAndChildren(output); break; } output.Append("</ul>"); output.Append("</div>"); output.Append("</div>"); }
public void Process(StringBuilder output, MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string innerContents) { bool secure = app.IsCurrentRequestSecure(); string mode = tag.GetSafeAttribute("mode"); if (mode == "system") { string baseScriptFolder = app.CurrentStore.RootUrl(); if (secure) { baseScriptFolder = app.CurrentStore.RootUrlSecure(); } if (baseScriptFolder.EndsWith("/") == false) { baseScriptFolder += "/"; } baseScriptFolder += "scripts/"; bool useCDN = false; string cdn = tag.GetSafeAttribute("cdn"); if (cdn == "1" || cdn == "true" || cdn == "y" || cdn == "Y") { useCDN = true; } if (useCDN) { // CDN JQuery if (secure) { output.Append("<script src='https://ajax.microsoft.com/ajax/jQuery/jquery-1.5.1.min.js' type=\"text/javascript\"></script>"); } else { output.Append("<script src='http://ajax.microsoft.com/ajax/jQuery/jquery-1.5.1.min.js' type=\"text/javascript\"></script>"); } } else { // Local JQuery output.Append("<script src='" + baseScriptFolder + "jquery-1.5.1.min.js' type=\"text/javascript\"></script>"); } output.Append(System.Environment.NewLine); output.Append("<script src='" + baseScriptFolder + "jquery-ui-1.8.7.custom/js/jquery-ui-1.8.7.custom.min.js' type=\"text/javascript\"></script>"); output.Append("<script src='" + baseScriptFolder + "jquery.form.js' type=\"text/javascript\"></script>"); output.Append(System.Environment.NewLine); } else { string src = tag.GetSafeAttribute("src"); string fileName = tag.GetSafeAttribute("file"); if (fileName.Trim().Length > 0) { var tm = app.ThemeManager(); src = tm.ThemeFileUrl(fileName, app); } output.Append("<script src=\"" + src + "\" type=\"text/javascript\"></script>"); } }
public void Process(StringBuilder output, MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string innerContents) { string mode = tag.GetSafeAttribute("mode"); string href = string.Empty; string sysid = tag.GetSafeAttribute("sysid"); switch (mode.Trim().ToLowerInvariant()) { case "home": href = app.CurrentStore.RootUrl(); break; case "checkout": href = app.CurrentStore.RootUrlSecure() + "checkout"; if (innerContents == string.Empty) innerContents = "<span>Checkout</span>"; break; case "cart": href = app.CurrentStore.RootUrl() + "cart"; if (innerContents == string.Empty) { string itemCount = "0"; string subTotal = "$0.00"; if (SessionManager.CurrentUserHasCart(app.CurrentStore)) { itemCount = SessionManager.GetCookieString(WebAppSettings.CookieNameCartItemCount(app.CurrentStore.Id), app.CurrentStore); subTotal = SessionManager.GetCookieString(WebAppSettings.CookieNameCartSubTotal(app.CurrentStore.Id), app.CurrentStore); if (itemCount.Trim().Length < 1) itemCount = "0"; if (subTotal.Trim().Length < 1) subTotal = "$0.00"; } innerContents = "<span>View Cart: " + itemCount + " items</span>"; } break; case "carttotal": href = app.CurrentStore.RootUrl() + "cart"; if (innerContents == string.Empty) { string subTotal = "$0.00"; if (SessionManager.CurrentUserHasCart(app.CurrentStore)) { subTotal = SessionManager.GetCookieString(WebAppSettings.CookieNameCartSubTotal(app.CurrentStore.Id), app.CurrentStore); if (subTotal.Trim().Length < 1) subTotal = "$0.00"; } innerContents = "<span>" + subTotal + "</span>"; } break; case "category": Category cat = app.CatalogServices.Categories.Find(sysid); href = app.CurrentStore.RootUrl() + cat.RewriteUrl; break; case "product": Product p = app.CatalogServices.Products.Find(sysid); href = app.CurrentStore.RootUrl() + p.UrlSlug; break; case "": string temp = tag.GetSafeAttribute("href"); if (temp.StartsWith("http://") || temp.StartsWith("https://")) { href = temp; } else { href = app.CurrentStore.RootUrl() + temp.TrimStart('/'); } break; case "myaccount": href = app.CurrentStore.RootUrlSecure() + "account"; if (innerContents == string.Empty) innerContents = "<span>My Account</span>"; break; case "signin": string currentUserId = app.CurrentCustomerId; if (currentUserId == string.Empty) { href = app.CurrentStore.RootUrlSecure() + "signin"; if (innerContents == string.Empty) innerContents = "<span>Sign In</span>"; } else { href = app.CurrentStore.RootUrlSecure() + "signout"; if (innerContents == string.Empty) innerContents = "<span>Sign Out</span>"; } break; } //if (href.Trim().Length > 0) //{ output.Append("<a href=\"" + href + "\""); PassAttribute(ref output, tag, "id"); PassAttribute(ref output, tag, "title"); PassAttribute(ref output, tag, "style"); PassAttribute(ref output, tag, "class"); PassAttribute(ref output, tag, "dir"); PassAttribute(ref output, tag, "lang"); PassAttribute(ref output, tag, "target"); PassAttribute(ref output, tag, "rel"); PassAttribute(ref output, tag, "media"); PassAttribute(ref output, tag, "hreflang"); PassAttribute(ref output, tag, "type"); PassAttribute(ref output, tag, "name"); output.Append(">"); // Process any inner tags Processor proc = new Processor(app, viewBag, innerContents, tagProvider); proc.RenderForDisplay(output); output.Append("</a>"); //} }
public void Process(StringBuilder output, MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string innerContents) { string mode = tag.GetSafeAttribute("mode"); string href = string.Empty; string sysid = tag.GetSafeAttribute("sysid"); switch (mode.Trim().ToLowerInvariant()) { case "home": href = app.CurrentStore.RootUrl(); break; case "checkout": href = app.CurrentStore.RootUrlSecure() + "checkout"; if (innerContents == string.Empty) { innerContents = "<span>Checkout</span>"; } break; case "cart": href = app.CurrentStore.RootUrl() + "cart"; if (innerContents == string.Empty) { string itemCount = "0"; string subTotal = "$0.00"; if (SessionManager.CurrentUserHasCart(app.CurrentStore)) { itemCount = SessionManager.GetCookieString(WebAppSettings.CookieNameCartItemCount(app.CurrentStore.Id), app.CurrentStore); subTotal = SessionManager.GetCookieString(WebAppSettings.CookieNameCartSubTotal(app.CurrentStore.Id), app.CurrentStore); if (itemCount.Trim().Length < 1) { itemCount = "0"; } if (subTotal.Trim().Length < 1) { subTotal = "$0.00"; } } innerContents = "<span>View Cart: " + itemCount + " items</span>"; } break; case "carttotal": href = app.CurrentStore.RootUrl() + "cart"; if (innerContents == string.Empty) { string subTotal = "$0.00"; if (SessionManager.CurrentUserHasCart(app.CurrentStore)) { subTotal = SessionManager.GetCookieString(WebAppSettings.CookieNameCartSubTotal(app.CurrentStore.Id), app.CurrentStore); if (subTotal.Trim().Length < 1) { subTotal = "$0.00"; } } innerContents = "<span>" + subTotal + "</span>"; } break; case "category": Category cat = app.CatalogServices.Categories.Find(sysid); href = app.CurrentStore.RootUrl() + cat.RewriteUrl; break; case "product": Product p = app.CatalogServices.Products.Find(sysid); href = app.CurrentStore.RootUrl() + p.UrlSlug; break; case "": string temp = tag.GetSafeAttribute("href"); if (temp.StartsWith("http://") || temp.StartsWith("https://")) { href = temp; } else { href = app.CurrentStore.RootUrl() + temp.TrimStart('/'); } break; case "myaccount": href = app.CurrentStore.RootUrlSecure() + "account"; if (innerContents == string.Empty) { innerContents = "<span>My Account</span>"; } break; case "signin": string currentUserId = app.CurrentCustomerId; if (currentUserId == string.Empty) { href = app.CurrentStore.RootUrlSecure() + "signin"; if (innerContents == string.Empty) { innerContents = "<span>Sign In</span>"; } } else { href = app.CurrentStore.RootUrlSecure() + "signout"; if (innerContents == string.Empty) { innerContents = "<span>Sign Out</span>"; } } break; } //if (href.Trim().Length > 0) //{ output.Append("<a href=\"" + href + "\""); PassAttribute(ref output, tag, "id"); PassAttribute(ref output, tag, "title"); PassAttribute(ref output, tag, "style"); PassAttribute(ref output, tag, "class"); PassAttribute(ref output, tag, "dir"); PassAttribute(ref output, tag, "lang"); PassAttribute(ref output, tag, "target"); PassAttribute(ref output, tag, "rel"); PassAttribute(ref output, tag, "media"); PassAttribute(ref output, tag, "hreflang"); PassAttribute(ref output, tag, "type"); PassAttribute(ref output, tag, "name"); output.Append(">"); // Process any inner tags Processor proc = new Processor(app, viewBag, innerContents, tagProvider); proc.RenderForDisplay(output); output.Append("</a>"); //} }
public string Process(MerchantTribeApplication app, Dictionary <string, ITagHandler> handlers, ParsedTag tag, string contents) { StringBuilder sb = new StringBuilder(); string mode = tag.GetSafeAttribute("mode"); string href = string.Empty; string sysid = tag.GetSafeAttribute("sysid"); switch (mode.Trim().ToLowerInvariant()) { case "home": href = app.CurrentStore.RootUrl(); break; case "checkout": href = app.CurrentStore.RootUrlSecure() + "checkout"; if (contents == string.Empty) { contents = "<span>Checkout</span>"; } break; case "cart": href = app.CurrentStore.RootUrl() + "cart"; if (contents == string.Empty) { string itemCount = "0"; string subTotal = "$0.00"; if (SessionManager.CurrentUserHasCart(app.CurrentStore)) { itemCount = SessionManager.GetCookieString(WebAppSettings.CookieNameCartItemCount(app.CurrentStore.Id), app.CurrentStore); subTotal = SessionManager.GetCookieString(WebAppSettings.CookieNameCartSubTotal(app.CurrentStore.Id), app.CurrentStore); if (itemCount.Trim().Length < 1) { itemCount = "0"; } if (subTotal.Trim().Length < 1) { subTotal = "$0.00"; } } contents = "<span>View Cart: " + itemCount + " items</span>"; } break; case "category": Catalog.Category cat = app.CatalogServices.Categories.Find(sysid); href = app.CurrentStore.RootUrl() + cat.RewriteUrl; break; case "product": Catalog.Product p = app.CatalogServices.Products.Find(sysid); href = app.CurrentStore.RootUrl() + p.UrlSlug; break; case "": string temp = tag.GetSafeAttribute("href"); if (temp.StartsWith("http://") || temp.StartsWith("https://")) { href = temp; } else { href = app.CurrentStore.RootUrl() + temp.TrimStart('/'); } break; case "myaccount": href = app.CurrentStore.RootUrlSecure() + "account"; if (contents == string.Empty) { contents = "<span>My Account</span>"; } break; case "signin": string currentUserId = SessionManager.GetCurrentUserId(app.CurrentStore); if (currentUserId == string.Empty) { href = app.CurrentStore.RootUrlSecure() + "signin"; if (contents == string.Empty) { contents = "<span>Sign In</span>"; } } else { href = app.CurrentStore.RootUrlSecure() + "signout"; if (contents == string.Empty) { contents = "<span>Sign Out</span>"; } } break; } if (href.Trim().Length > 0) { sb.Append("<a href=\"" + href + "\""); PassAttribute(ref sb, tag, "id"); PassAttribute(ref sb, tag, "title"); PassAttribute(ref sb, tag, "style"); PassAttribute(ref sb, tag, "class"); PassAttribute(ref sb, tag, "dir"); PassAttribute(ref sb, tag, "lang"); PassAttribute(ref sb, tag, "target"); PassAttribute(ref sb, tag, "rel"); PassAttribute(ref sb, tag, "media"); PassAttribute(ref sb, tag, "hreflang"); PassAttribute(ref sb, tag, "type"); PassAttribute(ref sb, tag, "name"); sb.Append(">" + contents + "</a>"); } return(sb.ToString()); }
public void Process(StringBuilder output, MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, ITagProvider tagProvider, ParsedTag tag, string innerContents) { int linksPerRow = 9; string tryLinksPerRow = tag.GetSafeAttribute("linksperrow"); int temp1 = -1; if (int.TryParse(tryLinksPerRow, out temp1)) { linksPerRow = temp1; } if (linksPerRow < 1) { linksPerRow = 1; } int maxLinks = 9; int temp2 = -1; string tryMaxLinks = tag.GetSafeAttribute("maxlinks"); if (int.TryParse(tryMaxLinks, out temp2)) { maxLinks = temp2; } if (maxLinks < 1) { maxLinks = 1; } int tabIndex = 0; string tryTabIndex = tag.GetSafeAttribute("tabindex"); int.TryParse(tryTabIndex, out tabIndex); if (tabIndex < 0) { tabIndex = 0; } MainMenuViewModel model = new MainMenuViewModel(); model.LinksPerRow = linksPerRow; model.MaxLinks = maxLinks; //Find Categories to Display in Menu List <MerchantTribe.Commerce.Catalog.CategorySnapshot> categories = app.CatalogServices.Categories.FindForMainMenu(); int tempTabIndex = 0; foreach (var c in categories) { var l = new MainMenuViewModelLink(); l.AltText = c.MetaTitle; l.DisplayName = c.Name; l.TabIndex = tempTabIndex; l.Target = string.Empty; l.IsActive = false; l.Url = MerchantTribe.Commerce.Utilities.UrlRewriter.BuildUrlForCategory(c, app.CurrentRequestContext.RoutingContext); if (c.Bvin == SessionManager.CategoryLastId) { l.IsActive = true; } if (c.SourceType == MerchantTribe.Commerce.Catalog.CategorySourceType.CustomLink || c.SourceType == MerchantTribe.Commerce.Catalog.CategorySourceType.CustomPage) { if (c.CustomPageOpenInNewWindow) { l.Target = "_blank"; } } model.Links.Add(l); tempTabIndex += 1; } Render(output, model); }
public string Process(MerchantTribeApplication app, Dictionary <string, ITagHandler> handlers, ParsedTag tag, string contents) { StringBuilder sb = new StringBuilder(); int linksPerRow = 9; string tryLinksPerRow = tag.GetSafeAttribute("linksperrow"); int temp1 = -1; if (int.TryParse(tryLinksPerRow, out temp1)) { linksPerRow = temp1; } if (linksPerRow < 1) { linksPerRow = 1; } int maxLinks = 9; int temp2 = -1; string tryMaxLinks = tag.GetSafeAttribute("maxlinks"); if (int.TryParse(tryMaxLinks, out temp2)) { maxLinks = temp2; } if (maxLinks < 1) { maxLinks = 1; } int tabIndex = 0; string tryTabIndex = tag.GetSafeAttribute("tabindex"); int.TryParse(tryTabIndex, out tabIndex); if (tabIndex < 0) { tabIndex = 0; } int tempTabIndex = 0; //Find Categories to Display in Menu List <Catalog.CategorySnapshot> categories = app.CatalogServices.Categories.FindForMainMenu(); // Limit number of links int stopCount = categories.Count - 1; if ((maxLinks > 0) && ((maxLinks - 1) < stopCount)) { stopCount = (maxLinks - 1); } //Open List if (categories.Count > 0) { sb.Append("<ul>"); } tempTabIndex = tabIndex; //Build each Row for (int i = 0; i <= stopCount; i++) { sb.Append(BuildLink(categories[i], app.CurrentRequestContext.RoutingContext, ref tempTabIndex)); // Move to Next Row if Not Last Item int endOfRowCount = (i + 1) % linksPerRow; if ((endOfRowCount == 0) && (i < stopCount)) { sb.Append("</ul><ul>"); } } // Close List if (categories.Count > 0) { sb.Append("</ul>"); } return(sb.ToString()); }