private void DeactivatePages()
 {
     foreach (var page in pages)
     {
         page.SetActivate(false);
     }
     _currentActivePage = null;
 }
예제 #2
0
 public ActionResult Page(string url)
 {
     return(PageUI.PageModel(url)
            .Select(model => View("~/Views/Page.cshtml", model) as ActionResult)
            .LogErrors(Log.Error)
            .Or(() => url.NullOrEmpty() ? EmptyView() : Redirect("~/"))
            .Value);
 }
예제 #3
0
        /// <summary>
        /// AJAX分页
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="html"></param>
        /// <param name="pagedList"></param>
        /// <param name="UpdateTargetId"></param>
        /// <param name="ActionName"></param>
        /// <param name="ControllerName"></param>
        /// <returns></returns>
        public static MvcHtmlString AjaxPager <T>(this HtmlHelper html, PagedResult <T> pagedList, string UpdateTargetId, string ActionName, string ControllerName, bool isDisplayCompletePage, bool isTop)
        {
            var mvcUrl   = new UrlHelper(html.ViewContext.RequestContext).Action(ActionName, ControllerName); //占岭修改
            var localUrl = string.Format(@"{0}://{1}", html.ViewContext.RequestContext.HttpContext.Request.Url.Scheme, html.ViewContext.RequestContext.HttpContext.Request.Url.Authority);
            var url      = string.Format("{0}{1}{2}", localUrl, mvcUrl, html.ViewContext.RequestContext.HttpContext.Request.Url.Query);
            var ui       = new PageUI(url, UpdateTargetId, pagedList.AddParameters);

            return(MvcHtmlString.Create(ui.GetPage(pagedList.PageIndex, pagedList.PageSize, pagedList.TotalRecords, isDisplayCompletePage, false, isTop)));
        }
예제 #4
0
        /// <summary>
        /// AJAX分页
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="html"></param>
        /// <param name="pagedList"></param>
        /// <param name="UpdateTargetId"></param>
        /// <returns></returns>
        public static MvcHtmlString AjaxPager <T>(this HtmlHelper html, PagedResult <T> pagedList, string UpdateTargetId, bool isDisplayCompletePage)
        {
            var ui = new PageUI(html.ViewContext.RequestContext.HttpContext.Request.Url.ToString(), UpdateTargetId, pagedList.AddParameters);

            if (!isDisplayCompletePage)
            {
                return(MvcHtmlString.Create(ui.GetPage(pagedList.PageIndex, pagedList.PageSize, pagedList.TotalRecords, false)));
            }
            else
            {
                return(MvcHtmlString.Create(ui.GetPage(pagedList.PageIndex, pagedList.PageSize, pagedList.TotalRecords)));
            }
        }
예제 #5
0
        public void OnInteract(Entity entity)
        {
            Player player = entity as Player;

            if (player != null)
            {
                PageUI pageUI = MenuManager.CreatePage(name, this);
                UnityEngine.Debug.Log(pageUI);
                WorkBenchUI workBenchUI = new WorkBenchUI();
                workBenchUI.CreateUI(craftingData, input, output, pageUI);
                if (!MenuManager.IsMenuActive())
                {
                    MenuManager.ToggleMenu();
                }
                MenuManager.SetTab(MenuManager.GetPagesCount() - 1);
            }
        }
예제 #6
0
    /// <summary>
    /// go to page type T where T:Page
    /// </summary>
    /// <typeparam name="T">go to page type T</typeparam>
    public void SwitchPageOn <T>(params object[] parameters) where T : PageUI
    {
        PageUI pageActvate = null;

        foreach (var page in pages)
        {
            if (page.GetType() == typeof(T))
            {
                pageActvate = page;
                _pagesHistory.Push(page);
            }
            else
            {
                page.SetActivate(false);
            }
        }
        pageActvate.SetActivate(true, parameters);
    }
예제 #7
0
        /// <summary>
        /// Html分页,router为true表示走MVC路由
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="html"></param>
        /// <param name="pagedList"></param>
        /// <param name="router">路由</param>
        /// <param name="className">CSS类名</param>
        /// <returns></returns>
        public static MvcHtmlString Pager <T>(this HtmlHelper html, PagedResult <T> pagedList, bool router, bool isCompleteDisplay, string className)
        {
            if (pagedList == null)
            {
                return(null);
            }
            PageUI ui = new PageUI(html.ViewContext.RequestContext.HttpContext.Request.Url.ToString(), pagedList.AddParameters);

            if (router)
            {
                return(MvcHtmlString.Create(ui.GetPage(pagedList.PageIndex
                                                       , pagedList.PageSize
                                                       , pagedList.TotalRecords
                                                       , 0
                                                       , new UrlHelper(html.ViewContext.RequestContext)
                                                       , html.ViewContext.RouteData.Values["action"].ToString()
                                                       , html.ViewContext.RouteData.Values["controller"].ToString(), isCompleteDisplay, false, className)));
            }
            return(MvcHtmlString.Create(ui.GetPage(pagedList.PageIndex, pagedList.PageSize, pagedList.TotalRecords, isCompleteDisplay, className)));
        }
예제 #8
0
    public void SwitchPageBack()
    {
        print(_pagesHistory.Peek().GetType());
        _pagesHistory.Pop();
        print(_pagesHistory.Peek().GetType());
        PageUI pageActvate = null;

        foreach (var page in pages)
        {
            if (page.GetType() == _pagesHistory.Peek().GetType())
            {
                pageActvate = page;
            }
            else
            {
                page.SetActivate(false);
            }
        }
        pageActvate.ReOpen();
    }
예제 #9
0
        private bool CreateUserInterface(User owner, GuideEntry masthead, ref PageUI pageInterface)
        {
		    bool allowDiscuss = true;
            bool allowEdit = false;

            // get the ID of the forum if we have been given a masthead article and
            // it actually has a forum (which it should)
            int forumID = 0;
            if (masthead != null)
            {
                forumID = masthead.ForumID;
            }
            if (forumID == 0)
            {
                allowDiscuss = false;
            }
            // check if we have a registered viewer and also if this happens to be their
            // own home page and set the appropriate button flags
            if (InputContext.ViewingUser.UserID > 0 && InputContext.ViewingUser.UserLoggedIn)
            {
                if (InputContext.ViewingUser.UserID == owner.UserID)
                {
                    // also if this is their own home page they have an edit page button
                    allowEdit = true;
                }
            }

            string discussLink = "AddThread?forum=" + forumID.ToString() + "&amp;article=";

            int h2g2ID = 0;
            if (owner != null)
            {
                h2g2ID = owner.Masthead;
            }
            if (h2g2ID == 0)
            {
                if (masthead != null)
                {
                    h2g2ID = masthead.H2G2ID;
                }
            }

            discussLink += h2g2ID.ToString();

            string editLink = "/UserEdit" + h2g2ID.ToString() + "?Masthead=1";

		    // now set the apppropriate buttons in the UI object
		    // currently you only get the edit page button if this is actually your homepage, i.e. you
		    // wont get it if you have editor status
            pageInterface.SetDiscussVisibility(allowDiscuss, discussLink);
            pageInterface.SetEditPageVisibility(allowEdit, editLink);

            return true;
        }
예제 #10
0
        /// <summary>
        /// Calls the individual objects to generate the User Page XML
        /// </summary>
        /// <param name="userPageParameters"></param>
        private void GenerateUserPageXml(UserPageParameters userPageParameters)
        {
            // all the XML objects we need to build the page
            if (userPageParameters.IsRegistering)
            {
                //TODO REGISTER USER STUFF
            }
            else
            {
	            // introducing the players - these will point to the BBC.DNA Component objects required
	            // to construct a user page
                PageUI          pageInterface = new PageUI(userPageParameters.UserID);
	            User			owner = new User(InputContext);
	            GuideEntry		masthead = null;
	            Forum			pageForum = new Forum(InputContext);
	            Forum			journal = new Forum(InputContext);
	            PostList		recentPosts = new PostList(InputContext);
	            ArticleList	    recentArticles = new ArticleList(InputContext);
	            ArticleList	    recentApprovals = new ArticleList(InputContext);
	            CommentsList	recentComments = new CommentsList(InputContext);
                ArticleSubscriptionsList subscribedUsersArticles = new ArticleSubscriptionsList(InputContext);

                // get or create all the appropriate xml objects
                bool gotMasthead = false;
                bool gotPageForum = false;
                bool gotJournal = false;
                bool gotRecentPosts = false;
                bool gotRecentArticles = false;
                bool gotRecentApprovals = false;
                bool gotRecentComments = false;
                bool gotSubscribedToUsersRecentArticles = false;

                bool gotOwner = CreatePageOwner(userPageParameters.UserID, ref owner);

		        if (InputContext.GetSiteOptionValueBool("PersonalSpace", "IncludeUsersGuideEntry")      || userPageParameters.IncludeUsersGuideEntries ||
                    InputContext.GetSiteOptionValueBool("PersonalSpace", "IncludeUsersGuideEntryForum") || userPageParameters.IncludeUsersGuideEntriesForums)
		        {
                    gotMasthead = CreatePageArticle(userPageParameters.UserID, owner, out masthead);

                    if (gotMasthead && (InputContext.GetSiteOptionValueBool("PersonalSpace", "IncludeUsersGuideEntryForum") || userPageParameters.IncludeUsersGuideEntriesForums))
			        {
				        // GuideEntry forum can not be returned if GuideEntry is not being returned.
                        gotPageForum = CreatePageForum(masthead, ref pageForum);
			        }
		        }

                bool gotInterface = CreateUserInterface(owner, masthead, ref pageInterface);
        		
		        // Only display other information if the page has a valid masthead
		        if (gotMasthead)
		        {
                    if (InputContext.GetSiteOptionValueBool("PersonalSpace", "IncludeJournal") || userPageParameters.IncludeJournals)
			        {
                        gotJournal = CreateJournal(owner, ref journal);
			        }

                    if (InputContext.GetSiteOptionValueBool("PersonalSpace", "IncludeRecentPosts") || userPageParameters.IncludeRecentPosts)
			        {
                        gotRecentPosts = CreateRecentPosts(owner, ref recentPosts);
			        }

                    if (InputContext.GetSiteOptionValueBool("PersonalSpace", "IncludeRecentComments") || userPageParameters.IncludeRecentComments)
			        {
                        gotRecentComments = CreateRecentComments(owner, ref recentComments);
			        }

                    if (InputContext.GetSiteOptionValueBool("PersonalSpace", "IncludeRecentGuideEntries") || userPageParameters.IncludeRecentGuideEntries)
			        {
                        gotRecentArticles = CreateRecentArticles(owner, ref recentArticles);
                        gotRecentApprovals = CreateRecentApprovedArticles(owner, ref recentApprovals);
			        }

                    if (InputContext.GetSiteOptionValueBool("PersonalSpace", "IncludeUploads") || userPageParameters.IncludeRecentUploads)
			        {
				        //string sUploadsXML;
				        //CUpload Upload(m_InputContext);
				        //Upload.GetUploadsForUser(iUserID,sUploadsXML);
				        //pWholePage->AddInside("H2G2",sUploadsXML);
			        }

                    if (InputContext.GetSiteOptionValueBool("PersonalSpace", "IncludeRecentArticlesOfSubscribedToUsers") || userPageParameters.IncludeRecentArticlesOfSubscribedUsers)
			        {
                        gotSubscribedToUsersRecentArticles = CreateSubscribedToUsersRecentArticles(owner, InputContext.CurrentSite.SiteID, ref subscribedUsersArticles); 
			        }
                }


                XmlElement pageOwner = AddElementTag(RootElement, "PAGE-OWNER");
                if(gotOwner)
                {
                    AddInside(pageOwner, owner);
                }
                else
                {
                    XmlElement pretendUser = AddElementTag(pageOwner, "USER");
                    AddIntElement(pretendUser, "USERID", userPageParameters.UserID);
                    AddTextTag(pretendUser, "USERNAME", "Researcher " + userPageParameters.UserID.ToString());
                }
                if(gotInterface)
                {
                    AddInside(pageInterface, "");
                }

                if (userPageParameters.Clip)
                {
                    string clipSubject = String.Empty;
                    if (gotOwner)
                    {
                        clipSubject = owner.UserName;
                    }
                    else
                    {
                        clipSubject = "U" + userPageParameters.UserID.ToString();
                    }
                    Link link = new Link(InputContext);
                    //TODO ClipPageToUser page
                    link.ClipPageToUserPage("userpage", userPageParameters.UserID, clipSubject, String.Empty, InputContext.ViewingUser, userPageParameters.Private);
                    AddInside(link);                       
                }

                // if masthead NULL stylesheet should do the default response
                if (gotMasthead && (InputContext.GetSiteOptionValueBool("PersonalSpace", "IncludeUsersGuideEntry") || userPageParameters.IncludeUsersGuideEntries))
                {
                    AddInside(masthead);
                }
                // add page forum if there is one => this is the forum associated with
                // the guide enty that is the masthead for this user
                if (gotPageForum && (InputContext.GetSiteOptionValueBool("PersonalSpace", "IncludeUsersGuideEntryForum") || userPageParameters.IncludeUsersGuideEntriesForums))
                {
                    XmlElement articleForumTag = AddElementTag(RootElement, "ARTICLEFORUM");
                    AddInside(articleForumTag, pageForum);
                }
                // add journal if it exists
                if ( gotJournal)
                {
                    XmlElement journalTag = AddElementTag(RootElement, "JOURNAL");
                    AddInside(journalTag, journal);
                }
                // add recent posts if they exist, this may add an empty
                // POST-LIST tag if the user exists but has never posted
                if ( gotRecentPosts)
                {
                    XmlElement recentPostsTag = AddElementTag(RootElement, "RECENT-POSTS");
                    AddInside(recentPostsTag, recentPosts);
                }
                // add recent articles if they exist, this may add an empty
                // ARTICLES-LIST tag if the user exists but has never written a guide entry
                if ( gotRecentArticles)
                {
                    XmlElement recentEntries = AddElementTag(RootElement, "RECENT-ENTRIES");
                    AddInside(recentEntries, recentArticles);
                    // add the user XML for the owner too
                    if (gotOwner)
                    {
                        AddInside(recentEntries, owner);
                    }
                }
                // add recent approvals if they exist, this may add an empty
                // ARTICLES-LIST tag if the user exists but has never had an entry approved
                if ( gotRecentApprovals)
                {
                    XmlElement recentApprovalsTag = AddElementTag(RootElement, "RECENT-APPROVALS");
                    AddInside(recentApprovalsTag, recentApprovals);
                    // add the user XML for the owner too
                    if (gotOwner)
                    {
                        AddInside(recentApprovalsTag, owner);
                    }
                }
                // add recent comments if they exist, this may add an empty
                // COMMENTS-LIST tag if the user exists but has never posted
                if ( gotRecentComments)
                {
                    XmlElement recentCommentsTag = AddElementTag(RootElement, "RECENT-COMMENTS");
                    AddInside(recentCommentsTag, recentComments);
                }

                if ( gotSubscribedToUsersRecentArticles)
                {
                    XmlElement subscribedUsersArticlesTag = AddElementTag(RootElement, "RECENT-SUBSCRIBEDARTICLES");
                    AddInside(subscribedUsersArticlesTag, subscribedUsersArticles);
                }

                SiteXmlBuilder siteXml = new SiteXmlBuilder(InputContext);
                RootElement.AppendChild(ImportNode(siteXml.GenerateAllSitesXml(InputContext.TheSiteList).FirstChild));

                AddWatchListSection(userPageParameters, gotMasthead);

                AddWhosOnlineSection();

                AddClubsSection(userPageParameters, gotMasthead);

                AddPrivateForumSection(userPageParameters, gotMasthead, gotOwner);

                AddLinksSection(userPageParameters, owner, gotMasthead, gotOwner);

                AddTaggedNodesSection(userPageParameters, owner, gotMasthead);

                AddNoticeBoardPostcoderSection(userPageParameters, gotMasthead);

                AddSiteOptionSection(userPageParameters);
            }
        }
        /// <summary>
        /// Process Request Override
        /// </summary>
        public override void ProcessRequest()
        {
            // Add the standard PageUI
            PageUI pageUI = new PageUI(InputContext.ViewingUser.UserID);
            AddInside(pageUI);

            // Get the current request params
            string nextAction = "default";
            _actionProcessed = false;
            string selectedTemplateType = "";
            string selectedInsert = "";

            string viewModeObject = InputContext.GetParamStringOrEmpty("view", "Get the current view object type");
            int viewModeObjectID = InputContext.GetParamIntOrZero("viewid", "Get the current view object id");
            string actionObjectName = InputContext.GetParamStringOrEmpty("emailtemplatename", "Get the email template name");
            int actionObjectTypeID = InputContext.GetParamIntOrZero("emailtemplateid", "Get the email template id");
            selectedTemplateType = actionObjectName;
            if (actionObjectName.Length == 0)
            {
                actionObjectName = InputContext.GetParamStringOrEmpty("insertname", "Get the insert name");
                actionObjectTypeID = InputContext.GetParamIntOrZero("insertid", "Get the insert id");
                selectedInsert = actionObjectName;
            }

            int siteID = InputContext.GetParamIntOrZero("siteid", "Get the requested siteid");
            int modClassID = InputContext.GetParamIntOrZero("modclassid", "Get the mod class id");

            EmailTemplateTypes eTemplateType = (viewModeObject == "site" || siteID > 0) ? EmailTemplateTypes.SiteTemplates : EmailTemplateTypes.ClassTemplates;

            // Process the action if given
            string action = "";
            if (InputContext.DoesParamExist("action", "Get the request action"))
            {
                action = ProcessAction(out nextAction, actionObjectName, modClassID, viewModeObjectID);
            }
            else if (InputContext.DoesParamExist("insertsaveandreturnhome", "save insert template and finish") || InputContext.DoesParamExist("insertsaveandcreatenew", "save insert template and create a new one"))
	        {
                CreateUpdateEmailInsert(ref actionObjectName, siteID, modClassID, ref eTemplateType, ref action);
            }
            else if (InputContext.DoesParamExist("insertcreate", "create a new insert"))
            {
                action = "createinsert";
                nextAction = "createinsert";
                _pageStatus = "Creating new insert";
                if (eTemplateType == EmailTemplateTypes.ClassTemplates)
                {
                    modClassID = viewModeObjectID;
                }
                else
                {
                    siteID = viewModeObjectID;
                }
            }
            
            if (InputContext.DoesParamExist("saveandcreatenew", "Save email template and create a new one") || InputContext.DoesParamExist("saveandreturnhome", "Save the email tmeplate and return to the home page"))
            {
                CreateUpdateEmailTemplate(modClassID, action);
            }
            else if (InputContext.DoesParamExist("createnewemail", "Setup for creating a new template"))
            {
                action = "createnewemail";
                nextAction = "createnewemail";
                _pageStatus = "Creating new template";
                if (eTemplateType == EmailTemplateTypes.ClassTemplates)
                {
                    modClassID = viewModeObjectID;
                }
                else
                {
                    siteID = viewModeObjectID;
                }
            }

            if (_actionProcessed)
            {
                UpdatePageViewForProcessedAction(ref nextAction, ref selectedTemplateType, ref selectedInsert, ref viewModeObject, ref viewModeObjectID, ref actionObjectName, ref actionObjectTypeID, siteID, modClassID, ref eTemplateType, ref action);
            }

            // Add the moderation page XML
            AddModerationPageXML(nextAction, selectedTemplateType, selectedInsert, modClassID, siteID);

            // Add the current view options to the page
            string displayMode = viewModeObject;
            if (action.Length > 0)
            {
                displayMode = action;
            }

            int currentEditObjectID = viewModeObjectID;
            if (actionObjectTypeID > 0)
            {
                currentEditObjectID = actionObjectTypeID;
            }

            if (viewModeObject == "site")
            {
                siteID = viewModeObjectID;
            }
            else
            {
                modClassID = viewModeObjectID;
            }

            AddModerationViewXML(modClassID, siteID, displayMode, currentEditObjectID);

            // Get all the email templates for the current requested object
            EmailTemplates emailTemplates = EmailTemplates.GetEmailTemplates(AppContext.ReaderCreator, eTemplateType, viewModeObjectID);
            SerialiseAndAppend(emailTemplates, "");

            // Get all the email inserts for the requested object
            EmailInserts emailInserts = EmailInserts.GetEmailInserts(AppContext.ReaderCreator, eTemplateType, viewModeObjectID);
            SerialiseAndAppend(emailInserts, "");

            // Add the current site list
            AddSiteListXML();

            // Add all the other default page XML objects
            AddDefaultEmailModerationDetailsXML();
        }