示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var topNavPanel = (TopNavigationPanel) LoadControl(TopNavigationPanel.Location);

            var dashboardItem = new NavigationItem()
                                    {
                                        Name = Resources.CommunityResource.Dashboard,
                                        URL = VirtualPathUtility.ToAbsolute("~/products/community/"),
                                        Selected = (this.Page is _Default)
                                    };

            topNavPanel.NavigationItems.Add(dashboardItem);


            var employeesItem = new NavigationItem()
                                    {
                                        Name = CustomNamingPeople.Substitute<Resources.CommunityResource>("Employees"),
                                        Selected = UserOnlineManager.Instance.IsEmployeesPage() || UserOnlineManager.Instance.IsUserProfilePage(),
                                        URL = CommonLinkUtility.GetEmployees(CommunityProduct.ID)
                                    };
            topNavPanel.NavigationItems.Add(employeesItem);

            var product = ProductManager.Instance[CommunityProduct.ID];

            var currentModule = UserOnlineManager.Instance.GetCurrentModule();
            foreach (var item in WebItemManager.Instance.GetSubItems(product.ID))
            {
                var moduleItem = new NavigationItem
                                     {
                                         URL = VirtualPathUtility.ToAbsolute(item.StartURL),
                                         Name = item.Name,
                                         Description = item.Description,
                                     };
                if (currentModule != null && currentModule.ID.Equals(item.ID)) moduleItem.Selected = true;
                topNavPanel.NavigationItems.Add(moduleItem);
            }

            _topNavigatorPlaceHolder.Controls.Add(topNavPanel);

            var bottomNavigator = new BottomNavigator();
            _bottomNavigatorPlaceHolder.Controls.Add(bottomNavigator);

            var onlineUsersControl = (OnlineUsers) LoadControl(OnlineUsers.Location);
            onlineUsersControl.ProductId = CommunityProduct.ID;
            phOnlineUsers.Controls.Add(onlineUsersControl);
        }
        protected void RenderHeader()
        {
            var topNavigationPanel = (TopNavigationPanel) LoadControl(TopNavigationPanel.Location);
            topNavigationPanel.SingleSearchHandlerType = typeof (SearchHandler);

            var absolutePathWithoutQuery = Request.Url.AbsolutePath.Substring(0, Request.Url.AbsolutePath.IndexOf(".aspx"));
            var sysName = absolutePathWithoutQuery.Substring(absolutePathWithoutQuery.LastIndexOf('/') + 1);
            var project = RequestContext.GetCurrentProject(false);
            var projectID = -1;

            if (RequestContext.IsInConcreteProject())
            {
                projectID = project.ID;

                var rigthItems = new List<NavigationItem>();
                foreach (var webitem in WebItemManager.Instance.GetSubItems(ProductEntryPoint.ID))
                {
                    var module = webitem as IModule;

                    var navigationItem = new NavigationItem()
                                             {
                                                 URL = String.Format(webitem.StartURL, projectID),
                                                 Name = webitem.Name,
                                                 Description = webitem.Description,
                                                 Selected = String.Compare(sysName, module.ModuleSysName, true) == 0
                                             };

                    var added = false;
                    if (String.Compare(module.ModuleSysName, "History", true) == 0 ||
                        String.Compare(module.ModuleSysName, "ProjectAction", true) == 0 ||
                        String.Compare(module.ModuleSysName, "ProjectTeam", true) == 0)
                    {
                        navigationItem.RightAlign = true;
                        rigthItems.Add(navigationItem);
                        added = true;
                    }

                    //hide in private projects
                    if (String.Compare(module.ModuleSysName, "Messages", true) == 0 && !ProjectSecurity.CanReadMessages(RequestContext.GetCurrentProject()))
                    {
                        continue;
                    }
                    if (String.Compare(module.ModuleSysName, "TMDocs", true) == 0 && !ProjectSecurity.CanReadFiles(RequestContext.GetCurrentProject()))
                    {
                        continue;
                    }

                    if (String.Compare(module.ModuleSysName, "TMDocs", true) == 0)
                    {
                        navigationItem.Selected = String.Compare(sysName, "tmdocs", true) == 0;
                        navigationItem.Name = ProjectsFileResource.Documents;
                        navigationItem.URL = PathProvider.BaseAbsolutePath + "tmdocs.aspx?prjID=" + projectID;
                    }

                    if (!added)
                        topNavigationPanel.NavigationItems.Add(navigationItem);
                }

                rigthItems.Reverse();
                topNavigationPanel.NavigationItems.AddRange(rigthItems);

            }
            else
            {
                topNavigationPanel.NavigationItems.Add(new NavigationItem
                                                           {
                                                               URL = String.Concat(PathProvider.BaseAbsolutePath, "default.aspx"),
                                                               Name = ProjectsCommonResource.Dashboard,
                                                               Description = "",
                                                               Selected = String.Compare(sysName, "Default", true) == 0
                                                           });

                topNavigationPanel.NavigationItems.Add(new NavigationItem
                                                           {
                                                               URL = String.Concat(PathProvider.BaseAbsolutePath, "projects.aspx"),
                                                               Name = ProjectResource.Projects,
                                                               Description = "",
                                                               Selected = String.Compare(sysName, "Projects", true) == 0 || String.Compare(sysName, "ProjectAction", true) == 0
                                                           });


                topNavigationPanel.NavigationItems.Add(new NavigationItem
                                                           {
                                                               URL = String.Concat(PathProvider.BaseAbsolutePath, "milestones.aspx"),
                                                               Name = MilestoneResource.Milestones,
                                                               Description = "",
                                                               Selected = String.Compare(sysName, "milestones", true) == 0
                                                           });

                topNavigationPanel.NavigationItems.Add(new NavigationItem
                                                           {
                                                               URL = String.Concat(PathProvider.BaseAbsolutePath, "tasks.aspx"),
                                                               Name = TaskResource.Tasks,
                                                               Description = "",
                                                               Selected = String.Compare(sysName, "tasks", true) == 0
                                                           });

                topNavigationPanel.NavigationItems.Add(new NavigationItem
                                                           {
                                                               URL = String.Concat(PathProvider.BaseAbsolutePath, "messages.aspx"),
                                                               Name = MessageResource.Messages,
                                                               Description = "",
                                                               Selected = String.Compare(sysName, "messages", true) == 0
                                                           });
              
                topNavigationPanel.NavigationItems.Add(new NavigationItem
                                                           {
                                                               URL = String.Concat(PathProvider.BaseAbsolutePath, "reports.aspx"),
                                                               Name = ReportResource.Reports,
                                                               Description = "",
                                                               Selected = String.Compare(sysName, "Reports", true) == 0 || String.Compare(sysName, "Templates", true) == 0
                                                           });

                topNavigationPanel.NavigationItems.Add(new NavigationItem
                                                            {
                                                                URL = String.Concat(PathProvider.BaseAbsolutePath, "history.aspx"),
                                                                Name = ProjectsCommonResource.History,
                                                                Description = "",
                                                                Selected = String.Compare(sysName, "History", true) == 0
                                                            });


                if (ProjectSecurity.IsAdministrator(SecurityContext.CurrentAccount.ID))
                {
                    topNavigationPanel.NavigationItems.Add(new NavigationItem
                                                               {
                                                                   URL = String.Concat(PathProvider.BaseAbsolutePath, "projectTemplates.aspx"),
                                                                   Name = ProjectResource.ProjectTemplates,
                                                                   Description = "",
                                                                   Selected = String.Compare(sysName, "ProjectTemplates", true) == 0,
                                                                   RightAlign = true
                                                               });
                }

                topNavigationPanel.NavigationItems.Add(new NavigationItem
                                                           {
                                                               URL = CommonLinkUtility.GetEmployees(ProductEntryPoint.ID),
                                                               Name = CustomNamingPeople.Substitute<ProjectsCommonResource>("Employees"),
                                                               Description = "",
                                                               Selected = UserOnlineManager.Instance.IsEmployeesPage() ||UserOnlineManager.Instance.IsUserProfilePage(),
                                                               RightAlign = true

                                                           });

            }
            if (RequestContext.HasAnyProjects())
            {
                var pageName = "default";
                switch (sysName)
                {
                    case "userprofile":
                    case "default":
                    case "reports":
                    case "projectTemplates":
                    case "createprojectfromtemplate":
                    case "editprojecttemplate":
                        pageName = "projects";
                        break;

                    case "settings":
                        pageName = "projectAction";
                        break;

                    case "employee":
                        pageName = "projectTeam";
                        break;
                    default:
                        pageName = sysName;
                        break;
                }
                topNavigationPanel.CustomInfoHTML = RenderAllProjectsBlock(projectID, pageName);
            }
            _topNavigationPanelPlaceHolder.Controls.Add(topNavigationPanel);
        }