/// <summary> /// Displays the product rating /// </summary> /// <param name="ThisCustomer">Customer object</param> /// <param name="ProductID">Product ID of the product rating to display</param> /// <param name="CategoryID">Category ID of the product rating to display</param> /// <param name="SectionID">Section ID of the product rating to display</param> /// <param name="ManufacturerID">Manufacturer ID of the product rating to display</param> /// <param name="SkinID">skin id of the page</param> /// <param name="encloseInTab">set to true if not to be displayed in a tabUI</param> /// <returns>returns string html to be rendered</returns> static public String Display(Customer ThisCustomer, int ProductID, int CategoryID, int SectionID, int ManufacturerID, int SkinID, bool encloseInTab) { string productName = AppLogic.GetProductName(ProductID, ThisCustomer.LocaleSetting); StringBuilder tmpS = new StringBuilder(50000); if (!AppLogic.IsAdminSite) { tmpS.Append("<input type=\"hidden\" name=\"ProductID\" value=\"" + ProductID.ToString() + "\">"); tmpS.Append("<input type=\"hidden\" name=\"CategoryID\" value=\"" + CategoryID.ToString() + "\">"); tmpS.Append("<input type=\"hidden\" name=\"SectionID\" value=\"" + SectionID.ToString() + "\">"); tmpS.Append("<input type=\"hidden\" name=\"ManufacturerID\" value=\"" + ManufacturerID.ToString() + "\">"); if (!encloseInTab) { tmpS.Append("<input type=\"hidden\" name=\"productTabs\" value=\"2\">"); } } if (encloseInTab) { tmpS.Append("<div class=\"group-header rating-header\">" + AppLogic.GetString("Header.ProductRatings", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</div>"); } // RATINGS BODY: string sql = string.Format("aspdnsf_ProductStats {0}, {1}", ProductID, AppLogic.StoreID()); int ratingsCount = 0; decimal ratingsAverage = 0; using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn())) { dbconn.Open(); using (IDataReader rs = DB.GetRS(sql, dbconn)) { rs.Read(); ratingsCount = DB.RSFieldInt(rs, "NumRatings"); int SumRatings = DB.RSFieldInt(rs, "SumRatings"); ratingsAverage = DB.RSFieldDecimal(rs, "AvgRating"); } } int[] ratingPercentages = new int[6]; // indexes 0-5, but we only use indexes 1-5 using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn())) { string query = string.Format("select Productid, rating, count(rating) as N from Rating with (NOLOCK) where Productid = {0} and StoreID = {1} group by Productid,rating order by rating", ProductID, AppLogic.StoreID()); dbconn.Open(); using (IDataReader rs = DB.GetRS(query, dbconn)) { while (rs.Read()) { int NN = DB.RSFieldInt(rs, "N"); Decimal pp = ((Decimal)NN) / ratingsCount; int pper = (int)(pp * 100.0M); ratingPercentages[DB.RSFieldInt(rs, "Rating")] = pper; } } } string sortDescription = AppLogic.GetString("ratings.cs.1", SkinID, Thread.CurrentThread.CurrentUICulture.Name); string filterDescription = string.Empty; string fieldSuffix = string.Empty; int orderIndex = 0; if ("OrderBy".Equals(CommonLogic.FormCanBeDangerousContent("__EVENTTARGET"), StringComparison.InvariantCultureIgnoreCase)) { orderIndex = CommonLogic.FormNativeInt("OrderBy"); } if (orderIndex == 0) { orderIndex = 3; } switch (orderIndex) { case 1: sortDescription = AppLogic.GetString("ratings.cs.1", SkinID, Thread.CurrentThread.CurrentUICulture.Name); break; case 2: sortDescription = AppLogic.GetString("ratings.cs.2", SkinID, Thread.CurrentThread.CurrentUICulture.Name); break; case 3: sortDescription = AppLogic.GetString("ratings.cs.3", SkinID, Thread.CurrentThread.CurrentUICulture.Name); break; case 4: sortDescription = AppLogic.GetString("ratings.cs.4", SkinID, Thread.CurrentThread.CurrentUICulture.Name); break; case 5: sortDescription = AppLogic.GetString("ratings.cs.5", SkinID, Thread.CurrentThread.CurrentUICulture.Name); break; case 6: sortDescription = AppLogic.GetString("ratings.cs.6", SkinID, Thread.CurrentThread.CurrentUICulture.Name); break; } int pageSize = AppLogic.AppConfigUSInt("RatingsPageSize"); int pageNumber = CommonLogic.QueryStringUSInt("PageNum"); if (pageNumber == 0) { pageNumber = 1; } if (pageSize == 0) { pageSize = 10; } if (CommonLogic.QueryStringCanBeDangerousContent("show") == "all") { pageSize = 1000000; pageNumber = 1; } SqlConnection conn = new SqlConnection(); conn.ConnectionString = DB.GetDBConn(); conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "aspdnsf_GetProductComments"; cmd.Parameters.Add(new SqlParameter("@ProductID", SqlDbType.Int)); cmd.Parameters.Add(new SqlParameter("@votingcustomer", SqlDbType.Int)); cmd.Parameters.Add(new SqlParameter("@pagesize", SqlDbType.Int)); cmd.Parameters.Add(new SqlParameter("@pagenum", SqlDbType.Int)); cmd.Parameters.Add(new SqlParameter("@sort", SqlDbType.TinyInt)); cmd.Parameters.Add(new SqlParameter("@storeID", SqlDbType.Int)); cmd.Parameters["@ProductID"].Value = ProductID; cmd.Parameters["@votingcustomer"].Value = ThisCustomer.CustomerID; cmd.Parameters["@pagesize"].Value = pageSize; cmd.Parameters["@pagenum"].Value = pageNumber; cmd.Parameters["@sort"].Value = orderIndex; cmd.Parameters["@storeID"].Value = AppLogic.StoreID(); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); int rowsCount = Convert.ToInt32(dr["totalcomments"]); int pagesCount = Convert.ToInt32(dr["pages"]); dr.NextResult(); if (pageNumber > pagesCount && pageNumber > 1 && rowsCount == 0) { dr.Close(); HttpContext.Current.Response.Redirect("showProduct.aspx?ProductID=" + ProductID.ToString() + "&pagenum=" + (pageNumber - 1).ToString()); } int StartRow = (pageSize * (pageNumber - 1)) + 1; int StopRow = CommonLogic.IIF((StartRow + pageSize - 1) > rowsCount, rowsCount, StartRow + pageSize - 1); if (ratingsCount > 0) { tmpS.AppendFormat("<span itemprop=\"aggregateRating\" itemscope itemtype=\"{0}://schema.org/AggregateRating\">{1}", HttpContext.Current.Request.Url.Scheme, Environment.NewLine); tmpS.AppendFormat("<meta itemprop=\"ratingValue\" content=\"{0}\"/>{1}", ratingsAverage, Environment.NewLine); tmpS.AppendFormat("<meta itemprop=\"reviewCount\" content=\"{0}\"/>{1}", ratingsCount, Environment.NewLine); tmpS.AppendFormat("<meta itemprop=\"bestRating\" content=\"5\"/>{0}", Environment.NewLine); tmpS.AppendFormat("<meta itemprop=\"worstRating\" content=\"1\"/>{0}", Environment.NewLine); tmpS.AppendFormat("</span>{0}", Environment.NewLine); } tmpS.Append("<div class=\"page-row total-rating-row\">"); tmpS.Append(" <div class=\"rating-stars-wrap\">"); tmpS.Append(CommonLogic.BuildStarsImage(ratingsAverage, SkinID) + "<span class=\"ratings-average-wrap\">(" + String.Format("{0:f}", ratingsAverage) + ")</span>"); tmpS.Append(" </div>"); tmpS.Append(" <div class=\"rating-count-wrap\">"); tmpS.Append(" <span>" + AppLogic.GetString("ratings.cs.23", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</span> " + ratingsCount.ToString()); tmpS.Append(" </div>"); tmpS.Append("</div>"); string rateScript = "javascript:RateIt(" + ProductID.ToString() + ");"; int productRating = Ratings.GetProductRating(ThisCustomer.CustomerID, ProductID); tmpS.Append("<div class=\"page-row rating-link-row\">"); if (productRating != 0) { tmpS.Append("<div class=\"rating-link-wrap\">"); tmpS.Append(" <span>" + AppLogic.GetString("ratings.cs.24", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + " " + productRating.ToString() + "</span>"); tmpS.Append("</div>"); if (!AppLogic.IsAdminSite) { tmpS.Append("<div class=\"rating-link-wrap\">"); tmpS.Append(" <a href=\"" + rateScript + "\">" + AppLogic.GetString("ratings.cs.25", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</a> "); tmpS.Append(" <span>"+ AppLogic.GetString("ratings.cs.26", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</span>"); tmpS.Append("</div>"); } } else { if ((AppLogic.AppConfigBool("RatingsCanBeDoneByAnons") || ThisCustomer.IsRegistered) && !AppLogic.IsAdminSite) { tmpS.Append("<div class=\"rating-link-wrap\">"); tmpS.Append(" <a href=\"" + rateScript + "\">" + AppLogic.GetString("image.altText.10", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</a>"); tmpS.Append("</div>"); tmpS.Append("<div class=\"rating-link-wrap\">"); tmpS.Append(" <a href=\"" + rateScript + "\">" + AppLogic.GetString("ratings.cs.28", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</a> "); tmpS.Append(" <span>"+ AppLogic.GetString("ratings.cs.27", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</span>"); tmpS.Append("</div>"); } else { tmpS.Append("<div class=\"rating-link-wrap\">"); tmpS.Append(" <span>" + AppLogic.GetString("ratings.cs.29", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</span>"); tmpS.Append("</div>"); } } tmpS.Append("</div>"); if (rowsCount == 0) { tmpS.Append(AppLogic.GetString("ratings.cs.39", SkinID, Thread.CurrentThread.CurrentUICulture.Name)); if (AppLogic.AppConfigBool("RatingsCanBeDoneByAnons") || ThisCustomer.IsRegistered && !AppLogic.IsAdminSite) { tmpS.Append(" <a href=\"" + rateScript + "\">" + AppLogic.GetString("ratings.cs.40", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</a> " + AppLogic.GetString("ratings.cs.41", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</a>"); } } else { while (dr.Read()) { tmpS.AppendFormat("<div class=\"page-row rating-comment-row\" itemprop=\"review\" itemscope itemtype=\"{0}://schema.org/Review\">{1}", HttpContext.Current.Request.Url.Scheme, Environment.NewLine); tmpS.AppendFormat("<meta itemprop=\"datePublished\" content=\"{0}\"/>{1}", Convert.ToDateTime(dr["CreatedOn"]).ToString("yyyy-MM-dd"), Environment.NewLine); tmpS.AppendFormat("<meta itemprop=\"itemReviewed\" content=\"{0}\"/>{1}", productName, Environment.NewLine); tmpS.Append(" <div class=\"rating-author-wrap\">\n"); tmpS.Append(" <span class=\"rating-row-number\">"+ dr["rownum"].ToString() + ". </span><span class=\"rating-row-author\" itemprop=\"author\">" + HttpContext.Current.Server.HtmlEncode(CommonLogic.IIF(dr["FirstName"].ToString().Length == 0, AppLogic.GetString("ratings.cs.14", SkinID, Thread.CurrentThread.CurrentUICulture.Name), dr["FirstName"].ToString())) + "</span> <span class=\"rating-row-said\">" + AppLogic.GetString("ratings.cs.15", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + " " + Localization.ToThreadCultureShortDateString(Convert.ToDateTime(dr["CreatedOn"])) + ", " + AppLogic.GetString("ratings.cs.16", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + " </span>"); tmpS.Append(" </div>"); tmpS.AppendFormat("<div class=\"rating-comment-stars\" itemprop=\"reviewRating\" itemscope itemtype=\"{0}://schema.org/Rating\">{1}", HttpContext.Current.Request.Url.Scheme, Environment.NewLine); tmpS.AppendFormat("<meta itemprop=\"bestRating\" content=\"5\"/>{0}", Environment.NewLine); tmpS.AppendFormat("<meta itemprop=\"worstRating\" content=\"1\"/>{0}", Environment.NewLine); tmpS.AppendFormat("<meta itemprop=\"ratingValue\" content=\"{0}\"/>{1}", Convert.ToDecimal(dr["Rating"]), Environment.NewLine); tmpS.Append(CommonLogic.BuildStarsImage(Convert.ToDecimal(dr["Rating"]), SkinID)); tmpS.Append(" </div>"); tmpS.Append(" <div class=\"rating-comments\" itemprop=\"reviewBody\">\n"); tmpS.Append(HttpContext.Current.Server.HtmlEncode(dr["Comments"].ToString())); tmpS.Append(" </div>\n"); tmpS.Append("</div>\n"); tmpS.Append("<div class=\"form rating-comment-helpfulness-wrap\">"); tmpS.Append(" <div class=\"form-group\">"); if (ThisCustomer.CustomerID != Convert.ToInt32(dr["CustomerID"])) { if (!AppLogic.IsAdminSite) { tmpS.Append(AppLogic.GetString("ratings.cs.42", SkinID, Thread.CurrentThread.CurrentUICulture.Name)); tmpS.Append("<input TYPE=\"RADIO\" NAME=\"helpful_" + ProductID.ToString() + "_" + dr["CustomerID"].ToString() + "\" onClick=\"return RateComment('" + ProductID.ToString() + "','" + ThisCustomer.CustomerID + "','Yes','" + dr["CustomerID"].ToString() + "');\" " + CommonLogic.IIF(Convert.ToInt16(dr["CommentHelpFul"]) == 1, " checked ", "") + ">\n"); tmpS.Append("<span>" + AppLogic.GetString("ratings.cs.43", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</span> \n"); tmpS.Append("<input TYPE=\"RADIO\" NAME=\"helpful_" + ProductID.ToString() + "_" + dr["CustomerID"].ToString() + "\" onClick=\"return RateComment('" + ProductID.ToString() + "','" + ThisCustomer.CustomerID + "','No','" + dr["CustomerID"].ToString() + "');\" " + CommonLogic.IIF(Convert.ToInt16(dr["CommentHelpFul"]) == 0, " checked ", "") + ">\n"); tmpS.Append("<span>" + AppLogic.GetString("ratings.cs.44", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</span> \n"); } else { tmpS.Append(AppLogic.GetString("ratings.cs.42", SkinID, Thread.CurrentThread.CurrentUICulture.Name)); tmpS.Append("<input TYPE=\"RADIO\" NAME=\"helpful_" + ProductID.ToString() + "_" + dr["CustomerID"].ToString() + "\" " + CommonLogic.IIF(Convert.ToInt16(dr["CommentHelpFul"]) == 1, " checked ", "") + ">\n"); tmpS.Append("<span>" + AppLogic.GetString("ratings.cs.43", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</span>\n"); tmpS.Append("<input TYPE=\"RADIO\" NAME=\"helpful_" + ProductID.ToString() + "_" + dr["CustomerID"].ToString() + "\" " + CommonLogic.IIF(Convert.ToInt16(dr["CommentHelpFul"]) == 0, " checked ", "") + ">\n"); tmpS.Append("<span>" + AppLogic.GetString("ratings.cs.44", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</span>\n"); } } tmpS.Append(" </div>\n"); tmpS.Append(" <div class=\"form-text rating-helpfulness-text\">"); tmpS.Append(" ("+ dr["FoundHelpful"].ToString() + " " + AppLogic.GetString("ratings.cs.17", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + " " + CommonLogic.IIF(ThisCustomer.CustomerID != Convert.ToInt32(dr["CustomerID"]), AppLogic.GetString("ratings.cs.18", SkinID, Thread.CurrentThread.CurrentUICulture.Name), AppLogic.GetString("ratings.cs.19", SkinID, Thread.CurrentThread.CurrentUICulture.Name)) + " " + AppLogic.GetString("ratings.cs.20", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + ", " + dr["FoundNotHelpful"].ToString() + " " + AppLogic.GetString("ratings.cs.21", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + ")"); tmpS.Append(" </div>\n"); tmpS.Append("</div>\n"); } } dr.Close(); if (rowsCount > 0) { tmpS.Append("<div class=\"page-row comments-count-wrap\">"); tmpS.Append(String.Format(AppLogic.GetString("ratings.cs.37", SkinID, Thread.CurrentThread.CurrentUICulture.Name), StartRow.ToString(), StopRow.ToString(), rowsCount.ToString())); if (pagesCount > 1) { tmpS.Append(" ("); if (pageNumber > 1) { tmpS.Append("<a href=\"showProduct.aspx?ProductID=" + CommonLogic.QueryStringUSInt("ProductID").ToString() + "&OrderBy=" + orderIndex.ToString() + "&pagenum=" + (pageNumber - 1).ToString() + "\">" + AppLogic.GetString("ratings.cs.10", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + " " + pageSize.ToString() + "</a>"); } if (pageNumber > 1 && pageNumber < pagesCount) { tmpS.Append(" | "); } if (pageNumber < pagesCount) { tmpS.Append("<a href=\"showProduct.aspx?ProductID=" + CommonLogic.QueryStringUSInt("ProductID").ToString() + "&OrderBy=" + orderIndex.ToString() + "&pagenum=" + (pageNumber + 1).ToString() + "\">" + AppLogic.GetString("ratings.cs.11", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + " " + pageSize.ToString() + "</a>"); } tmpS.Append(")"); } tmpS.Append("</div>\n"); tmpS.Append("<div class=\"page-row comments-pager-wrap\">"); if (pagesCount > 1) { tmpS.Append("<a href=\"showProduct.aspx?ProductID=" + CommonLogic.QueryStringUSInt("ProductID").ToString() + "&show=all\">" + AppLogic.GetString("ratings.cs.28", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</a> " + AppLogic.GetString("ratings.cs.38", SkinID, Thread.CurrentThread.CurrentUICulture.Name)); } tmpS.Append("</div>\n"); } // END RATINGS BODY: if (!AppLogic.IsAdminSite) { tmpS.Append("<div id=\"RateCommentDiv\" name=\"RateCommentDiv\" style=\"position:absolute; left:0px; top:0px; visibility:" + AppLogic.AppConfig("RatingsCommentFrameVisibility") + "; z-index:2000; \">\n"); tmpS.Append("<iframe name=\"RateCommentFrm\" id=\"RateCommentFrm\" width=\"400\" height=\"100\" hspace=\"0\" vspace=\"0\" marginheight=\"0\" marginwidth=\"0\" frameborder=\"0\" noresize scrolling=\"yes\" src=\"" + AppLogic.LocateImageURL("empty.htm") + "\"></iframe>\n"); tmpS.Append("</div>\n"); tmpS.Append("<script type=\"text/javascript\">\n"); tmpS.Append("function RateComment(ProductID,MyCustomerID,MyVote,RatersCustomerID)\n"); tmpS.Append(" {\n"); tmpS.Append(" RateCommentFrm.location = 'RateComment.aspx?Productid=' + ProductID + '&VotingCustomerID=' + MyCustomerID + '&MyVote=' + MyVote + '&CustomerID=' + RatersCustomerID\n"); tmpS.Append(" }\n"); tmpS.Append("</script>\n"); tmpS.Append("<script type=\"text/javascript\">\n"); tmpS.Append(" function RateIt(ProductID)\n"); tmpS.Append(" {\n"); tmpS.Append(" window.open('"+ AppLogic.ResolveUrl("~/rateit.aspx") + "?Productid=' + ProductID + '&refresh=no&returnurl=" + HttpContext.Current.Server.UrlEncode(CommonLogic.PageInvocation()) + "','ASPDNSF_ML" + CommonLogic.GetRandomNumber(1, 100000).ToString() + "','height=550,width=400,top=10,left=20,status=no,toolbar=no,menubar=no,scrollbars=yes,location=no')\n"); tmpS.Append(" }\n"); tmpS.Append("</SCRIPT>\n"); } return(tmpS.ToString()); }
/// <summary> /// Displays the product rating /// </summary> /// <param name="customer">Customer object</param> /// <param name="productId">Product ID of the product rating to display</param> /// <param name="categoryId">Category ID of the product rating to display</param> /// <param name="sectionId">Section ID of the product rating to display</param> /// <param name="manufacturerId">Manufacturer ID of the product rating to display</param> /// <param name="skinId">skin id of the page</param> /// <param name="encloseInTab">set to true if not to be displayed in a tabUI</param> /// <returns>returns string html to be rendered</returns> static public string Display(Customer customer, int productId, int categoryId, int sectionId, int manufacturerId, int skinId, bool encloseInTab) { var productName = AppLogic.GetProductName(productId, customer.LocaleSetting); var outputString = new StringBuilder(50000); if (!AppLogic.IsAdminSite) { outputString.Append($"<input type=\"hidden\" name=\"ProductID\" value=\"{productId}\">"); outputString.Append($"<input type=\"hidden\" name=\"CategoryID\" value=\"{categoryId}\">"); outputString.Append($"<input type=\"hidden\" name=\"SectionID\" value=\"{sectionId}\">"); outputString.Append($"<input type=\"hidden\" name=\"ManufacturerID\" value=\"{manufacturerId}\">"); if (!encloseInTab) { outputString.Append("<input type=\"hidden\" name=\"productTabs\" value=\"2\">"); } } if (encloseInTab) { outputString.Append($"<h2 class=\"group-header rating-header\">{AppLogic.GetString("Header.ProductRatings")}</h2>"); } // RATINGS BODY: var productQuery = "aspdnsf_ProductStats @productId, @storeId"; var productParams = new SqlParameter[] { new SqlParameter("@productId", productId), new SqlParameter("@storeId", AppLogic.StoreID()) }; var ratingsCount = 0; var ratingsAverage = 0M; using (var connection = new SqlConnection(DB.GetDBConn())) { connection.Open(); using (var reader = DB.GetRS(productQuery, connection, productParams)) { reader.Read(); ratingsCount = DB.RSFieldInt(reader, "NumRatings"); ratingsAverage = DB.RSFieldDecimal(reader, "AvgRating"); } } var ratingPercentages = new int[6]; // indexes 0-5, but we only use indexes 1-5 using (var connection = new SqlConnection(DB.GetDBConn())) { var ratingQuery = @"SELECT ProductID, Rating, COUNT(Rating) AS N FROM Rating WITH (NOLOCK) WHERE Productid = @productId AND StoreID = @storeId GROUP BY Productid, Rating ORDER BY Rating" ; var ratingParams = new SqlParameter[] { new SqlParameter("@productId", productId), new SqlParameter("@storeId", AppLogic.StoreID()) }; connection.Open(); using (var reader = DB.GetRS(ratingQuery, connection, ratingParams)) { while (reader.Read()) { var numRatings = DB.RSFieldInt(reader, "N"); var ratingPercentage = ((decimal)numRatings) / ratingsCount; var ratingForDisplay = (int)(ratingPercentage * 100.0M); ratingPercentages[DB.RSFieldInt(reader, "Rating")] = ratingForDisplay; } } } var orderIndex = 0; if ("OrderBy".Equals(CommonLogic.FormCanBeDangerousContent("__EVENTTARGET"), StringComparison.InvariantCultureIgnoreCase)) { orderIndex = CommonLogic.FormNativeInt("OrderBy"); } if (orderIndex == 0) { orderIndex = 3; } var pageSize = AppLogic.AppConfigUSInt("RatingsPageSize"); var pageNumber = CommonLogic.QueryStringUSInt("PageNum"); if (pageNumber == 0) { pageNumber = 1; } if (pageSize == 0) { pageSize = 10; } if (CommonLogic.QueryStringCanBeDangerousContent("show") == "all") { pageSize = 1000000; pageNumber = 1; } using (var connection = new SqlConnection(DB.GetDBConn())) { connection.Open(); using (var command = new SqlCommand()) { command.Connection = connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = "aspdnsf_GetProductComments"; command.Parameters.Add(new SqlParameter("@ProductID", SqlDbType.Int)); command.Parameters.Add(new SqlParameter("@votingcustomer", SqlDbType.Int)); command.Parameters.Add(new SqlParameter("@pagesize", SqlDbType.Int)); command.Parameters.Add(new SqlParameter("@pagenum", SqlDbType.Int)); command.Parameters.Add(new SqlParameter("@sort", SqlDbType.TinyInt)); command.Parameters.Add(new SqlParameter("@storeID", SqlDbType.Int)); command.Parameters["@ProductID"].Value = productId; command.Parameters["@votingcustomer"].Value = customer.CustomerID; command.Parameters["@pagesize"].Value = pageSize; command.Parameters["@pagenum"].Value = pageNumber; command.Parameters["@sort"].Value = orderIndex; command.Parameters["@storeID"].Value = AppLogic.StoreID(); var reader = command.ExecuteReader(); reader.Read(); var rowsCount = Convert.ToInt32(reader["totalcomments"]); var pagesCount = Convert.ToInt32(reader["pages"]); reader.NextResult(); if (pageNumber > pagesCount && pageNumber > 1 && rowsCount == 0) { reader.Close(); var redirectUrl = Url.BuildProductLink( id: productId, additionalRouteValues: new Dictionary <string, object> { { "pagenum", pageNumber - 1 } }); HttpContext.Current.Response.Redirect(redirectUrl); } var startRow = (pageSize * (pageNumber - 1)) + 1; var stopRow = (startRow + pageSize - 1) > rowsCount ? rowsCount : startRow + pageSize - 1; if (ratingsCount > 0) { outputString.Append($"<span itemprop=\"aggregateRating\" itemscope itemtype=\"https://schema.org/AggregateRating\">{Environment.NewLine}"); outputString.Append($"<meta itemprop=\"ratingValue\" content=\"{ratingsAverage}\"/>{Environment.NewLine}"); outputString.Append($"<meta itemprop=\"reviewCount\" content=\"{ratingsCount}\"/>{Environment.NewLine}"); outputString.Append($"<meta itemprop=\"bestRating\" content=\"5\"/>{Environment.NewLine}"); outputString.Append($"<meta itemprop=\"worstRating\" content=\"1\"/>{Environment.NewLine}"); outputString.Append($"</span>{Environment.NewLine}"); } outputString.Append("<div class=\"page-row total-rating-row\">"); outputString.Append(" <div class=\"rating-stars-wrap\">"); outputString.Append(BuildStarImages(ratingsAverage, skinId) + "<span class=\"ratings-average-wrap\"> (" + string.Format("{0:f}", ratingsAverage) + ")"); outputString.Append($"<span class=\"screen-reader-only\">{AppLogic.GetString("ratings.outof5")}</span></span>"); outputString.Append(" </div>"); outputString.Append(" <div class=\"rating-count-wrap\">"); outputString.Append($" <span>{AppLogic.GetString("ratings.cs.23")}</span> {ratingsCount}"); outputString.Append(" </div>"); outputString.Append("</div>"); var rateScript = $"javascript:RateIt({productId});"; var productRating = GetProductRating(customer.CustomerID, productId); outputString.Append("<div class=\"page-row rating-link-row\">"); if (productRating != 0) { outputString.Append("<div class=\"rating-link-wrap\">"); outputString.Append(" <span>" + AppLogic.GetString("ratings.cs.24", skinId, Thread.CurrentThread.CurrentUICulture.Name) + " " + productRating.ToString() + "</span>"); outputString.Append("</div>"); if (!AppLogic.IsAdminSite) { outputString.Append("<div class=\"rating-link-wrap\">"); outputString.Append($" <a class=\"btn btn-default change-rating-button\" href=\"{rateScript}\">{AppLogic.GetString("ratings.cs.25")}</a> "); outputString.Append($" <span>{AppLogic.GetString("ratings.cs.26")}</span>"); outputString.Append("</div>"); } } else { if ((AppLogic.AppConfigBool("RatingsCanBeDoneByAnons") || customer.IsRegistered) && !AppLogic.IsAdminSite) { outputString.Append("<div class=\"rating-link-wrap\">"); outputString.Append($" <a class=\"btn btn-default add-rating-button\" href=\"{rateScript}\">{AppLogic.GetString("ratings.cs.28")}</a> "); outputString.Append($" <span>{AppLogic.GetString("ratings.cs.27")}</span>"); outputString.Append("</div>"); } else { outputString.Append("<div class=\"rating-link-wrap\">"); outputString.Append($" <span>{AppLogic.GetString("ratings.cs.29")}</span>"); outputString.Append("</div>"); } } outputString.Append("</div>"); if (rowsCount > 0) { int idSuffix = 0; while (reader.Read()) { var firstName = string.IsNullOrEmpty(reader["FirstName"].ToString()) ? AppLogic.GetString("ratings.cs.14") : reader["FirstName"].ToString(); outputString.Append($"<div class=\"page-row rating-comment-row\" itemprop=\"review\" itemscope itemtype=\"https://schema.org/Review\">{Environment.NewLine}"); outputString.Append($"<meta itemprop=\"datePublished\" content=\"{Convert.ToDateTime(reader["CreatedOn"]).ToString("yyyy-MM-dd")}\"/>{Environment.NewLine}"); outputString.Append($"<meta itemprop=\"itemReviewed\" content=\"{productName}\"/>{Environment.NewLine}"); outputString.Append(" <div class=\"rating-author-wrap\">\n"); outputString.Append($" <span class=\"rating-row-number\">{reader["rownum"]}. </span><span class=\"rating-row-author\" itemprop=\"author\">" + HttpContext.Current.Server.HtmlEncode(firstName) + "</span> <span class=\"rating-row-said\">" + AppLogic.GetString("ratings.cs.15") + " " + Localization.ToThreadCultureShortDateString(Convert.ToDateTime(reader["CreatedOn"])) + ", " + AppLogic.GetString("ratings.cs.16") + " </span>"); var userRating = (int)(reader["Rating"]); outputString.Append(" </div>"); outputString.Append($"<div class=\"rating-comment-stars\" itemprop=\"reviewRating\" itemscope itemtype=\"https://schema.org/Rating\">{Environment.NewLine}"); outputString.Append($"<meta itemprop=\"bestRating\" content=\"5\"/>{Environment.NewLine}"); outputString.Append($"<meta itemprop=\"worstRating\" content=\"1\"/>{Environment.NewLine}"); outputString.Append($"<meta itemprop=\"ratingValue\" content=\"{userRating}\"/>{Environment.NewLine}"); outputString.Append($"<span class=\"screen-reader-only\">{userRating} {AppLogic.GetString("ratings.outof5")}</span></span>"); outputString.Append(BuildStarImages(Convert.ToDecimal(reader["Rating"]), skinId)); outputString.Append(" </div>"); outputString.Append(" <div class=\"rating-comments\" itemprop=\"reviewBody\">\n"); outputString.Append(HttpContext.Current.Server.HtmlEncode(reader["Comments"].ToString())); outputString.Append(" </div>\n"); outputString.Append("</div>\n"); outputString.Append("<div class=\"form rating-comment-helpfulness-wrap\">"); outputString.Append(" <div class=\"form-group\">"); outputString.Append(" <fieldset>"); if (customer.CustomerID != Convert.ToInt32(reader["CustomerID"])) { outputString.Append($"<legend id=\"ratings-legend\" class=\"rating-comment-helpfulness-legend\">{AppLogic.GetString("ratings.cs.42")}</legend>"); idSuffix++; if (!AppLogic.IsAdminSite) { outputString.Append($"<input id=\"helpfulyes_{idSuffix}\" type=\"radio\" name=\"helpful_{productId}_{reader["CustomerID"]}\" onClick=\"return RateComment('{productId}'," + $"'{customer.CustomerID}','Yes','{reader["CustomerID"]}');" + $"\" {CommonLogic.IIF(Convert.ToInt16(reader["CommentHelpFul"]) == 1, " checked ", string.Empty)}\">\n"); outputString.Append($"<label for=\"helpfulyes_{idSuffix}\">{AppLogic.GetString("ratings.cs.43")}</label> \n"); outputString.Append($"<input id=\"helpfulno_{idSuffix}\" type=\"radio\" name=\"helpful_{productId}_{reader["CustomerID"]}\" onClick=\"return RateComment('{productId}'," + $"'{customer.CustomerID}','No','{reader["CustomerID"]}');" + $"\" {CommonLogic.IIF(Convert.ToInt16(reader["CommentHelpFul"]) == 0, " checked ", string.Empty)}\">\n"); outputString.Append($"<label for=\"helpfulno_{idSuffix}\">{AppLogic.GetString("ratings.cs.44")}</label> \n"); } else { outputString.Append($"<input id=\"helpfulyes_{idSuffix}\" type=\"radio\" name=\"helpful_{productId}_{reader["CustomerID"]}\" " + $"{CommonLogic.IIF(Convert.ToInt16(reader["CommentHelpFul"]) == 1, " checked ", string.Empty)}>\n"); outputString.Append($"<label for=\"helpfulyes_{idSuffix}\">{AppLogic.GetString("ratings.cs.43")}</label>\n"); outputString.Append($"<input id=\"helpfulno_{idSuffix}\" type=\"radio\" name=\"helpful_{productId}_{reader["CustomerID"]}\" " + $"{ CommonLogic.IIF(Convert.ToInt16(reader["CommentHelpFul"]) == 0, " checked ", string.Empty)}>\n"); outputString.Append($"<label for=\"helpfulno_{idSuffix}\" >{AppLogic.GetString("ratings.cs.44")}</label>\n"); } } outputString.Append(" </fieldset>\n"); outputString.Append(" </div>\n"); outputString.Append(" <div class=\"form-text rating-helpfulness-text\">"); outputString.Append($" ({reader["FoundHelpful"].ToString()} {AppLogic.GetString("ratings.cs.17")} "+ $"{CommonLogic.IIF(customer.CustomerID != Convert.ToInt32(reader["CustomerID"]), AppLogic.GetString("ratings.cs.18"), AppLogic.GetString("ratings.cs.19"))} " + $"{AppLogic.GetString("ratings.cs.20")}, {reader["FoundNotHelpful"].ToString()} {AppLogic.GetString("ratings.cs.21")})"); outputString.Append(" </div>\n"); outputString.Append("</div>\n"); } } reader.Close(); if (rowsCount > 0) { outputString.Append("<div class=\"page-row comments-count-wrap\">"); outputString.AppendFormat(AppLogic.GetString("ratings.cs.37"), startRow, stopRow, rowsCount); if (pagesCount > 1) { outputString.Append(" ("); if (pageNumber > 1) { var url = Url.BuildProductLink( id: CommonLogic.QueryStringUSInt("ProductID"), additionalRouteValues: new Dictionary <string, object> { { "OrderBy", orderIndex }, { "pagenum", pageNumber - 1 }, }); outputString.AppendFormat( "<a href=\"{0}\">{1} {2}</a>", url, AppLogic.GetString("ratings.cs.10"), pageSize); } if (pageNumber > 1 && pageNumber < pagesCount) { outputString.Append(" | "); } if (pageNumber < pagesCount) { var url = Url.BuildProductLink( id: CommonLogic.QueryStringUSInt("ProductID"), additionalRouteValues: new Dictionary <string, object> { { "OrderBy", orderIndex }, { "pagenum", pageNumber + 1 }, }); outputString.AppendFormat( "<a href=\"{0}\">{1} {2}</a>", url, AppLogic.GetString("ratings.cs.11"), pageSize); } outputString.Append(")"); } outputString.Append("</div>\n"); outputString.Append("<div class=\"page-row comments-pager-wrap\">"); if (pagesCount > 1) { var url = Url.BuildProductLink( id: CommonLogic.QueryStringUSInt("ProductID"), additionalRouteValues: new Dictionary <string, object> { { "show", "all" }, { "pagenum", pageNumber + 1 }, }); outputString.AppendFormat( "<a href=\"{0}\">{1}</a> {2}", url, AppLogic.GetString("ratings.cs.28"), AppLogic.GetString("ratings.cs.38")); } outputString.Append("</div>\n"); } // END RATINGS BODY: if (!AppLogic.IsAdminSite) { var rateCommentUrl = Url.Action( actionName: ActionNames.RateComment, controllerName: ControllerNames.Rating); var rateProductUrl = Url.Action( actionName: ActionNames.Index, controllerName: ControllerNames.Rating); outputString.AppendLine($"<div id=\"RateCommentDiv\" name=\"RateCommentDiv\" style=\"position:absolute; left:0px; top:0px; visibility:{AppLogic.AppConfig("RatingsCommentFrameVisibility")}; z-index:2000; \">"); outputString.Append($"<iframe name=\"RateCommentFrm\" id=\"RateCommentFrm\" width=\"400\" height=\"100\" hspace=\"0\" vspace=\"0\" marginheight=\"0\" marginwidth=\"0\" frameborder=\"0\" noresize scrolling=\"yes\" src=\"{Url.Content("~/empty.htm")}\"></iframe>"); outputString.AppendLine("</div>"); var scriptBuilder = new StringBuilder(); scriptBuilder.AppendLine("<script type=\"text/javascript\">"); scriptBuilder.AppendLine("function RateComment(ProductID, MyCustomerID, MyVote, RatersCustomerID) {"); scriptBuilder.AppendLine($" RateCommentFrm.location = '{rateCommentUrl}?Productid=' + ProductID + '&VotingCustomerID=' + MyCustomerID + '&Vote=' + MyVote + '&RatingCustomerID=' + RatersCustomerID"); scriptBuilder.AppendLine("}"); scriptBuilder.AppendLine("function RateIt(ProductID) {"); scriptBuilder.AppendLine($" window.open('{rateProductUrl}?Productid=' + ProductID + '&refresh=no&returnurl={HttpContext.Current.Server.UrlEncode(CommonLogic.PageInvocation())}','ASPDNSF_ML{CommonLogic.GetRandomNumber(1, 100000)}','height=550,width=400,top=10,left=20,status=no,toolbar=no,menubar=no,scrollbars=yes,location=no')"); scriptBuilder.AppendLine("}"); scriptBuilder.AppendLine("</script>"); var httpContext = DependencyResolver.Current.GetService <HttpContextBase>(); var clientScriptRegistry = DependencyResolver.Current.GetService <IClientScriptRegistry>(); outputString.Append(clientScriptRegistry.RegisterInlineScript(httpContext, scriptBuilder.ToString())); } } } return(outputString.ToString()); }
public void LoadFromDB() { string suffix = "_" + m_ProductID.ToString(); string pvsuffix = "_" + m_ProductID.ToString() + "_" + m_VariantID.ToString(); m_ImageNumbersSplit = m_ImageNumbers.Split(','); bool m_WatermarksEnabled = AppLogic.AppConfigBool("Watermark.Enabled"); m_ColorsSplit = new String[1] { "" }; if (m_Colors == String.Empty) { using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn())) { dbconn.Open(); using (IDataReader rs = DB.GetRS("select Colors from productvariant with (NOLOCK) where VariantID=" + m_VariantID.ToString(), dbconn)) { if (rs.Read()) { m_Colors = DB.RSFieldByLocale(rs, "Colors", Localization.GetDefaultLocale()); // remember to add "empty" color to front, for no color selected if (m_Colors.Length != 0) { m_ColorsSplit = ("," + m_Colors).Split(','); } } } } } else { m_ColorsSplit = ("," + m_Colors).Split(','); } if (m_Colors.Length != 0) { for (int i = m_ColorsSplit.GetLowerBound(0); i <= m_ColorsSplit.GetUpperBound(0); i++) { String s2 = AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]); m_ColorsSplit[i] = CommonLogic.MakeSafeFilesystemName(s2); } } if (AppLogic.AppConfigBool("MultiImage.UseProductIconPics")) { m_ImageUrlsicon = new String[m_ImageNumbersSplit.Length, m_ColorsSplit.Length]; for (int x = m_ImageNumbersSplit.GetLowerBound(0); x <= m_ImageNumbersSplit.GetUpperBound(0); x++) { int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[x]); for (int i = m_ColorsSplit.GetLowerBound(0); i <= m_ColorsSplit.GetUpperBound(0); i++) { String Url = string.Empty; if (m_ProductSKU == string.Empty) { Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "icon"); } else { Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_ProductSKU, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "icon"); } if (m_WatermarksEnabled && Url.Length != 0 && Url.IndexOf("nopicture") == -1) { if (Url.StartsWith("/")) { m_ImageUrlsicon[x, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length); } else { m_ImageUrlsicon[x, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length - 1); } if (m_ImageUrlsicon[x, i].StartsWith("/")) { m_ImageUrlsicon[x, i] = m_ImageUrlsicon[x, i].TrimStart('/'); } } else { m_ImageUrlsicon[x, i] = Url; } } } for (int x = m_ImageNumbersSplit.GetLowerBound(0); x <= m_ImageNumbersSplit.GetUpperBound(0); x++) { int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[x]); if (m_ImageUrlsicon[x, 0].IndexOf("nopicture") == -1) { m_MaxImageIndex = ImgIdx; } } } m_ImageUrlsmedium = new String[m_ImageNumbersSplit.Length, m_ColorsSplit.Length]; for (int j = m_ImageNumbersSplit.GetLowerBound(0); j <= m_ImageNumbersSplit.GetUpperBound(0); j++) { int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[j]); for (int i = m_ColorsSplit.GetLowerBound(0); i <= m_ColorsSplit.GetUpperBound(0); i++) { String Url = string.Empty; if (m_ProductSKU == string.Empty) { Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "medium"); } else { Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_ProductSKU, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "medium"); } if (m_WatermarksEnabled && Url.Length != 0 && Url.IndexOf("nopicture") == -1) { if (Url.StartsWith("/")) { m_ImageUrlsmedium[j, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length); } else { m_ImageUrlsmedium[j, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length - 1); } if (m_ImageUrlsmedium[j, i].StartsWith("/")) { m_ImageUrlsmedium[j, i] = m_ImageUrlsmedium[j, i].TrimStart('/'); } } else { m_ImageUrlsmedium[j, i] = Url; } } } for (int j = m_ImageNumbersSplit.GetLowerBound(0); j <= m_ImageNumbersSplit.GetUpperBound(0); j++) { int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[j]); if (m_ImageUrlsmedium[j, 0].IndexOf("nopicture") == -1) { m_MaxImageIndex = ImgIdx; } } m_ImageUrlslarge = new String[m_ImageNumbersSplit.Length, m_ColorsSplit.Length]; for (int j = m_ImageNumbersSplit.GetLowerBound(0); j <= m_ImageNumbersSplit.GetUpperBound(0); j++) { int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[j]); for (int i = m_ColorsSplit.GetLowerBound(0); i <= m_ColorsSplit.GetUpperBound(0); i++) { String Url = string.Empty; if (m_ProductSKU == string.Empty) { Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "large"); } else { Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_ProductSKU, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "large"); } if (m_WatermarksEnabled && Url.Length != 0 && Url.IndexOf("nopicture") == -1) { if (Url.StartsWith("/")) { m_ImageUrlslarge[j, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length); } else { m_ImageUrlslarge[j, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length - 1); } if (m_ImageUrlslarge[j, i].StartsWith("/")) { m_ImageUrlslarge[j, i] = m_ImageUrlslarge[j, i].TrimStart('/'); } m_HasSomeLarge = true; } else if (Url.Length == 0 || Url.IndexOf("nopicture") != -1) { m_ImageUrlslarge[j, i] = String.Empty; } else { m_HasSomeLarge = true; m_ImageUrlslarge[j, i] = Url; } } } if (!IsEmpty()) { bool AttemptZoomify = AppLogic.AppConfigBool("Zoomify.Active") && (AppLogic.AppConfigBool("Zoomify.GalleryMedium") || AppLogic.AppConfigBool("Zoomify.ProductMedium")); bool GalleryZoomify = AttemptZoomify && AppLogic.AppConfigBool("Zoomify.GalleryMedium"); StringBuilder tmpS = new StringBuilder(4096); tmpS.Append("<script type=\"text/javascript\">\n"); tmpS.Append("var ProductPicIndex" + suffix + " = 1;\n"); tmpS.Append("var ProductColor" + suffix + " = '';\n"); tmpS.Append("var boardpics" + suffix + " = new Array();\n"); tmpS.Append("var boardpicslg" + suffix + " = new Array();\n"); tmpS.Append("var boardpicslgwidth" + suffix + " = new Array();\n"); tmpS.Append("var boardpicslgheight" + suffix + " = new Array();\n"); if (AttemptZoomify) { tmpS.Append("var boardpicsZ" + suffix + " = new Array();\n"); } for (int i = 1; i <= m_MaxImageIndex; i++) { foreach (String c in m_ColorsSplit) { String MdUrl = ImageUrl(i, c, "medium").ToLowerInvariant(); String MdWatermarkedUrl = MdUrl; if (m_WatermarksEnabled) { if (MdUrl.Length > 0) { string[] split = MdUrl.Split('/'); string lastPart = split.Last(); MdUrl = AppLogic.LocateImageURL(lastPart, "PRODUCT", "medium", ""); } } tmpS.Append("boardpics" + suffix + "['" + i.ToString() + "," + c + "'] = '" + MdWatermarkedUrl + "';\n"); String LgUrl = ImageUrl(i, c, "large").ToLowerInvariant(); String LgWatermarkedUrl = LgUrl; if (m_WatermarksEnabled) { if (LgUrl.Length > 0) { string[] split = LgUrl.Split('/'); string lastPart = split.Last(); LgUrl = AppLogic.LocateImageURL(lastPart, "PRODUCT", "large", ""); } } tmpS.Append("boardpicslg" + suffix + "['" + i.ToString() + "," + c + "'] = '" + LgWatermarkedUrl + "';\n"); if (LgUrl.Length > 0) { System.Drawing.Size lgsz = CommonLogic.GetImagePixelSize(LgUrl); tmpS.Append("boardpicslgwidth" + suffix + "['" + i.ToString() + "," + c + "'] = '" + lgsz.Width.ToString() + "';\n"); tmpS.Append("boardpicslgheight" + suffix + "['" + i.ToString() + "," + c + "'] = '" + lgsz.Height.ToString() + "';\n"); } if (AttemptZoomify) { String ZMdUrl = string.Empty; // Yes we use the large url here, because the Zoomify data is always in Large if (LgUrl.Length > 0) { ZMdUrl = LgUrl.Remove(LgUrl.Length - 4); // remove extension } if (GalleryZoomify && CommonLogic.FileExists(CommonLogic.SafeMapPath(LgUrl))) { tmpS.Append("boardpicsZ" + suffix + "['" + i.ToString() + "," + c + "'] = '" + AppLogic.RunXmlPackage("Zoomify.Medium", null, null, m_SkinID, "", "ImagePath=" + ZMdUrl + "&AltSrc=" + LgUrl, false, false).Replace("\r\n", " ").Replace("\r", " ").Replace("\n", " ").Replace("'", "\\'") + "';\n"); // the Replace's are to make the xmlpackage output consumable by javascript } else { tmpS.Append("boardpicsZ" + suffix + "['" + i.ToString() + "," + c + "'] = '';\n"); } } } } if (AttemptZoomify) { tmpS.Append("function changeContent(markup)\n"); tmpS.Append("{\n"); tmpS.Append(" id='divProductPicZ"+ m_ProductID.ToString() + "';\n"); tmpS.Append(" if (document.getElementById || document.all)\n"); tmpS.Append(" {\n"); tmpS.Append(" var el = document.getElementById? document.getElementById(id): document.all[id];\n"); tmpS.Append(" if (el && typeof el.innerHTML != \"undefined\") el.innerHTML = markup;\n"); tmpS.Append(" }\n"); tmpS.Append("}\n"); } tmpS.Append("function changecolorimg" + suffix + "()\n"); tmpS.Append("{\n"); tmpS.Append(" var scidx = ProductPicIndex"+ suffix + " + ',' + ProductColor" + suffix + ".toLowerCase();\n"); if (AttemptZoomify) { tmpS.Append("if (boardpicsZ" + suffix + "[scidx]!='') {\n"); tmpS.Append(" divProductPicZ" + m_ProductID.ToString() + ".style.display='inline';\n"); tmpS.Append(" divProductPic" + m_ProductID.ToString() + ".style.display='none';\n"); tmpS.Append(" changeContent(boardpicsZ" + suffix + "[scidx]); }\n"); tmpS.Append("else {\n"); tmpS.Append(" divProductPicZ" + m_ProductID.ToString() + ".style.display='none';\n"); tmpS.Append(" divProductPic" + m_ProductID.ToString() + ".style.display='inline';\n"); tmpS.Append(" document.ProductPic" + m_ProductID.ToString() + ".src=boardpics" + suffix + "[scidx]; }\n"); } else { tmpS.Append(" document.ProductPic"+ m_ProductID.ToString() + ".src=boardpics" + suffix + "[scidx];\n"); } tmpS.Append("}\n"); tmpS.Append("function popuplarge" + suffix + "()\n"); tmpS.Append("{\n"); tmpS.Append(" var scidx = ProductPicIndex"+ suffix + " + ',' + ProductColor" + suffix + ".toLowerCase();\n"); tmpS.Append(" var LargeSrc = boardpicslg"+ suffix + "[scidx];\n"); if (m_WatermarksEnabled) { tmpS.AppendFormat(" var imageName = LargeSrc.split(\"/\").pop(-1);{0}", Environment.NewLine); tmpS.AppendFormat(" LargeSrc = 'watermark.axd?size=large&imgurl=images/product/large/' + imageName;{0}", Environment.NewLine); } tmpS.Append("if(boardpicslg" + suffix + "[scidx] != '')\n"); tmpS.Append("{\n"); tmpS.Append(" window.open('popup.aspx?src=' + LargeSrc,'LargerImage"+ CommonLogic.GetRandomNumber(1, 100000) + "','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=" + CommonLogic.IIF(AppLogic.AppConfigBool("ResizableLargeImagePopup"), "yes", "no") + ",resizable=" + CommonLogic.IIF(AppLogic.AppConfigBool("ResizableLargeImagePopup"), "yes", "no") + ",copyhistory=no,width=' + boardpicslgwidth" + suffix + "[scidx] + ',height=' + boardpicslgheight" + suffix + "[scidx] + ',left=0,top=0');\n"); tmpS.Append("}\n"); tmpS.Append("else\n"); tmpS.Append("{\n"); tmpS.Append(" alert('There is no large image available for this picture');\n"); tmpS.Append("}\n"); tmpS.Append("}\n"); tmpS.Append("function setcolorpicidx" + suffix + "(idx)\n"); tmpS.Append("{\n"); tmpS.Append(" ProductPicIndex"+ suffix + " = idx;\n"); tmpS.Append(" changecolorimg"+ suffix + "();\n"); tmpS.Append("}\n"); tmpS.Append("function setActive(element)\n"); tmpS.Append("{\n"); tmpS.Append(" adnsf$('li.page-link').removeClass('active');\n"); tmpS.Append(" adnsf$(element).parent().addClass('active');\n"); tmpS.Append("}\n"); tmpS.Append("function cleansizecoloroption" + suffix + "(theVal)\n"); tmpS.Append("{\n"); tmpS.Append(" if(theVal.indexOf('[') != -1){theVal = theVal.substring(0, theVal.indexOf('['))}"); tmpS.Append(" theVal = theVal.replace(/[\\W]/g,\"\");\n"); tmpS.Append(" theVal = theVal.toLowerCase();\n"); tmpS.Append(" return theVal;\n"); tmpS.Append("}\n"); tmpS.Append("function setcolorpic" + suffix + "(color)\n"); tmpS.Append("{\n"); tmpS.Append(" while(color != unescape(color))\n"); tmpS.Append(" {\n"); tmpS.Append(" color = unescape(color);\n"); tmpS.Append(" }\n"); tmpS.Append(" if(color == '-,-' || color == '-')\n"); tmpS.Append(" {\n"); tmpS.Append(" color = '';\n"); tmpS.Append(" }\n"); tmpS.Append(" if(color != '' && color.indexOf(',') != -1)\n"); tmpS.Append(" {\n"); tmpS.Append(" color = color.substring(0,color.indexOf(',')).replace(new RegExp(\"'\", 'gi'), '');\n"); // remove sku from color select value tmpS.Append(" }\n"); tmpS.Append(" if(color != '' && color.indexOf('[') != -1)\n"); tmpS.Append(" {\n"); tmpS.Append(" color = color.substring(0,color.indexOf('[')).replace(new RegExp(\"'\", 'gi'), '');\n"); tmpS.Append(" color = color.replace(/[\\s]+$/g,\"\");\n"); tmpS.Append(" }\n"); tmpS.Append(" ProductColor"+ suffix + " = cleansizecoloroption" + suffix + "(color);\n"); tmpS.Append(" changecolorimg"+ suffix + "();\n"); tmpS.Append(" setcolorlisttoactiveitem"+ suffix + "(color);\n"); tmpS.Append(" return (true);\n"); tmpS.Append("}\n"); // this one (without suffix) added back for backwards compatibility with older existing product data, where // the swatch map called to this js routine directly tmpS.Append("function setcolorpic(color)\n"); tmpS.Append("{\n"); tmpS.Append(" if(color == '-,-' || color == '-')\n"); tmpS.Append(" {\n"); tmpS.Append(" color = '';\n"); tmpS.Append(" }\n"); tmpS.Append(" if(color != '' && color.indexOf(',') != -1)\n"); tmpS.Append(" {\n"); tmpS.Append(" color = color.substring(0,color.indexOf(',')).replace(new RegExp(\"'\", 'gi'), '');\n"); // remove sku from color select value tmpS.Append(" }\n"); tmpS.Append(" if(color != '' && color.indexOf('[') != -1)\n"); tmpS.Append(" {\n"); tmpS.Append(" color = color.substring(0,color.indexOf('[')).replace(new RegExp(\"'\", 'gi'), '');\n"); tmpS.Append(" color = color.replace(/[\\s]+$/g,\"\");\n"); tmpS.Append(" }\n"); tmpS.Append(" ProductColor"+ suffix + " = cleansizecoloroption" + suffix + "(color);\n"); tmpS.Append(" changecolorimg"+ suffix + "();\n"); tmpS.Append(" setcolorlisttoactiveitem"+ suffix + "(color.toLowerCase());\n"); tmpS.Append(" return (true);\n"); tmpS.Append("}\n"); tmpS.Append("function setcolorlisttoactiveitem" + suffix + "(color)\n"); tmpS.Append("{\n"); tmpS.Append("var lst = document.getElementById('Color" + pvsuffix + "');\n"); tmpS.Append("var matchColor = cleansizecoloroption" + suffix + "(color);\n"); tmpS.Append("for (var i=0; i < lst.length; i++)\n"); tmpS.Append(" {\n"); tmpS.Append("var value = lst[i].value;\n"); tmpS.Append("var arrayValue = value.split(',');\n"); tmpS.Append("var lstColor = cleansizecoloroption" + suffix + "(arrayValue[0]);\n"); //tmpS.Append(" var lstColor = cleansizecoloroption" + suffix + "(lst[i].value);\n"); tmpS.Append(" if (lstColor == matchColor)\n"); tmpS.Append(" {\n"); tmpS.Append(" lst.selectedIndex = i;\n"); tmpS.Append(" return (true);\n"); tmpS.Append(" }\n"); tmpS.Append(" }\n"); tmpS.Append("return (true);\n"); tmpS.Append("}\n"); tmpS.Append("</script>\n"); m_ImgDHTML = tmpS.ToString(); bool useMicros = AppLogic.AppConfigBool("UseImagesForMultiNav"); bool microAction = CommonLogic.IIF(AppLogic.AppConfigBool("UseRolloverForMultiNav"), true, false); if (m_MaxImageIndex > 1) { tmpS.Remove(0, tmpS.Length); if (!AppLogic.AppConfigBool("MultiImage.UseProductIconPics") && !useMicros) { tmpS.Append("<ul class=\"pagination image-paging\">"); for (int i = 1; i <= m_MaxImageIndex; i++) { if (i == 1) { tmpS.Append("<li class=\"page-link active\">"); } else { tmpS.Append("<li class=\"page-link\">"); } tmpS.Append(string.Format("<a href=\"javascript:void(0);\" onclick='setcolorpicidx{0}({1});setActive(this);' class=\"page-number\">{1}</a>", suffix, i)); tmpS.Append("</li>"); } tmpS.Append("</ul>"); } else { tmpS.Append("<div class=\"product-gallery-items\">"); for (int i = 1; i <= m_MaxImageIndex; i++) { tmpS.Append("<div class=\"product-gallery-item\">"); tmpS.Append(" <div class=\"gallery-item-inner\">"); if (AppLogic.AppConfigBool("MultiImage.UseProductIconPics")) { string strImageTag = "<img class='product-gallery-image' onclick='setcolorpicidx{0}({1});setImageURL(\"{2}\")' alt='Show Picture {1}' src='{2}' border='0' />"; tmpS.AppendFormat(strImageTag, new object[] { suffix, i, m_ImageUrlsicon[i - 1, 0].ToString() }); } else { // check for different extensions but don't let the non existance leave a gap // or crash because it can't find an image String ImageLoc = String.Empty; if (AppLogic.AppConfigBool("UseSKUForProductImageName")) { using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn())) { dbconn.Open(); using (IDataReader skus = DB.GetRS("SELECT p.SKU FROM Product p with (NOLOCK) WHERE p.ProductID=" + m_ProductID.ToString(), dbconn)) { try { String microSKU = String.Empty; if (skus.Read()) { microSKU = DB.RSField(skus, "SKU"); } ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + microSKU.ToString() + "_" + i.ToString() + ".gif"); if (!CommonLogic.FileExists(ImageLoc)) { ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + microSKU.ToString() + "_" + i.ToString() + "_" + ".gif"); } if (!CommonLogic.FileExists(ImageLoc)) { ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + microSKU.ToString() + "_" + i.ToString() + ".jpg"); } if (!CommonLogic.FileExists(ImageLoc)) { ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + microSKU.ToString() + "_" + i.ToString() + "_" + ".jpg"); } if (!CommonLogic.FileExists(ImageLoc)) { ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + microSKU.ToString() + "_" + i.ToString() + ".png"); } if (!CommonLogic.FileExists(ImageLoc)) { ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + microSKU.ToString() + "_" + i.ToString() + "_" + ".png"); } if (!CommonLogic.FileExists(ImageLoc)) { ImageLoc = AppLogic.LocateImageURL("App_Themes/skin_" + m_SkinID + "/images/nopicturemicro.gif"); } } catch { } } } } else { ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + m_ProductID.ToString() + "_" + i.ToString() + ".gif"); if (!CommonLogic.FileExists(ImageLoc)) { ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + m_ProductID.ToString() + "_" + i.ToString() + "_" + ".gif"); } if (!CommonLogic.FileExists(ImageLoc)) { ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + m_ProductID.ToString() + "_" + i.ToString() + ".jpg"); } if (!CommonLogic.FileExists(ImageLoc)) { ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + m_ProductID.ToString() + "_" + i.ToString() + "_" + ".jpg"); } if (!CommonLogic.FileExists(ImageLoc)) { ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + m_ProductID.ToString() + "_" + i.ToString() + ".png"); } if (!CommonLogic.FileExists(ImageLoc)) { ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + m_ProductID.ToString() + "_" + i.ToString() + "_" + ".png"); } if (!CommonLogic.FileExists(ImageLoc)) { ImageLoc = AppLogic.LocateImageURL("App_Themes/skin_" + m_SkinID + "/images/nopicturemicro.gif"); } } // if not using rollover to change the images if (!microAction && ImageLoc.Length > 0) { string strImageTag = string.Format("<img class='product-gallery-image' onclick='setcolorpicidx{0}({1});setImageURL(\"{2}\")' alt='Show Picture {1}' src='{2}' border='0' />", new object[] { suffix, i, ImageLoc }); tmpS.Append(strImageTag); } else if (ImageLoc.Length > 0) { string strImageTag = string.Format("<img class='product-gallery-image' onMouseOver='setcolorpicidx{0}({1});setImageURL(\"{2}\")' alt='Show Picture {1}' src='{2}' border='0' />", new object[] { suffix, i, ImageLoc }); tmpS.Append(strImageTag); } } tmpS.Append(" </div>"); tmpS.Append("</div>"); } tmpS.Append("</div>"); } m_ImgGalIcons = tmpS.ToString(); } } }
/// <summary> /// Builds ImgDHTML /// </summary> void BuildImageGalleryScript(string productIdSuffix, bool m_WatermarksEnabled, UrlHelper urlHelper) { var scriptBuilder = new StringBuilder(4096); scriptBuilder.AppendLine("<script type=\"text/javascript\">"); scriptBuilder.AppendLine("var ProductPicIndex" + productIdSuffix + " = 1;"); scriptBuilder.AppendLine("var ProductColor" + productIdSuffix + " = '';"); scriptBuilder.AppendLine("var boardpics" + productIdSuffix + " = new Array();"); scriptBuilder.AppendLine("var boardpicslg" + productIdSuffix + " = new Array();"); scriptBuilder.AppendLine("var boardpicslgAltText" + productIdSuffix + " = new Array();"); scriptBuilder.AppendLine("var boardpicslgwidth" + productIdSuffix + " = new Array();"); scriptBuilder.AppendLine("var boardpicslgheight" + productIdSuffix + " = new Array();"); var product = new Product(ProductId); var altText = HttpContext.Current.Server.UrlEncode( string.IsNullOrEmpty(product.SEAltText) ? string.Format(AppLogic.GetString("popup.alttext"), product.LocaleName) : product.SEAltText); var popupImageBuilder = DependencyResolver.Current.GetService <IPopupImageBuilder>(); for (int i = 1; i <= ImageCountIndex; i++) { foreach (string c in VariantColors) { string MdUrl = ImageUrl(i, c, nameof(ProductImageSize.medium)).ToLowerInvariant(); string MdWatermarkedUrl = MdUrl; if (m_WatermarksEnabled) { if (MdUrl.Length > 0) { string[] split = MdUrl.Split('/'); string lastPart = split.Last(); MdUrl = AppLogic.LocateImageURL(lastPart, "PRODUCT", nameof(ProductImageSize.medium), ""); } } scriptBuilder.AppendLine("boardpics" + productIdSuffix + "['" + i.ToString() + "," + c + "'] = '" + MdWatermarkedUrl + "';"); string LgUrl = ImageUrl(i, c, nameof(ProductImageSize.large)).ToLowerInvariant(); string LgWatermarkedUrl = LgUrl; if (m_WatermarksEnabled) { if (LgUrl.Length > 0) { string[] split = LgUrl.Split('/'); string lastPart = split.Last(); LgUrl = AppLogic.LocateImageURL(lastPart, "PRODUCT", nameof(ProductImageSize.large), ""); } } scriptBuilder.AppendLine("boardpicslg" + productIdSuffix + "['" + i.ToString() + "," + c + "'] = '" + LgWatermarkedUrl + "';"); if (LgUrl.Length > 0) { var encodedAltText = popupImageBuilder.EncodePopupAltText($"Picture {i} {altText}"); scriptBuilder.AppendLine("boardpicslgAltText" + productIdSuffix + "['" + i.ToString() + "," + c + "'] = '" + encodedAltText + "';"); System.Drawing.Size lgsz = CommonLogic.GetImagePixelSize(LgUrl); scriptBuilder.AppendLine("boardpicslgwidth" + productIdSuffix + "['" + i.ToString() + "," + c + "'] = '" + lgsz.Width.ToString() + "';"); scriptBuilder.AppendLine("boardpicslgheight" + productIdSuffix + "['" + i.ToString() + "," + c + "'] = '" + lgsz.Height.ToString() + "';"); } } } scriptBuilder.AppendLine("function changecolorimg" + productIdSuffix + "() {"); scriptBuilder.AppendLine(" var scidx = ProductPicIndex"+ productIdSuffix + " + ',' + ProductColor" + productIdSuffix + ".toLowerCase();"); scriptBuilder.AppendLine(" document.ProductPic"+ ProductId.ToString() + ".src=boardpics" + productIdSuffix + "[scidx];"); scriptBuilder.AppendLine("}"); scriptBuilder.AppendLine("function popuplarge" + productIdSuffix + "() {"); scriptBuilder.AppendLine(" var scidx = ProductPicIndex"+ productIdSuffix + " + ',' + ProductColor" + productIdSuffix + ".toLowerCase();"); scriptBuilder.AppendLine(" var LargeSrc = encodeURIComponent(boardpicslg"+ productIdSuffix + "[scidx]);"); scriptBuilder.AppendLine(" if(boardpicslg"+ productIdSuffix + "[scidx] != '') {"); var popupUrl = urlHelper.Action(ActionNames.PopUp, ControllerNames.Image); scriptBuilder.AppendLine(" window.open('"+ popupUrl + "?" + RouteDataKeys.ImagePath + "=' + LargeSrc + '&altText=' + boardpicslgAltText" + productIdSuffix + "[scidx],'LargerImage" + CommonLogic.GetRandomNumber(1, 100000) + "','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=" + CommonLogic.IIF(AppLogic.AppConfigBool("ResizableLargeImagePopup"), "yes", "no") + ",resizable=" + CommonLogic.IIF(AppLogic.AppConfigBool("ResizableLargeImagePopup"), "yes", "no") + ",copyhistory=no,width=' + boardpicslgwidth" + productIdSuffix + "[scidx] + ',height=' + boardpicslgheight" + productIdSuffix + "[scidx] + ',left=0,top=0');"); scriptBuilder.AppendLine(" } else {"); scriptBuilder.AppendLine(" alert('There is no large image available for this picture');"); scriptBuilder.AppendLine(" }"); scriptBuilder.AppendLine("}"); scriptBuilder.AppendLine("function setcolorpicidx" + productIdSuffix + "(idx) {"); scriptBuilder.AppendLine(" ProductPicIndex"+ productIdSuffix + " = idx;"); scriptBuilder.AppendLine(" changecolorimg"+ productIdSuffix + "();"); scriptBuilder.AppendLine("}"); scriptBuilder.AppendLine("function setActive(element) {"); scriptBuilder.AppendLine(" adnsf$('li.page-link').removeClass('active');"); scriptBuilder.AppendLine(" adnsf$('a.page-number').children().remove();"); scriptBuilder.AppendLine(" adnsf$(element).parent().addClass('active');"); scriptBuilder.AppendLine(" adnsf$(element).append('<span class=\"screen-reader-only\"> Selected</span>');"); scriptBuilder.AppendLine("}"); scriptBuilder.AppendLine("function cleansizecoloroption" + productIdSuffix + "(theVal) {"); scriptBuilder.AppendLine(" if(theVal.indexOf('[') != -1) {"); scriptBuilder.AppendLine(" theVal = theVal.substring(0, theVal.indexOf('['))"); scriptBuilder.AppendLine(" }"); scriptBuilder.AppendLine(" theVal = theVal.replace(/[\\W]/g,\"\");"); scriptBuilder.AppendLine(" theVal = theVal.toLowerCase();"); scriptBuilder.AppendLine(" return theVal;"); scriptBuilder.AppendLine("}"); scriptBuilder.AppendLine("function setcolorpic" + productIdSuffix + "(color) {"); scriptBuilder.AppendLine(" while(color != unescape(color)) {"); scriptBuilder.AppendLine(" color = unescape(color);"); scriptBuilder.AppendLine(" }"); scriptBuilder.AppendLine(" if(color == '-,-' || color == '-') {"); scriptBuilder.AppendLine(" color = '';"); scriptBuilder.AppendLine(" }"); scriptBuilder.AppendLine(" if(color != '' && color.indexOf(',') != -1) {"); scriptBuilder.AppendLine(" color = color.substring(0,color.indexOf(',')).replace(new RegExp(\"'\", 'gi'), '');"); // remove sku from color select value scriptBuilder.AppendLine(" }"); scriptBuilder.AppendLine(" if(color != '' && color.indexOf('[') != -1) {"); scriptBuilder.AppendLine(" color = color.substring(0,color.indexOf('[')).replace(new RegExp(\"'\", 'gi'), '');"); scriptBuilder.AppendLine(" color = color.replace(/[\\s]+$/g,\"\");"); scriptBuilder.AppendLine(" }"); scriptBuilder.AppendLine(" ProductColor"+ productIdSuffix + " = cleansizecoloroption" + productIdSuffix + "(color);"); scriptBuilder.AppendLine(" changecolorimg"+ productIdSuffix + "();"); scriptBuilder.AppendLine(" return (true);"); scriptBuilder.AppendLine("}"); scriptBuilder.AppendLine("</script>"); GalleryScript = scriptBuilder.ToString(); }
public void LoadFromDB() { var suffix = "_" + m_ProductID.ToString(); m_ImageNumbersSplit = m_ImageNumbers.Split(','); var m_WatermarksEnabled = AppLogic.AppConfigBool("Watermark.Enabled"); var urlHelper = DependencyResolver.Current.GetService <UrlHelper>(); m_ColorsSplit = new String[1] { "" }; if (m_Colors == string.Empty) { using (var dbconn = new SqlConnection(DB.GetDBConn())) { dbconn.Open(); using (var rs = DB.GetRS("select Colors from productvariant with (NOLOCK) where VariantID=" + m_VariantID.ToString(), dbconn)) { if (rs.Read()) { m_Colors = DB.RSFieldByLocale(rs, "Colors", Localization.GetDefaultLocale()); // remember to add "empty" color to front, for no color selected if (m_Colors.Length != 0) { m_ColorsSplit = ("," + m_Colors).Split(','); } } } } } else { m_ColorsSplit = ("," + m_Colors).Split(','); } if (m_Colors.Length != 0) { for (int i = m_ColorsSplit.GetLowerBound(0); i <= m_ColorsSplit.GetUpperBound(0); i++) { String s2 = AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]); m_ColorsSplit[i] = CommonLogic.MakeSafeFilesystemName(s2); } } if (AppLogic.AppConfigBool("MultiImage.UseProductIconPics")) { m_ImageUrlsicon = new String[m_ImageNumbersSplit.Length, m_ColorsSplit.Length]; for (int x = m_ImageNumbersSplit.GetLowerBound(0); x <= m_ImageNumbersSplit.GetUpperBound(0); x++) { int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[x]); for (int i = m_ColorsSplit.GetLowerBound(0); i <= m_ColorsSplit.GetUpperBound(0); i++) { String Url = string.Empty; if (m_ProductSKU == string.Empty) { Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "icon"); } else { Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_ProductSKU, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "icon"); } if (m_WatermarksEnabled && Url.Length != 0 && Url.IndexOf("nopicture") == -1) { if (Url.StartsWith("/")) { m_ImageUrlsicon[x, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length); } else { m_ImageUrlsicon[x, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length - 1); } if (m_ImageUrlsicon[x, i].StartsWith("/")) { m_ImageUrlsicon[x, i] = m_ImageUrlsicon[x, i].TrimStart('/'); } } else { m_ImageUrlsicon[x, i] = Url; } } } for (int x = m_ImageNumbersSplit.GetLowerBound(0); x <= m_ImageNumbersSplit.GetUpperBound(0); x++) { int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[x]); if (m_ImageUrlsicon[x, 0].IndexOf("nopicture") == -1) { m_MaxImageIndex = ImgIdx; } } } m_ImageUrlsmedium = new String[m_ImageNumbersSplit.Length, m_ColorsSplit.Length]; for (int j = m_ImageNumbersSplit.GetLowerBound(0); j <= m_ImageNumbersSplit.GetUpperBound(0); j++) { int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[j]); for (int i = m_ColorsSplit.GetLowerBound(0); i <= m_ColorsSplit.GetUpperBound(0); i++) { if (m_ProductSKU == string.Empty) { m_ImageUrlsmedium[j, i] = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "medium"); } else { m_ImageUrlsmedium[j, i] = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_ProductSKU, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "medium"); } } } for (int j = m_ImageNumbersSplit.GetLowerBound(0); j <= m_ImageNumbersSplit.GetUpperBound(0); j++) { int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[j]); if (m_ImageUrlsmedium[j, 0].IndexOf("nopicture") == -1) { m_MaxImageIndex = ImgIdx; } } m_ImageUrlslarge = new String[m_ImageNumbersSplit.Length, m_ColorsSplit.Length]; for (int j = m_ImageNumbersSplit.GetLowerBound(0); j <= m_ImageNumbersSplit.GetUpperBound(0); j++) { int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[j]); for (int i = m_ColorsSplit.GetLowerBound(0); i <= m_ColorsSplit.GetUpperBound(0); i++) { String Url = string.Empty; if (m_ProductSKU == string.Empty) { Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "large"); } else { Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_ProductSKU, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "large"); } if (m_WatermarksEnabled && Url.Length != 0 && Url.IndexOf("nopicture") == -1) { if (Url.StartsWith("/")) { m_ImageUrlslarge[j, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length); } else { m_ImageUrlslarge[j, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length - 1); } if (m_ImageUrlslarge[j, i].StartsWith("/")) { m_ImageUrlslarge[j, i] = m_ImageUrlslarge[j, i].TrimStart('/'); } m_HasSomeLarge = true; } else if (Url.Length == 0 || Url.IndexOf("nopicture") != -1) { m_ImageUrlslarge[j, i] = String.Empty; } else { m_HasSomeLarge = true; m_ImageUrlslarge[j, i] = Url; } } } if (!IsEmpty()) { StringBuilder tmpS = new StringBuilder(4096); tmpS.Append("<script type=\"text/javascript\">\n"); tmpS.Append("var ProductPicIndex" + suffix + " = 1;\n"); tmpS.Append("var ProductColor" + suffix + " = '';\n"); tmpS.Append("var boardpics" + suffix + " = new Array();\n"); tmpS.Append("var boardpicslg" + suffix + " = new Array();\n"); tmpS.Append("var boardpicslgwidth" + suffix + " = new Array();\n"); tmpS.Append("var boardpicslgheight" + suffix + " = new Array();\n"); for (int i = 1; i <= m_MaxImageIndex; i++) { foreach (String c in m_ColorsSplit) { String MdUrl = ImageUrl(i, c, "medium").ToLowerInvariant(); String MdWatermarkedUrl = MdUrl; if (m_WatermarksEnabled) { if (MdUrl.Length > 0) { string[] split = MdUrl.Split('/'); string lastPart = split.Last(); MdUrl = AppLogic.LocateImageURL(lastPart, "PRODUCT", "medium", ""); } } tmpS.Append("boardpics" + suffix + "['" + i.ToString() + "," + c + "'] = '" + MdWatermarkedUrl + "';\n"); String LgUrl = ImageUrl(i, c, "large").ToLowerInvariant(); String LgWatermarkedUrl = LgUrl; if (m_WatermarksEnabled) { if (LgUrl.Length > 0) { string[] split = LgUrl.Split('/'); string lastPart = split.Last(); LgUrl = AppLogic.LocateImageURL(lastPart, "PRODUCT", "large", ""); } } tmpS.Append("boardpicslg" + suffix + "['" + i.ToString() + "," + c + "'] = '" + LgWatermarkedUrl + "';\n"); if (LgUrl.Length > 0) { System.Drawing.Size lgsz = CommonLogic.GetImagePixelSize(LgUrl); tmpS.Append("boardpicslgwidth" + suffix + "['" + i.ToString() + "," + c + "'] = '" + lgsz.Width.ToString() + "';\n"); tmpS.Append("boardpicslgheight" + suffix + "['" + i.ToString() + "," + c + "'] = '" + lgsz.Height.ToString() + "';\n"); } } } tmpS.Append("function changecolorimg" + suffix + "()\n"); tmpS.Append("{\n"); tmpS.Append(" var scidx = ProductPicIndex"+ suffix + " + ',' + ProductColor" + suffix + ".toLowerCase();\n"); tmpS.Append(" document.ProductPic"+ m_ProductID.ToString() + ".src=boardpics" + suffix + "[scidx];\n"); tmpS.Append("}\n"); tmpS.Append("function popuplarge" + suffix + "()\n"); tmpS.Append("{\n"); tmpS.Append(" var scidx = ProductPicIndex"+ suffix + " + ',' + ProductColor" + suffix + ".toLowerCase();\n"); tmpS.Append(" var LargeSrc = encodeURIComponent(boardpicslg"+ suffix + "[scidx]);\n"); tmpS.Append("if(boardpicslg" + suffix + "[scidx] != '')\n"); tmpS.Append("{\n"); var popupUrl = urlHelper.Action(ActionNames.PopUp, ControllerNames.Image); tmpS.Append(" window.open('"+ popupUrl + "?" + RouteDataKeys.ImagePath + "=' + LargeSrc,'LargerImage" + CommonLogic.GetRandomNumber(1, 100000) + "','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=" + CommonLogic.IIF(AppLogic.AppConfigBool("ResizableLargeImagePopup"), "yes", "no") + ",resizable=" + CommonLogic.IIF(AppLogic.AppConfigBool("ResizableLargeImagePopup"), "yes", "no") + ",copyhistory=no,width=' + boardpicslgwidth" + suffix + "[scidx] + ',height=' + boardpicslgheight" + suffix + "[scidx] + ',left=0,top=0');\n"); tmpS.Append("}\n"); tmpS.Append("else\n"); tmpS.Append("{\n"); tmpS.Append(" alert('There is no large image available for this picture');\n"); tmpS.Append("}\n"); tmpS.Append("}\n"); tmpS.Append("function setcolorpicidx" + suffix + "(idx)\n"); tmpS.Append("{\n"); tmpS.Append(" ProductPicIndex"+ suffix + " = idx;\n"); tmpS.Append(" changecolorimg"+ suffix + "();\n"); tmpS.Append("}\n"); tmpS.Append("function setActive(element)\n"); tmpS.Append("{\n"); tmpS.Append(" adnsf$('li.page-link').removeClass('active');\n"); tmpS.Append(" adnsf$(element).parent().addClass('active');\n"); tmpS.Append("}\n"); tmpS.Append("function cleansizecoloroption" + suffix + "(theVal)\n"); tmpS.Append("{\n"); tmpS.Append(" if(theVal.indexOf('[') != -1){theVal = theVal.substring(0, theVal.indexOf('['))}"); tmpS.Append(" theVal = theVal.replace(/[\\W]/g,\"\");\n"); tmpS.Append(" theVal = theVal.toLowerCase();\n"); tmpS.Append(" return theVal;\n"); tmpS.Append("}\n"); tmpS.Append("function setcolorpic" + suffix + "(color)\n"); tmpS.Append("{\n"); tmpS.Append(" while(color != unescape(color))\n"); tmpS.Append(" {\n"); tmpS.Append(" color = unescape(color);\n"); tmpS.Append(" }\n"); tmpS.Append(" if(color == '-,-' || color == '-')\n"); tmpS.Append(" {\n"); tmpS.Append(" color = '';\n"); tmpS.Append(" }\n"); tmpS.Append(" if(color != '' && color.indexOf(',') != -1)\n"); tmpS.Append(" {\n"); tmpS.Append(" color = color.substring(0,color.indexOf(',')).replace(new RegExp(\"'\", 'gi'), '');\n"); // remove sku from color select value tmpS.Append(" }\n"); tmpS.Append(" if(color != '' && color.indexOf('[') != -1)\n"); tmpS.Append(" {\n"); tmpS.Append(" color = color.substring(0,color.indexOf('[')).replace(new RegExp(\"'\", 'gi'), '');\n"); tmpS.Append(" color = color.replace(/[\\s]+$/g,\"\");\n"); tmpS.Append(" }\n"); tmpS.Append(" ProductColor"+ suffix + " = cleansizecoloroption" + suffix + "(color);\n"); tmpS.Append(" changecolorimg"+ suffix + "();\n"); tmpS.Append(" return (true);\n"); tmpS.Append("}\n"); tmpS.Append("</script>\n"); m_ImgDHTML = tmpS.ToString(); bool useMicros = AppLogic.AppConfigBool("UseImagesForMultiNav"); bool microAction = CommonLogic.IIF(AppLogic.AppConfigBool("UseRolloverForMultiNav"), true, false); if (m_MaxImageIndex > 1) { tmpS.Remove(0, tmpS.Length); if (!AppLogic.AppConfigBool("MultiImage.UseProductIconPics") && !useMicros) { tmpS.Append("<ul class=\"pagination image-paging\">"); for (int i = 1; i <= m_MaxImageIndex; i++) { if (i == 1) { tmpS.Append("<li class=\"page-link active\">"); } else { tmpS.Append("<li class=\"page-link\">"); } tmpS.Append(string.Format("<a href=\"javascript:void(0);\" onclick='setcolorpicidx{0}({1});setActive(this);' class=\"page-number\">{1}</a>", suffix, i)); tmpS.Append("</li>"); } tmpS.Append("</ul>"); } else { tmpS.Append("<div class=\"product-gallery-items\">"); for (int i = 1; i <= m_MaxImageIndex; i++) { tmpS.Append("<div class=\"product-gallery-item\">"); tmpS.Append(" <div class=\"gallery-item-inner\">"); var imageUrl = GetImageUrl( size: AppLogic.AppConfigBool("MultiImage.UseProductIconPics") ? "icon" : "micro", identifier: AppLogic.AppConfigBool("UseSKUForProductImageName") ? m_ProductSKU : m_ProductID.ToString(), index: i); // if not using rollover to change the images if (!microAction && imageUrl.Length > 0) { var strImageTag = string.Format("<img class='product-gallery-image' onclick='setcolorpicidx{0}({1});' alt='Show Picture {1}' src='{2}' border='0' />", suffix, i, imageUrl ); tmpS.Append(strImageTag); } else if (imageUrl.Length > 0) { var strImageTag = string.Format("<img class='product-gallery-image' onMouseOver='setcolorpicidx{0}({1});' alt='Show Picture {1}' src='{2}' border='0' />", suffix, i, imageUrl ); tmpS.Append(strImageTag); } tmpS.Append(" </div>"); tmpS.Append("</div>"); } tmpS.Append("</div>"); } m_ImgGalIcons = tmpS.ToString(); } } }
// these can change on EVERY page request!! public void BuildPageDynamicTokens() { if (m_DynamicTokens == null) { // page/customer specific items (that may change every page): m_DynamicTokens = new Hashtable(); if (CommonLogic.GetThisPageName(false).ToLowerInvariant().StartsWith("orderconfirmation.aspx")) { m_DynamicTokens.Add("(!GOOGLE_ECOM_TRACKING!)", AppLogic.GetGoogleEComTracking(ThisCustomer)); } else { m_DynamicTokens.Add("(!GOOGLE_ECOM_TRACKING!)", String.Empty); } if (CommonLogic.GetThisPageName(false).ToLowerInvariant().StartsWith("orderconfirmation.aspx")) { m_DynamicTokens.Add("(!GOOGLE_ECOM_TRACKING_V2!)", String.Empty); } else { m_DynamicTokens.Add("(!GOOGLE_ECOM_TRACKING_V2!)", AppLogic.GetGoogleEComTrackingV2(ThisCustomer, false)); } if (!AppLogic.VATIsEnabled()) { m_DynamicTokens.Add("(!VATREGISTRATIONID!)", String.Empty); } else { StringBuilder tmpS2 = new StringBuilder(1024); if (ThisCustomer.HasCustomerRecord) { tmpS2.Append("<span class=\"VATRegistrationIDPrompt\">" + AppLogic.GetString("setvatsetting.aspx.8", ThisCustomer.SkinID, ThisCustomer.LocaleSetting) + "</span><input type=\"text\" style=\"VATRegistrationID\" id=\"VATRegistrationID\" value=\"" + ThisCustomer.VATRegistrationID + "\">"); } m_DynamicTokens.Add("(!VATREGISTRATIONID!)", tmpS2.ToString()); } if (AppLogic.NumLocaleSettingsInstalled() < 2) { m_DynamicTokens.Add("(!COUNTRYDIVVISIBILITY!)", "hidden"); m_DynamicTokens.Add("(!COUNTRYDIVDISPLAY!)", "none"); m_DynamicTokens.Add("(!COUNTRYSELECTLIST!)", String.Empty); } else { m_DynamicTokens.Add("(!COUNTRYDIVVISIBILITY!)", "visible"); m_DynamicTokens.Add("(!COUNTRYDIVDISPLAY!)", "inline"); m_DynamicTokens.Add("(!COUNTRYSELECTLIST!)", AppLogic.GetCountrySelectList(ThisCustomer.LocaleSetting)); } if (Currency.NumPublishedCurrencies() < 2) { m_DynamicTokens.Add("(!CURRENCYDIVVISIBILITY!)", "hidden"); m_DynamicTokens.Add("(!CURRENCYDIVDISPLAY!)", "none"); m_DynamicTokens.Add("(!CURRENCYSELECTLIST!)", String.Empty); } else { m_DynamicTokens.Add("(!CURRENCYDIVVISIBILITY!)", "visible"); m_DynamicTokens.Add("(!CURRENCYDIVDISPLAY!)", "inline"); m_DynamicTokens.Add("(!CURRENCYSELECTLIST!)", AppLogic.GetCurrencySelectList(ThisCustomer)); } if (AppLogic.VATIsEnabled() && AppLogic.AppConfigBool("VAT.AllowCustomerToChooseSetting")) { m_DynamicTokens.Add("(!VATDIVVISIBILITY!)", "visible"); m_DynamicTokens.Add("(!VATDIVDISPLAY!)", "inline"); m_DynamicTokens.Add("(!VATSELECTLIST!)", AppLogic.GetVATSelectList(ThisCustomer)); } else { m_DynamicTokens.Add("(!VATDIVVISIBILITY!)", "hidden"); m_DynamicTokens.Add("(!VATDIVDISPLAY!)", "none"); m_DynamicTokens.Add("(!VATSELECTLIST!)", String.Empty); } if (!ThisCustomer.IsRegistered) { m_DynamicTokens.Add("(!SUBSCRIPTION_EXPIRATION!)", AppLogic.ro_NotApplicable); } else { if (ThisCustomer.SubscriptionExpiresOn.Equals(System.DateTime.MinValue)) { m_DynamicTokens.Add("(!SUBSCRIPTION_EXPIRATION!)", "Expired"); } else { m_DynamicTokens.Add("(!SUBSCRIPTION_EXPIRATION!)", Localization.ToThreadCultureShortDateString(ThisCustomer.SubscriptionExpiresOn)); } } m_DynamicTokens.Add("(!PAGEURL!)", HttpContext.Current.Server.UrlEncode(CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING"))); m_DynamicTokens.Add("(!RANDOM!)", CommonLogic.GetRandomNumber(1, 7).ToString()); m_DynamicTokens.Add("(!HDRID!)", CommonLogic.GetRandomNumber(1, 7).ToString()); m_DynamicTokens.Add("(!INVOCATION!)", HttpContext.Current.Server.HtmlEncode(CommonLogic.PageInvocation())); m_DynamicTokens.Add("(!REFERRER!)", HttpContext.Current.Server.HtmlEncode(CommonLogic.PageReferrer())); StringBuilder tmp = new StringBuilder(4096); tmp.Append("<!--\n"); tmp.Append("PAGE INVOCATION: " + HttpContext.Current.Server.HtmlEncode(CommonLogic.PageInvocation()) + "\n"); tmp.Append("PAGE REFERRER: " + HttpContext.Current.Server.HtmlEncode(CommonLogic.PageReferrer()) + "\n"); tmp.Append("STORE LOCALE: " + Localization.GetDefaultLocale() + "\n"); tmp.Append("STORE CURRENCY: " + Localization.GetPrimaryCurrency() + "\n"); tmp.Append("CUSTOMER ID: " + ThisCustomer.CustomerID.ToString() + "\n"); tmp.Append("AFFILIATE ID: " + ThisCustomer.AffiliateID.ToString() + "\n"); tmp.Append("CUSTOMER LOCALE: " + ThisCustomer.LocaleSetting + "\n"); tmp.Append("CURRENCY SETTING: " + ThisCustomer.CurrencySetting + "\n"); tmp.Append("CACHE MENUS: " + AppLogic.AppConfigBool("CacheMenus").ToString() + "\n"); tmp.Append("-->\n"); m_DynamicTokens.Add("(!PAGEINFO!)", tmp.ToString()); bool IsRegistered = CommonLogic.IIF(ThisCustomer != null, ThisCustomer.IsRegistered, false); String tmpS = String.Empty; if (IsRegistered) { if (!AppLogic.IsAdminSite) { tmpS = AppLogic.GetString("skinbase.cs.1", SkinID, ThisCustomer.LocaleSetting) + " <a class=\"username\" href=\"account.aspx\">" + ThisCustomer.FullName() + "</a>" + CommonLogic.IIF(ThisCustomer.CustomerLevelID != 0, " (" + ThisCustomer.CustomerLevelName + ")", ""); } m_DynamicTokens.Add("(!USER_NAME!)", tmpS); m_DynamicTokens.Add("(!USERNAME!)", tmpS); } else { m_DynamicTokens.Add("(!USER_NAME!)", String.Empty); m_DynamicTokens.Add("(!USERNAME!)", String.Empty); } m_DynamicTokens.Add("(!USER_MENU_NAME!)", CommonLogic.IIF(!IsRegistered, "my account", ThisCustomer.FullName())); m_DynamicTokens.Add("(!USER_MENU!)", AppLogic.GetUserMenu(ThisCustomer.IsRegistered, SkinID, ThisCustomer.LocaleSetting)); if (AppLogic.MicropayIsEnabled()) { tmpS = "Your " + AppLogic.GetString("account.aspx.11", SkinID, ThisCustomer.LocaleSetting) + " balance is: " + Localization.DecimalStringForDB(ThisCustomer.MicroPayBalance); m_DynamicTokens.Add("(!MICROPAY_BALANCE!)", tmpS); m_DynamicTokens.Add("(!MICROPAY_BALANCE_RAW!)", Localization.DecimalStringForDB(ThisCustomer.MicroPayBalance)); m_DynamicTokens.Add("(!MICROPAY_BALANCE_CURRENCY!)", ThisCustomer.CurrencyString(ThisCustomer.MicroPayBalance)); } tmpS = ShoppingCart.NumItems(ThisCustomer.CustomerID, CartTypeEnum.ShoppingCart).ToString(); m_DynamicTokens.Add("(!NUM_CART_ITEMS!)", tmpS); tmpS = AppLogic.GetString("AppConfig.CartPrompt", SkinID, ThisCustomer.LocaleSetting); m_DynamicTokens.Add("(!CARTPROMPT!)", tmpS); tmpS = ShoppingCart.NumItems(ThisCustomer.CustomerID, CartTypeEnum.WishCart).ToString(); m_DynamicTokens.Add("(!NUM_WISH_ITEMS!)", tmpS); tmpS = ShoppingCart.NumItems(ThisCustomer.CustomerID, CartTypeEnum.GiftRegistryCart).ToString(); m_DynamicTokens.Add("(!NUM_GIFT_ITEMS!)", tmpS); tmpS = CommonLogic.IIF(!IsRegistered, AppLogic.GetString("skinbase.cs.4", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("skinbase.cs.5", SkinID, ThisCustomer.LocaleSetting)); m_DynamicTokens.Add("(!SIGNINOUT_TEXT!)", tmpS); m_DynamicTokens.Add("(!SIGNINOUT_LINK!)", CommonLogic.IIF(!IsRegistered, "signin.aspx", "signout.aspx")); String PN = CommonLogic.GetThisPageName(false); if (AppLogic.AppConfigBool("ShowMiniCart")) { if (PN.StartsWith("shoppingcart", StringComparison.InvariantCultureIgnoreCase) || PN.StartsWith("checkout", StringComparison.InvariantCultureIgnoreCase) || PN.StartsWith("cardinal", StringComparison.InvariantCultureIgnoreCase) || PN.StartsWith("addtocart") || PN.IndexOf("_process", StringComparison.InvariantCultureIgnoreCase) != -1 || PN.StartsWith("lat_", StringComparison.InvariantCultureIgnoreCase)) { m_DynamicTokens.Add("(!MINICART!)", String.Empty); // don't show on these pages } else { m_DynamicTokens.Add("(!MINICART!)", ShoppingCart.DisplayMiniCart(ThisCustomer, SkinID, true)); } if (PN.StartsWith("shoppingcart", StringComparison.InvariantCultureIgnoreCase) || PN.StartsWith("checkout", StringComparison.InvariantCultureIgnoreCase) || PN.StartsWith("cardinal", StringComparison.InvariantCultureIgnoreCase) || PN.StartsWith("addtocart", StringComparison.InvariantCultureIgnoreCase) || PN.IndexOf("_process", StringComparison.InvariantCultureIgnoreCase) != -1 || PN.StartsWith("lat_", StringComparison.InvariantCultureIgnoreCase)) { m_DynamicTokens.Add("(!MINICART_PLAIN!)", String.Empty); // don't show on these pages } else { m_DynamicTokens.Add("(!MINICART_PLAIN!)", ShoppingCart.DisplayMiniCart(ThisCustomer, SkinID, false)); } } m_DynamicTokens.Add("(!CUSTOMERID!)", ThisCustomer.CustomerID.ToString()); } }