Exemplo n.º 1
0
        public void Process(List<ITemplateAction> actions, MerchantTribe.Commerce.MerchantTribeApplication app, ITagProvider tagProvider, ParsedTag tag, string innerContents)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<" + _tagName);

            string pathToTemplate = app.ThemeManager().ThemeFileUrl("",app) + "templates/";

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

            if (tag.IsSelfClosed)
            {
                sb.Append("/>");
            }
            else
            {
                sb.Append(">" + innerContents + "</" + _tagName + ">");
            }

            actions.Add(new Actions.LiteralText(sb.ToString()));
        }
Exemplo n.º 2
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);
        }
        public virtual SC3StringSegment DeserializeTag(ParsedTag tag)
        {
            switch (tag.Name)
            {
            case "color":
                return(DeserializeColorTag(tag));

            case "margin":
                return(DeserializeMarginTag(tag));

            case "font":
                return(DeserializeFontSizeTag(tag));

            case "center":
                return(new CenterTextCommand());

            case "%p":
                return(new PresentCommand(false));

            case "%e":
                return(new PresentCommand(true));

            default:
                return(DeserializeMarker(tag));
            }
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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));
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
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 + ">");
            }
        }
Exemplo n.º 8
0
        public string ReturnCorrectRepresentation_WithNoProperties(string value, Tag tag)
        {
            var parsedTag = ParsedTag.Create(TagInfo.Create(tag, TagPosition.None, 0)); // works bad with header tag

            parsedTag.Value = value;
            return(parsedTag.GetCurrentRepresentation());
        }
Exemplo n.º 9
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);
        }
        private Marker DeserializeMarker(ParsedTag tag)
        {
            switch (tag.Name.ToLowerInvariant())
            {
            case "%n":
                return(new Marker(MarkerKind.LineSeperator));

            case "name":
                return(new Marker(MarkerKind.CharacterName));

            case "line":
                return(new Marker(MarkerKind.DialogueLine));

            case "rubybase":
                return(new Marker(MarkerKind.RubyBase));

            case "rubytextstart":
                return(new Marker(MarkerKind.RubyTextStart));

            case "rubytextend":
                return(new Marker(MarkerKind.RubyTextEnd));

            case "and":
                return(new Marker(MarkerKind.NameAndCode));

            case "temp":
                return(new Marker(MarkerKind.TempMarker));

            default:
                throw new InvalidDataException();
            }
        }
Exemplo n.º 11
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 + ">");
            }                        
        }
Exemplo n.º 12
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);
        }
        private SetColorCommand DeserializeColorTag(ParsedTag tag)
        {
            string index = tag.GetAttribute("index");
            var    bytes = BinaryUtils.HexStrToBytes(index);

            return(new SetColorCommand(SC3ExpressionParser.ParseExpression(bytes)));
        }
Exemplo n.º 14
0
        public string Process(MerchantTribeApplication app, Dictionary<string, ITagHandler> handlers, ParsedTag tag, string contents)
        {
            this.App = app;
            this.Url = new System.Web.Mvc.UrlHelper(app.CurrentRequestContext.RoutingContext);
            CurrentCategory = app.CurrentRequestContext.CurrentCategory;
            if (CurrentCategory == null)
            {
                CurrentCategory = new Category();
                CurrentCategory.Bvin = "0";
            }

            StringBuilder sb = new StringBuilder();

            sb.Append("<div class=\"categorymenu\">");
            sb.Append("<div class=\"decoratedblock\">");

            string title = tag.GetSafeAttribute("title");
            if (title.Trim().Length > 0)
            {
                sb.Append("<h4>" + title + "</h4>");
            }

            sb.Append("<ul>");

            int maxDepth = 5;

            string mode = tag.GetSafeAttribute("mode");
            switch (mode.Trim().ToUpperInvariant())
            {
                case "ROOT":
                case "ROOTS":
                    // Root Categories Only
                    LoadRoots(sb);
                    break;
                case "ALL":
                    // All Categories
                    LoadAllCategories(sb, maxDepth);
                    break;
                case "":
                case "PEERS":
                    // Peers, Children and Parents
                    LoadPeersAndChildren(sb);
                    break;
                case "ROOTPLUS":
                    // Show root and expanded children
                    LoadRootPlusExpandedChildren(sb);
                    break;
                default:
                    // All Categories
                    LoadPeersAndChildren(sb);
                    break;
            }

            sb.Append("</ul>");

            sb.Append("</div>");
            sb.Append("</div>");

            return sb.ToString();
        }
Exemplo n.º 15
0
        public string Process(MerchantTribeApplication app, Dictionary<string, ITagHandler> handlers, ParsedTag tag, string contents)
        {
            string fileUrl = string.Empty;
            bool secure = app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection;

            ThemeManager tm = app.ThemeManager();

            string mode = tag.GetSafeAttribute("mode");
            if (mode == "legacy")
            {
                fileUrl = tm.CurrentStyleSheet(app, secure);
            }
            else if (mode == "system")
            {
                string cssFile = tag.GetSafeAttribute("file");
                fileUrl = app.StoreUrl(secure, false) + cssFile.TrimStart('/');
            }
            else
            {
                string fileName = tag.GetSafeAttribute("file");
                fileUrl = tm.ThemeFileUrl(fileName, app);
            }

            string result = string.Empty;
            result = "<link href=\"" + fileUrl + "\" rel=\"stylesheet\" type=\"text/css\" />";
            return result;
        }
Exemplo n.º 16
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);            
        }
Exemplo n.º 17
0
        public string Process(MerchantTribeApplication app, Dictionary<string, ITagHandler> handlers, ParsedTag tag, string contents)
        {
            string result = string.Empty;

            Orders.Order o = new Orders.Order();
            if (app.CurrentRequestContext.CurrentReceiptOrder != null)
            {
                o = app.CurrentRequestContext.CurrentReceiptOrder;

                // Adwords Tracker at bottom if needed
                if (app.CurrentStore.Settings.Analytics.UseGoogleAdWords)
                {
                    result = MerchantTribe.Commerce.Metrics.GoogleAnalytics.RenderGoogleAdwordTracker(
                                                            o.TotalGrand,
                                                            app.CurrentStore.Settings.Analytics.GoogleAdWordsId,
                                                            app.CurrentStore.Settings.Analytics.GoogleAdWordsLabel,
                                                            app.CurrentStore.Settings.Analytics.GoogleAdWordsBgColor,
                                                            app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection);
                }

                // Add Yahoo Tracker to Bottom if Needed
                if (app.CurrentStore.Settings.Analytics.UseYahooTracker)
                {
                    result += MerchantTribe.Commerce.Metrics.YahooAnalytics.RenderYahooTracker(
                        o, app.CurrentStore.Settings.Analytics.YahooAccountId);
                }
            }

            return result;
        }
Exemplo n.º 18
0
        public string Process(MerchantTribeApplication app, Dictionary<string, ITagHandler> handlers, ParsedTag tag, string contents)
        {
            StringBuilder sb = new StringBuilder();
            bool isSecureRequest = app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection;
            bool textOnly = false;
            string textOnlyTag = tag.GetSafeAttribute("textonly").Trim().ToLowerInvariant();
            if (textOnlyTag == "1" || textOnlyTag == "y" || textOnlyTag == "yes" || textOnlyTag == "true") textOnly = true;

            string storeRootUrl = app.CurrentStore.RootUrl();
            string storeName = app.CurrentStore.Settings.FriendlyName;

            string logoImage = app.CurrentStore.Settings.LogoImageFullUrl(app, isSecureRequest);
            string logoText = app.CurrentStore.Settings.LogoText;

            sb.Append("<a href=\"" + storeRootUrl + "\" title=\"" + storeName + "\"");

            if (contents.Trim().Length > 0)
            {
                sb.Append(">");
                sb.Append(contents);
            }
            else if (app.CurrentStore.Settings.UseLogoImage && textOnly == false)
            {
                sb.Append("><img src=\"" + logoImage + "\" alt=\"" + storeName + "\" />");
            }
            else
            {
                sb.Append(" class=\"logo\">");
                sb.Append(System.Web.HttpUtility.HtmlEncode(logoText));
            }
            sb.Append("</a>");

            return sb.ToString();
        }
Exemplo n.º 19
0
        public string Process(MerchantTribeApplication app, Dictionary<string, ITagHandler> handlers, ParsedTag tag, string contents)
        {
            string areaName = tag.GetSafeAttribute("name");

            string result = contents;

            // Get area data from the category if it exists, otherwise use the default area content
            if (app.CurrentRequestContext.CurrentCategory != null)
            {
                CategoryPageVersion v = app.CurrentRequestContext.CurrentCategory.GetCurrentVersion();
                if (v != null)
                {
                    string fromCat = v.Areas.GetAreaContent(areaName);
                    if (fromCat.Trim().Length > 0)
                    {
                        result = fromCat;
                    }
                }
            }

            // do replacements for legacy tags here
            result = MerchantTribe.Commerce.Utilities.TagReplacer.ReplaceContentTags(result,
                            app,
                            "",
                            app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection);
            return result;
        }
        private SetFontSizeCommand DeserializeFontSizeTag(ParsedTag tag)
        {
            string strSize = tag.GetAttribute("size");
            int    size    = int.Parse(strSize);

            return(new SetFontSizeCommand(size));
        }
Exemplo n.º 21
0
        public void Process(List<ITemplateAction> actions, MerchantTribe.Commerce.MerchantTribeApplication app, ITagProvider tagProvider, ParsedTag tag, string innerContents)
        {
            string fileUrl = string.Empty;
            bool secure = app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection;

            var tm = app.ThemeManager();

            string mode = tag.GetSafeAttribute("mode");
            if (mode == "legacy")
            {
                fileUrl = tm.CurrentStyleSheet(app, secure);
            }
            else if (mode == "system")
            {
                string cssFile = tag.GetSafeAttribute("file");
                fileUrl = app.StoreUrl(secure, false) + cssFile.TrimStart('/');
            }
            else
            {
                string fileName = tag.GetSafeAttribute("file");
                fileUrl = tm.ThemeFileUrl(fileName, app);
            }

            string result = string.Empty;
            result = "<link href=\"" + fileUrl + "\" rel=\"stylesheet\" type=\"text/css\" />";
            actions.Add(new Actions.LiteralText(result));
        }
Exemplo n.º 22
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>");
            }            
        }
Exemplo n.º 23
0
 public void Process(StringBuilder output,
                     MerchantTribeApplication app,
                     dynamic viewBag,
                     ITagProvider tagProvider,
                     ParsedTag tag, string contents)
 {
     Render(output, app, viewBag);
 }
Exemplo n.º 24
0
 public void Process(StringBuilder output, 
                     MerchantTribeApplication app, 
                     dynamic viewBag, 
                     ITagProvider tagProvider, 
                     ParsedTag tag, string contents)
 {
     Render(output, app, viewBag);
 }
Exemplo n.º 25
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);            
        }
Exemplo n.º 26
0
        public string Process(MerchantTribeApplication app, Dictionary<string, ITagHandler> handlers, ParsedTag tag, string contents)
        {
            StringBuilder sb = new StringBuilder();
            bool secure = app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection;
            string mode = tag.GetSafeAttribute("mode");

            if (mode == "system")
            {
                string baseScriptFolder = app.CurrentStore.RootUrl();
                if (secure) baseScriptFolder = app.CurrentStore.RootUrlSecure();
                if (baseScriptFolder.EndsWith("/") == false)
                {
                    baseScriptFolder += "/";
                }
                baseScriptFolder += "scripts/";

                bool useCDN = false;
                string cdn = tag.GetSafeAttribute("cdn");
                if (cdn == "1" || cdn == "true" || cdn == "y" || cdn == "Y") useCDN = true;

                if (useCDN)
                {
                    // CDN JQuery
                    if (secure)
                    {
                        sb.Append("<script src='https://ajax.microsoft.com/ajax/jQuery/jquery-1.5.1.min.js' type=\"text/javascript\"></script>");
                    }
                    else
                    {
                        sb.Append("<script src='http://ajax.microsoft.com/ajax/jQuery/jquery-1.5.1.min.js' type=\"text/javascript\"></script>");
                    }
                }
                else
                {
                    // Local JQuery
                    sb.Append("<script src='" + baseScriptFolder + "jquery-1.5.1.min.js' type=\"text/javascript\"></script>");
                }
                sb.Append(System.Environment.NewLine);

                sb.Append("<script src='" + baseScriptFolder + "jquery-ui-1.8.7.custom/js/jquery-ui-1.8.7.custom.min.js' type=\"text/javascript\"></script>");
                sb.Append("<script src='" + baseScriptFolder + "jquery.form.js' type=\"text/javascript\"></script>");
                sb.Append(System.Environment.NewLine);
            }
            else
            {
                string src = tag.GetSafeAttribute("src");
                string fileName = tag.GetSafeAttribute("file");
                if (fileName.Trim().Length > 0)
                {
                    ThemeManager tm = app.ThemeManager();
                    src = tm.ThemeFileUrl(fileName, app);
                }
                sb.Append("<script src=\"" + src + "\" type=\"text/javascript\"></script>");
            }

            return sb.ToString();
        }
Exemplo n.º 27
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());
 }
Exemplo n.º 28
0
 public void Process(StringBuilder output,
                     MerchantTribe.Commerce.MerchantTribeApplication app,
                     dynamic viewBag,
                     ITagProvider tagProvider,
                     ParsedTag tag,
                     string innerContents)
 {
     output.Append((string)viewBag.analyticsbottom);
 }
Exemplo n.º 29
0
 public void Process(List<ITemplateAction> actions, MerchantTribe.Commerce.MerchantTribeApplication app, ITagProvider tagProvider, ParsedTag tag, string innerContents)
 {
     StringBuilder sb = new StringBuilder();
     foreach (string s in app.CurrentRequestContext.TempMessages)
     {
         sb.Append(s);
     }
     actions.Add(new Actions.LiteralText(sb.ToString()));
 }
Exemplo n.º 30
0
 public void Process(StringBuilder output,
                     MerchantTribe.Commerce.MerchantTribeApplication app,
                     dynamic viewBag,
                     ITagProvider tagProvider,
                     ParsedTag tag,
                     string innerContents)
 {
     output.Append(Render(app, viewBag));
 }
Exemplo n.º 31
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());
 }
Exemplo n.º 32
0
        private void PassAttribute(ref StringBuilder sb, ParsedTag tag, string name)
        {
            string value = tag.GetSafeAttribute(name);

            if (value.Length > 0)
            {
                sb.Append(" " + name + "=\"" + value + "\"");
            }
        }
Exemplo n.º 33
0
        public void Process(List<ITemplateAction> actions, MerchantTribe.Commerce.MerchantTribeApplication app, ITagProvider tagProvider, ParsedTag tag, string innerContents)
        {
            string byParam = tag.GetSafeAttribute("by");

            dynamic model = new ExpandoObject();
            model.By = byParam;

            actions.Add(new Actions.PartialView("~/views/shared/_copyright.cshtml", model));
        }
Exemplo n.º 34
0
 public void Process(StringBuilder output,
                     MerchantTribe.Commerce.MerchantTribeApplication app,
                     dynamic viewBag,
                     ITagProvider tagProvider,
                     ParsedTag tag,
                     string innerContents)
 {
     output.Append((string)viewBag.analyticsbottom);
 }
Exemplo n.º 35
0
 public void Process(StringBuilder output,
                     MerchantTribe.Commerce.MerchantTribeApplication app,
                     dynamic viewBag,
                     ITagProvider tagProvider,
                     ParsedTag tag,
                     string innerContents)
 {
     output.Append(Render(app, viewBag));
 }
Exemplo n.º 36
0
        public void Process(List<ITemplateAction> actions, MerchantTribe.Commerce.MerchantTribeApplication app, 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.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection);

            actions.Add(new Actions.PartialView("~/views/shared/_SearchForm.cshtml", model));
        }
Exemplo n.º 37
0
        public string Process(MerchantTribeApplication app, Dictionary<string, ITagHandler> handlers, ParsedTag tag, string contents)
        {
            string partName = tag.GetSafeAttribute("part");

            ThemeManager tm = app.ThemeManager();
            string result = tm.GetTemplatePartFromCurrentTheme(partName);
            TemplateProcessor proc = new TemplateProcessor(app, result, handlers);
            string processed = proc.RenderForDisplay();
            return processed;
        }
Exemplo n.º 38
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);
        }
Exemplo n.º 39
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());            
 }
Exemplo n.º 40
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));
                }
            }
        }
Exemplo n.º 41
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));
                }
            }
        }
Exemplo n.º 42
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));
 }
Exemplo n.º 43
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);
        }
Exemplo n.º 44
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());
        }
Exemplo n.º 45
0
        public string Process(MerchantTribeApplication app, Dictionary<string, ITagHandler> handlers, ParsedTag tag, string contents)
        {
            StringBuilder sb = new StringBuilder();

            foreach (string s in app.CurrentRequestContext.TempMessages)
            {
                sb.Append(s);
            }

            return sb.ToString();
        }
Exemplo n.º 46
0
        public void Process(List<ITemplateAction> actions, MerchantTribe.Commerce.MerchantTribeApplication app, ITagProvider tagProvider, ParsedTag tag, string innerContents)
        {
            List<BreadCrumbItem> extras = new List<BreadCrumbItem>();

            string[] parts = innerContents.Split(',');
            if (parts.Length > 0)
            {
                foreach (string p in parts)
                {
                    string[] linkParts = p.Split('|');
                    if (linkParts.Length > 0)
                    {
                        string name = linkParts[0].Trim();
                        if (name.Length > 0)
                        {
                            BreadCrumbItem item = new BreadCrumbItem();
                            item.Name = linkParts[0].Trim();
                            item.Link = "";
                            if (linkParts.Length > 1)
                            {
                                item.Link = linkParts[1].Trim();
                            }
                            extras.Add(item);
                        }
                    }
                }
            }

            string mode = tag.GetSafeAttribute("mode");
            if (mode == "manual")
            {
                actions.Add(new Actions.CallAction("BreadCrumb", "ManualTrail",
                        new { extras = extras }));
            }
            else
            {
                if (app.CurrentRequestContext.CurrentProduct != null)
                {
                    actions.Add(new Actions.CallAction("BreadCrumb", "ProductTrail",
                        new { product = app.CurrentRequestContext.CurrentProduct, extras = extras }));
                }
                else if (app.CurrentRequestContext.CurrentCategory != null)
                {
                    actions.Add(new Actions.CallAction("BreadCrumb", "CategoryTrail",
                        new { cat = app.CurrentRequestContext.CurrentCategory, extras = extras }));
                }
                else
                {
                    actions.Add(new Actions.CallAction("BreadCrumb", "ManualTrail",
                        new { extras = extras }));
                }
            }
        }
Exemplo n.º 47
0
        public string Process(MerchantTribeApplication app, Dictionary<string, ITagHandler> handlers, ParsedTag tag, string contents)
        {
            StringBuilder sb = new StringBuilder();

            string rootUrl = app.StoreUrl(false, true);
            string buttonUrl = app.ThemeManager().ButtonUrl("Go", app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection);
            sb.Append("<form class=\"searchform\" action=\"" + rootUrl + "search\" method=\"get\">");
            sb.Append("<input type=\"text\" name=\"q\" class=\"searchinput\" /> <input class=\"searchgo\" type=\"image\" src=\"" + buttonUrl + "\" alt=\"Search\" />");
            sb.Append("</form>");

            return sb.ToString();
        }
Exemplo n.º 48
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);
     }
 }
Exemplo n.º 49
0
        public void ReturnCorrectHyperlinkRepresentation()
        {
            var parsedTag = ParsedTag.Create(new HyperlinkTagInfo(new TagType(TagPosition.None, 0)));

            parsedTag.Value = "some_text";
            parsedTag.AddProperty("href", "ya.ru");
            var expectedResult = "<a href=\"ya.ru\">some_text</a>";

            var actualResult = parsedTag.GetCurrentRepresentation();

            actualResult.Should().Be(expectedResult);
        }
Exemplo n.º 50
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);
     }
 }
Exemplo n.º 51
0
        public override SC3StringSegment DeserializeTag(ParsedTag tag)
        {
            if (IsNumber(tag.Name))
            {
                return(null);
            }

            if (tag.Name == "comment")
            {
                return(null);
            }

            return(base.DeserializeTag(tag));
        }
Exemplo n.º 52
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));
        }
Exemplo n.º 53
0
        void ITagHandler.Process(StringBuilder output,
                                 MerchantTribeApplication app,
                                 dynamic viewBag,
                                 ITagProvider tagProvider,
                                 ParsedTag tag,
                                 string innerContents)
        {
            string partName = tag.GetSafeAttribute("part");

            ThemeManager tm     = app.ThemeManager();
            string       result = tm.GetTemplatePartFromCurrentTheme(partName);
            Processor    proc   = new Processor(app, viewBag, result, tagProvider);

            proc.RenderForDisplay(output);
        }
Exemplo n.º 54
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 + "\">");
        }
Exemplo n.º 55
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);
        }
Exemplo n.º 56
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));
        }
Exemplo n.º 57
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>");
                }
            }
        }
Exemplo n.º 58
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);
        }
Exemplo n.º 59
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);
        }
        private SetMarginCommand DeserializeMarginTag(ParsedTag tag)
        {
            if (!tag.Attributes.Any())
            {
                throw new InvalidDataException();
            }

            var attr = tag.Attributes.First();

            switch (attr.Key)
            {
            case "left":
                return(new SetMarginCommand(int.Parse(attr.Value), null));

            case "top":
                return(new SetMarginCommand(null, int.Parse(attr.Value)));

            default:
                throw new InvalidDataException();
            }
        }