Наследование: Universe.Framework.Modules.IDataTransferable
Пример #1
0
 private string GetTranslatedString(ITranslator translator, string name, GridPage page, bool isTooltip)
 {
     string retVal = translator.GetTranslatedString(name);
     if (retVal == "UNKNOWN CHARACTER")
         return isTooltip ? page.MenuToolTip : page.MenuTitle;
     return retVal;
 }
 public GridPage GetPage(string item, GridPage rootPage)
 {
     if (rootPage == null)
         rootPage = this;
     foreach (var page in rootPage.Children)
     {
         if (page.MenuID == item)
             return page;
         else if (page.Children.Count > 0)
         {
             var p = GetPage(item, page);
             if (p != null)
                 return p;
         }
     }
     return null;
 }
Пример #3
0
        public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                               OSHttpResponse httpResponse, Dictionary<string, object> requestParameters,
                                               ITranslator translator, out string response)
        {
            response = null;
            var vars = new Dictionary<string, object>();

            #region Find pages

            List<Dictionary<string, object>> pages = new List<Dictionary<string, object>>();

            IGenericsConnector generics = Framework.Utilities.DataManager.RequestPlugin<IGenericsConnector>();
            GridPage rootPage = generics.GetGeneric<GridPage>(UUID.Zero, "WebPages", "Root");
            if (rootPage == null)
                return null;            // major bummer !!

            rootPage.Children.Sort((a, b) => a.MenuPosition.CompareTo(b.MenuPosition));
            List<GridPage> allPages = new List<GridPage>(rootPage.Children);
            foreach (GridPage page in rootPage.Children)
                allPages.AddRange(page.Children);
            allPages.RemoveAll((a) => !a.ShowInMenu);

            string MenuItem = requestParameters.ContainsKey("MenuItem")
                                  ? requestParameters["MenuItem"].ToString()
                                  : "";
            foreach (GridPage page in allPages)
            {
                pages.Add(new Dictionary<string, object>
                              {
                                  {"Value", page.Location},
                                  {"Name", page.Location},
                                  {
                                      "PageSelected", MenuItem == page.Location
                                                          ? "selected=\"selected\""
                                                          : ""
                                  }
                              });
            }
            vars.Add("PagesList", pages);

            #endregion

            if (requestParameters.ContainsKey("DeleteItem"))
            {
                rootPage.RemovePageByLocation(MenuItem, null);
                generics.AddGeneric(UUID.Zero, "WebPages", "Root", rootPage.ToOSD());
                response = "<h3>Successfully updated menu</h3>" +
                           "<script language=\"javascript\">" +
                           "setTimeout(function() {window.location.href = \"index.html\";}, 0);" +
                           "</script>";
                return null;
            }
            if (requestParameters.ContainsKey("AddItem"))
            {
                //generics.AddGeneric(UUID.Zero, "WebPages", "Root", rootPage.ToOSD());
                vars.Add("EdittingPageID", -2);
                vars.Add("DisplayEdit", true);
            }
            if (requestParameters.ContainsKey("SelectItem"))
            {
                GridPage page = rootPage.GetPageByLocation(MenuItem);

                vars.Add("PageTitle", page.MenuTitle);
                vars.Add("PageTooltip", page.MenuToolTip);
                vars.Add("PageID", page.MenuID);
                vars.Add("PagePosition", page.MenuPosition);
                vars.Add("PageLocation", page.Location);
                vars.Add("EdittingPageID", page.MenuID);
                vars.Add("RequiresLoginYes", page.LoggedInRequired ? "selected=\"selected\"" : "");
                vars.Add("RequiresLoginNo", !page.LoggedInRequired ? "selected=\"selected\"" : "");
                vars.Add("RequiresLogoutYes", page.LoggedOutRequired ? "selected=\"selected\"" : "");
                vars.Add("RequiresLogoutNo", !page.LoggedOutRequired ? "selected=\"selected\"" : "");
                vars.Add("RequiresAdminYes", page.AdminRequired ? "selected=\"selected\"" : "");
                vars.Add("RequiresAdminNo", !page.AdminRequired ? "selected=\"selected\"" : "");
                vars.Add("RequiresAdminLevel", page.AdminLevelRequired);
                vars.Add("DisplayInMenuYes", page.ShowInMenu ? "selected=\"selected\"" : "");
                vars.Add("DisplayInMenuNo", !page.ShowInMenu ? "selected=\"selected\"" : "");
                vars.Add("DisplayEdit", true);

                pages = new List<Dictionary<string, object>>
                            {
                                new Dictionary<string, object>
                                    {
                                        {"Value", "Top Level"},
                                        {"Name", translator.GetTranslatedString("TopLevel")},
                                        {"PageSelected", ""}
                                    }
                            };
                GridPage parent = rootPage.GetParent(page);
                foreach (GridPage p in allPages)
                {
                    pages.Add(new Dictionary<string, object>
                                  {
                                      {"Value", p.Location},
                                      {"Name", p.Location},
                                      {
                                          "PageSelected", parent.Location == p.Location
                                                              ? "selected=\"selected\""
                                                              : ""
                                      }
                                  });
                }
                vars.Add("ParentPagesList", pages);
            }

            if (requestParameters.ContainsKey("AddItem"))
            {
                vars.Add("PageTitle", "");
                vars.Add("PageTooltip", "");
                vars.Add("PageID", "");
                vars.Add("PagePosition", "");
                vars.Add("PageLocation", "");
                if (!vars.ContainsKey("EdittingPageID"))
                    vars.Add("EdittingPageID", "");
                vars.Add("RequiresLoginYes", "");
                vars.Add("RequiresLoginNo", "");
                vars.Add("RequiresLogoutYes", "");
                vars.Add("RequiresLogoutNo", "");
                vars.Add("RequiresAdminYes", "");
                vars.Add("RequiresAdminNo", "");
                vars.Add("RequiresAdminLevel", "1");

                pages = new List<Dictionary<string, object>>
                            {
                                new Dictionary<string, object>
                                    {
                                        {"Value", "Top Level"},
                                        {"Name", translator.GetTranslatedString("TopLevel")},
                                        {"PageSelected", ""}
                                    }
                            };
                foreach (GridPage p in allPages)
                {
                    pages.Add(new Dictionary<string, object>
                                  {
                                      {"Value", p.Location},
                                      {"Name", p.Location},
                                      {"PageSelected", ""}
                                  });
                }
                vars.Add("ParentPagesList", pages);
            }

            if (requestParameters.ContainsKey("SaveMenuItem"))
            {
                string edittingPageID = requestParameters["EdittingPageID"].ToString();
                string PageTitle = requestParameters["PageTitle"].ToString();
                string PageTooltip = requestParameters["PageTooltip"].ToString();
                string PagePosition = requestParameters["PagePosition"].ToString();
                string PageID = requestParameters["PageID"].ToString();
                string PageLocation = requestParameters["PageLocation"].ToString();
                bool RequiresLogin = bool.Parse(requestParameters["RequiresLogin"].ToString());
                bool RequiresLogout = bool.Parse(requestParameters["RequiresLogout"].ToString());
                bool RequiresAdmin = bool.Parse(requestParameters["RequiresAdmin"].ToString());
                bool DisplayInMenu = bool.Parse(requestParameters["DisplayInMenu"].ToString());
                string ParentMenuItem = requestParameters["ParentMenuItem"].ToString();
                int RequiredAdminLevel = int.Parse(requestParameters["RequiredAdminLevel"].ToString());
                GridPage page = rootPage.GetPage(edittingPageID);
                bool add = page == null;
                if (page == null)
                    page = new GridPage {MenuID = PageLocation, ShowInMenu = true};

                page.Location = PageLocation;
                page.MenuID = PageID;
                page.MenuPosition = int.Parse(PagePosition);
                page.MenuTitle = PageTitle;
                page.MenuToolTip = PageTooltip;
                page.LoggedInRequired = RequiresLogin;
                page.LoggedOutRequired = RequiresLogout;
                page.AdminRequired = RequiresAdmin;
                page.AdminLevelRequired = RequiredAdminLevel;
                page.ShowInMenu = DisplayInMenu;

                GridPage parent = rootPage.GetPageByLocation(ParentMenuItem);

                if (parent != page)
                {
                    if (!add)
                        rootPage.RemovePage(edittingPageID, page);

                    if (parent != null)
                        parent.Children.Add(page);
                    else //Top Level
                        rootPage.Children.Add(page);

                    response = "<h3>Successfully updated menu</h3>" +
                               "<script language=\"javascript\">" +
                               "setTimeout(function() {window.location.href = \"index.html\";}, 0);" +
                               "</script>";
                }
                else
                    response = "<h3>" + translator.GetTranslatedString("CannotSetParentToChild") + "</h3>";

                generics.AddGeneric(UUID.Zero, "WebPages", "Root", rootPage.ToOSD());
                return null;
            }

            vars.Add("PageTitleText", translator.GetTranslatedString("PageTitleText"));
            vars.Add("PageTooltipText", translator.GetTranslatedString("PageTooltipText"));
            vars.Add("PagePositionText", translator.GetTranslatedString("PagePositionText"));
            vars.Add("PageIDText", translator.GetTranslatedString("PageIDText"));
            vars.Add("PageLocationText", translator.GetTranslatedString("PageLocationText"));
            vars.Add("SaveMenuItemChanges", translator.GetTranslatedString("SaveMenuItemChanges"));
            vars.Add("RequiresLoginText", translator.GetTranslatedString("RequiresLoginText"));
            vars.Add("RequiresLogoutText", translator.GetTranslatedString("RequiresLogoutText"));
            vars.Add("RequiresAdminText", translator.GetTranslatedString("RequiresAdminText"));
            vars.Add("RequiresAdminLevelText", translator.GetTranslatedString("RequiresAdminLevelText"));
            vars.Add("DisplayInMenu", translator.GetTranslatedString("DisplayInMenu"));
            vars.Add("SelectItem", translator.GetTranslatedString("SelectItem"));
            vars.Add("DeleteItem", translator.GetTranslatedString("DeleteItem"));
            vars.Add("AddItem", translator.GetTranslatedString("AddItem"));
            vars.Add("PageManager", translator.GetTranslatedString("PageManager"));
            vars.Add("ParentText", translator.GetTranslatedString("ParentText"));
            vars.Add("Yes", translator.GetTranslatedString("Yes"));
            vars.Add("No", translator.GetTranslatedString("No"));

            return vars;
        }
 public void ReplacePage(string MenuItem, GridPage replacePage)
 {
     foreach (var page in this.Children)
     {
         if (page.MenuID == MenuItem)
         {
             page.FromOSD(replacePage.ToOSD());
             return;
         }
         else if (page.Children.Count > 0)
         {
             var p = GetPage(MenuItem, page);
             if (p != null)
             {
                 p.FromOSD(replacePage.ToOSD());
                 return;
             }
         }
     }
 }
        internal GridPage GetGridPages()
        {
            if (webPages == null)
            {
                IGenericsConnector generics = Framework.Utilities.DataManager.RequestPlugin<IGenericsConnector> ();
                GridPage rootPage = generics.GetGeneric<GridPage> (UUID.Zero, "WebPages", "Root");
                if (rootPage == null)
                    rootPage = new GridPage ();

                return rootPage;
            }

            return webPages;
        }
 public GridPage GetParent(GridPage item, GridPage toCheck)
 {
     if (toCheck == null)
         toCheck = this;
     foreach (var p in toCheck.Children)
     {
         if (item.Location == p.Location)
             return toCheck;
         else if (p.Children.Count > 0)
         {
             var pp = GetParent(item, p);
             if (pp != null)
                 return pp;
         }
     }
     return null;
 }
 public void RemovePageByLocation(string MenuLocation, GridPage replacePage)
 {
     GridPage foundPage = null;
     foreach (var page in this.Children)
     {
         if (page.Location == MenuLocation)
         {
             foundPage = page;
             break;
         }
         else if (page.Children.Count > 0)
         {
             var p = GetPageByLocation(MenuLocation, page);
             if (p != null)
             {
                 page.Children.Remove(p);
                 return;
             }
         }
     }
     if (foundPage != null)
         this.Children.Remove(foundPage);
 }
 public GridPage GetParent(GridPage page)
 {
     return GetParent(page, null);
 }
Пример #9
0
        static void InitializeDefaults()
        {
            _rootPage = new GridPage();

            // home
            _rootPage.Children.Add (new GridPage {
                ShowInMenu = true,
                MenuID = "home",
                Location = "home.html",
                MenuPosition = 0,
                MenuTitle = "MenuHome",
                MenuToolTip = "TooltipsMenuHome"
            });

            // news
            _rootPage.Children.Add (new GridPage {
                ShowInMenu = true,
                MenuID = "news",
                Location = "news_list.html",
                MenuPosition = 1,
                MenuTitle = "MenuNews",
                MenuToolTip = "TooltipsMenuNews"
            });

            // world map
            _rootPage.Children.Add (new GridPage {
                ShowInMenu = true,
                MenuID = "world",
                Location = "world.html",
                MenuPosition = 2,
                MenuTitle = "MenuWorld",
                MenuToolTip = "TooltipsMenuWorld",
                Children = new List<GridPage> {
                    new GridPage {
                        ShowInMenu = true,
                        MenuID = "world",
                        Location = "world.html",
                        MenuPosition = 0,
                        MenuTitle = "MenuWorldMap",
                        MenuToolTip = "TooltipsMenuWorldMap"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        MenuID = "region_search",
                        Location = "region_search.html",
                        MenuPosition = 1,
                        MenuTitle = "MenuRegionSearch",
                        MenuToolTip = "TooltipsMenuRegionSearch"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        MenuID = "region_list",
                        Location = "region_list.html",
                        MenuPosition = 2,
                        MenuTitle = "MenuRegion",
                        MenuToolTip = "TooltipsMenuRegion"
                    }
                }
            });

            // users
            _rootPage.Children.Add (new GridPage {
                ShowInMenu = true,
                LoggedInRequired = true,
                MenuID = "users",
                Location = "user_profile.html",
                MenuPosition = 3,
                MenuTitle = "MenuUser",
                MenuToolTip = "TooltipsMenuUser",
                Children = new List<GridPage> {
                    new GridPage {
                        ShowInMenu = true,
                        LoggedInRequired = true,
                        MenuID = "online_users",
                        Location = "online_users.html",
                        MenuPosition = 0,
                        MenuTitle = "MenuOnlineUsers",
                        MenuToolTip = "TooltipsMenuOnlineUsers"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        LoggedInRequired = true,
                        MenuID = "user_search",
                        Location = "user_search.html",
                        MenuPosition = 1,
                        MenuTitle = "MenuUserSearch",
                        MenuToolTip = "TooltipsMenuUserSearch"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        LoggedInRequired = true,
                        MenuID = "purchases",
                        Location = "user_purchases.html",
                        MenuPosition = 2,
                        MenuTitle = "MenuMyPurchases",
                        MenuToolTip = "TooltipsMenuPurchases"

                    },
                    new GridPage {
                        ShowInMenu = true,
                        LoggedInRequired = true,
                        MenuID = "Transactions",
                        Location = "user_transactions.html",
                        MenuPosition = 3,
                        MenuTitle = "MenuMyTransactions",
                        MenuToolTip = "TooltipsMenuTransactions"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        LoggedInRequired = true,
                        MenuID = "change_user_information",
                        Location = "change_user_information.html",
                        MenuPosition = 4,
                        MenuTitle = "MenuChangeUserInformation",
                        MenuToolTip = "TooltipsMenuChangeUserInformation"
                    }
                }
            });

            // help
            _rootPage.Children.Add (new GridPage {
                ShowInMenu = true,
                MenuID = "help",
                Location = "help.html",
                MenuPosition = 5,
                MenuTitle = "MenuHelp",
                MenuToolTip = "TooltipsMenuHelp",
                Children = new List<GridPage> {
                    new GridPage {
                        ShowInMenu = true,
                        MenuID = "help",
                        Location = "help.html",
                        MenuPosition = 1,
                        MenuTitle = "MenuViewerHelp",
                        MenuToolTip = "TooltipsMenuViewerHelp"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        MenuID = "chat",
                        Location = "chat.html",
                        MenuPosition = 2,
                        MenuTitle = "MenuChat",
                        MenuToolTip = "TooltipsMenuChat"
                    }
                }
            });

            // register
            _rootPage.Children.Add (new GridPage {
                ShowInMenu = true,
                LoggedInRequired = true,
                MenuID = "logout",
                Location = "logout.html",
                MenuPosition = 6,
                MenuTitle = "MenuLogout",
                MenuToolTip = "TooltipsMenuLogout"
            });

            // login
            _rootPage.Children.Add (new GridPage {
                ShowInMenu = true,
                LoggedOutRequired = true,
                MenuID = "register",
                Location = "register.html",
                MenuPosition = 6,
                MenuTitle = "MenuRegister",
                MenuToolTip = "TooltipsMenuRegister"
            });

            // Logout
            _rootPage.Children.Add (new GridPage {
                ShowInMenu = true,
                LoggedOutRequired = true,
                MenuID = "login",
                Location = "login.html",
                MenuPosition = 7,
                MenuTitle = "MenuLogin",
                MenuToolTip = "TooltipsMenuLogin",
                Children = new List<GridPage> {
                    new GridPage {
                        ShowInMenu = true,
                        MenuID = "forgot_pass",
                        Location = "forgot_pass.html",
                        MenuPosition = 1,
                        MenuTitle = "MenuForgotPass",
                        MenuToolTip = "TooltipsMenuForgotPass"
                    }
                }
            });

            // Management
            _rootPage.Children.Add (new GridPage {
                ShowInMenu = true,
                AdminRequired = true,
                MenuID = "manager",
                Location = "admin/manager.html",
                MenuPosition = 8,
                MenuTitle = "MenuManager",
                MenuToolTip = "TooltipsMenuManager",
                Children = new List<GridPage> {
                    new GridPage {
                        ShowInMenu = true,
                        AdminRequired = true,
                        MenuID = "news_manager",
                        Location = "admin/news_manager.html",
                        MenuPosition = 2,
                        MenuTitle = "MenuNewsManager",
                        MenuToolTip = "TooltipsMenuNewsManager"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        AdminRequired = true,
                        MenuID = "user_search",
                        Location = "user_search.html",
                        MenuPosition = 1,
                        MenuTitle = "MenuUserManager",
                        MenuToolTip = "TooltipsMenuUserManager"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        AdminRequired = true,
                        MenuID = "new_user",
                        Location = "register.html",
                        MenuPosition = 0,
                        MenuTitle = "MenuRegister",
                        MenuToolTip = "TooltipsMenuRegister"
                    },
                    new GridPage {
                        ShowInMenu = false,
                        AdminRequired = true,
                        MenuID = "new_region",
                        Location = "admin/region_manager.html",
                        MenuPosition = 3,
                        MenuTitle = "MenuRegionManager",
                        MenuToolTip = "TooltipsMenuRegionManager"
                    },
                    new GridPage {
                        ShowInMenu = false,
                        AdminRequired = true,
                        MenuID = "sim_console",
                        Location = "admin/sim_console.html",
                        MenuPosition = 4,
                        MenuTitle = "MenuManagerSimConsole",
                        MenuToolTip = "TooltipsMenuManagerSimConsole"

                    },
                    new GridPage {
                        ShowInMenu = true,
                        AdminRequired = true,
                        MenuID = "Purchases_admin",
                        Location = "admin/purchases.html",
                        MenuPosition = 5,
                        MenuTitle = "MenuPurchases",
                        MenuToolTip = "TooltipsMenuPurchases"

                    },
                    new GridPage {
                        ShowInMenu = true,
                        AdminRequired = true,
                        MenuID = "Abuse_admin",
                        Location = "admin/abuse_list.html",
                        MenuPosition = 6,
                        MenuTitle = "MenuAbuse",
                        MenuToolTip = "TooltipsMenuAbuse"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        AdminRequired = true,
                        MenuID = "Transactions_admin",
                        Location = "admin/transactions.html",
                        MenuPosition = 7,
                        MenuTitle = "MenuTransactions",
                        MenuToolTip = "TooltipsMenuTransactions"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        AdminRequired = true,
                        MenuID = "Statistics",
                        Location = "admin/statistics.html",
                        MenuPosition = 8,
                        MenuTitle = "MenuStatistics",
                        MenuToolTip = "TooltipsMenuStatistics"
                    }
                }
            });

            // admin settings
            _rootPage.Children.Add (new GridPage {
                ShowInMenu = true,
                AdminRequired = true,
                MenuID = "manager",
                Location = "admin/settings.html",
                MenuPosition = 9,
                MenuTitle = "MenuSettings",
                MenuToolTip = "TooltipsMenuSettingsManager",
                Children = new List<GridPage> {
                    new GridPage {
                        ShowInMenu = true,
                        AdminRequired = true,
                        MenuID = "factory_reset",
                        Location = "admin/factory_reset.html",
                        MenuPosition = 4,
                        MenuTitle = "MenuFactoryReset",
                        MenuToolTip = "TooltipsMenuFactoryReset"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        AdminRequired = true,
                        MenuID = "page_manager",
                        Location = "admin/page_manager.html",
                        MenuPosition = 2,
                        MenuTitle = "MenuPageManager",
                        MenuToolTip = "TooltipsMenuPageManager"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        AdminRequired = true,
                        MenuID = "settings_manager",
                        Location = "admin/settings_manager.html",
                        MenuPosition = 1,
                        MenuTitle = "MenuSettingsManager",
                        MenuToolTip = "TooltipsMenuSettingsManager"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        AdminRequired = true,
                        MenuID = "gridsettings_manager",
                        Location = "admin/gridsettings_manager.html",
                        MenuPosition = 0,
                        MenuTitle = "MenuGridSettings",
                        MenuToolTip = "TooltipsMenuGridSettings"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        AdminRequired = true,
                        MenuID = "welcomescreen_manager",
                        Location = "admin/welcomescreen_manager.html",
                        MenuPosition = 3,
                        MenuTitle = "MenuWelcomeScreenManager",
                        MenuToolTip = "TooltipsMenuWelcomeScreenManager"

                    }
                }
            });

            // these are indivual paages that can be called
            _rootPage.Children.Add(new GridPage
                                       {
                                           MenuID = "add_news",
                                           ShowInMenu = false,
                                           AdminRequired = true,
                                           MenuPosition = 8,
                                           Location = "admin/add_news.html"
                                       });
            _rootPage.Children.Add(new GridPage
                                       {
                                           MenuID = "edit_news",
                                           ShowInMenu = false,
                                           AdminRequired = true,
                                           MenuPosition = 8,
                                           Location = "admin/edit_news.html"
                                       });
            _rootPage.Children.Add(new GridPage
                                       {
                                           MenuID = "edit_user",
                                           ShowInMenu = false,
                                           AdminRequired = true,
                                           MenuPosition = 8,
                                           Location = "admin/edit_user.html"
                                       });

            _rootPage.Children.Add(new GridPage
                                       {
                                           ShowInMenu = false,
                                           MenuID = "news_info",
                                           Location = "news.html"
                                       });
            _rootPage.Children.Add(new GridPage
            {
                MenuID = "abuse_report",
                ShowInMenu = false,
                AdminRequired = true,
                MenuPosition = 8,
                Location = "admin/abuse_report.html"
            });

            //Things added, but not used
            /*pages.Add(new Dictionary<string, object> { { "MenuItemID", "tweets" },
                { "ShowInMenu", false },
                { "MenuItemLocation", "tweets.html" },
                { "MenuItemTitleHelp", translator.GetTranslatedString("TooltipsMenuTweets") },
                { "MenuItemTitle", translator.GetTranslatedString("MenuTweets") } });

            pages.Add(new Dictionary<string, object> { { "MenuItemID", "agent_info" },
                { "ShowInMenu", false },
                { "MenuItemLocation", "agent_info.html" },
                { "MenuItemTitleHelp", translator.GetTranslatedString("TooltipsMenuAgentInfo") },
                { "MenuItemTitle", translator.GetTranslatedString("MenuAgentInfo") } });

            pages.Add(new Dictionary<string, object> { { "MenuItemID", "region_info" },
                { "ShowInMenu", false },
                { "MenuItemLocation", "region_info.html" },
                { "MenuItemTitleHelp", translator.GetTranslatedString("TooltipsMenuRegionInfo") },
                { "MenuItemTitle", translator.GetTranslatedString("MenuRegionInfo") } });
            pages.Add(new Dictionary<string, object> { { "MenuItemID", "add_news" },
                { "ShowInMenu", false },
                { "MenuItemLocation", "admin/add_news.html" },
                { "MenuItemTitleHelp", translator.GetTranslatedString("TooltipsMenuNewsManager") },
                { "MenuItemTitle", translator.GetTranslatedString("MenuNewsManager") } });
            pages.Add(new Dictionary<string, object> { { "MenuItemID", "edit_news" },
                { "ShowInMenu", false },
                { "MenuItemLocation", "admin/edit_news.html" },
                { "MenuItemTitleHelp", translator.GetTranslatedString("TooltipsMenuNewsManager") },
                { "MenuItemTitle", translator.GetTranslatedString("MenuNewsManager") } });*/
        }
Пример #10
0
        public void RemovePage(string MenuID, GridPage replacePage)
        {
            GridPage foundPage = null;
            foreach (var page in Children)
            {
                if (page.MenuID == MenuID)
                {
                    foundPage = page;
                    break;
                }

                if (page.Children.Count > 0)
                {
                    var p = GetPage(MenuID, page);
                    if (p != null)
                    {
                        page.Children.Remove(p);
                        return;
                    }
                }
            }
            if (foundPage != null)
                Children.Remove(foundPage);
        }
Пример #11
0
        public GridPage GetPageByLocation(string item, GridPage rootPage)
        {
            if (rootPage == null)
                rootPage = this;
            foreach (var page in rootPage.Children)
            {
                if (page.Location == item)
                    return page;

                if (page.Children.Count > 0)
                {
                    var p = GetPageByLocation (item, page);
                    if (p != null)
                        return p;
                }
            }
            return null;
        }
        private static void InitializeDefaults()
        {
            _rootPage = new GridPage();

            // home
            _rootPage.Children.Add (new GridPage {
                ShowInMenu = true,
                MenuID = "home",
                Location = "home.html",
                MenuPosition = 0,
                MenuTitle = "MenuHome",
                MenuToolTip = "TooltipsMenuHome"
            });

            // news
            _rootPage.Children.Add (new GridPage {
                ShowInMenu = true,
                MenuID = "news",
                Location = "news_list.html",
                MenuPosition = 1,
                MenuTitle = "MenuNews",
                MenuToolTip = "TooltipsMenuNews"
            });

            // world map
            _rootPage.Children.Add (new GridPage {
                ShowInMenu = true,
                MenuID = "world",
                Location = "world.html",
                MenuPosition = 2,
                MenuTitle = "MenuWorld",
                MenuToolTip = "TooltipsMenuWorld",
                Children = new List<GridPage> {
                    new GridPage {
                        ShowInMenu = true,
                        MenuID = "world",
                        Location = "world.html",
                        MenuPosition = 0,
                        MenuTitle = "MenuWorldMap",
                        MenuToolTip = "TooltipsMenuWorldMap"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        MenuID = "region_search",
                        Location = "region_search.html",
                        MenuPosition = 1,
                        MenuTitle = "MenuRegionSearch",
                        MenuToolTip = "TooltipsMenuRegionSearch"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        MenuID = "region_list",
                        Location = "region_list.html",
                        MenuPosition = 2,
                        MenuTitle = "MenuRegion",
                        MenuToolTip = "TooltipsMenuRegion"
                    }
                }
            });

            // users
            _rootPage.Children.Add (new GridPage {
                ShowInMenu = true,
                LoggedInRequired = true,
                MenuID = "users",
                Location = "user_profile.html",
                MenuPosition = 3,
                MenuTitle = "MenuUser",
                MenuToolTip = "TooltipsMenuUser",
                Children = new List<GridPage> {
                    new GridPage {
                        ShowInMenu = true,
                        LoggedInRequired = true,
                        MenuID = "online_users",
                        Location = "online_users.html",
                        MenuPosition = 0,
                        MenuTitle = "MenuOnlineUsers",
                        MenuToolTip = "TooltipsMenuOnlineUsers"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        LoggedInRequired = true,
                        MenuID = "user_search",
                        Location = "user_search.html",
                        MenuPosition = 1,
                        MenuTitle = "MenuUserSearch",
                        MenuToolTip = "TooltipsMenuUserSearch"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        LoggedInRequired = true,
                        MenuID = "purchases",
                        Location = "user_purchases.html",
                        MenuPosition = 2,
                        MenuTitle = "MenuMyPurchases",
                        MenuToolTip = "TooltipsMenuPurchases"

                    },
                    new GridPage {
                        ShowInMenu = true,
                        LoggedInRequired = true,
                        MenuID = "Transactions",
                        Location = "user_transactions.html",
                        MenuPosition = 3,
                        MenuTitle = "MenuMyTransactions",
                        MenuToolTip = "TooltipsMenuTransactions"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        LoggedInRequired = true,
                        MenuID = "change_user_information",
                        Location = "change_user_information.html",
                        MenuPosition = 4,
                        MenuTitle = "MenuChangeUserInformation",
                        MenuToolTip = "TooltipsMenuChangeUserInformation"
                    }
                }
            });

            // help
            _rootPage.Children.Add (new GridPage {
                ShowInMenu = true,
                MenuID = "help",
                Location = "help.html",
                MenuPosition = 5,
                MenuTitle = "MenuHelp",
                MenuToolTip = "TooltipsMenuHelp",
                Children = new List<GridPage> {
                    new GridPage {
                        ShowInMenu = true,
                        MenuID = "help",
                        Location = "help.html",
                        MenuPosition = 1,
                        MenuTitle = "MenuViewerHelp",
                        MenuToolTip = "TooltipsMenuViewerHelp"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        MenuID = "chat",
                        Location = "chat.html",
                        MenuPosition = 2,
                        MenuTitle = "MenuChat",
                        MenuToolTip = "TooltipsMenuChat"
                    }
                }
            });

            // register
            _rootPage.Children.Add (new GridPage {
                ShowInMenu = true,
                LoggedInRequired = true,
                MenuID = "logout",
                Location = "logout.html",
                MenuPosition = 6,
                MenuTitle = "MenuLogout",
                MenuToolTip = "TooltipsMenuLogout"
            });

            // login
            _rootPage.Children.Add (new GridPage {
                ShowInMenu = true,
                LoggedOutRequired = true,
                MenuID = "register",
                Location = "register.html",
                MenuPosition = 6,
                MenuTitle = "MenuRegister",
                MenuToolTip = "TooltipsMenuRegister"
            });

            // Logout
            _rootPage.Children.Add (new GridPage {
                ShowInMenu = true,
                LoggedOutRequired = true,
                MenuID = "login",
                Location = "login.html",
                MenuPosition = 7,
                MenuTitle = "MenuLogin",
                MenuToolTip = "TooltipsMenuLogin",
                Children = new List<GridPage> {
                    new GridPage {
                        ShowInMenu = true,
                        MenuID = "forgot_pass",
                        Location = "forgot_pass.html",
                        MenuPosition = 1,
                        MenuTitle = "MenuForgotPass",
                        MenuToolTip = "TooltipsMenuForgotPass"
                    }
                }
            });

            // Management
            _rootPage.Children.Add (new GridPage {
                ShowInMenu = true,
                AdminRequired = true,
                MenuID = "manager",
                Location = "admin/manager.html",
                MenuPosition = 8,
                MenuTitle = "MenuManager",
                MenuToolTip = "TooltipsMenuManager",
                Children = new List<GridPage> {
                    new GridPage {
                        ShowInMenu = true,
                        AdminRequired = true,
                        MenuID = "news_manager",
                        Location = "admin/news_manager.html",
                        MenuPosition = 2,
                        MenuTitle = "MenuNewsManager",
                        MenuToolTip = "TooltipsMenuNewsManager"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        AdminRequired = true,
                        MenuID = "user_search",
                        Location = "user_search.html",
                        MenuPosition = 1,
                        MenuTitle = "MenuUserManager",
                        MenuToolTip = "TooltipsMenuUserManager"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        AdminRequired = true,
                        MenuID = "new_user",
                        Location = "register.html",
                        MenuPosition = 0,
                        MenuTitle = "MenuRegister",
                        MenuToolTip = "TooltipsMenuRegister"
                    },
                    new GridPage {
                        ShowInMenu = false,
                        AdminRequired = true,
                        MenuID = "new_region",
                        Location = "admin/region_manager.html",
                        MenuPosition = 3,
                        MenuTitle = "MenuRegionManager",
                        MenuToolTip = "TooltipsMenuRegionManager"
                    },
                    new GridPage {
                        ShowInMenu = false,
                        AdminRequired = true,
                        MenuID = "sim_console",
                        Location = "admin/sim_console.html",
                        MenuPosition = 4,
                        MenuTitle = "MenuManagerSimConsole",
                        MenuToolTip = "TooltipsMenuManagerSimConsole"

                    },
                    new GridPage {
                        ShowInMenu = true,
                        AdminRequired = true,
                        MenuID = "Purchases_admin",
                        Location = "admin/purchases.html",
                        MenuPosition = 5,
                        MenuTitle = "MenuPurchases",
                        MenuToolTip = "TooltipsMenuPurchases"

                    },
                    new GridPage {
                        ShowInMenu = true,
                        AdminRequired = true,
                        MenuID = "Transactions_admin",
                        Location = "admin/transactions.html",
                        MenuPosition = 6,
                        MenuTitle = "MenuTransactions",
                        MenuToolTip = "TooltipsMenuTransactions"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        AdminRequired = true,
                        MenuID = "Statistics",
                        Location = "admin/statistics.html",
                        MenuPosition = 6,
                        MenuTitle = "MenuStatistics",
                        MenuToolTip = "TooltipsMenuStatistics"
                    }
                }
            });

            // admin settings
            _rootPage.Children.Add (new GridPage {
                ShowInMenu = true,
                AdminRequired = true,
                MenuID = "manager",
                Location = "admin/settings.html",
                MenuPosition = 9,
                MenuTitle = "MenuSettings",
                MenuToolTip = "TooltipsMenuSettingsManager",
                Children = new List<GridPage> {
                    new GridPage {
                        ShowInMenu = true,
                        AdminRequired = true,
                        MenuID = "factory_reset",
                        Location = "admin/factory_reset.html",
                        MenuPosition = 4,
                        MenuTitle = "MenuFactoryReset",
                        MenuToolTip = "TooltipsMenuFactoryReset"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        AdminRequired = true,
                        MenuID = "page_manager",
                        Location = "admin/page_manager.html",
                        MenuPosition = 2,
                        MenuTitle = "MenuPageManager",
                        MenuToolTip = "TooltipsMenuPageManager"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        AdminRequired = true,
                        MenuID = "settings_manager",
                        Location = "admin/settings_manager.html",
                        MenuPosition = 1,
                        MenuTitle = "MenuSettingsManager",
                        MenuToolTip = "TooltipsMenuSettingsManager"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        AdminRequired = true,
                        MenuID = "gridsettings_manager",
                        Location = "admin/gridsettings_manager.html",
                        MenuPosition = 0,
                        MenuTitle = "MenuGridSettings",
                        MenuToolTip = "TooltipsMenuGridSettings"
                    },
                    new GridPage {
                        ShowInMenu = true,
                        AdminRequired = true,
                        MenuID = "welcomescreen_manager",
                        Location = "admin/welcomescreen_manager.html",
                        MenuPosition = 3,
                        MenuTitle = "MenuWelcomeScreenManager",
                        MenuToolTip = "TooltipsMenuWelcomeScreenManager"

                    }
                }
            });

            _rootPage.Children.Add(new GridPage
                                       {
                                           MenuID = "add_news",
                                           ShowInMenu = false,
                                           AdminRequired = true,
                                           MenuPosition = 8,
                                           Location = "admin/add_news.html"
                                       });
            _rootPage.Children.Add(new GridPage
                                       {
                                           MenuID = "edit_news",
                                           ShowInMenu = false,
                                           AdminRequired = true,
                                           MenuPosition = 8,
                                           Location = "admin/edit_news.html"
                                       });
            _rootPage.Children.Add(new GridPage
                                       {
                                           MenuID = "edit_user",
                                           ShowInMenu = false,
                                           AdminRequired = true,
                                           MenuPosition = 8,
                                           Location = "admin/edit_user.html"
                                       });

            _rootPage.Children.Add(new GridPage
                                       {
                                           ShowInMenu = false,
                                           MenuID = "news_info",
                                           Location = "news.html"
                                       });
        }