public void CanStoreAndRecoverCategoryWithPageVersion() { Category target = new Category(); target.Name = "Test Category"; target.ParentId = "0"; target.StoreId = 0; target.SourceType = CategorySourceType.FlexPage; CategoryRepository repo = CategoryRepository.InstantiateForMemory(new RequestContext()); Assert.IsTrue(repo.Create(target), "Create should be true"); string categoryId = target.Bvin; Assert.AreNotEqual(string.Empty, categoryId, "Category Bvin should not be empty."); Category found = repo.Find(categoryId); Assert.IsNotNull(found, "Found category should not be null"); Assert.AreEqual(found.Name, target.Name, "Names should match"); Assert.AreEqual(1, found.Versions.Count, "Versions count should be one."); CategoryPageVersion foundVersion = found.Versions[0]; Assert.IsNotNull(foundVersion, "Found page version should not be null."); Assert.IsTrue(foundVersion.Id > 0, "Found version should have Id > 0 assigned."); }
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 CanAddPageVersionToCategory() { Category target = new Category(); Assert.AreEqual(0, target.Versions.Count, "Should be No Page Versions Yet"); string newPageName = "Unit Test Version"; CategoryPageVersion v = new CategoryPageVersion() { AdminName = newPageName }; target.Versions.Add(v); Assert.IsNotNull(target.Versions[0], "Page Version should not be null"); Assert.AreEqual(newPageName, target.Versions[0].AdminName, "Admin name should match"); }
private Category EditorSetup(string id) { Category result = MTApp.CatalogServices.Categories.Find(id); if (result == null) { result = new Category(); } // Fill with data from category, making sure legacy description is used if no area data CategoryPageVersion version = result.GetCurrentVersion(); if (version.Id == 0) { // Create Initial Version version.PublishedStatus = PublishStatus.Draft; version.PageId = result.Bvin; result.Versions.Add(version); MTApp.CatalogServices.Categories.Update(result); version = result.GetCurrentVersion(); } if (!version.Areas.HasArea("main")) { version.Areas.SetAreaContent("main", result.PreTransformDescription); MTApp.CatalogServices.Categories.Update(result); } string areaMain = version.Areas.GetAreaContent("main"); if (areaMain == string.Empty && result.PreTransformDescription != string.Empty) { result.GetCurrentVersion().Areas.SetAreaContent("main", result.PreTransformDescription); } ViewData["ViewInStoreUrl"] = UrlRewriter.BuildUrlForCategory(new CategorySnapshot(result), MTApp.CurrentRequestContext.RoutingContext); LoadTemplates(); ViewData["OtherUrls"] = LoadUrls(result); return(result); }
// // GET: /CustomPage/ public ActionResult Index(string slug) { Category cat = MTApp.CatalogServices.Categories.FindBySlugForStore(slug, MTApp.CurrentRequestContext.CurrentStore.Id); if (cat == null) { cat = new Category(); } MTApp.CurrentRequestContext.CurrentCategory = cat; // Record View for Analytics RecordCategoryView(cat.Bvin); // Get page.html Template ThemeManager tm = MTApp.ThemeManager(); if (cat.TemplateName == string.Empty) { cat.TemplateName = "default.html"; } string template = tm.GetTemplateFromCurrentTheme(cat.TemplateName); // Fill with data from category, making sure legacy description is used if no area data CategoryPageVersion version = cat.GetCurrentVersion(); if (version.Id == 0) { // Create Initial Version version.PublishedStatus = PublishStatus.Draft; version.PageId = cat.Bvin; cat.Versions.Add(version); MTApp.CatalogServices.Categories.Update(cat); version = cat.GetCurrentVersion(); } if (!version.Areas.HasArea("main")) { version.Areas.SetAreaContent("main", cat.PreTransformDescription); } TemplateProcessor proc = new TemplateProcessor(this.MTApp, template); string processed = proc.RenderForDisplay(); // Process Template Here return(new ContentResult() { Content = processed, ContentEncoding = Encoding.UTF8, ContentType = "text/html" }); /* OLD RAZOR VIEW */ //ViewBag.Title = cat.MetaTitle; //ViewBag.MetaKeywords = cat.MetaKeywords; //ViewBag.MetaDescription = cat.MetaDescription; //ViewBag.DisplayHtml = TagReplacer.ReplaceContentTags(cat.Description, // this.MTApp, // "", // Request.IsSecureConnection); //return View(cat); }
// // GET: /CustomPage/ public ActionResult Index(string slug) { Category cat = MTApp.CatalogServices.Categories.FindBySlugForStore(slug, MTApp.CurrentRequestContext.CurrentStore.Id); if (cat == null) { cat = new Category(); } MTApp.CurrentRequestContext.CurrentCategory = cat; ViewBag.Title = cat.MetaTitle; if (String.IsNullOrEmpty(ViewBag.Title)) { ViewBag.Title = cat.Name; } ViewBag.MetaKeywords = cat.MetaKeywords; ViewBag.MetaDescription = cat.MetaDescription; // Record View for Analytics RecordCategoryView(cat.Bvin); // Get page.html Template ThemeManager tm = MTApp.ThemeManager(); if (cat.TemplateName == string.Empty) { cat.TemplateName = "default.html"; } string template = tm.GetTemplateFromCurrentTheme(cat.TemplateName, "default.html"); // Try default in theme before system // Fill with data from category, making sure legacy description is used if no area data CategoryPageVersion version = cat.GetCurrentVersion(); if (version.Id == 0) { // Create Initial Version version.PublishedStatus = PublishStatus.Draft; version.PageId = cat.Bvin; cat.Versions.Add(version); MTApp.CatalogServices.Categories.Update(cat); version = cat.GetCurrentVersion(); } if (!version.Areas.HasArea("main")) { version.Areas.SetAreaContent("main", cat.PreTransformDescription); } ITagProvider tagProvider = new TagProvider(); Processor proc = new Processor(this.MTApp, this.ViewBag, template, tagProvider); // Render Bread Crumbs var breadRender = new code.TemplateEngine.TagHandlers.BreadCrumbs(); ViewBag.BreadCrumbsFinal = breadRender.RenderCategory(MTApp, new List <BreadCrumbItem>(), cat); var columnRenderer = new code.TemplateEngine.TagHandlers.ContentColumn(); ViewBag.SideColumn = columnRenderer.RenderColumnToString("4", MTApp, ViewBag); StringBuilder output = new StringBuilder(); proc.RenderForDisplay(output); return(Content(output.ToString())); }