Example #1
0
        public void Process(StringBuilder output, 
            MerchantTribe.Commerce.MerchantTribeApplication app,
            dynamic viewBag,
            ITagProvider tagProvider,
            ParsedTag tag,
            string innerContents)
        {
            output.Append("<" + _tagName);

            string pathToTemplate = app.ThemeManager().ThemeFileUrl("",app) + "templates/";
            if (pathToTemplate.StartsWith("http://"))
            {
                pathToTemplate = pathToTemplate.Replace("http://", "//");
            }

            foreach (var att in tag.Attributes)
            {
                string name = att.Key;
                string val = att.Value;
                if (_attributesToFix.Contains(att.Key.ToLowerInvariant()))
                {
                    val = FixUpValue(val, pathToTemplate);
                }
                output.Append(" " + name + "=\"" + val + "\"");
            }

            if (tag.IsSelfClosed)
            {
                output.Append("/>");
            }
            else
            {
                output.Append(">" + innerContents + "</" + _tagName + ">");
            }
        }
Example #2
0
        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);
        }
Example #3
0
 public void Process(StringBuilder output,
                     MerchantTribe.Commerce.MerchantTribeApplication app,
                     dynamic viewBag,
                     ITagProvider tagProvider,
                     ParsedTag tag,
                     string innerContents)
 {
     output.Append((string)viewBag.analyticsbottom);
 }
Example #4
0
 public void Process(StringBuilder output,
                     MerchantTribe.Commerce.MerchantTribeApplication app,
                     dynamic viewBag,
                     ITagProvider tagProvider,
                     ParsedTag tag,
                     string innerContents)
 {
     output.Append(MerchantTribe.Commerce.Utilities.HtmlRendering.PromoTag());
 }
Example #5
0
        public string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
        {
            string result = string.Empty;

            if (block != null)
            {
                result = block.BaseSettings.GetSettingOrEmpty("HtmlData");
            }
            result = TagReplacer.ReplaceContentTags(result, app, "");
            return(result);
        }
Example #6
0
        public void Process(StringBuilder output,
                            MerchantTribe.Commerce.MerchantTribeApplication app,
                            dynamic viewBag,
                            ITagProvider tagProvider,
                            ParsedTag tag,
                            string innerContents)
        {
            var rendered = MiniProfiler.RenderIncludes();

            output.Append(rendered.ToHtmlString());
        }
Example #7
0
 public void Process(StringBuilder output,
                     MerchantTribe.Commerce.MerchantTribeApplication app,
                     dynamic viewBag,
                     ITagProvider tagProvider,
                     ParsedTag tag,
                     string innerContents)
 {
     foreach (string s in app.CurrentRequestContext.TempMessages)
     {
         output.Append(s);
     }
 }
Example #8
0
 public void Process(StringBuilder output,
                     MerchantTribe.Commerce.MerchantTribeApplication app,
                     dynamic viewBag,
                     ITagProvider tagProvider,
                     ParsedTag tag,
                     string innerContents)
 {
     output.Append("<meta name=\"keywords\" content=\"" + HttpUtility.HtmlEncode((string)viewBag.MetaKeywords) + "\" />");
     output.Append("<meta name=\"description\" content=\"" + HttpUtility.HtmlEncode((string)viewBag.MetaDescription) + "\" />");
     if (!String.IsNullOrEmpty(viewBag.AdditionalMetaTags))
     {
         output.Append((string)viewBag.AdditionalMetaTags);
     }
 }
Example #9
0
        private CategoryUrlMatchData IsCategoryMatch(string fullSlug, MerchantTribe.Commerce.MerchantTribeApplication app)
        {
            CategoryUrlMatchData result = new CategoryUrlMatchData();

            Category cat = app.CatalogServices.Categories.FindBySlugForStore(fullSlug, app.CurrentRequestContext.CurrentStore.Id);

            if (cat != null)
            {
                result.IsFound    = true;
                result.SourceType = cat.SourceType;
            }

            return(result);
        }
Example #10
0
        private bool IsProductUrl(string fullSlug, MerchantTribe.Commerce.MerchantTribeApplication app)
        {
            // See if we have a matching Product URL
            MerchantTribe.Commerce.Catalog.Product p = app.CatalogServices.Products.FindBySlug(fullSlug);
            if (p != null)
            {
                if (p.Bvin != string.Empty)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #11
0
        string IContentBlockRenderController.Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
        {
            string result = string.Empty;

            if (block != null)
            {
                result = block.BaseSettings.GetSettingOrEmpty("HtmlData");
            }
            //result = TagReplacer.ReplaceContentTags(result,
            //                                        app,
            //                                        "",
            //                                        app.IsCurrentRequestSecure());
            return(result);
        }
Example #12
0
        public void Process(StringBuilder output,
                            MerchantTribe.Commerce.MerchantTribeApplication app,
                            dynamic viewBag,
                            ITagProvider tagProvider,
                            ParsedTag tag,
                            string innerContents)
        {
            SearchFormViewModel model = new SearchFormViewModel();
            string rootUrl            = app.StoreUrl(false, true);

            model.SearchFormUrl  = rootUrl + "search";
            model.ButtonImageUrl = app.ThemeManager().ButtonUrl("Go", app.IsCurrentRequestSecure());

            Render(output, model);
        }
Example #13
0
        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 + "\">");
        }
Example #14
0
        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));
        }
Example #15
0
        public void Process(StringBuilder output,
                            MerchantTribe.Commerce.MerchantTribeApplication app,
                            dynamic viewBag,
                            ITagProvider tagProvider,
                            ParsedTag tag,
                            string innerContents)
        {
            string title = viewBag.PageTitle;

            if (string.IsNullOrEmpty(title))
            {
                title = viewBag.Title;
            }
            output.Append(HttpUtility.HtmlEncode(title));
        }
        public string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
        {
            BannerAdViewModel model = new BannerAdViewModel();

            if (block != null)
            {
                model.ImageUrl = block.BaseSettings.GetSettingOrEmpty("imageurl");
                model.AltText  = block.BaseSettings.GetSettingOrEmpty("alttext");
                model.CssId    = block.BaseSettings.GetSettingOrEmpty("cssid");
                model.CssClass = block.BaseSettings.GetSettingOrEmpty("cssclass");
                model.LinkUrl  = block.BaseSettings.GetSettingOrEmpty("linkurl");
                model.ImageUrl = TagReplacer.ReplaceContentTags(model.ImageUrl, app, "");
                //model.ImageUrl;
            }
            return(RenderModel(model));
        }
Example #17
0
        public void Process(StringBuilder output,
                            MerchantTribe.Commerce.MerchantTribeApplication app,
                            dynamic viewBag,
                            ITagProvider tagProvider,
                            ParsedTag tag,
                            string innerContents)
        {
            var category = app.CurrentRequestContext.CurrentCategory;

            if (category != null)
            {
                if (category.ShowTitle == true)
                {
                    output.Append("<h1>" + HttpUtility.HtmlEncode(category.Name) + "</h1>");
                }
            }
        }
Example #18
0
 private void CheckFor301(string slug, MerchantTribe.Commerce.MerchantTribeApplication app)
 {
     MerchantTribe.Commerce.Content.CustomUrl url = app.ContentServices.CustomUrls.FindByRequestedUrl(slug);
     if (url != null)
     {
         if (url.Bvin != string.Empty)
         {
             if (url.IsPermanentRedirect)
             {
                 app.CurrentRequestContext.RoutingContext.HttpContext.Response.RedirectPermanent(url.RedirectToUrl);
             }
             else
             {
                 app.CurrentRequestContext.RoutingContext.HttpContext.Response.Redirect(url.RedirectToUrl);
             }
         }
     }
 }
        public void Process(StringBuilder output,
                            MerchantTribe.Commerce.MerchantTribeApplication app,
                            dynamic viewBag,
                            ITagProvider tagProvider,
                            ParsedTag tag,
                            string innerContents)
        {
            var category = app.CurrentRequestContext.CurrentCategory;

            if (category != null)
            {
                if (category.Description.Trim().Length > 0)
                {
                    var description = category.Description;
                    //var description = TagReplacer.ReplaceContentTags(category.Description,
                    //                                             app,
                    //                                             "",
                    //                                             app.IsCurrentRequestSecure());
                    output.Append(description);
                }
            }
        }
Example #20
0
        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);
        }
Example #21
0
        private string GetCustomSlug(MerchantTribe.Commerce.MerchantTribeApplication mtapp)
        {
            string result = string.Empty;

            if (mtapp == null)
            {
                return(result);
            }
            if (mtapp.CurrentStore.Settings.HomePageIsFlex == false)
            {
                return(result);
            }
            string bvin = mtapp.CurrentStore.Settings.HomePageIsFlexBvin;
            var    cat  = mtapp.CatalogServices.Categories.Find(bvin);

            if (cat == null)
            {
                return(result);
            }
            result = cat.RewriteUrl;
            return(result);
        }
Example #22
0
        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);
        }
Example #23
0
        public void Process(StringBuilder output,
                            MerchantTribe.Commerce.MerchantTribeApplication app,
                            dynamic viewBag,
                            ITagProvider tagProvider,
                            ParsedTag tag,
                            string innerContents)
        {
            var category = app.CurrentRequestContext.CurrentCategory;

            if (category != null)
            {
                if (category.BannerImageUrl.Trim().Length > 0)
                {
                    string bannerUrl = MerchantTribe.Commerce.Storage.DiskStorage.CategoryBannerUrl(
                        app,
                        category.Bvin,
                        category.BannerImageUrl,
                        app.IsCurrentRequestSecure());
                    output.Append("<div id=\"categorybanner\">");
                    output.Append("<img src=\"" + bannerUrl + "\" alt=\"" + HttpUtility.HtmlEncode(category.Name) + "\" />");
                    output.Append("</div>");
                }
            }
        }
 public BaseRestHandler(MerchantTribe.Commerce.MerchantTribeApplication app)
 {
     this.MTApp = app;
 }
Example #25
0
 public BaseRestHandler(MerchantTribe.Commerce.MerchantTribeApplication app)
 {
     this.MTApp = app;
 }
        public static IRestHandler Instantiate(string version, string modelname, MerchantTribe.Commerce.MerchantTribeApplication app)
        {
            switch (modelname.Trim().ToLowerInvariant())
            {
            case "categories":
                return(new CategoriesHandler(app));

            case "pricegroups":
                return(new PriceGroupsHandler(app));

            case "customeraccounts":
                return(new CustomerAccountHandler(app));

            case "affiliates":
                return(new AffiliatesHandler(app));

            case "taxschedules":
                return(new TaxSchedulesHandler(app));

            case "taxes":
                return(new TaxesHandler(app));

            case "vendors":
                return(new VendorsHandler(app));

            case "manufacturers":
                return(new ManufacturersHandler(app));

            case "producttypes":
                return(new ProductTypesHandler(app));

            case "productproperties":
                return(new ProductPropertiesHandler(app));

            case "productoptions":
                return(new ProductOptionsHandler(app));

            case "products":
                return(new ProductsHandler(app));

            case "productmainimage":
                return(new ProductsMainImageHandler(app));

            case "categoriesimagesicon":
                return(new CategoriesImagesIconHandler(app));

            case "categoriesimagesbanner":
                return(new CategoriesImagesBannerHandler(app));

            case "productfiles":
                return(new ProductFilesHandler(app));

            case "productfilesdata":
                return(new ProductFilesDataHandler(app));

            case "productfilesxproducts":
                return(new ProductFilesXProductsHandler(app));

            case "productrelationships":
                return(new ProductRelationshipsHandler(app));

            case "productinventory":
                return(new ProductInventoryHandler(app));

            case "productimages":
                return(new ProductImagesHandler(app));

            case "productimagesupload":
                return(new ProductImagesUploadHandler(app));

            case "productvolumediscounts":
                return(new ProductVolumeDiscountsHandler(app));

            case "productreviews":
                return(new ProductReviewsHandler(app));

            case "categoryproductassociations":
                return(new CategoryProductAssociationsHandler(app));

            case "searchmanager":
                return(new SearchManagerHandler(app));

            case "orders":
                return(new OrdersHandler(app));

            case "ordertransactions":
                return(new OrderTransactionsHandler(app));

            case "utilities":
                return(new UtilitiesHandler(app));

            case "wishlistitems":
                return(new WishListItemsHandler(app));
            }

            return(null);
        }
Example #27
0
 public string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
 {
     return("<div style=\"background:#ffcccc;\">Missing Block: " + block.ControlName + "</div>");
     //return string.Empty;
 }
Example #28
0
        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>");
            }
        }
Example #29
0
        public System.Web.IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            string fullSlug = (string)(requestContext.RouteData.Values["slug"] ?? string.Empty);

            fullSlug = fullSlug.ToLowerInvariant() ?? string.Empty;

            // Application Context
            MerchantTribe.Commerce.MerchantTribeApplication MTApp = MerchantTribe.Commerce.MerchantTribeApplication.InstantiateForDataBase(new MerchantTribe.Commerce.RequestContext());
            MTApp.CurrentRequestContext.RoutingContext = requestContext;

            // Determine store id
            MTApp.CurrentStore = MerchantTribe.Commerce.Utilities.UrlHelper.ParseStoreFromUrl(System.Web.HttpContext.Current.Request.Url, MTApp);

            // Home page check
            if (fullSlug == string.Empty)
            {
                // Redirect to Sign up if we're multi-store
                if (!MerchantTribe.Commerce.WebAppSettings.IsIndividualMode)
                {
                    if (MTApp.CurrentStore.StoreName == "www")
                    {
                        requestContext.RouteData.Values["controller"] = "Home";
                        requestContext.RouteData.Values["area"]       = "signup";
                        requestContext.RouteData.Values["action"]     = "Index";
                        System.Web.Mvc.MvcHandler signupHandler = new MvcHandler(requestContext);
                        return(signupHandler);
                    }
                }

                // Check for custom homepage
                string customSlug = GetCustomSlug(MTApp);
                if (customSlug.Trim().Length < 1)
                {
                    // Send to home controller
                    requestContext.RouteData.Values["controller"] = "Home";
                    requestContext.RouteData.Values["action"]     = "Index";
                    System.Web.Mvc.MvcHandler homeHandler = new MvcHandler(requestContext);
                    return(homeHandler);
                }
                else
                {
                    // Pass along the slug to work with (custom page)
                    fullSlug = customSlug;
                    requestContext.RouteData.Values["slug"] = customSlug;
                }
            }

            // Check for Category/Page Match
            CategoryUrlMatchData categoryMatchData = IsCategoryMatch(fullSlug, MTApp);

            if (categoryMatchData.IsFound)
            {
                switch (categoryMatchData.SourceType)
                {
                case CategorySourceType.ByRules:
                case CategorySourceType.CustomLink:
                case CategorySourceType.Manual:
                    requestContext.RouteData.Values["controller"] = "Category";
                    requestContext.RouteData.Values["action"]     = "Index";
                    System.Web.Mvc.MvcHandler mvcHandlerCat = new MvcHandler(requestContext);
                    return(mvcHandlerCat);

                case CategorySourceType.DrillDown:
                    requestContext.RouteData.Values["controller"] = "Category";
                    requestContext.RouteData.Values["action"]     = "DrillDownIndex";
                    System.Web.Mvc.MvcHandler mvcHandlerCatDrill = new MvcHandler(requestContext);
                    return(mvcHandlerCatDrill);

                case CategorySourceType.FlexPage:
                    requestContext.RouteData.Values["controller"] = "FlexPage";
                    requestContext.RouteData.Values["action"]     = "Index";
                    System.Web.Mvc.MvcHandler mvcHandler2 = new System.Web.Mvc.MvcHandler(requestContext);
                    return(mvcHandler2);

                case CategorySourceType.CustomPage:
                    requestContext.RouteData.Values["controller"] = "CustomPage";
                    requestContext.RouteData.Values["action"]     = "Index";
                    System.Web.Mvc.MvcHandler mvcHandlerCustom = new MvcHandler(requestContext);
                    return(mvcHandlerCustom);
                }
            }

            // Check for Product URL
            if (IsProductUrl(fullSlug, MTApp))
            {
                requestContext.RouteData.Values["controller"] = "Products";
                requestContext.RouteData.Values["action"]     = "Index";
                System.Web.Mvc.MvcHandler mvcHandlerProducts = new MvcHandler(requestContext);
                return(mvcHandlerProducts);
            }

            // no match on product or category so do a 301 check
            CheckFor301(fullSlug, MTApp);

            // If not product, send to FlexPage Controller
            requestContext.RouteData.Values["controller"] = "FlexPage";
            requestContext.RouteData.Values["action"]     = "Index";
            System.Web.Mvc.MvcHandler mvcHandler = new System.Web.Mvc.MvcHandler(requestContext);
            return(mvcHandler);
        }