private Control processToken(string tokenName) { ProductController productController = new ProductController(); ArrayList productList = new ArrayList(); Control parent = new Control(); switch (tokenName) { case "MESSAGE": if(bool.Parse(moduleSettings.General.ShowMessage) && categoryInfo != null) { // canadean changed: added category name LiteralControl message = new LiteralControl(Server.HtmlDecode(categoryInfo.CategoryName)); parent.Controls.Add(message); message = new LiteralControl(Server.HtmlDecode(categoryInfo.Message)); parent.Controls.Add(message); } if (catalogNav.CategoryID != Null.NullInteger) { //sub categories... CategoryController controller = new CategoryController(); ArrayList subCategories = controller.GetCategories(PortalId, false, catalogNav.CategoryID); if (subCategories.Count > 0) { LiteralControl BreakRow4 = new LiteralControl("<br /><div align=\"center\">"); parent.Controls.Add(BreakRow4); } //StoreController storeController = new StoreController(); //StoreInfo storeInfo = storeController.GetStoreInfo(PortalId); foreach (CategoryInfo category in subCategories) { LiteralControl BreakRow = new LiteralControl("| "); parent.Controls.Add(BreakRow); HyperLink link = new HyperLink(); link.Text = category.CategoryName; StringDictionary replaceParams = new StringDictionary(); replaceParams["CategoryID"] = category.CategoryID.ToString(); replaceParams["ProductID"] = Null.NullString; replaceParams["PageIndex"] = Null.NullString; link.NavigateUrl = catalogNav.GetNavigationUrl(replaceParams, storeInfo.StorePageID); parent.Controls.Add(link); LiteralControl BreakRow2 = new LiteralControl(" "); parent.Controls.Add(BreakRow2); } if (subCategories.Count > 0) { LiteralControl BreakRow3 = new LiteralControl("|</div><br/>"); parent.Controls.Add(BreakRow3); } else { LiteralControl BreakRow5 = new LiteralControl("<br/>"); parent.Controls.Add(BreakRow5); } } return parent; // Canadean changed: added subcategory token case "SUBCATEGORY": /*LiteralControl lc = new LiteralControl("pId: " + catalogNav.ProductID); parent.Controls.Add(lc);*/ if ((catalogNav.CategoryID != Null.NullInteger) && (catalogNav.ProductID == Null.NullInteger)) { //sub categories... CategoryController controller = new CategoryController(); ArrayList subCategories = controller.GetCategories(PortalId, false, catalogNav.CategoryID); if (subCategories.Count > 0) { /* String htmlstr = "<br><table cellspacing='3' cellpadding='0' border='0'><tr><td class='subtitleShop'>select report category</td></tr><tr><td>" + "<table cellspacing='0' cellpadding='0' border='0'> " + " <tbody>" + " <tr>" + " <td><a class='shopIntroText' href='/Shop/Reports/tabid/109/CategoryID/5/Default.aspx'>Soft Drinks</a></td>" + " <td><a href='/Shop/Reports/tabid/109/CategoryID/5/Default.aspx'><img alt='' border='0' src='/images/canadean/shop/shop_bullet.gif' /> </a></td>" + " <td> </td>" + " <td><a class='shopIntroText' href='/Shop/Reports/tabid/109/CategoryID/8/Default.aspx'>Beverage Packaging</a></td>" + " <td><a href='/Shop/Reports/tabid/109/CategoryID/8/Default.aspx'><img alt='' border='0' src='/images/canadean/shop/shop_bullet.gif' /> </a></td>" + " <td> </td>" + " </tr>" + " <tr>" + " <td><a class='shopIntroText' href='/Shop/Reports/tabid/109/CategoryID/6/Default.aspx'>Beer</a></td>" + " <td><a class='shopIntroText' href='/Shop/Reports/tabid/109/CategoryID/6/Default.aspx'><img alt='' border='0' src='/images/canadean/shop/shop_bullet.gif' /> </a></td>" + " <td> </td>" + " <td><a class='shopIntroText' href='/Shop/Reports/tabid/109/CategoryID/9/Default.aspx'>All Beverages</a></td>" + " <td><a class='shopIntroText' href='/Shop/Reports/tabid/109/CategoryID/9/Default.aspx'><img alt='' border='0' src='/images/canadean/shop/shop_bullet.gif' /> </a></td>" + " <td> </td>" + " </tr>" + " <tr>" + " <td><a class='shopIntroText' href='/Shop/Reports/tabid/109/CategoryID/7/Default.aspx'>Dairy</a></td>" + " <td><a class='shopIntroText' href='/Shop/Reports/tabid/109/CategoryID/7/Default.aspx'><img alt='' border='0' src='/images/canadean/shop/shop_bullet.gif' /> </a></td>" + " <td> </td>" + " <td> </td>" + " <td> </td>" + " <td> </td>" + " </tr>" + " </tbody>" + "</table></td></tr></table><p> </p>"; */ // LiteralControl title = new LiteralControl(htmlstr); //parent.Controls.Add(title); phSubcategory.Visible = true; } /* // Not used because of aesthetics questions if (subCategories.Count > 0) { LiteralControl title = new LiteralControl("<br /><div class=subtitleShop>select report category</div>"); parent.Controls.Add(title); LiteralControl BreakRow4 = new LiteralControl("<div class=categoryList><ul>"); parent.Controls.Add(BreakRow4); } //StoreController storeController = new StoreController(); //StoreInfo storeInfo = storeController.GetStoreInfo(PortalId); foreach (CategoryInfo category in subCategories) { LiteralControl BreakRow = new LiteralControl("<li>"); parent.Controls.Add(BreakRow); HyperLink link = new HyperLink(); link.Text = category.CategoryName; link.CssClass = "newsMenuOn"; StringDictionary replaceParams = new StringDictionary(); replaceParams["CategoryID"] = category.CategoryID.ToString(); replaceParams["ProductID"] = Null.NullString; replaceParams["PageIndex"] = Null.NullString; link.NavigateUrl = catalogNav.GetNavigationUrl(replaceParams, storeInfo.StorePageID); parent.Controls.Add(link); LiteralControl BreakRow2 = new LiteralControl("</li>"); parent.Controls.Add(BreakRow2); } if (subCategories.Count > 0) { LiteralControl BreakRow3 = new LiteralControl("<ul></div>"); parent.Controls.Add(BreakRow3); } //else //{ // LiteralControl BreakRow5 = new LiteralControl("<br/>"); // parent.Controls.Add(BreakRow5); //} */ return parent; } return null; // Canadean changed: added subsubcategory token case "SUBSUBCATEGORY": if ((catalogNav.CategoryID3 == Null.NullInteger) && (catalogNav.CategoryID != Null.NullInteger) && (categoryInfo.ParentCategoryID == 4)) // Only show DD sub categories when we're on the Drink Type category { phSubSubcategory.Visible = true; int categoryId1 = -1; int categoryId2 = -1; int returnCategory = 2; categoryId1 = catalogNav.CategoryID; CategoryController controller = new CategoryController(); if (catalogNav.CategoryID2 != Null.NullInteger) // Type & Continent already selected, missing Country { labelSubSubcategoryNow.Text = "now select country"; categoryId2 = catalogNav.CategoryID2; returnCategory = 3; CategoryInfo categoryInfo2 = new CategoryInfo(); categoryInfo2 = controller.GetCategory(catalogNav.CategoryID2); //labelCategoryName.Text = categoryInfo.CategoryName + " in " + categoryInfo2.CategoryName; labelCategoryName.Text = "<u><a href='" + FixHyperlinkCatalog(catalogNav, 1) + "' class='demoHeadingLink'>" + categoryInfo.CategoryName + "</a></u> in " + "<u><a href='" + FixHyperlinkCatalog(catalogNav, 2) + "' class='demoHeadingLink'>" + categoryInfo2.CategoryName + "</a></u>"; } else { labelSubSubcategoryNow.Text = "now select continent"; //labelCategoryName.Text = categoryInfo.CategoryName; labelCategoryName.Text = "<u><a href='" + FixHyperlinkCatalog(catalogNav, 1) + "' class='demoHeadingLink'>" + categoryInfo.CategoryName + "</a></u>"; } /*String str = "<br>Getting data. Portal " + PortalId + " c1: " + categoryId1 + " c2: " + categoryId2 + " rc: " + returnCategory; labelLog2.Text = str; Response.Write(str);*/ ArrayList subCategories = controller.GetCategoriesFromProducts(PortalId, categoryId1, categoryId2, -1, returnCategory); if (subCategories.Count > 0) { //labelSubSubCategory.Text = "<ul>"; bool two_columns = false; int count = 0; if(subCategories.Count > 24) two_columns = true; //Response.Write("lines: " + subCategories.Count); labelSubSubCategory.Text = "<br /><table cellspacing='0' cellpadding='0' border='0'>"; CatalogNavigation currentCatalogNav = catalogNav; foreach (CategoryInfo cur_category in subCategories) { String cat_name = cur_category.CategoryName; int cat_id = cur_category.CategoryID; StringDictionary replaceParams = new StringDictionary(); replaceParams["CategoryID"] = categoryId1.ToString(); if (catalogNav.CategoryID2 != Null.NullInteger) { replaceParams["CategoryID2"] = catalogNav.CategoryID2.ToString(); replaceParams["CategoryID3"] = cat_id.ToString(); } else { replaceParams["CategoryID2"] = cat_id.ToString(); } replaceParams["ProductID"] = Null.NullString; replaceParams["PageIndex"] = Null.NullString; String linkCat = currentCatalogNav.GetNavigationUrl(replaceParams); //Response.Write("two_colums: " + two_columns + " mod: " + (count % 2)); if (!two_columns || (count % 2 == 0)) labelSubSubCategory.Text += "<tr>"; //labelSubSubCategory.Text += "<li><a href='" + linkCat + "' class='newsMenuOff'>" + cat_name + "</a></li>"; labelSubSubCategory.Text += "<td><a class='shopIntroText' href='" + linkCat + "'>" + cat_name + "</a></td><td> </td>"; labelSubSubCategory.Text += "<td><a href='" + linkCat + "'><img border='0' alt='' src='/images/canadean/shop/shop_bullet.gif' /></a></td>"; labelSubSubCategory.Text += "<td width='20%'> </td>"; if (!two_columns || (count % 2 == 1)) labelSubSubCategory.Text += "</tr>"; count++; } //labelSubSubCategory.Text += "</ul>"; labelSubSubCategory.Text += "</table><br />"; } //Response.Write("SUBCATEGORYDD make it visible "); return parent; } else { // Only show the products if we have all the categories information if ((catalogNav.CategoryID != Null.NullInteger) && (catalogNav.CategoryID2 != Null.NullInteger) && (catalogNav.CategoryID3 != Null.NullInteger) && (catalogNav.ProductID == Null.NullInteger)) { phSubSubcategory.Visible = true; tableSubSubCategory.Visible = false; phSearchResults.Visible = true; PopulateGridView(true); Label1.Visible = true; return parent; } } return null; // Canadean changed: added subcategory token (unused for now) case "SUBCATEGORYDD": if ((catalogNav.CategoryID != Null.NullInteger) && (categoryInfo.ParentCategoryID == 4)) // Only show DD sub categories when we're on the Drink Type category { phSubcategoryDD.Visible = true; phSearchResults.Visible = true; ddHidden.Items.Add(new ListItem(catalogNav.CategoryID.ToString(), catalogNav.CategoryID.ToString())); labelAreaName.Text = categoryInfo.CategoryName; //Response.Write("SUBCATEGORYDD make it visible "); return parent; } return null; // Canadean changed: added Data Extracts subcategory token case "SUBCATEGORYDEDD": //Response.Write("SUBCATEGORYDEDD make it visible {" + catalogNav.CategoryID + "} {" + categoryInfo.ParentCategoryID + "}"); //if ((catalogNav.CategoryID != Null.NullInteger) && (categoryInfo.ParentCategoryID == -1)) // Only show DD sub categories when we're on the Data Extracts category if ((catalogNav.CategoryID != Null.NullInteger) && (categoryInfo.CategoryID == 2)) // Only show DD sub categories when we're on the Data Extracts category { phSubcategoryDEDD.Visible = true; ddDEHidden.Items.Add(new ListItem(catalogNav.CategoryID.ToString(), catalogNav.CategoryID.ToString())); //Response.Write("<br>Inside SUBCATEGORYDEDD make it visible. Selected item: " + ddDEHidden.SelectedIndex); ddDEHidden.ClearSelection(); System.Collections.ArrayList prods = PopulateDEGridView(true); int numProds = prods.Count; Label2.Text = "Total cart cost: £" + numProds * 50 + ""; return parent; } return null; case "SELECTED": // Disabled!! Show the products that exist in the current selected categories Response.Write("SELECTED: " + catalogNav.CategoryID + " - " + catalogNav.CategoryID2 + " - " + catalogNav.CategoryID3); if ((catalogNav.CategoryID != Null.NullInteger) && (catalogNav.CategoryID2 != Null.NullInteger) && (catalogNav.CategoryID3 != Null.NullInteger)) // Only show the products if we all the categories information { int categoryID1 = catalogNav.CategoryID; int categoryID2 = catalogNav.CategoryID2; int categoryID3 = catalogNav.CategoryID3; phSearchResults.Visible = true; GetSelectedProducts(-1, categoryID1, categoryID2, categoryID3, productList); //productList = truncateList(productList, int.Parse(moduleSettings.NewProducts.RowCount) * int.Parse(moduleSettings.NewProducts.ColumnCount)); return loadProductList(productList, ProductListTypes.Category); } return null; // Canadean changed: added search token case "CATALOGSEARCH": phSearchResults.Visible = true; /* int categoryID = 0; string searchTerm = ""; Response.Write("here I am: " + searchTerm); if (Page.IsPostBack) Response.Write(" postback: "); else Response.Write(" not a postback: "); */ /* if (!Page.IsPostBack) { if (Request.Params["SearchCategoryId"] != null) int.TryParse(Request.Params["SearchCategoryId"].ToString(), out categoryID); if (Request.Params["Search"] != null) searchTerm = Request.Params["Search"].ToString(); GetSearchedProducts(categoryID, searchTerm, productList); //productList = truncateList(productList, int.Parse(moduleSettings.NewProducts.RowCount) * int.Parse(moduleSettings.NewProducts.ColumnCount)); if (productList.Count > 0) { gvResults.DataSource = productList; gvResults.DataBind(); } } */ Label1.Visible = false; PopulateGridView(true); return parent; case "NEW": if (bool.Parse(moduleSettings.General.ShowNewProducts)) { if (catalogNav.CategoryID != Null.NullInteger) { GetNewProducts(catalogNav.CategoryID, productList); productList = truncateList(productList, int.Parse(moduleSettings.NewProducts.RowCount) * int.Parse(moduleSettings.NewProducts.ColumnCount)); return loadProductList(productList, ProductListTypes.New); } else { productList = productController.GetPortalNewProducts(PortalId, false); productList = truncateList(productList, int.Parse(moduleSettings.NewProducts.RowCount) * int.Parse(moduleSettings.NewProducts.ColumnCount)); return loadProductList(productList, ProductListTypes.New); } } else { return null; } case "FEATURED": if (bool.Parse(moduleSettings.General.ShowFeaturedProducts)) { if(catalogNav.CategoryID != Null.NullInteger) { GetFeaturedProducts(catalogNav.CategoryID, productList); productList = SortProductsInRandomOrder(productList); productList = truncateList(productList, int.Parse(moduleSettings.FeaturedProducts.RowCount) * int.Parse(moduleSettings.FeaturedProducts.ColumnCount)); return loadProductList(productList, ProductListTypes.Featured); } else { productList = productController.GetPortalFeaturedProducts(PortalId, false); productList = truncateList(productList, int.Parse(moduleSettings.FeaturedProducts.RowCount) * int.Parse(moduleSettings.FeaturedProducts.ColumnCount)); return loadProductList(productList, ProductListTypes.Featured); } } else { return null; } case "POPULAR": if (bool.Parse(moduleSettings.General.ShowPopularProducts)) { if(catalogNav.CategoryID != Null.NullInteger) { GetPopularProducts(catalogNav.CategoryID, productList); productList = SortProductsInRandomOrder(productList); productList = truncateList(productList, int.Parse(moduleSettings.PopularProducts.RowCount) * int.Parse(moduleSettings.PopularProducts.ColumnCount)); return loadProductList(productList, ProductListTypes.Popular); } else { productList = productController.GetPortalPopularProducts(PortalId, false); productList = truncateList(productList, int.Parse(moduleSettings.PopularProducts.RowCount) * int.Parse(moduleSettings.PopularProducts.ColumnCount)); return loadProductList(productList, ProductListTypes.Popular); } } else { return null; } case "CATEGORY": if (bool.Parse(moduleSettings.General.ShowCategoryProducts)) { if(catalogNav.CategoryID != Null.NullInteger && catalogNav.ProductID == Null.NullInteger) { GetCategoryProducts(catalogNav.CategoryID, productList); productList = SortProductsInAlphabeticalOrder(productList); return loadProductList(productList, ProductListTypes.Category); } else { return null; } } else { return null; } case "DETAIL": if(bool.Parse(moduleSettings.General.ShowProductDetail) && catalogNav.ProductID != Null.NullInteger) { return loadProductDetail(); } else { return null; } default: LiteralControl litText = new LiteralControl(tokenName); return litText; } }