예제 #1
0
        protected override void Render(HtmlTextWriter output) {


            RoleController rc = new RoleController();
            IList<RoleInfo> roles = TestableRoleController.Instance.GetRoles(PortalSettings.PortalId, 
                                                (grp) => grp.SecurityMode != SecurityMode.SecurityRole 
                                                            && grp.RoleGroupID == RoleGroupId 
                                                            && grp.Status == RoleStatus.Approved
                                                            && (grp.IsPublic || currentUser.IsInRole(grp.RoleName))
                                        );

            decimal pages = (decimal)roles.Count / (decimal)PageSize;

            output.Write(HeaderTemplate);
            string resxPath = "~/desktopmodules/SocialGroups/App_LocalResources/SharedResources.resx";
            ItemTemplate = ItemTemplate.Replace("{resx:posts}", Localization.GetString("posts", resxPath));
            ItemTemplate = ItemTemplate.Replace("{resx:members}", Localization.GetString("members", resxPath));
            ItemTemplate = ItemTemplate.Replace("{resx:photos}", Localization.GetString("photos", resxPath));
            ItemTemplate = ItemTemplate.Replace("{resx:documents}", Localization.GetString("documents", resxPath));
           
            ItemTemplate = ItemTemplate.Replace("{resx:Join}", Localization.GetString("Join", resxPath));
            ItemTemplate = ItemTemplate.Replace("{resx:Pending}", Localization.GetString("Pending", resxPath));
            ItemTemplate = ItemTemplate.Replace("{resx:LeaveGroup}", Localization.GetString("LeaveGroup", resxPath));

            if (roles.Count == 0) {
                output.Write(String.Format("<div class=\"dnnFormMessage dnnFormInfo\"><span>{0}</span></div>", Localization.GetString("NoGroupsFound", resxPath)));
        
            }
            int rowItem = 0;
            if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["page"]))
            {
                CurrentIndex = Convert.ToInt32(HttpContext.Current.Request.QueryString["page"].ToString());
                CurrentIndex = CurrentIndex - 1;
            }
            int recordStart = (CurrentIndex * PageSize);
            if (CurrentIndex == 0)
            {
                recordStart = 0;
            }
            for (int x = recordStart; x < (recordStart + PageSize); x++)
            {
                if (x > roles.Count-1)
                {
                    break;
                }
                var role = roles[x];
                string rowTemplate = ItemTemplate;
                if (rowItem == 0)
                {
                    output.Write(RowHeaderTemplate);
                }
                var groupParser = new Components.GroupViewParser(PortalSettings, role, currentUser, rowTemplate, GroupViewTabId);
                output.Write(groupParser.ParseView());

                rowItem += 1;
                if (rowItem == ItemsPerRow)
                {
                    output.Write(RowFooterTemplate);
                    rowItem = 0;
                }
            }
           
            if (rowItem > 0) {
                output.Write(RowFooterTemplate);
            }

            output.Write(FooterTemplate);
            int TotalPages = Convert.ToInt32(System.Math.Ceiling(pages));
       
       
            if (TotalPages == 0)
            {
                TotalPages = 1;
            }
            string sUrlFormat = "<a href=\"{0}\" class=\"{1}\">{2}</a>";
            string[] currParams = new string[] { };

            StringBuilder sb = new StringBuilder();
            if (TotalPages > 1)
            {
              
                for (int x = 1; x <= TotalPages; x++)
                {
                    string[] @params = new string[] { };
                    if (currParams.Length > 0 & x > 1)
                    {
                        @params = Utilities.AddParams("page=" + x.ToString(), currParams);
                    } else if (currParams.Length > 0 & x == 1)
                    {
                        @params = currParams;
                    } else if (x > 1)
                    {
                        @params = new string[] { "page=" + x.ToString() };
                    }
                    string sUrl = Utilities.NavigateUrl(TabId, @params);
                    string cssClass = "pagerItem";
                    if (x-1 == CurrentIndex)
                    {
                        cssClass = "pagerItemSelected";
                    }
                    sb.AppendFormat(sUrlFormat, sUrl, cssClass, x.ToString());
                }
                
            }
            output.Write("<div class=\"dnnClear groupPager\">");
            output.Write(sb.ToString());
            output.Write("</div>");

        }
예제 #2
0
        protected override void Render(HtmlTextWriter output)
        {
            RoleController   rc    = new RoleController();
            IList <RoleInfo> roles = TestableRoleController.Instance.GetRoles(PortalSettings.PortalId,
                                                                              (grp) => grp.SecurityMode != SecurityMode.SecurityRole &&
                                                                              grp.RoleGroupID == RoleGroupId &&
                                                                              grp.Status == RoleStatus.Approved &&
                                                                              (grp.IsPublic || currentUser.IsInRole(grp.RoleName))
                                                                              );

            decimal pages = (decimal)roles.Count / (decimal)PageSize;

            output.Write(HeaderTemplate);
            string resxPath = "~/desktopmodules/SocialGroups/App_LocalResources/SharedResources.resx";

            ItemTemplate = ItemTemplate.Replace("{resx:posts}", Localization.GetString("posts", resxPath));
            ItemTemplate = ItemTemplate.Replace("{resx:members}", Localization.GetString("members", resxPath));
            ItemTemplate = ItemTemplate.Replace("{resx:photos}", Localization.GetString("photos", resxPath));
            ItemTemplate = ItemTemplate.Replace("{resx:documents}", Localization.GetString("documents", resxPath));

            ItemTemplate = ItemTemplate.Replace("{resx:Join}", Localization.GetString("Join", resxPath));
            ItemTemplate = ItemTemplate.Replace("{resx:Pending}", Localization.GetString("Pending", resxPath));
            ItemTemplate = ItemTemplate.Replace("{resx:LeaveGroup}", Localization.GetString("LeaveGroup", resxPath));

            if (roles.Count == 0)
            {
                output.Write(String.Format("<div class=\"dnnFormMessage dnnFormInfo\"><span>{0}</span></div>", Localization.GetString("NoGroupsFound", resxPath)));
            }
            int rowItem = 0;

            if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["page"]))
            {
                CurrentIndex = Convert.ToInt32(HttpContext.Current.Request.QueryString["page"].ToString());
                CurrentIndex = CurrentIndex - 1;
            }
            int recordStart = (CurrentIndex * PageSize);

            if (CurrentIndex == 0)
            {
                recordStart = 0;
            }
            for (int x = recordStart; x < (recordStart + PageSize); x++)
            {
                if (x > roles.Count - 1)
                {
                    break;
                }
                var    role        = roles[x];
                string rowTemplate = ItemTemplate;
                if (rowItem == 0)
                {
                    output.Write(RowHeaderTemplate);
                }
                var groupParser = new Components.GroupViewParser(PortalSettings, role, currentUser, rowTemplate, GroupViewTabId);
                output.Write(groupParser.ParseView());

                rowItem += 1;
                if (rowItem == ItemsPerRow)
                {
                    output.Write(RowFooterTemplate);
                    rowItem = 0;
                }
            }

            if (rowItem > 0)
            {
                output.Write(RowFooterTemplate);
            }

            output.Write(FooterTemplate);
            int TotalPages = Convert.ToInt32(System.Math.Ceiling(pages));


            if (TotalPages == 0)
            {
                TotalPages = 1;
            }
            string sUrlFormat = "<a href=\"{0}\" class=\"{1}\">{2}</a>";

            string[] currParams = new string[] { };

            StringBuilder sb = new StringBuilder();

            if (TotalPages > 1)
            {
                for (int x = 1; x <= TotalPages; x++)
                {
                    string[] @params = new string[] { };
                    if (currParams.Length > 0 & x > 1)
                    {
                        @params = Utilities.AddParams("page=" + x.ToString(), currParams);
                    }
                    else if (currParams.Length > 0 & x == 1)
                    {
                        @params = currParams;
                    }
                    else if (x > 1)
                    {
                        @params = new string[] { "page=" + x.ToString() };
                    }
                    string sUrl     = Utilities.NavigateUrl(TabId, @params);
                    string cssClass = "pagerItem";
                    if (x - 1 == CurrentIndex)
                    {
                        cssClass = "pagerItemSelected";
                    }
                    sb.AppendFormat(sUrlFormat, sUrl, cssClass, x.ToString());
                }
            }
            output.Write("<div class=\"dnnClear groupPager\">");
            output.Write(sb.ToString());
            output.Write("</div>");
        }