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; } }
private ArrayList GetPopularProducts(int categoryID, ArrayList products) { CategoryController categoryController = new CategoryController(); ProductController productController = new ProductController(); CategoryInfo category = categoryController.GetCategory(categoryID); foreach (ProductInfo product in productController.GetPopularProducts(PortalId, categoryID, false)) { products.Add(product); } foreach (CategoryInfo childCategory in categoryController.GetCategories(PortalId, false, categoryID)) { if (childCategory.CategoryID != Null.NullInteger) { GetPopularProducts(childCategory.CategoryID, products); } } return products; }
protected void Page_Load(object sender, System.EventArgs e) { try { // Load utility objects _nav = new CatalogNavigation(Request.QueryString); _nav.ProductID = Null.NullInteger; //Product should not be displayed! if (_nav.CategoryID == 0) { _nav.CategoryID = Null.NullInteger; } //Get category and parent category data CategoryController categoryController = new CategoryController(); selectedCategoryID = _nav.CategoryID; if (selectedCategoryID != Null.NullInteger) { CategoryInfo category = categoryController.GetCategory(selectedCategoryID); parentCategories.Add(category); if (category.CategoryID != category.ParentCategoryID) { while (category.ParentCategoryID != Null.NullInteger) { category = categoryController.GetCategory(category.ParentCategoryID); parentCategories.Add(category); foreach (CategoryInfo cat in parentCategories) { if (cat.CategoryID == category.CategoryID) { //Cyclical categories found break; } } } } } if (parentCategories.Count > 0) { parentCategories.Reverse(); } if (storeInfo == null) { StoreController storeController = new StoreController(); storeInfo = storeController.GetStoreInfo(PortalId); if (storeInfo.PortalTemplates) { CssTools.AddCss(this.Page, PortalSettings.HomeDirectory + "Store", PortalId); } else { CssTools.AddCss(this.Page, this.TemplateSourceDirectory, PortalId); } } _settings = new ModuleSettings(this.ModuleId, this.TabId); // Databind to list of categories CategoryController controller = new CategoryController(); ArrayList categoryList = controller.GetCategories(this.PortalId, false, -2); MyList.RepeatColumns = int.Parse(_settings.CategoryMenu.ColumnCount); MyList.DataSource = categoryList; MyList.DataBind(); //MyList.SelectedIndex = GetSelectedIndex(); } catch(Exception ex) { if (ex.InnerException != null) { Exceptions.ProcessModuleLoadException(this, ex.InnerException); } else { string ErrorSettings = Localization.GetString("ErrorSettings", this.LocalResourceFile); Exceptions.ProcessModuleLoadException(ErrorSettings, this, ex, true); } } }
private void DisplayChildCategories(CategoryInfo category, DataListItem dataListItem, int storePageID, int indentLevel) { CategoryController controller = new CategoryController(); StringDictionary replaceParams = new StringDictionary(); replaceParams["ProductID"] = Null.NullString; replaceParams["PageIndex"] = Null.NullString; ArrayList childCategories = controller.GetCategories(PortalId, false, category.CategoryID); foreach (CategoryInfo childCategory in childCategories) { replaceParams["CategoryID"] = childCategory.CategoryID.ToString(); dataListItem.Controls.Add(GetBreakRow(indentLevel)); dataListItem.Controls.Add(CreateHyperLink(childCategory.CategoryName, _nav.GetNavigationUrl(replaceParams, storePageID), selectedCategoryID == childCategory.CategoryID)); //If this category is in the parent array, then recurse... foreach (CategoryInfo myCategory in parentCategories) { if (myCategory.CategoryID == childCategory.CategoryID) { int newIndentLevel = indentLevel + 1; DisplayChildCategories(childCategory, dataListItem, storePageID, newIndentLevel); } } } }
protected void Page_Load(object sender, System.EventArgs e) { try { if (!Page.IsPostBack) { CategoryController categoryController = new CategoryController(); ArrayList categoryList = categoryController.GetCategories(this.PortalId, false, -1); bool defaultExists = false; lstDefaultCategory.Items.Add(new ListItem(Localization.GetString("SelectDefaultCategory", this.LocalResourceFile), "-1")); foreach (CategoryInfo categoryInfo in categoryList) { lstDefaultCategory.Items.Add(new ListItem(categoryInfo.CategoryName, categoryInfo.CategoryID.ToString())); if (categoryInfo.CategoryID.ToString() == moduleSettings.General.DefaultCategoryID) { defaultExists = true; } } if (lstDefaultCategory.Items.Count > 1 && Int32.Parse(moduleSettings.General.DefaultCategoryID) > 0 && defaultExists) { lstDefaultCategory.SelectedValue = moduleSettings.General.DefaultCategoryID; } } } catch(Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
private void FillCategoryCombo() { CategoryController controller = new CategoryController(); ArrayList categoryList = controller.GetCategories(this.PortalId, true, -1); cmbCategory.DataSource = categoryList; cmbCategory.DataBind(); cmbCategory.Items.Insert(0, new ListItem("--- " + Localization.GetString("All.Text") + " ---", Null.NullInteger.ToString())); cmbCategory.SelectedValue = _nav.CategoryID.ToString(); }