Example #1
0
 protected string RenderCategoryImage(string imageUrl, int categoryId, string urlPath, string categoryName)
 {
     if (imageUrl.IsNullOrEmpty())
     {
         return(string.Empty);
     }
     return(string.Format("<a href=\"{0}\"><img src=\"{1}\" class=\"cat-image\" alt=\"{2}\" title=\"{2}\" /></a>",
                          UrlService.GetLink(ParamType.Category, urlPath, Convert.ToInt32(categoryId)),
                          FoldersHelper.GetImageCategoryPath(CategoryImageType.Small, imageUrl, false),
                          HttpUtility.HtmlEncode(categoryName)));
 }
 protected string RenderCategoryImage(string imageUrl, int categoryId, string urlPath, string categoryName)
 {
     if (imageUrl.IsNullOrEmpty())
     {
         return(string.Empty);
     }
     return(string.Format("<a href=\"{0}\"><img src=\"{1}\" class=\"cat-image\" alt=\"{2}\" /></a>",
                          "social/catalogsocial.aspx?categoryid=" + categoryId,
                          FoldersHelper.GetImageCategoryPath(CategoryImageType.Small, imageUrl, false),
                          categoryName));
 }
Example #3
0
        protected string RenderCategoryImage(string imageUrl, int categoryId, string urlPath, string categoryName)
        {
            var result = string.Empty;


            if (imageUrl.IsNullOrEmpty() && !CustomerContext.CurrentCustomer.IsAdmin)
            {
                return(result);
            }


            result = string.Format("<a class=\"cat-lnk\" href=\"{0}\"><img src=\"{1}\" class=\"cat-image {4}\" alt=\"{2}\" title=\"{2}\" {3}/></a>",
                                   UrlService.GetLink(ParamType.Category, urlPath, SQLDataHelper.GetInt(categoryId)),
                                   imageUrl.IsNullOrEmpty() ? "images/nophoto_small.jpg" : FoldersHelper.GetImageCategoryPath(CategoryImageType.Small, imageUrl, false),
                                   HttpUtility.HtmlEncode(categoryName),
                                   InplaceEditor.Image.AttributesCategory(categoryId, InplaceEditor.Image.Field.CategorySmall),
                                   InplaceEditor.CanUseInplace(RoleActionKey.DisplayCatalog) ? "js-inplace-image-visible-permanent" : "");


            return(result);
        }
        protected string GetMenu()
        {
            if (CacheManager.Contains(MenuCatalogCacheKey))
            {
                return(CacheManager.Get <string>(MenuCatalogCacheKey));
            }

            var result = new StringBuilder();

            foreach (var rootItem in CategoryService.GetChildCategoriesByCategoryIdForMenu(0).Where(cat => cat.Enabled))
            {
                //Пункт в главном меню
                result.AppendFormat("<li class=\"item{0}\"><a href=\"{1}\" class=\"lnk-item\">{3}<span class='tbl tbl-text'>{2}</span></a>", rootItem.HasChild ? " parent" : "",
                                    UrlService.GetLink(ParamType.Category, rootItem.UrlPath, rootItem.CategoryId), rootItem.Name,
                                    rootItem.Icon != null && rootItem.Icon.PhotoName.IsNotEmpty()
                                                    ? string.Format("<span class='tbl'><img src='{0}' class='menu-icon' /></span>",
                                                                    FoldersHelper.GetImageCategoryPath(CategoryImageType.Icon, rootItem.Icon.PhotoName, false))
                                                    : "");

                if (rootItem.HasChild)
                {
                    result.AppendLine("<div class=\"tree-submenu\">");

                    var children = CategoryService.GetChildCategoriesByCategoryId(rootItem.CategoryId, false).Where(cat => cat.Enabled).ToList();

                    if (rootItem.DisplaySubCategoriesInMenu)
                    {
                        //раздел категорий
                        result.Append("<div class=\"tree-submenu-category\">");
                        for (int i = 0; i < children.Count; ++i)
                        {
                            //колонка категорий
                            result.Append("<div class=\"tree-submenu-column\">");

                            //1 уровень
                            result.AppendFormat("<span class=\"title-column\"><a href=\"{0}\">{1}</a></span>",
                                                UrlService.GetLink(ParamType.Category, children[i].UrlPath,
                                                                   children[i].CategoryId), children[i].Name);
                            result.AppendFormat("<div class=\"tree-submenu-children\">");
                            //2 уровень
                            var subchildren = CategoryService.GetChildCategoriesByCategoryId(children[i].CategoryId, false).Where(cat => cat.Enabled).ToList();

                            for (int j = 0; j < subchildren.Count && j < 10; j++)
                            {
                                result.AppendFormat("<a href=\"{0}\">{1}</a>", UrlService.GetLink(ParamType.Category, subchildren[j].UrlPath, subchildren[j].CategoryId), subchildren[j].Name);
                            }
                            if (subchildren.Count > 10)
                            {
                                result.AppendFormat("<a href=\"{0}\">{1}</a>", UrlService.GetLink(ParamType.Category, children[i].UrlPath, children[i].CategoryId), Resources.Resource.Client_MasterPage_ViewMore);
                            }
                            result.AppendFormat("</div>");

                            //Колонка категорий закрывается
                            result.Append("</div>");

                            int columns = rootItem.DisplayBrandsInMenu ? 3 : 4;
                            if (i % columns == columns - 1)
                            {
                                result.Append("<br class=\"clear\" />");
                            }
                        }
                        //раздел категорий закрывается
                        result.Append("</div>\r\n");

                        //раздел производителей
                        if (rootItem.DisplayBrandsInMenu)
                        {
                            var brands = BrandService.GetBrandsByCategoryID(rootItem.CategoryId, true);
                            if (brands.Count > 0)
                            {
                                result.Append("<div class=\"tree-submenu-brand\">");
                                result.AppendFormat("<div class=\"title-column\">{0}</div>", Resources.Resource.Client_MasterPage_Brands);

                                result.Append("<div class=\"tree-submenu-column\">");
                                foreach (Brand br in brands)
                                {
                                    result.AppendFormat("<a href=\"{0}\">{1}</a>", UrlService.GetLink(ParamType.Brand, br.UrlPath, br.BrandId), br.Name);
                                }
                                result.AppendFormat("</div>");

                                result.AppendFormat("</div>");
                            }
                        }
                    }
                    else
                    {
                        int columnsCount = 0;
                        //раздел категорий
                        result.Append("<div class=\"tree-submenu-category\">");
                        for (int i = 0; i < children.Count; ++i)
                        {
                            //колонка категорий
                            if (i % ItemsPerCol == 0)
                            {
                                result.Append("<div class=\"tree-submenu-column\">");
                            }
                            result.AppendFormat("<a href=\"{0}\">{1}</a>", UrlService.GetLink(ParamType.Category, children[i].UrlPath, children[i].CategoryId), children[i].Name);

                            //Колонка категорий закрывается
                            if (i % ItemsPerCol == ItemsPerCol - 1 || i == children.Count - 1)
                            {
                                columnsCount++;
                                result.Append("</div>");
                                int columns = rootItem.DisplayBrandsInMenu ? 3 : 4;
                                if (columnsCount % columns == 0)
                                {
                                    result.Append("<br /><br />");
                                }
                            }
                        }
                        //раздел категорий закрывается
                        result.Append("</div>\r\n");

                        //раздел производителей
                        if (rootItem.DisplayBrandsInMenu)
                        {
                            var brands = BrandService.GetBrandsByCategoryID(rootItem.CategoryId, true);
                            if (brands.Count > 0)
                            {
                                result.Append("<div class=\"tree-submenu-brand\">");
                                result.AppendFormat("<div class=\"title-column\">{0}</div>", Resources.Resource.Client_MasterPage_Brands);

                                result.Append("<div class=\"tree-submenu-column\">");
                                foreach (Brand br in brands)
                                {
                                    result.AppendFormat("<a href=\"{0}\">{1}</a>", UrlService.GetLink(ParamType.Brand, br.UrlPath, br.BrandId), br.Name);
                                }
                                result.AppendFormat("</div>");

                                result.AppendFormat("</div>");
                            }
                        }
                    }

                    //Подменю закрывается
                    result.AppendLine("</div>");
                }

                //Пункт в главном меню закрывается
                result.AppendLine("</li>");
            }

            var resultString = result.ToString();

            CacheManager.Insert(MenuCatalogCacheKey, resultString);
            return(resultString);
        }
Example #5
0
        protected void LoadCategory(int catId)
        {
            try
            {
                Category category = CategoryService.GetCategory(catId);
                txtName.Text = category.Name;
                if (category.Picture != null && File.Exists(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Big, category.Picture.PhotoName)))
                {
                    Label10.Text     = category.Picture.PhotoName;
                    pnlImage.Visible = true;
                    Image1.ImageUrl  = FoldersHelper.GetImageCategoryPath(CategoryImageType.Big, category.Picture.PhotoName, true);
                    Image1.ToolTip   = category.Picture.PhotoName;
                }
                else
                {
                    Label10.Text     = @"No picture";
                    pnlImage.Visible = false;
                }

                if (category.MiniPicture != null && File.Exists(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Small, category.MiniPicture.PhotoName)))
                {
                    lblMiniPictureFileName.Text = category.MiniPicture.PhotoName;
                    pnlMiniImage.Visible        = true;

                    imgMiniPicture.ImageUrl = FoldersHelper.GetImageCategoryPath(CategoryImageType.Small, category.MiniPicture.PhotoName, true);
                    imgMiniPicture.ToolTip  = category.MiniPicture.PhotoName;
                }
                else
                {
                    lblMiniPictureFileName.Text = @"No picture";
                    pnlMiniImage.Visible        = false;
                }

                if (category.Icon != null && File.Exists(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Icon, category.Icon.PhotoName)))
                {
                    lblIconFileName.Text = category.Icon.PhotoName;
                    pnlIcon.Visible      = true;

                    imgIcon.ImageUrl = FoldersHelper.GetImageCategoryPath(CategoryImageType.Icon, category.Icon.PhotoName, true);
                    imgIcon.ToolTip  = category.Icon.PhotoName;
                }
                else
                {
                    lblIconFileName.Text = @"No picture";
                    pnlIcon.Visible      = false;
                }

                SubCategoryDisplayStyle.SelectedValue = category.DisplayStyle;
                //ChkDisplayChildProducts.Checked = category.DisplayChildProducts;
                ChkDisplayBrands.Checked        = category.DisplayBrandsInMenu;
                ChkDisplaySubCategories.Checked = category.DisplaySubCategoriesInMenu;
                fckDescription.Text             = category.Description;
                fckBriefDescription.Text        = category.BriefDescription;
                txtSortIndex.Text         = category.SortOrder.ToString();
                ChkEnableCategory.Checked = category.Enabled;

                txtSynonym.Text = category.UrlPath;

                ddlSorting.SelectedValue = ((int)category.Sorting).ToString();

                var meta = MetaInfoService.GetMetaInfo(catId, MetaType.Category);
                if (meta == null)
                {
                    category.Meta          = new MetaInfo(0, 0, MetaType.Product, string.Empty, string.Empty, string.Empty, string.Empty);
                    chbDefaultMeta.Checked = true;
                }
                else
                {
                    chbDefaultMeta.Checked  = false;
                    category.Meta           = meta;
                    txtTitle.Text           = category.Meta.Title;
                    txtMetaKeywords.Text    = category.Meta.MetaKeywords;
                    txtMetaDescription.Text = category.Meta.MetaDescription;
                    txtH1.Text = category.Meta.H1;
                }
            }
            catch (Exception ex)
            {
                MsgErr(ex.Message + " at LoadCategory");
                Debug.LogError(ex, "at LoadCategory");
            }
        }
Example #6
0
        protected string GetMenu()
        {
            var result = new StringBuilder();

            var menuItems = GetCategoryMenuItems();

            var rootIndex = 0;

            foreach (var rootCategory in menuItems.SubCategories)
            {
                //ѕункт в главном меню
                result.AppendFormat("<div class=\"{0}\"><div class=\"tree-item-inside\">",
                                    rootCategory.CategoryId == _selectedCategoryId ? "tree-item-selected" : "tree-item");

                result.AppendFormat("<a href=\"{0}\" class=\"{1}\">{3}{2}</a>",
                                    UrlService.GetLink(ParamType.Category, rootCategory.UrlPath, rootCategory.CategoryId),
                                    rootCategory.HasChild ? "tree-item-link tree-parent" : "tree-item-link", rootCategory.Name,
                                    rootCategory.IconPath.IsNotEmpty() ? string.Format("<img class='menu-icon' src='{0}' />", FoldersHelper.GetImageCategoryPath(CategoryImageType.Icon, rootCategory.IconPath, false)) : "");

                if (rootCategory.HasChild)
                {
                    //Ќачало подменю
                    result.Append("<div class=\"tree-submenu\"><div class=\"container\">\r\n");

                    if (rootCategory.DisplaySubCategoriesInMenu)
                    {
                        //раздел категорий
                        result.Append("<div class=\"tree-submenu-category\">");

                        int j = 0;
                        foreach (var subCategory in rootCategory.SubCategories)
                        {
                            //колонка категорий
                            result.Append("<div class=\"tree-submenu-column\">");

                            //1 уровень
                            result.AppendFormat("<span class=\"title-column\"><a href=\"{0}\">{1}</a></span>",
                                                UrlService.GetLink(ParamType.Category, subCategory.UrlPath, subCategory.CategoryId),
                                                subCategory.Name);

                            result.AppendFormat("<div class=\"tree-submenu-children\">");

                            //2 уровень
                            foreach (var childrenCategory in subCategory.SubCategories)
                            {
                                result.AppendFormat("<a href=\"{0}\">{1}</a>",
                                                    UrlService.GetLink(ParamType.Category, childrenCategory.UrlPath, childrenCategory.CategoryId),
                                                    childrenCategory.Name);
                            }

                            if (subCategory.SubCategories.Count > 10)
                            {
                                result.AppendFormat("<a href=\"{0}\">{1}</a>",
                                                    UrlService.GetLink(ParamType.Category, subCategory.UrlPath, subCategory.CategoryId),
                                                    Resources.Resource.Client_MasterPage_ViewMore);
                            }
                            result.AppendFormat("</div>");

                            // олонка категорий закрываетс¤
                            result.Append("</div>");

                            var columns = rootCategory.DisplayBrandsInMenu ? 4 : 5;
                            if (j++ % columns == columns - 1)
                            {
                                result.Append("<br class=\"clear\" />");
                            }
                        }
                        //раздел категорий закрываетс¤
                        result.Append("</div>\r\n");

                        //раздел производителей
                        if (rootCategory.DisplayBrandsInMenu)
                        {
                            result.Append(RenderBrands(rootCategory.Brands));
                        }
                    }
                    else
                    {
                        //раздел категорий
                        result.Append("<div class=\"tree-submenu-category\">");

                        int i = 0;
                        foreach (var subCategory in rootCategory.SubCategories)
                        {
                            //колонка категорий
                            if (i % ItemsPerCol == 0)
                            {
                                result.Append("<div class=\"tree-submenu-column\">");
                            }
                            result.AppendFormat("<a href=\"{0}\">{1}</a>",
                                                UrlService.GetLink(ParamType.Category, subCategory.UrlPath, subCategory.CategoryId),
                                                subCategory.Name);

                            // олонка категорий закрываетс¤
                            if (i % ItemsPerCol == ItemsPerCol - 1 || i == rootCategory.SubCategories.Count - 1)
                            {
                                result.Append("</div>");
                            }
                            i++;
                        }
                        //раздел категорий закрываетс¤
                        result.Append("</div>\r\n");

                        //раздел производителей
                        if (rootCategory.DisplayBrandsInMenu)
                        {
                            result.Append(RenderBrands(rootCategory.Brands));
                        }
                    }

                    //ѕодменю закрываетс¤

                    result.AppendFormat("</div>{0}</div>",
                                        rootCategory.CategoryPicturePath.IsNotEmpty()
                            ? string.Format("<div class=\"tree-submenu-image\"><img src='{0}' /></div>",
                                            FoldersHelper.GetImageCategoryPath(CategoryImageType.Big, rootCategory.CategoryPicturePath, false))
                            : "");
                }

                //ѕункт в главном меню закрываетс¤
                result.AppendFormat("</div></div>");

                //spliter
                if (rootIndex++ != menuItems.SubCategories.Count - 1)
                {
                    result.AppendFormat("<div class=\"tree-item-split\"></div>");
                }
            }

            return(result.ToString());
        }
Example #7
0
 protected string RenderCategoryImage(string photoName, string categoryName)
 {
     return(string.Format("<img src='{0}' alt='{1}' />", photoName.IsNotEmpty() ? FoldersHelper.GetImageCategoryPath(CategoryImageType.Small, photoName, true) :
                          "../images/nophoto_small.jpg", categoryName));
 }