示例#1
0
 public void OrderReceived(Orders.Order order, MerchantTribeApplication app)
 {
     if (OnOrderReceived != null)
     {
         OnOrderReceived(this, order, app);
     }
 }
        public static string BuildForStore(MerchantTribeApplication app)
        {
            if (app == null) return string.Empty;

            string root = app.CurrentStore.RootUrl();
            SiteMapNode rootNode = new SiteMapNode();

            // home
            rootNode.AddUrl(root);
            // sitemap
            rootNode.AddUrl(root + "sitemap");

            // Categories
            foreach (Catalog.CategorySnapshot cat in app.CatalogServices.Categories.FindAll())
            {
                string caturl = Utilities.UrlRewriter.BuildUrlForCategory(cat, app.CurrentRequestContext.RoutingContext);
                rootNode.AddUrl(root.TrimEnd('/') + caturl);
            }

            // Products
            foreach (Catalog.Product p in app.CatalogServices.Products.FindAllPaged(1,3000))
            {
                string produrl = Utilities.UrlRewriter.BuildUrlForProduct(p, app.CurrentRequestContext.RoutingContext, string.Empty);
                rootNode.AddUrl(root.TrimEnd('/') + produrl);
            }
            return rootNode.RenderAsXmlSiteMap();
        }
        public SingleProductViewModel(Product p, MerchantTribeApplication mtapp)
        {
            var profiler = MiniProfiler.Current;

            using (profiler.Step("Price Product " + p.ProductName))
            {
                this.UserPrice = mtapp.PriceProduct(p, mtapp.CurrentCustomer, null, mtapp.CurrentlyActiveSales);
            }
            this.IsFirstItem = false;
            this.IsLastItem = false;
            this.Item = p;
            using (profiler.Step("Image Url Product" + p.ProductName))
            {
                this.ImageUrl = MerchantTribe.Commerce.Storage.DiskStorage.ProductImageUrlSmall(
                    mtapp,
                    p.Bvin,
                    p.ImageFileSmall,
                    mtapp.IsCurrentRequestSecure());
            }
            using (profiler.Step("Product Link " + p.ProductName))
            {
                this.ProductLink = UrlRewriter.BuildUrlForProduct(p,
                                                mtapp.CurrentRequestContext.RoutingContext,
                                                string.Empty);
            }
        }
        private void LoadCategory(SingleCategoryViewModel model, string categoryId, MerchantTribeApplication app)
        {
            Category c = app.CatalogServices.Categories.Find(categoryId);
            if (c != null)
            {
                if (c.Bvin != string.Empty)
                {
                    string destination = UrlRewriter.BuildUrlForCategory(new CategorySnapshot(c), app.CurrentRequestContext.RoutingContext);

                    if (c.ImageUrl.StartsWith("~") | c.ImageUrl.StartsWith("http://"))
                    {
                        model.IconUrl = ImageHelper.SafeImage(app.CurrentRequestContext.UrlHelper.Content(c.ImageUrl));
                    }
                    else
                    {
                        model.IconUrl = ImageHelper.SafeImage(app.CurrentRequestContext.UrlHelper.Content("~/" + c.ImageUrl));
                    }

                    model.LinkUrl = destination;
                    model.AltText = c.MetaTitle;
                    model.Name = c.Name;

                    if (c.SourceType == CategorySourceType.CustomLink)
                    {
                        model.OpenInNewWindow = c.CustomPageOpenInNewWindow;
                    }
                }
            }
        }
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);
                        
            CurrentRequestContext.RoutingContext = this.Request.RequestContext;
            MTApp = new MerchantTribeApplication(CurrentRequestContext);

            // Determine store id        
            CurrentStore = MerchantTribe.Commerce.Utilities.UrlHelper.ParseStoreFromUrl(System.Web.HttpContext.Current.Request.Url, MTApp);
            if (CurrentStore == null)
            {
                Response.Redirect("~/storenotfound");
            }

            if (CurrentStore.Status == MerchantTribe.Commerce.Accounts.StoreStatus.Deactivated)
            {
                Response.Redirect("~/storenotavailable");
            }

            // Culture Settings
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(CurrentStore.Settings.CultureCode);
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(CurrentStore.Settings.CultureCode);

            ValidateSuperLogin();

            // Jquery
            ViewData["JQueryInclude"] = Helpers.Html.JQueryIncludes(Url.Content("~/scripts"), this.Request.IsSecureConnection);
            
            ViewBag.AppVersion = WebAppSettings.SystemVersionNumber;
            ViewBag.StoreName = MTApp.CurrentStore.Settings.FriendlyName;
            ViewBag.RenderedMenu = Helpers.Html.RenderSuperMenu(MTApp);                

        }
示例#6
0
        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);
        }
        protected override void OnPreInit(EventArgs e)
        {
            base.OnPreInit(e);
            MTApp = MerchantTribeApplication.InstantiateForDataBase(new RequestContext());

            // Store routing context for URL Rewriting
            MTApp.CurrentRequestContext.RoutingContext = this.Request.RequestContext;

            // Determine store id        
            MTApp.CurrentStore = MerchantTribe.Commerce.Utilities.UrlHelper.ParseStoreFromUrl(System.Web.HttpContext.Current.Request.Url, MTApp);
            if (MTApp.CurrentStore == null)
            {
                Response.Redirect("~/storenotfound");
            }

            if (MTApp.CurrentStore.Status == MerchantTribe.Commerce.Accounts.StoreStatus.Deactivated)
            {
                Response.Redirect("~/storenotavailable");
            }

            // Culture Settings
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(MTApp.CurrentStore.Settings.CultureCode);
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(MTApp.CurrentStore.Settings.CultureCode);


            ValidateAdminLogin();
        }
示例#8
0
 public void Render(StringBuilder sb, MerchantTribe.Commerce.Catalog.Product p, MerchantTribeApplication app)
 {
     if (p == null) return;
     if (p.Bvin == string.Empty) return;
     var model = new SingleProductViewModel(p, app);
     RenderModel(sb, model, app);
 }
示例#9
0
 public Processor(MerchantTribeApplication app, dynamic viewBag, string template, ITagProvider tagProvider)
 {
     this.MTApp = app;
     this.TagProvider = tagProvider;
     this.Template = template;
     this.ViewBag = viewBag;
 }
示例#10
0
        public void Process(List<ITemplateAction> actions, MerchantTribe.Commerce.MerchantTribeApplication app, 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";
            }

            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>");

            actions.Add(new Actions.LiteralText(sb.ToString()));
        }
示例#11
0
        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);
        }
        protected override void Render(StringBuilder sb,
                            MerchantTribeApplication app,
                            dynamic viewBag,
                            ProductListViewModel model,
                            bool showPagers, int columns)
        {
            var profiler = MiniProfiler.Current;
            using (profiler.Step("Rendering Detailed List..."))
            {
                var preppedItems = base.PrepProducts(model.Items, columns, app);
                var pagerRenderer = new code.TemplateEngine.TagHandlers.Pager();

                string buttonUrlDetails = app.ThemeManager().ButtonUrl("View", app.IsCurrentRequestSecure());
                string buttonUrlAddToCart = app.ThemeManager().ButtonUrl("AddToCart", app.IsCurrentRequestSecure());

                if (showPagers == true)
                {
                    pagerRenderer.Render(sb, model.PagerData);
                }
                foreach (var item in preppedItems)
                {
                    RenderSingleModel(sb, item, app, buttonUrlDetails, buttonUrlAddToCart);
                }
                if (showPagers == true)
                {
                    pagerRenderer.Render(sb, model.PagerData);
                }
            }
        }
 public static void RecordProductViews(string bvin, MerchantTribeApplication app)
 {
     if (WebAppSettings.LastProductsViewedCookieName != string.Empty)
     {
         string SavedProductIDs = SessionManager.GetCookieString(WebAppSettings.LastProductsViewedCookieName, app.CurrentStore);
         if (SavedProductIDs != string.Empty)
         {
             string[] AllIDs = SavedProductIDs.Split(',');
             System.Collections.Generic.Queue<string> q = new System.Collections.Generic.Queue<string>();
             q.Enqueue(bvin);
             foreach (string id in AllIDs)
             {
                 if (q.Count < 10)
                 {
                     if (!q.Contains(id))
                     {
                         q.Enqueue(id);
                     }
                 }
             }
             SessionManager.SetCookieString(WebAppSettings.LastProductsViewedCookieName, string.Join(",", q.ToArray()), app.CurrentStore);
         }
         else
         {
             SessionManager.SetCookieString(WebAppSettings.LastProductsViewedCookieName, bvin, app.CurrentStore);
         }
     }
 }
示例#14
0
        public void RenderModel(StringBuilder sb, SingleProductViewModel model, MerchantTribeApplication app)
        {
            if (model.IsLastItem == true)
            {
                sb.Append("<div class=\"record lastrecord\">");
            }
            else if (model.IsFirstItem == true)
            {
                sb.Append("<div class=\"record firstrecord\">");
            }
            else
            {
                sb.Append("<div class=\"record\">");
            }
            sb.Append("<div class=\"recordimage\">");
            sb.Append("<a href=\"" + model.ProductLink + "\">");
            sb.Append("<img src=\"" + model.ImageUrl + "\" alt=\"" + HttpUtility.HtmlEncode(model.Item.ImageFileSmallAlternateText) + "\" /></a>");
            sb.Append("</div>");

            sb.Append("<div class=\"recordname\">");
            sb.Append("<a href=\"" + model.ProductLink + "\">" + HttpUtility.HtmlEncode(model.Item.ProductName) + "</a>");
            sb.Append("</div>");
            sb.Append("<div class=\"recordsku\">");
            sb.Append("<a href=\"" + model.ProductLink + "\">" + HttpUtility.HtmlEncode(model.Item.Sku) + "</a>");
            sb.Append("</div>");
            sb.Append("<div class=\"recordprice\">");
            sb.Append("<a href=\"" + model.ProductLink + "\">" + model.UserPrice.DisplayPrice(true) + "</a>");
            sb.Append("</div>");
            sb.Append("</div>");
        }
示例#15
0
        public string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
        {
            FeaturedProductsViewModel model = new FeaturedProductsViewModel();

            model.Items = PrepProducts(app.CatalogServices.Products.FindFeatured(1, 100), app);
            return(RenderModel(model, app));
        }
        private void PopulateTags(MerchantTribeApplication app)
        {
            List<IReplaceable> items = new List<IReplaceable>();

            // Default Tags
            Replaceable defaultTags = new Replaceable();
            defaultTags.Tags.AddRange(new HtmlTemplate().DefaultReplacementTags(app));
            items.Add(defaultTags);

            // Objects with tags
            items.Add(new MailingListMember());
            items.Add(new CustomerAccount());
            items.Add(new VendorManufacturer());
            items.Add(new Order());
            items.Add(new LineItem());
            items.Add(new OrderPackage());
            items.Add(new Product());

            // Get all tags from everything into one big list
            List<HtmlTemplateTag> t = new List<HtmlTemplateTag>();
            foreach (IReplaceable r in items)
            {
                t.AddRange(r.GetReplaceableTags(app));
            }

            this.Tags.DataSource = t;
            this.Tags.DataValueField = "Tag";
            this.Tags.DataTextField = "Tag";
            this.Tags.DataBind();
        }
示例#17
0
        protected override void Render(StringBuilder sb, 
                            MerchantTribeApplication app, 
                            dynamic viewBag, 
                            ProductListViewModel model, 
                            bool showPagers, int columns)
        {
            var profiler = MiniProfiler.Current;
            using (profiler.Step("Rendering Grid..."))
            {
                var preppedItems = PrepProducts(model.Items, columns, app);
                var pagerRenderer = new code.TemplateEngine.TagHandlers.Pager();
                var productRenderer = new code.TemplateEngine.TagHandlers.SingleProduct();

                if (showPagers == true)
                {
                    pagerRenderer.Render(sb, model.PagerData);                    
                }
                foreach (var item in preppedItems)
                {
                    productRenderer.RenderModel(sb, item, app);
                }
                if (showPagers == true)
                {
                    pagerRenderer.Render(sb, model.PagerData);                    
                }
            }
        }
        private List<SingleProductViewModel> PrepProducts(List<Product> products, MerchantTribeApplication app)
        {
            List<SingleProductViewModel> result = new List<SingleProductViewModel>();

            int columnCount = 1;

            foreach (Product p in products)
            {
                SingleProductViewModel model = new SingleProductViewModel(p, app);

                bool isLastInRow = false;
                bool isFirstInRow = false;
                if ((columnCount == 1))
                {
                    isFirstInRow = true;
                }

                if ((columnCount == 3))
                {
                    isLastInRow = true;
                    columnCount = 1;
                }
                else
                {
                    columnCount += 1;
                }

                //model.IsFirstItem = isFirstInRow;
                //model.IsLastItem = isLastInRow;

                result.Add(model);
            }

            return result;
        }
示例#19
0
        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));
        }
示例#20
0
        public string Render(MerchantTribeApplication app, BreadCrumbViewModel model)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<div class=\"breadcrumbs\">");
            sb.Append("<div class=\"links\">");
            if (model.HideHomeLink == false)
            {
                sb.Append("<a href=\"" + app.StoreUrl(false, false) + "\">Home</a>" + model.Spacer);
            }           
            while (model.Items.Count > 0)
            {
                var item = model.Items.Dequeue();
                if (item.Link == string.Empty)
                {
                    sb.Append("<span class=\"current\">" + HttpUtility.HtmlEncode(item.Name) + "</span>");
                }
                else
                {
                    sb.Append("<a href=\"" + item.Link + "\" title=\"" + HttpUtility.HtmlEncode(item.Title) + "\">" + HttpUtility.HtmlEncode(item.Name) + "</a>");
                }
                        
                if (model.Items.Count > 0 && model.Items.Peek() != null)
                {
                    sb.Append(model.Spacer);
                }
            }
            sb.Append("</div>");
            sb.Append("</div>");

            return sb.ToString();
        }
示例#21
0
        public string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
        {
            ImageRotatorViewModel model = new ImageRotatorViewModel();

            if (block != null)
            {
                var imageList = block.Lists.FindList("Images");
                foreach (var listItem in imageList)
                {
                    ImageRotatorImageViewModel img = new ImageRotatorImageViewModel();
                    img.ImageUrl = ResolveUrl(listItem.Setting1, app);
                    img.Url      = listItem.Setting2;
                    if (img.Url.StartsWith("~"))
                    {
                        img.Url = app.CurrentRequestContext.UrlHelper.Content(img.Url);
                    }
                    img.NewWindow = (listItem.Setting3 == "1");
                    img.Caption   = listItem.Setting4;
                    model.Images.Add(img);
                }
                string cleanId = MerchantTribe.Web.Text.ForceAlphaNumericOnly(block.Bvin);
                model.CssId    = "rotator" + cleanId;
                model.CssClass = block.BaseSettings.GetSettingOrEmpty("cssclass");

                model.Height = block.BaseSettings.GetIntegerSetting("Height");
                model.Width  = block.BaseSettings.GetIntegerSetting("Width");

                if (block.BaseSettings.GetBoolSetting("ShowInOrder") == false)
                {
                    RandomizeList(model.Images);
                }
            }

            return(RenderModel(model));
        }
示例#22
0
        public static string BuildForStore(MerchantTribeApplication app)
        {
            if (app == null) return string.Empty;

            string root = app.CurrentStore.RootUrl();
            SiteMapNode rootNode = new SiteMapNode();
            
            // home
            rootNode.AddUrl(root);
            // sitemap
            rootNode.AddUrl(root + "sitemap");

            // Categories
            foreach (Catalog.CategorySnapshot cat in app.CatalogServices.Categories.FindAll())
            {                
                string caturl = Utilities.UrlRewriter.BuildUrlForCategory(cat, app.CurrentRequestContext.RoutingContext);
                
                // Skip Pages with Outbound links as they aren't supported in sitemap format
                string temp = caturl.ToUpperInvariant();
                if (temp.StartsWith("HTTP:") || temp.StartsWith("HTTPS:")) continue;

                rootNode.AddUrl(root.TrimEnd('/') + caturl);
            }

            // Products
            foreach (Catalog.Product p in app.CatalogServices.Products.FindAllPaged(1,3000))
            {
                string produrl = Utilities.UrlRewriter.BuildUrlForProduct(p, app.CurrentRequestContext.RoutingContext, string.Empty);
                rootNode.AddUrl(root.TrimEnd('/') + produrl);
            }
            return rootNode.RenderAsXmlSiteMap();                        
        }
示例#23
0
 public void Process(StringBuilder output, 
                     MerchantTribeApplication app, 
                     dynamic viewBag, 
                     ITagProvider tagProvider, 
                     ParsedTag tag, string contents)
 {
     Render(output, app, viewBag);
 }
        public string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)        
        {
            this.MTApp = app;
            this.ViewBag = viewBag;

            CategoryMenuViewModel model = new CategoryMenuViewModel();
            LoadMenu(model, block);
            return Render(model);
        }
        public string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
        {
            ProductListViewModel model = new ProductListViewModel();

            model.Title = SiteTerms.GetTerm(SiteTermIds.RecentlyViewedItems);
            model.Items = LoadItems(app);

            return(RenderModel(model, app));
        }
示例#26
0
 public void Process(StringBuilder output,
                     MerchantTribe.Commerce.MerchantTribeApplication app,
                     dynamic viewBag,
                     ITagProvider tagProvider,
                     ParsedTag tag,
                     string innerContents)
 {
     output.Append(Render(app, viewBag));
 }
示例#27
0
 public static bool IsUserAuthenticated(MerchantTribeApplication app)
 {
         string uid = app.CurrentCustomerId;
         if (uid.Trim() == string.Empty) return false;
         MerchantTribe.Commerce.Membership.CustomerAccount customer = app.MembershipServices.Customers.Find(uid);
         if (customer == null) return false;
         if (customer.Bvin.Trim() == string.Empty) return false;
         return true;                
 }
示例#28
0
        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 Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
        {
            this.MTApp   = app;
            this.ViewBag = viewBag;

            CategoryMenuViewModel model = new CategoryMenuViewModel();

            LoadMenu(model, block);
            return(Render(model));
        }
示例#30
0
        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));
                }
            }
        }
示例#31
0
        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);
        }
示例#32
0
 public void Render(StringBuilder sb, MerchantTribeApplication app, dynamic viewBag)
 {            
     if (viewBag.IsAdmin == true)
     {
         sb.Append("<div id=\"adminpanel\">");
         sb.Append("   <a id=\"adminpanellogo\" href=\"" + AddSecureRoot(viewBag, "bvadmin") + "\"><img src=\"" + app.StoreUrl(false, false) + "images/system/AdminPanelLogo.png\" alt=\"MerchantTribeStore\" /></a>");
         sb.Append(StoreClosedLink(viewBag));
         sb.Append("   <a href=\"" + AddSecureRoot(viewBag, "bvadmin") + "\" class=\"right\">Go To Admin Dashboard</a>");
         sb.Append("</div>");
     }         
 }
        private List<SingleProductViewModel> LoadProductGrid(ContentBlock b, MerchantTribeApplication app)
        {
            List<SingleProductViewModel> result = new List<SingleProductViewModel>();

            List<ContentBlockSettingListItem> myProducts = b.Lists.FindList("ProductGrid");
            if (myProducts != null)
            {
                int column = 1;

                if (b != null)
                {
                    int maxColumns = b.BaseSettings.GetIntegerSetting("GridColumns");
                    if (maxColumns < 1) maxColumns = 3;


                    // Pull all products in a single db call instead of individual calls
                    List<string> allProductBvins = myProducts.Select(y => y.Setting1).ToList();
                    List<Product> allProducts = app.CatalogServices.Products.FindMany(allProductBvins);

                    foreach (ContentBlockSettingListItem sett in myProducts)
                    {
                        string bvin = sett.Setting1;
                        Product p = allProducts.Where(y => y.Bvin == bvin).FirstOrDefault(); // app.CatalogServices.Products.Find(bvin);
                        if (p != null)
                        {
                            bool isLastInRow = false;
                            bool isFirstInRow = false;
                            if ((column == 1))
                            {
                                isFirstInRow = true;
                            }

                            if ((column == maxColumns))
                            {
                                column = 1;
                                isLastInRow = true;
                            }
                            else
                            {
                                column += 1;
                            }

                            SingleProductViewModel vm = new SingleProductViewModel(p, app);
                            vm.IsFirstItem = isFirstInRow;
                            vm.IsLastItem = isLastInRow;

                            result.Add(vm);
                        }
                    }
                }
            }

            return result;
        }
示例#34
0
 public void RenderColumn(StringBuilder sb, string colId, MerchantTribeApplication app, dynamic viewBag)
 {
     var column = LocateColumn(colId, app);
     if (column != null)
     {
         foreach (var block in column.Blocks)
         {
             sb.Append(MerchantTribeStore.Areas.ContentBlocks.RenderControllers.ContentBlockRenderFactory.RenderBlock(block, app, viewBag));
         }
     }
 }
示例#35
0
        public Accounts.UserAccount CurrentAdministrator(MerchantTribeApplication app) 
        {
                if (!IsAdmin(app)) return null;
                Accounts.AccountService accountServices = Accounts.AccountService.InstantiateForDatabase(this);
                Accounts.UserAccount admin = accountServices.FindAdminUserByAuthTokenId(_adminAuthTokenId.Value);
                
                if (admin == null) return null;
                if (admin.Id < 1) return null;

                return admin;        
        }
        public string RenderModel(SingleProductViewModel model, MerchantTribeApplication app)
        {
            StringBuilder sb = new StringBuilder();

            var productRenderer = new code.TemplateEngine.TagHandlers.SingleProduct();

            sb.Append("<div class=\"productrotator\"><div class=\"decoratedblock\"><div class=\"blockcontent\">");            
            sb.Append(productRenderer.RenderModelToString(model, app));            
            sb.Append("<div class=\"clear\"></div></div></div></div>");

            return sb.ToString();
        }      
示例#37
0
        protected override void Render(StringBuilder sb,
                            MerchantTribeApplication app,
                            dynamic viewBag,
                            ProductListViewModel model,
                            bool showPagers, int columns)
        {
            var profiler = MiniProfiler.Current;
            using (profiler.Step("Rendering Bulk Order List..."))
            {
                var preppedItems = base.PrepProducts(model.Items, columns, app);
                var pagerRenderer = new code.TemplateEngine.TagHandlers.Pager();

                if (showPagers == true)
                {
                    pagerRenderer.Render(sb, model.PagerData);
                }
                
                if (showPagers == true)
                {
                    pagerRenderer.Render(sb, model.PagerData);
                }

                                
                sb.Append("<form action=\"" + app.CurrentRequestContext.UrlHelper.Content("~/cart/bulkadd") + "\" method=\"post\">");
                sb.Append("<table width=\"100%\">");
                foreach (var item in preppedItems)
                {                    
                    sb.Append("<tr>");
                    sb.Append("<td class=\"checkbox\">");
                    if (item.Item.HasOptions())
                    {
                        sb.Append("&nbsp;");
                    }
                    else
                    {
                        sb.Append("<input type=\"checkbox\" name=\"bulkitem\" value=\"" + item.Item.Bvin + "\" />");
                    }
                    sb.Append("</td>");
                    sb.Append("<td class=\"records\">");
                    RenderSingleModel(sb, item, app);                            
                    sb.Append("</td>");
                    sb.Append("</tr>");              
                } 
                sb.Append("</table>");

                string buttonUrlAddToCart = app.ThemeManager().ButtonUrl("AddToCart", app.IsCurrentRequestSecure());
                sb.Append("<input type=\"image\" name=\"addtocart\" src=\"" + buttonUrlAddToCart + "\" alt=\"Add To Cart\" />");
                sb.Append("</form>");

            }
        }
示例#38
0
 public void RenderSingleModel(StringBuilder sb, SingleProductViewModel model, MerchantTribeApplication app)
 {
     sb.Append("<div class=\"record\">");
     sb.Append("<div class=\"recordsku\">");
     sb.Append("<a href=\"" + model.ProductLink + "\">" + HttpUtility.HtmlEncode(model.Item.Sku) + "</a>");
     sb.Append("</div>");
     sb.Append("<div class=\"recordname\">");
     sb.Append("<a href=\"" + model.ProductLink + "\">" + HttpUtility.HtmlEncode(model.Item.ProductName) + "</a>");
     sb.Append("</div>");
     sb.Append("<div class=\"recordprice\">");
     sb.Append("<a href=\"" + model.ProductLink + "\">" + model.UserPrice.DisplayPrice(true) + "</a>");
     sb.Append("</div>");
     sb.Append("</div>");
 }
        public string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
        {
            SingleCategoryViewModel model = new SingleCategoryViewModel();

            bool showInOrder = false;

            if (block != null)
            {
                showInOrder = block.BaseSettings.GetBoolSetting("ShowInOrder");

                List <ContentBlockSettingListItem> settings = block.Lists.FindList("Categories");

                int nextIndex = GetProductIndex(settings.Count - 1);

                if (settings.Count != 0)
                {
                    if (settings.Count > nextIndex)
                    {
                        LoadCategory(model, settings[nextIndex].Setting1, app);
                    }
                    else if (nextIndex >= settings.Count)
                    {
                        if (showInOrder)
                        {
                            nextIndex = 0;
                        }
                        else
                        {
                            nextIndex = MerchantTribe.Web.RandomNumbers.RandomInteger(settings.Count - 1, 0);
                        }
                        LoadCategory(model, settings[nextIndex].Setting1, app);
                    }

                    if (showInOrder)
                    {
                        nextIndex += 1;
                    }
                    else
                    {
                        nextIndex = MerchantTribe.Web.RandomNumbers.RandomInteger(settings.Count - 1, 0);
                    }
                }
            }

            return(RenderModel(model));
        }
        public string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
        {
            SideMenuViewModel model = new SideMenuViewModel();

            model.Title = "Top Weekly Sellers";

            DateTime _StartDate = DateTime.Now;
            DateTime _EndDate   = DateTime.Now;

            System.DateTime c = DateTime.Now;
            CalculateDates(c, _StartDate, _EndDate);
            model.Items = LoadProducts(app, _StartDate, _EndDate);

            model.Title = "Top Sellers";

            return(RenderModel(model));
        }
示例#41
0
        private MiniPagerViewModel FindModelForCurrentCategory(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, ParsedTag tag)
        {
            MiniPagerViewModel model = new MiniPagerViewModel();

            // get the current category
            var cat = app.CurrentRequestContext.CurrentCategory;

            if (cat == null)
            {
                return(model);
            }


            model.CurrentPage = GetPageFromRequest(app);
            int currentPageForCount = model.CurrentPage;

            if (model.CurrentPage == WebAppSettings.ViewAllPagesConstant)
            {
                // View All Requested
                model.TotalPages = 1;
            }
            else
            {
                // View by Pages Requested, calculate how many we have
                int pageSize = tag.GetSafeAttributeAsInteger("pagesize");
                if (pageSize < 1)
                {
                    pageSize = 9;
                }

                // Get Count of items in category, ignore pages because we just want the count
                int totalItems = 0;
                app.CatalogServices.FindProductForCategoryWithSort(cat.Bvin, MerchantTribe.Commerce.Catalog.CategorySortOrder.ManualOrder, false,
                                                                   1, 1, ref totalItems);
                model.TotalPages = MerchantTribe.Web.Paging.TotalPages(totalItems, pageSize);
            }

            model.PagerUrlFormat = UrlRewriter.BuildUrlForCategory(new CategorySnapshot(cat),
                                                                   app.CurrentRequestContext.RoutingContext,
                                                                   "{0}");
            model.PagerUrlFormatFirst = UrlRewriter.BuildUrlForCategory(new CategorySnapshot(cat),
                                                                        app.CurrentRequestContext.RoutingContext);
            return(model);
        }
示例#42
0
        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);
        }
示例#43
0
        public string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
        {
            SideMenuViewModel model = new SideMenuViewModel();

            if (block != null)
            {
                model.Title = block.BaseSettings.GetSettingOrEmpty("Title");

                List <ContentBlockSettingListItem> links = block.Lists.FindList("Links");
                if (links != null)
                {
                    foreach (ContentBlockSettingListItem l in links)
                    {
                        model.Items.Add(AddSingleLink(l));
                    }
                }
            }

            return(RenderModel(model));
        }
示例#44
0
        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 string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
        {
            RssFeedViewModel model = new RssFeedViewModel();

            model.Channel = new RSSChannel(new MerchantTribe.Commerce.EventLog());

            if (block != null)
            {
                string feedUrl = block.BaseSettings.GetSettingOrEmpty("FeedUrl");
                model.Channel.LoadFromFeed(feedUrl);
                model.ShowTitle       = block.BaseSettings.GetBoolSetting("ShowTitle");
                model.ShowDescription = block.BaseSettings.GetBoolSetting("ShowDescription");
                int max = block.BaseSettings.GetIntegerSetting("MaxItems");
                if (max <= 0)
                {
                    max = 5;
                }
                model.MaxItems = max;
            }

            return(RenderModel(model));
        }
示例#46
0
        public string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
        {
            SideMenuViewModel model = new SideMenuViewModel();

            System.DateTime s = new System.DateTime(1900, 1, 1);
            System.DateTime e = new System.DateTime(3000, 12, 31);
            List <Product>  products;

            products = app.ReportingTopSellersByDate(s, e, 10);
            foreach (Product p in products)
            {
                SideMenuItem item = new SideMenuItem();
                item.Title = p.ProductName;
                item.Name  = p.ProductName;
                item.Url   = UrlRewriter.BuildUrlForProduct(p, app.CurrentRequestContext.RoutingContext, string.Empty);
                item.Name += " - " + p.SitePrice.ToString("C");
                model.Items.Add(item);
            }

            model.Title = "Top Sellers";

            return(RenderModel(model));
        }
示例#47
0
        public string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
        {
            Product p = null;
            List <ContentBlockSettingListItem> myProducts = block.Lists.FindList("Products");

            if (myProducts != null)
            {
                if (myProducts.Count > 0)
                {
                    int displayIndex = GetProductIndex(myProducts.Count - 1);

                    ContentBlockSettingListItem data = myProducts[displayIndex];
                    string bvin = data.Setting1;
                    p = app.CatalogServices.Products.Find(bvin);
                }
            }

            if (p != null)
            {
                SingleProductViewModel model = new SingleProductViewModel(p, app);
                return(RenderModel(model, app));
            }
            return(string.Empty);
        }
 public ProductTypesHandler(MerchantTribe.Commerce.MerchantTribeApplication app)
     : base(app)
 {
 }
 public CategoriesImagesBannerHandler(MerchantTribe.Commerce.MerchantTribeApplication app)
     : base(app)
 {
 }
 public CustomerAccountHandler(MerchantTribe.Commerce.MerchantTribeApplication app)
     : base(app)
 {
 }
示例#51
0
 public TaxesHandler(MerchantTribe.Commerce.MerchantTribeApplication app)
     : base(app)
 {
 }
示例#52
0
 public ProductRelationshipsHandler(MerchantTribe.Commerce.MerchantTribeApplication app)
     : base(app)
 {
 }
示例#53
0
 public ProductFilesDataHandler(MerchantTribe.Commerce.MerchantTribeApplication app)
     : base(app)
 {
 }
 public ProductInventoryHandler(MerchantTribe.Commerce.MerchantTribeApplication app)
     : base(app)
 {
 }
示例#55
0
        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 ProductsMainImageHandler(MerchantTribe.Commerce.MerchantTribeApplication app)
     : base(app)
 {
 }
 public ProductImagesUploadHandler(MerchantTribe.Commerce.MerchantTribeApplication app)
     : base(app)
 {
 }
        public string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
        {
            List <SingleProductViewModel> model = LoadProductGrid(block, app);

            return(RenderModel(model, app));
        }
        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);
        }
示例#60
0
        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>");
            //}
        }