private static string PageInfoParser(Customer ThisCustomer) { 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"); return(tmp.ToString()); }
/// <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()); }
// 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()); } }