//
        // GET: /CustomPage/
        public ActionResult Index(string slug)
        {
            ViewBag.BodyClass = "store-category-page";

            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(true, 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());            
        }
        //
        // GET: /AdminContent/FileManager/        
        public ActionResult Index()
        {
            string path = Request.QueryString["path"] ?? string.Empty;
            string cleanPath = DiskStorage.FileManagerCleanPath(path);

            FileManagerViewModel model = new FileManagerViewModel(cleanPath);
            model.Directories = DiskStorage.FileManagerListDirectories(MTApp.CurrentStore.Id, cleanPath);
            model.Files = DiskStorage.FileManagerListFiles(MTApp.CurrentStore.Id, cleanPath);            
            model.BasePreviewUrl = "~/images/sites/" + MTApp.CurrentStore.Id + "/";

            var breadRender = new code.TemplateEngine.TagHandlers.BreadCrumbs();
            ViewBag.BreadCrumbsFinal = breadRender.Render(MTApp, BuildBreadCrumbs(cleanPath));
            return View(model);
        }
        private void SignInSetup()
        {
            ViewBag.Title = SiteTerms.GetTerm(SiteTermIds.Login);
            
            List<BreadCrumbItem> extraCrumbs = new List<BreadCrumbItem>();
            extraCrumbs.Add(new BreadCrumbItem() { Name = ViewBag.Title });            
            var breadRender = new code.TemplateEngine.TagHandlers.BreadCrumbs();
            ViewBag.BreadCrumbsFinal = breadRender.RenderManual(this.MTApp, extraCrumbs);

            ViewBag.IsPrivateStore = MTApp.CurrentStore.Settings.IsPrivateStore;
            ViewBag.PrivateStoreMessage = SiteTerms.GetTerm(SiteTermIds.PrivateStoreNewUser);

            ViewBag.LoginButtonUrl = MTApp.ThemeManager().ButtonUrl("Login", Request.IsSecureConnection);
            ViewBag.CreateButtonUrl = MTApp.ThemeManager().ButtonUrl("createaccount", Request.IsSecureConnection);            
        }
Пример #4
0
        // Get: /Policies/Faq
        public ActionResult Faq()
        {
            // Breadcrumbs
            BreadCrumbViewModel crumbs = new BreadCrumbViewModel();
            crumbs.HomeName = SiteTerms.GetTerm(SiteTermIds.Home);
            crumbs.Items.Enqueue(new BreadCrumbItem()
            {
                Name = SiteTerms.GetTerm(SiteTermIds.CustomerService),
                Link = Url.Content("~/ContactUs")
            });
            crumbs.Items.Enqueue(new BreadCrumbItem() { Name = SiteTerms.GetTerm(SiteTermIds.FAQ) });            
            var breadRender = new code.TemplateEngine.TagHandlers.BreadCrumbs();
            ViewBag.BreadCrumbsFinal = breadRender.Render(MTApp, crumbs);

            // Titles
            ViewBag.Title = SiteTerms.GetTerm(SiteTermIds.FAQ);

            Policy p = MTApp.ContentServices.Policies.FindOrCreateByType(PolicyType.Faq);
            if (p == null) p = new Policy();
            return View(p);
        }
        private void ForgotPasswordSetup(string email, string returnmode)
        {
            ViewBag.Title = SiteTerms.GetTerm(SiteTermIds.ForgotPassword);

            List<BreadCrumbItem> extraCrumbs = new List<BreadCrumbItem>();
            extraCrumbs.Add(new BreadCrumbItem() { Name = ViewBag.Title });
            var breadRender = new code.TemplateEngine.TagHandlers.BreadCrumbs();
            ViewBag.BreadCrumbsFinal = breadRender.RenderManual(MTApp, extraCrumbs);
            
            ViewBag.SendButtonUrl = MTApp.ThemeManager().ButtonUrl("Submit", Request.IsSecureConnection);

            if (returnmode.Trim().ToLowerInvariant() == "1")
            {
                ViewBag.CloseUrl = Url.Content("~/checkout");
            }
            else
            {
                ViewBag.CloseUrl = Url.Content("~/signin");
            }

            ViewBag.Email = email;
            ViewBag.PostBackUrl = Url.Action("ForgotPassword", new {email = email, returnmode = returnmode});            
        }        
 private void BreadCrumbs(Category cat)
 {
     var renderer = new code.TemplateEngine.TagHandlers.BreadCrumbs();
     ViewBag.BreadCrumbsFinal = renderer.RenderCategory(this.MTApp, new List<Models.BreadCrumbItem>(), cat);
 }
Пример #7
0
        private ProductPageViewModel IndexSetup(string slug)
        {
            ViewBag.BodyClass = "store-product-page";
            ProductPageViewModel model = new ProductPageViewModel();
            model.LocalProduct = ParseProductFromSlug(slug);
            RenderOptionsJavascript(model);


            // Page Title
            ViewBag.Title = model.LocalProduct.MetaTitle.Trim();
            if (model.LocalProduct.MetaTitle.Trim().Length > 0)
            {                
                ViewBag.Title = model.LocalProduct.MetaTitle;
            }
            else
            {             
                ViewBag.Title = model.LocalProduct.ProductName;
            }

            // Meta Keywords
            ViewBag.MetaKeywords = model.LocalProduct.MetaKeywords.Trim();
            if (model.LocalProduct.MetaKeywords.Trim().Length > 0)
            {             
                ViewBag.MetaKeywords = model.LocalProduct.MetaKeywords;
            }

            // Meta Description
            ViewBag.MetaDescription = model.LocalProduct.MetaDescription.Trim();
            if (model.LocalProduct.MetaDescription.Trim().Length > 0)
            {             
                ViewBag.MetaDescription = model.LocalProduct.MetaDescription;
            }
            

            ViewBag.RelatedItemsTitle = SiteTerms.GetTerm(SiteTermIds.RelatedItems);
            ViewBag.AddToCartButtonUrl = MTApp.ThemeManager().ButtonUrl("addtocart", Request.IsSecureConnection);
            ViewBag.SubmitButtonUrl = MTApp.ThemeManager().ButtonUrl("submit", Request.IsSecureConnection);
            ViewBag.SaveLaterButton = MTApp.ThemeManager().ButtonUrl("SaveForLater", Request.IsSecureConnection);

            CheckForBackOrder(model);

            // Allow custom image names instead of the auto-generated ones
            string imageName = model.LocalProduct.ImageFileMedium;
            if (imageName.Trim().Length < 3)
            {
                imageName = model.LocalProduct.ImageFileSmall;
            }
            model.MainImageUrl = MerchantTribe.Commerce.Storage.DiskStorage.ProductImageUrlMedium(MTApp, model.LocalProduct.Bvin, imageName, Request.IsSecureConnection);
            model.MainImageAltText = model.LocalProduct.ImageFileMediumAlternateText;
            if (model.MainImageAltText.Trim().Length < 1) model.MainImageAltText = model.LocalProduct.ImageFileSmallAlternateText;
            model.PreRenderedTypeValues = model.LocalProduct.GetTypeProperties(this.MTApp);

            // Prices                        
            RenderPrices(model);

            LoadRelatedItems(model);
            RenderAdditionalImages(model);

            if (Request.QueryString["LineItemId"] != null)
            {
                model.OrderId = Request.QueryString["OrderBvin"];
                model.LineItemId = Request.QueryString["LineItemId"];
            }

            if (SessionManager.IsUserAuthenticated(MTApp))
            {
                model.IsAvailableForWishList = true;
            }


            StringBuilder sb = new StringBuilder();

            sb.Append("<script src=\"" + Url.Content("~/scripts/tabs.js") + "\" type=\"text/javascript\"></script>");
            sb.Append("<script src=\"" + Url.Content("~/scripts/ProductPage.js") + "\" type=\"text/javascript\"></script>");
            sb.Append(model.JavaScripts);

            if (ViewBag.UseFaceBook == true)
            {
                sb.Append("<!-- FaceBook OpenGraph Tags -->");
                sb.Append("<meta property=\"og:title\" content=\"" + ViewBag.Title + "\"/>");
                sb.Append("<meta property=\"og:type\" content=\"product\"/>");
                sb.Append("<meta property=\"og:url\" content=\"" + ViewBag.CurrentUrl + "\"/>");
                sb.Append("<meta property=\"og:image\" content=\"" + model.MainImageUrl + "\"/>");
                sb.Append("<meta property=\"og:site_name\" content=\"" + ViewBag.StoreName + "\" />");
                sb.Append("<meta property=\"fb:admins\" content=\"" + ViewBag.FaceBookAdmins + "\" />");
                sb.Append("<meta property=\"fb:app_id\" content=\"" + ViewBag.FaceBookAppId + "\" />");
            }
            ViewData["AnalyticsTop"] += sb.ToString();

            StringBuilder sbb = new StringBuilder();
            sbb.Append("<div id=\"fb-root\"></div>");
            sbb.Append("<script>    (function (d, s, id) {");
            sbb.Append("var js, fjs = d.getElementsByTagName(s)[0];");
            sbb.Append("if (d.getElementById(id)) { return; }");
            sbb.Append("js = d.createElement(s); js.id = id;");
            sbb.Append("js.src = \"//connect.facebook.net/en_US/all.js#xfbml=1\";");
            sbb.Append("fjs.parentNode.insertBefore(js, fjs);");
            sbb.Append("} (document, 'script', 'facebook-jssdk'));</script>");

            ViewData["AnalyticsBottom"] += sbb.ToString();

            // Bread Crumbs
            var breadRender = new code.TemplateEngine.TagHandlers.BreadCrumbs();
            model.BreadCrumbsFinal = breadRender.RenderProduct(MTApp, new List<BreadCrumbItem>(), model.LocalProduct);

            // Columns
            var columnRender = new code.TemplateEngine.TagHandlers.ContentColumn();
            model.PreColumn = columnRender.RenderColumnToString(model.LocalProduct.PreContentColumnId, MTApp, ViewBag);
            model.PostColumn = columnRender.RenderColumnToString(model.LocalProduct.PostContentColumnId, MTApp, ViewBag);

            model.SwatchHtml = MerchantTribe.Commerce.Utilities.ImageHelper.GenerateSwatchHtmlForProduct(model.LocalProduct, this.MTApp);
        

            MTApp.CurrentRequestContext.CurrentProduct = model.LocalProduct;
            return model;
        }
Пример #8
0
        public ActionResult DrillDownIndex(string slug)
        {
            ViewBag.BodyClass = "store-categorydrilldown-page";

            Category cat = MTApp.CatalogServices.Categories.FindBySlugForStore(slug,
                                        MTApp.CurrentRequestContext.CurrentStore.Id);
            if (cat == null) cat = new Category();

            ViewBag.Title = cat.MetaTitle;
            if (String.IsNullOrEmpty(ViewBag.Title)) { ViewBag.Title = cat.Name; }
            ViewBag.MetaKeywords = cat.MetaKeywords;
            ViewBag.MetaDescription = cat.MetaDescription;
            ViewBag.DisplayHtml = cat.Description; // TagReplacer.ReplaceContentTags(cat.Description,
                                                   //              this.MTApp,
                                                   //              "",
                                                   //              Request.IsSecureConnection);

            string key = Request.QueryString["node"] ?? string.Empty;
            if (key == "-") key = string.Empty;
            ViewBag.Key = key;

            int pageNumber = GetPageNumber();
            int pageSize = 9;
            int totalItems = 0;

            CategoryPageViewModel model = new CategoryPageViewModel();

            CategoryFacetManager manager = CategoryFacetManager.InstantiateForDatabase(MTApp.CurrentRequestContext);
            List<CategoryFacet> facets = manager.FindByCategory(cat.Bvin);
            List<ProductProperty> properties = LoadProperties(facets);
            if (key == string.Empty)
            {
                key = CategoryFacetKeyHelper.BuildEmptyKey(facets.Count);
            }
            List<long> parsedKey = CategoryFacetKeyHelper.ParseKeyToList(key);

            List<Product> products = MTApp.CatalogServices.FindProductsMatchingKey(key,
                                                                            pageNumber,
                                                                            pageSize,
                                                                            ref totalItems);

            List<ProductFacetCount> productCounts = manager.FindCountsOfVisibleFacets(key, facets, properties);
            List<long> visibleIds = manager.FindVisibleFacetsIdsForKey(key, facets);

            model.Products = PrepProducts(products);
            model.LocalCategory = cat;
            model.PagerData.PageSize = pageSize;
            model.PagerData.TotalItems = totalItems;
            model.PagerData.CurrentPage = pageNumber;
            model.PagerData.PagerUrlFormat = UrlRewriter.BuildUrlForCategory(new CategorySnapshot(cat),
                                            MTApp.CurrentRequestContext.RoutingContext,
                                            "{0}");
            model.PagerData.PagerUrlFormatFirst = UrlRewriter.BuildUrlForCategory(new CategorySnapshot(cat),
                                            MTApp.CurrentRequestContext.RoutingContext);
            model.SubCategories = PrepSubCategories(MTApp.CatalogServices.Categories.FindVisibleChildren(cat.Bvin));

            StringBuilder sbNotSelected = new StringBuilder();

            List<BreadCrumbItem> extraCrumbs = new List<BreadCrumbItem>();

            for (int i = 0; i < facets.Count; i++)
            {
                if (visibleIds.Contains(facets[i].Id))
                {
                    // Find the property that matches the facet
                    var p = (from pr in properties
                             where pr.Id == facets[i].PropertyId
                             select pr).SingleOrDefault();
                    if (p != null)
                    {
                        if (parsedKey[i] < 1)
                        {
                            // not selected
                            this.RenderNonSelection(sbNotSelected, i, parsedKey[i], key, facets[i], p, productCounts, model);
                        }
                        else
                        {
                            // selected
                            this.RenderSelection(sbNotSelected, i, parsedKey[i], key, facets[i], p, facets, model, extraCrumbs);
                        }
                    }
                }
            }

            // Render Bread Crumbs
            var breadRender = new code.TemplateEngine.TagHandlers.BreadCrumbs();
            ViewBag.BreadCrumbsFinal = breadRender.RenderCategory(MTApp, extraCrumbs, cat);

            ViewBag.Filters = sbNotSelected.ToString();

            // Banner
            if (cat.BannerImageUrl.Trim().Length > 0)
            {
                ViewBag.ShowBanner = true;
                ViewBag.BannerUrl = MerchantTribe.Commerce.Storage.DiskStorage.CategoryBannerUrl(
                                        MTApp,
                                        cat.Bvin,
                                        cat.BannerImageUrl,
                                        Request.IsSecureConnection);
            }
            else
            {
                ViewBag.ShowBanner = false;
            }

            // Record Category View
            MerchantTribe.Commerce.SessionManager.CategoryLastId = cat.Bvin;

            return View("DrillDown", model);
        }