Esempio n. 1
0
        public static string ReplaceContentTags(string source, HotcakesApplication app)
        {
            if (source.Contains("{{"))
            {
                var isSecureRequest = app.IsCurrentRequestSecure();
                var currentUserId   = app.CurrentCustomerId;

                var output = source;

                var r = RouteTable.Routes;

                output = output.Replace("{{homelink}}", app.StoreUrl(isSecureRequest, false));
                output = output.Replace("{{logo}}", HtmlRendering.Logo(app, isSecureRequest));
                output = output.Replace("{{logotext}}", HtmlRendering.LogoText(app));
                output = output.Replace("{{headerlinks}}", HtmlRendering.HeaderLinks(app, currentUserId));
                output = output.Replace("{{sitefiles}}", DiskStorage.GetStoreDataUrl(app, isSecureRequest));

                output = output.Replace("{{storeaddress}}",
                                        app.ContactServices.Addresses.FindStoreContactAddress().ToHtmlString());

                return(output);
            }
            return(source);
        }
Esempio n. 2
0
        /// <summary>
        ///     This method will iterate through the specified swatches and emit the requisite HTML for each
        /// </summary>
        /// <param name="p">Product - an instance of the product to find swatches for</param>
        /// <param name="app">HotcakesApplicateion - an instance of the current store application object</param>
        /// <returns>String - the HTML to be used for rendering the swatches</returns>
        /// <remarks>
        ///     If the swatch doesn't match an available swatch file, it will not be included in the HTML. Also, all swatch
        ///     images must be PNG or GIF.
        /// </remarks>
        public static string GenerateSwatchHtmlForProduct(Product p, HotcakesApplication app)
        {
            var result = string.Empty;

            if (app.CurrentStore.Settings.ProductEnableSwatches == false)
            {
                return(result);
            }

            if (p.Options.Count > 0)
            {
                var found = false;

                var swatchBase = DiskStorage.GetStoreDataUrl(app, app.IsCurrentRequestSecure());
                swatchBase += "swatches";
                if (p.SwatchPath.Length > 0)
                {
                    swatchBase += "/" + p.SwatchPath;
                }

                var swatchPhysicalBase = DiskStorage.GetStoreDataPhysicalPath(app.CurrentStore.Id);
                swatchPhysicalBase += "swatches\\";
                if (p.SwatchPath.Length > 0)
                {
                    swatchPhysicalBase += p.SwatchPath + "\\";
                }

                var sb = new StringBuilder();
                sb.Append("<div class=\"productswatches\">");
                foreach (var opt in p.Options)
                {
                    if (opt.IsColorSwatch)
                    {
                        found = true;
                        foreach (var oi in opt.Items)
                        {
                            if (oi.IsLabel)
                            {
                                continue;
                            }

                            var prefix = CleanSwatchName(oi.Name);

                            if (File.Exists(swatchPhysicalBase + prefix + ".png"))
                            {
                                sb.Append("<img width=\"18\" height=\"18\" src=\"" + swatchBase + "/" + prefix +
                                          ".png\" border=\"0\" alt=\"" + prefix + "\" />");
                            }
                            else
                            {
                                sb.Append("<img width=\"18\" height=\"18\" src=\"" + swatchBase + "/" + prefix +
                                          ".gif\" border=\"0\" alt=\"" + prefix + "\" />");
                            }
                        }
                    }
                }
                sb.Append("</div>");

                if (found)
                {
                    result = sb.ToString();
                }
            }

            return(result);
        }