public SiteMap1(System.Collections.Generic.Dictionary <string, EntityHelper> EntityHelpers, int SkinID, Customer ThisCustomer) { bool FromCache = false; String CacheName = String.Format("SiteMap1_{0}_{1}", SkinID.ToString(), ThisCustomer.LocaleSetting); if (AppLogic.CachingOn) { m_Contents = (String)HttpContext.Current.Cache.Get(CacheName); if (m_Contents != null) { FromCache = true; } } if (!FromCache) { StringBuilder tmpS = new StringBuilder(50000); if (AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowCategories")) { // Categories: String s = AppLogic.LookupHelper("Category", 0).GetEntityULList(0, ThisCustomer.LocaleSetting, ThisCustomer.AffiliateID, ThisCustomer.CustomerLevelID, true, AppLogic.AppConfigBool("SiteMap.ShowProducts") && AppLogic.NumProductsInDB < 250, true, "sitemapul", true, 0, String.Empty); if (s.Length != 0) { tmpS.Append("<b>"); if (AppLogic.IsAdminSite) { tmpS.Append("<a href=\"newentities.aspx?entityname=category\">"); } tmpS.Append(AppLogic.GetString("AppConfig.CategoryPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()); if (AppLogic.IsAdminSite) { tmpS.Append("</a>"); } tmpS.Append("</b>"); tmpS.Append(s); } } if (AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowSections")) { // Sections: String s = AppLogic.LookupHelper("Section", 0).GetEntityULList(0, ThisCustomer.LocaleSetting, ThisCustomer.AffiliateID, ThisCustomer.CustomerLevelID, true, AppLogic.AppConfigBool("SiteMap.ShowProducts") && AppLogic.NumProductsInDB < 250, true, "sitemapul", true, 0, String.Empty); if (s.Length != 0) { tmpS.Append("<b>"); if (AppLogic.IsAdminSite) { tmpS.Append("<a href=\"newentities.aspx?entityname=section\">"); } tmpS.Append(AppLogic.GetString("AppConfig.SectionPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()); if (AppLogic.IsAdminSite) { tmpS.Append("</a>"); } tmpS.Append("</b>"); tmpS.Append(s); } } if (AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowLibraries")) { // Libraries: String s = AppLogic.LookupHelper("Library", 0).GetEntityULList(0, ThisCustomer.LocaleSetting, ThisCustomer.AffiliateID, ThisCustomer.CustomerLevelID, AppLogic.AppConfigBool("SiteMap.ShowDocuments"), true, true, "sitemapul", true, 0, String.Empty); if (s.Length != 0) { tmpS.Append("<b>"); if (AppLogic.IsAdminSite) { tmpS.Append("<a href=\"newentities.aspx?entityname=library\">"); } tmpS.Append(AppLogic.GetString("AppConfig.LibraryPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()); if (AppLogic.IsAdminSite) { tmpS.Append("</a>"); } tmpS.Append("</b>"); tmpS.Append(s); } } if (AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowManufacturers")) { // Manufacturers: String s = AppLogic.LookupHelper("Manufacturer", 0).GetEntityULList(0, ThisCustomer.LocaleSetting, ThisCustomer.AffiliateID, ThisCustomer.CustomerLevelID, false, AppLogic.AppConfigBool("SiteMap.ShowProducts") && AppLogic.NumProductsInDB < 250, true, "sitemapul", true, 0, String.Empty); if (s.Length != 0) { tmpS.Append("<b>"); if (AppLogic.IsAdminSite) { tmpS.Append("<a href=\"newentities.aspx?entityname=manufacturer\">"); } tmpS.Append(AppLogic.GetString("AppConfig.ManufacturerPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()); if (AppLogic.IsAdminSite) { tmpS.Append("</a>"); } tmpS.Append("</b>"); tmpS.Append(s); } } if (AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowTopics")) { // Topics: tmpS.Append("<b>"); if (AppLogic.IsAdminSite) { tmpS.Append("<a href=\"topics.aspx\">"); } tmpS.Append(AppLogic.GetString("sitemap.aspx.2", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()); if (AppLogic.IsAdminSite) { tmpS.Append("</a>"); } tmpS.Append("</b>"); tmpS.Append("<ul class=\"sitemapul\">\n"); using (SqlConnection dbconn = DB.dbConn()) { dbconn.Open(); using (IDataReader rs = DB.GetRS(string.Format("select count(*) as N from Topic with (NOLOCK) where {0} Deleted=0 AND Published=1 and (SkinID IS NULL or SkinID=0 or SkinID={1}) ", CommonLogic.IIF(AppLogic.IsAdminSite, "", "ShowInSiteMap=1 and "), SkinID.ToString()) + "; " + string.Format("select Name,Title,TopicID from Topic with (NOLOCK) where {0} Deleted=0 and Published=1 and (SkinID IS NULL or SkinID=0 or SkinID={1}) Order By DisplayOrder, Name ASC", CommonLogic.IIF(AppLogic.IsAdminSite, "", "ShowInSiteMap=1 and "), SkinID.ToString()), dbconn)) { if (rs.Read() && DB.RSFieldInt(rs, "N") > 0) { if (rs.NextResult()) { while (rs.Read()) { tmpS.Append("<li>"); if (AppLogic.IsAdminSite) { tmpS.Append(String.Format("<a href=\"edittopic.aspx?topicid={0}\">", DB.RSFieldInt(rs, "TopicID").ToString())); } else { tmpS.Append("<a href=\"" + SE.MakeDriverLink(DB.RSFieldByLocale(rs, "Name", Localization.GetDefaultLocale())) + "\">"); } tmpS.Append(Security.HtmlEncode(DB.RSFieldByLocale(rs, "Title", Localization.GetDefaultLocale()))); tmpS.Append("</a>"); tmpS.Append("</li>\n"); } } } } } // File Topics: // create an array to hold the list of files ArrayList fArray = new ArrayList(); // get information about our initial directory String SFP = CommonLogic.SafeMapPath(CommonLogic.IIF(AppLogic.IsAdminSite, "../", "") + "App_Templates/Skin_" + SkinID.ToString() + "/template.htm").Replace("template.htm", ""); DirectoryInfo dirInfo = new DirectoryInfo(SFP); // retrieve array of files & subdirectories FileSystemInfo[] myDir = dirInfo.GetFileSystemInfos(); for (int i = 0; i < myDir.Length; i++) { // check the file attributes // if a subdirectory, add it to the sArray // otherwise, add it to the fArray if (((Convert.ToUInt32(myDir[i].Attributes) & Convert.ToUInt32(FileAttributes.Directory)) > 0)) { } else { bool skipit = false; if (!myDir[i].FullName.EndsWith("htm", StringComparison.InvariantCultureIgnoreCase) || (myDir[i].FullName.IndexOf("TEMPLATE", StringComparison.InvariantCultureIgnoreCase) != -1) || (myDir[i].FullName.IndexOf("AFFILIATE_", StringComparison.InvariantCultureIgnoreCase) != -1) || (myDir[i].FullName.IndexOf(AppLogic.ro_PMMicropay, StringComparison.InvariantCultureIgnoreCase) != -1)) { skipit = true; } if (!skipit) { fArray.Add(Path.GetFileName(myDir[i].FullName)); } } } if (fArray.Count != 0) { // sort the files alphabetically fArray.Sort(0, fArray.Count, null); for (int i = 0; i < fArray.Count; i++) { tmpS.Append("<li>"); if (!AppLogic.IsAdminSite) // admin site can't link to these kinds of topics { tmpS.Append("<a href=\"" + SE.MakeDriverLink(fArray[i].ToString().Replace(".htm", "")) + "\">"); } else { tmpS.Append("(file based topic) "); } tmpS.Append(Security.HtmlEncode(CommonLogic.Capitalize(fArray[i].ToString().Replace(".htm", "")))); if (!AppLogic.IsAdminSite) { tmpS.Append("</a>"); } tmpS.Append("</li>\n"); } } tmpS.Append("</ul>\n"); } m_Contents = tmpS.ToString(); if (AppLogic.CachingOn) { HttpContext.Current.Cache.Insert(CacheName, m_Contents, null, System.DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()), TimeSpan.Zero); } } }
public SiteMapComponentArt(Dictionary <string, EntityHelper> EntityHelpers, int SkinID, Customer ThisCustomer, bool showCustomerService) { bool FromCache = false; String CacheName = String.Format("SiteMapComponentArt_{0}_{1}", SkinID.ToString(), ThisCustomer.LocaleSetting); if (AppLogic.CachingOn) { m_Contents = (String)HttpContext.Current.Cache.Get(CacheName); if (m_Contents != null) { FromCache = true; } } if (!FromCache) { StringBuilder tmpS = new StringBuilder(50000); tmpS.Append("<SiteMap>\n"); if (AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowCategories")) { // Categories: String s = AppLogic.LookupHelper("Category", 0).GetEntityComponentArtNode(0, ThisCustomer.LocaleSetting, ThisCustomer.AffiliateID, ThisCustomer.CustomerLevelID, true, AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowProducts") && AppLogic.NumProductsInDB < 250); if (s.Length != 0) { if (AppLogic.IsAdminSite) { tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(AppLogic.GetString("AppConfig.CategoryPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()) + "\" NavigateUrl=\"newentities.aspx?entityname=category\">\n"); } else { tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(AppLogic.GetString("AppConfig.CategoryPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()) + "\">\n"); } tmpS.Append(s); tmpS.Append("</node>"); } } if (AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowSections")) { // Sections: String s = AppLogic.LookupHelper("Section", 0).GetEntityComponentArtNode(0, ThisCustomer.LocaleSetting, ThisCustomer.AffiliateID, ThisCustomer.CustomerLevelID, true, AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowProducts") && AppLogic.NumProductsInDB < 250); if (s.Length != 0) { if (AppLogic.IsAdminSite) { tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(AppLogic.GetString("AppConfig.SectionPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()) + "\" NavigateUrl=\"newentities.aspx?entityname=section\">\n"); } else { tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(AppLogic.GetString("AppConfig.SectionPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()) + "\">\n"); } tmpS.Append(s); tmpS.Append("</node>"); } } if (AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowLibraries")) { // Libraries: String s = AppLogic.LookupHelper("Library", 0).GetEntityComponentArtNode(0, ThisCustomer.LocaleSetting, ThisCustomer.AffiliateID, ThisCustomer.CustomerLevelID, true, AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowDocuments") && AppLogic.NumProductsInDB < 250); if (s.Length != 0) { if (AppLogic.IsAdminSite) { tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(AppLogic.GetString("AppConfig.LibraryPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()) + "\" NavigateUrl=\"newentities.aspx?entityname=library\">\n"); } else { tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(AppLogic.GetString("AppConfig.LibraryPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()) + "\">\n"); } tmpS.Append(s); tmpS.Append("</node>"); } } if (AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowManufacturers")) { // Manufacturers: String s = AppLogic.LookupHelper("Manufacturer", 0).GetEntityComponentArtNode(0, ThisCustomer.LocaleSetting, ThisCustomer.AffiliateID, ThisCustomer.CustomerLevelID, true, AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowProducts") && AppLogic.NumProductsInDB < 250); if (s.Length != 0) { if (AppLogic.IsAdminSite) { tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(AppLogic.GetString("AppConfig.ManufacturerPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()) + "\" NavigateUrl=\"newentities.aspx?entityname=manufacturer\">\n"); } else { tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(AppLogic.GetString("AppConfig.ManufacturerPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()) + "\">\n"); } tmpS.Append(s); tmpS.Append("</node>"); } } if (!AppLogic.IsAdminSite && AppLogic.AppConfigBool("SiteMap.ShowCustomerService") && showCustomerService) { tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(AppLogic.GetString("menu.CustomerService", ThisCustomer.SkinID, ThisCustomer.LocaleSetting)) + "\">\n"); tmpS.Append(" <node Text=\""+ XmlCommon.XmlEncodeAttribute(AppLogic.GetString("menu.YourAccount", SkinID, ThisCustomer.LocaleSetting)) + "\" NavigateUrl=\"account.aspx\" />\n"); tmpS.Append(" <node Text=\""+ XmlCommon.XmlEncodeAttribute(AppLogic.GetString("menu.OrderHistory", SkinID, ThisCustomer.LocaleSetting)) + "\" NavigateUrl=\"account.aspx\" />\n"); tmpS.Append(" <node Text=\""+ XmlCommon.XmlEncodeAttribute(AppLogic.GetString("menu.PolicyReturns", SkinID, ThisCustomer.LocaleSetting)) + "\" NavigateUrl=\"" + SE.MakeDriverLink("returns") + "\" />\n"); tmpS.Append(" <node Text=\""+ XmlCommon.XmlEncodeAttribute(AppLogic.GetString("menu.Shipping", SkinID, ThisCustomer.LocaleSetting)) + "\" NavigateUrl=\"" + SE.MakeDriverLink("shipping") + "\" />\n"); tmpS.Append(" <node Text=\""+ XmlCommon.XmlEncodeAttribute(AppLogic.GetString("menu.Contact", SkinID, ThisCustomer.LocaleSetting)) + "\" NavigateUrl=\"contactus.aspx\" />\n"); tmpS.Append(" <node Text=\""+ XmlCommon.XmlEncodeAttribute(AppLogic.GetString("menu.PolicyPrivacy", SkinID, ThisCustomer.LocaleSetting)) + "\" NavigateUrl=\"" + SE.MakeDriverLink("privacy") + "\" />\n"); tmpS.Append(" <node Text=\""+ XmlCommon.XmlEncodeAttribute(AppLogic.GetString("menu.PolicySecurity", SkinID, ThisCustomer.LocaleSetting)) + "\" NavigateUrl=\"" + SE.MakeDriverLink("security") + "\" />\n"); tmpS.Append("</node>\n"); } if (AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowTopics")) { // Topics: if (AppLogic.IsAdminSite) { tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(AppLogic.GetString("sitemap.aspx.2", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()) + "\" NavigateUrl=\"topics.aspx\">\n"); } else { tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(AppLogic.GetString("sitemap.aspx.2", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()) + "\" NavigateUrl=\"\">\n"); } using (SqlConnection con = new SqlConnection(DB.GetDBConn())) { con.Open(); using (IDataReader rs = DB.GetRS(string.Format("select Name,Title,TopicID,ShowInSiteMap from Topic with (NOLOCK) where {0} Deleted=0 and Published=1 and (SkinID IS NULL or SkinID=0 or SkinID={1}) Order By DisplayOrder, Name ASC", CommonLogic.IIF(AppLogic.IsAdminSite, "", "ShowInSiteMap=1 and "), SkinID.ToString()), con)) { string displayname = string.Empty; string name = string.Empty; while (rs.Read()) { String URL = String.Empty; name = DB.RSFieldByLocale(rs, "Name", ThisCustomer.LocaleSetting); if (AppLogic.IsAdminSite) { URL = String.Format("topics.aspx?EditTopicId={0}", DB.RSFieldInt(rs, "TopicID").ToString()); } else { URL = SE.MakeDriverLink(name); } displayname = XmlCommon.XmlEncodeAttribute(DB.RSFieldByLocale(rs, "Title", ThisCustomer.LocaleSetting)); if (displayname != string.Empty) { if (name.IndexOf("GOOGLE", StringComparison.InvariantCultureIgnoreCase) == -1 && name.IndexOf("PHONE", StringComparison.InvariantCultureIgnoreCase) == -1 && name.IndexOf("AFFILIATE", StringComparison.InvariantCultureIgnoreCase) == -1 && name.IndexOf("GIFTREGISTRY", StringComparison.InvariantCultureIgnoreCase) == -1 && name.IndexOf("WISHLIST", StringComparison.InvariantCultureIgnoreCase) == -1 && name.IndexOf("CHECKOUTANON", StringComparison.InvariantCultureIgnoreCase) == -1 && name.IndexOf("DOWNLOAD", StringComparison.InvariantCultureIgnoreCase) == -1 && name.IndexOf("GENRE", StringComparison.InvariantCultureIgnoreCase) == -1 && name.IndexOf("DISTRIBUTOR", StringComparison.InvariantCultureIgnoreCase) == -1 && name.IndexOf("VECTOR", StringComparison.InvariantCultureIgnoreCase) == -1 && name.IndexOf("CARTPAGEFOOTER", StringComparison.InvariantCultureIgnoreCase) == -1 && name.IndexOf("CODINSTRUCTIONS", StringComparison.InvariantCultureIgnoreCase) == -1) { tmpS.Append("<node Text=\"" + displayname + "\" NavigateUrl=\"" + XmlCommon.XmlEncodeAttribute(URL) + "\" />\n"); } } } } } // File Topics: // create an array to hold the list of files ArrayList fArray = new ArrayList(); // get information about our initial directory String SFP = CommonLogic.SafeMapPath(CommonLogic.IIF(AppLogic.IsAdminSite, "../", "") + "App_Templates/Skin_" + SkinID.ToString() + "/template.htm").Replace("template.htm", ""); DirectoryInfo dirInfo = new DirectoryInfo(SFP); // retrieve array of files & subdirectories FileSystemInfo[] myDir = dirInfo.GetFileSystemInfos(); for (int i = 0; i < myDir.Length; i++) { // check the file attributes // if a subdirectory, add it to the sArray // otherwise, add it to the fArray if (((Convert.ToUInt32(myDir[i].Attributes) & Convert.ToUInt32(FileAttributes.Directory)) > 0)) { } else { bool skipit = false; if (!myDir[i].FullName.EndsWith("htm", StringComparison.InvariantCultureIgnoreCase) || (myDir[i].FullName.IndexOf("TEMPLATE", StringComparison.InvariantCultureIgnoreCase) != -1) || (myDir[i].FullName.IndexOf("AFFILIATE_", StringComparison.InvariantCultureIgnoreCase) != -1) || (myDir[i].FullName.IndexOf(AppLogic.ro_PMMicropay, StringComparison.InvariantCultureIgnoreCase) != -1)) { skipit = true; } if (!skipit) { fArray.Add(Path.GetFileName(myDir[i].FullName)); } } } if (fArray.Count != 0) { // sort the files alphabetically fArray.Sort(0, fArray.Count, null); for (int i = 0; i < fArray.Count; i++) { String URL = String.Empty; if (!AppLogic.IsAdminSite) // admin site can't link to these kinds of topics { URL = SE.MakeDriverLink(fArray[i].ToString().Replace(".htm", "")); } tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(CommonLogic.Capitalize(fArray[i].ToString().Replace(".htm", ""))) + "\" " + CommonLogic.IIF(URL.Length != 0, "NavigateUrl=\"" + XmlCommon.XmlEncodeAttribute(URL) + "\"", "") + "/>\n"); } } tmpS.Append("</node>"); } tmpS.Append("</SiteMap>\n"); m_Contents = tmpS.ToString(); if (AppLogic.CachingOn) { HttpContext.Current.Cache.Insert(CacheName, m_Contents, null, System.DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()), TimeSpan.Zero); } } }