//private void RenderCategoryTree()
        //{
        //    //string cacheKey = string.Format("{0}CategoryTreeRenderer::Portal::{1}::CategorySlug::{2}", Constants.CacheKeyPrefix, PortalId, StoreContext.Category.Slug);

        //    // NOTE: CACHING TURNED OFF IN ORDER TO ALLOW CATEGORY TREE TO UPDATE...PARTICULARLY WHEN CATEGORY MODULE IS SHOWN ON A PAGE OTHER THAN A PAGE WITH THE DISPATCH MODULE. ACTIVEROOT CLASS...
        //    // NOTE: ...GETS ADDED EVEN WHEN THE ACTIVE PAGE ISN'T THAT PARTICULAR CATEGORY.
        //    //string cacheKey = StoreContext.CacheKeys.Custom("TreeRenderHtml-CatSlug-" + StoreContext.Category.Slug);

        //    //string cachedHtml = CacheHelper.GetCache<string>(cacheKey);
        //    //if (!string.IsNullOrEmpty(cachedHtml))
        //    //{
        //    //    litCategoriesTree.Text = cachedHtml;
        //    //}
        //    //else
        //    //{
        //    CategoryTreeRenderer treeRenderer = new CategoryTreeRenderer(StoreContext.CurrentStore.Id.GetValueOrDefault(-1), GetTextForCategory, GetCssClassesForCategory);
        //    //treeRenderer.MaxNestingLevel = 2;
        //    string treeHtml = treeRenderer.RenderHtmlList();

        //    // cache it
        //    //DataCache.SetCache(cacheKey, treeHtml, TimeSpan.FromMinutes(1));
        //    //DataCache.SetCache(cacheKey, treeHtml TimeSpan.FromSeconds(10));

        //    litCategoriesTree.Text = treeHtml;
        //    //}
        //}

        private void RenderCategoryTree()
        {
            //string cacheKey = string.Format("DNNspotStore:CategoryMenu:Portal:{0}:Module:{1}:Slug:{2}", PortalId, ModuleId, StoreContext.Category.Slug);
            string cacheKey = string.Format("DNNspotStore:CategoryMenu:Portal:{0}:Module:{1}", PortalId, ModuleId);

            // NOTE: CACHING TURNED OFF IN ORDER TO ALLOW CATEGORY TREE TO UPDATE...PARTICULARLY WHEN CATEGORY MODULE IS SHOWN ON A PAGE OTHER THAN A PAGE WITH THE DISPATCH MODULE. ACTIVEROOT CLASS...
            // NOTE: ...GETS ADDED EVEN WHEN THE ACTIVE PAGE ISN'T THAT PARTICULAR CATEGORY.
            // string cacheKey = StoreContext.CacheKeys.Custom("TreeRenderHtml-CatSlug-" + StoreContext.Category.Slug);

            string cachedHtml = CacheHelper.GetCache <string>(cacheKey);

            if (!string.IsNullOrEmpty(cachedHtml))
            {
                litCategoriesTree.Text = cachedHtml;
            }
            else
            {
                CategoryTreeRenderer treeRenderer = new CategoryTreeRenderer(StoreContext.CurrentStore.Id.GetValueOrDefault(-1), GetTextForCategory, GetCssClassesForCategory);
                //treeRenderer.MaxNestingLevel = 2;
                string treeHtml = treeRenderer.RenderHtmlList();

                // cache it
                DataCache.SetCache(cacheKey, treeHtml, TimeSpan.FromMinutes(60));

                litCategoriesTree.Text = treeHtml;
            }
        }
예제 #2
0
        private void LoadCategoriesUI()
        {
            StringBuilder html = new StringBuilder();

            CategoryTreeRenderer treeRenderer = new CategoryTreeRenderer(
                StoreContext.CurrentStore.Id.GetValueOrDefault(-1),
                c => string.Format(@"<span> <span class=""edit"">{0}</span> <span class=""name"">{1}</span> <span class=""move"">{2}</span> <span class=""delete"">{3}</span> </span>",
                                   CategoryEditLink(c.Id.Value),
                                   //string.Format(@"<a href=""{0}"" target=""_blank"">{1}</a>", StoreUrls.Category(c), c.Name) + (!c.IsDisplayed.Value ? " [Hidden]" : ""),
                                   // NOTE - removed the link because it crashes if the 'main dispatch' module has not been added to a page yet!
                                   c.Name + (!c.IsDisplayed.Value ? " [Hidden]" : string.Empty),
                                   CategoryMoveHandle(c.Id.Value),
                                   CategoryDeleteLink(c))
                , CategoryCssClasses
                );

            treeRenderer.CssClassForOuterList    = "catDivs";
            treeRenderer.ContainingElementTag    = "div";
            treeRenderer.ItemElementTag          = "div";
            treeRenderer.IncludeHiddenCategories = true;

            litCategories.Text = treeRenderer.RenderHtmlList();
        }
예제 #3
0
        private void PopulateListControls(bool isEditMode)
        {
            // Delivery Methods
            List <ListItem> deliveryMethods = DeliveryMethodCollection.LoadAllToList().ConvertAll(d => d.ToListItem());

            rdoDeliveryMethod.Items.Clear();
            rdoDeliveryMethod.Items.AddRange(deliveryMethods.ToArray());
            rdoDeliveryMethod.SelectedIndex = 0;

            // Categories
            CategoryTreeRenderer treeRenderer = new CategoryTreeRenderer(
                StoreContext.CurrentStore.Id.GetValueOrDefault(-1),
                c => string.Format(@"<span> <input type=""checkbox"" id=""cat-{0}"" name=""productCategory"" value=""{0}"" {2} /> <label for=""cat-{0}"">{1}</label> </span>", c.Id, c.Name, GetProductCategoryCheckedAttribute(c.Id.Value))
                );

            treeRenderer.CssClassForOuterList    = "form";
            treeRenderer.IncludeHiddenCategories = true;
            litCategories.Text = treeRenderer.RenderHtmlList();

            // Descriptors
            List <ProductDescriptor> descriptors = product.GetProductDescriptors();

            if (descriptors.Count >= 1)
            {
                litDescriptorName1.Text = descriptors[0].Name;
                txtDescriptorName1.Text = descriptors[0].Name;
                (txtDescriptorText1 as DotNetNuke.UI.UserControls.TextEditor).Text = descriptors[0].Text;
            }
            if (descriptors.Count >= 2)
            {
                litDescriptorName2.Text = descriptors[1].Name;
                txtDescriptorName2.Text = descriptors[1].Name;
                (txtDescriptorText2 as DotNetNuke.UI.UserControls.TextEditor).Text = descriptors[1].Text;
            }
            if (descriptors.Count >= 3)
            {
                litDescriptorName3.Text = descriptors[2].Name;
                txtDescriptorName3.Text = descriptors[2].Name;
                (txtDescriptorText3 as DotNetNuke.UI.UserControls.TextEditor).Text = descriptors[2].Text;
            }
            if (descriptors.Count >= 4)
            {
                litDescriptorName4.Text = descriptors[3].Name;
                txtDescriptorName4.Text = descriptors[3].Name;
                (txtDescriptorText4 as DotNetNuke.UI.UserControls.TextEditor).Text = descriptors[3].Text;
            }
            if (descriptors.Count >= 5)
            {
                litDescriptorName5.Text = descriptors[4].Name;
                txtDescriptorName5.Text = descriptors[4].Name;
                (txtDescriptorText5 as DotNetNuke.UI.UserControls.TextEditor).Text = descriptors[4].Text;
            }

            //--- DNN roles & Add Role After Checkout
            RoleController          roleController    = new RoleController();
            List <RoleInfo>         roleInfos         = roleController.GetPortalRoles(PortalId).ToList <RoleInfo>();
            StringBuilder           checkoutRolesUi   = new StringBuilder();
            List <CheckoutRoleInfo> checkoutRoleInfos = product.GetCheckoutRoleInfos();

            bool isSelected = false;

            foreach (RoleInfo role in roleInfos)
            {
                CheckoutRoleInfo selectedRole = checkoutRoleInfos.Find(cr => cr.RoleId == role.RoleID);
                isSelected = (selectedRole != null);
                int?expireDays = (selectedRole != null) ? selectedRole.ExpireDays : null;

                checkoutRolesUi.AppendFormat(@"
                    <tr>
                        <td>
                            <input type=""checkbox"" id=""checkoutAssignRole-{0}"" name=""checkoutAssignRole"" value=""{0}"" {1} />
                            <label for=""checkoutAssignRole-{0}"">{2}</label>                                                    
                        </td>
                        <td>
                            <input type=""text"" name=""checkoutAssignRole-{0}-ExpireDays"" style=""width: 50px;"" value=""{3}"" /> <span class=""inputHelp"">days</span>
                        </td>
                    </tr>
                ",
                                             role.RoleID,
                                             isSelected ? @"checked=""checked""" : "",
                                             role.RoleName,
                                             expireDays
                                             );
            }
            litCheckoutRolesPickerUi.Text = checkoutRolesUi.ToString();


            //--- DNN roles -- VIEW PERMISSIONS
            StringBuilder viewPermissionsRolesUi = new StringBuilder();
            List <int>    viewPermission         = new List <int>();

            if (!String.IsNullOrEmpty(product.ViewPermissions))
            {
                viewPermission = product.ViewPermissions.ToListOfInt(",");
            }

            isSelected = viewPermission.Any(a => a == -1);

            viewPermissionsRolesUi.AppendFormat(@"
                    <tr>
                        <td>
                            <input type=""checkbox"" id=""viewPermissionId-{0}"" name=""viewPermissionRole"" value=""{0}"" {1} />
                            <label for=""viewPermissionId-{0}"">{2}</label>                                                    
                        </td>
                    </tr>
                ",
                                                -1,
                                                isSelected ? @"checked=""checked""" : "",
                                                "All Users"
                                                );

            foreach (RoleInfo role in roleInfos)
            {
                if (role.RoleType != RoleType.Administrator)
                {
                    isSelected = viewPermission.Any(a => a == role.RoleID);

                    viewPermissionsRolesUi.AppendFormat(
                        @"
                    <tr>
                        <td>
                            <input type=""checkbox"" id=""viewPermissionId-{0}"" name=""viewPermissionRole"" value=""{0}"" {1} />
                            <label for=""viewPermissionId-{0}"">{2}</label>                                                    
                        </td>
                    </tr>
                ",
                        role.RoleID,
                        isSelected ? @"checked=""checked""" : "",
                        role.RoleName
                        );
                }
            }

            litViewPermissions.Text = viewPermissionsRolesUi.ToString();

            //--- DNN roles -- CART PERMISSIONS
            StringBuilder cartPermissionsRolesUi = new StringBuilder();
            List <int>    cartPermission         = new List <int>();

            if (!String.IsNullOrEmpty(product.CheckoutPermissions))
            {
                cartPermission = product.CheckoutPermissions.ToListOfInt(",");
            }

            isSelected = cartPermission.Any(a => a == -1);

            cartPermissionsRolesUi.AppendFormat(@"
                    <tr>
                        <td>
                            <input type=""checkbox"" id=""cartPermissionId-{0}"" name=""cartPermissionRole"" value=""{0}"" {1} />
                            <label for=""cartPermissionId-{0}"">{2}</label>                                                    
                        </td>
                    </tr>
                ",
                                                -1,
                                                isSelected ? @"checked=""checked""" : "",
                                                "All Users"
                                                );

            foreach (RoleInfo role in roleInfos)
            {
                if (role.RoleType != RoleType.Administrator)
                {
                    isSelected = cartPermission.Any(a => a == role.RoleID);

                    cartPermissionsRolesUi.AppendFormat(
                        @"
                    <tr>
                        <td>
                            <input type=""checkbox"" id=""cartPermissionId-{0}"" name=""cartPermissionRole"" value=""{0}"" {1} />
                            <label for=""cartPermissionId-{0}"">{2}</label>                                                    
                        </td>
                    </tr>
                ",
                        role.RoleID,
                        isSelected ? @"checked=""checked""" : "",
                        role.RoleName
                        );
                }
            }

            litCartPermissions.Text = cartPermissionsRolesUi.ToString();
        }