コード例 #1
0
ファイル: MenuHelper.cs プロジェクト: liqueflies/pigeoncms
 public static PigeonCms.Menu GetCurrentMenu(string  menuType)
 {
     var res = new PigeonCms.Menu();
     var menuMan = new MenuManager(true, false);
     var filter = new MenuFilter();
     filter.FilterContentType = false;
     filter.MenuType = menuType;
     filter.Alias = MenuHelper.GetCurrentAlias();
     filter.RoutePattern = MenuHelper.GetCurrentRoutePattern();
     filter.ParentId = -1;
     List<PigeonCms.Menu> list = menuMan.GetByFilter(filter, "");
     if (list.Count > 0)
     {
         res = list[0];
     }
     return res;
 }
コード例 #2
0
ファイル: MenuHelper.cs プロジェクト: liqueflies/pigeoncms
        private static void loadMenuItems(ListBox listMenu, string menuType, int parentId, int level, int currMenuId)
        {
            MenuFilter menuFilter = new MenuFilter();
            menuFilter.Published = Utility.TristateBool.NotSet;
            menuFilter.MenuType = menuType;
            menuFilter.ParentId = parentId;

            List<PigeonCms.Menu> recordList =
                new MenuManager().GetTree(menuFilter, level);
            foreach (PigeonCms.Menu record1 in recordList)
            {
                ListItem menuItem = new ListItem();
                menuItem.Text = record1.Name;
                menuItem.Value = record1.Id.ToString();
                if (record1.Id == currMenuId)
                {
                    menuItem.Attributes.Add("disabled", "disabled");
                }
                listMenu.Items.Add(menuItem);
            }
        }
コード例 #3
0
ファイル: Default.ascx.cs プロジェクト: liqueflies/pigeoncms
    private void loadDropReferMenuId()
    {
        DropReferMenuId.Items.Clear();
        DropReferMenuId.Items.Add(new ListItem(Utility.GetLabel("LblSelectMenuEntry", "Select menu entry"), ""));

        MenuFilter filter = new MenuFilter();
        filter.FilterContentType = true;
        filter.ContentType = MenuContentType.Module;    //alias only for modules
        List<PigeonCms.Menu> recordList = new MenuManager().GetByFilter(filter, "menutype, t.name");
        foreach (PigeonCms.Menu record1 in recordList)
        {
            DropReferMenuId.Items.Add(new ListItem(record1.MenuType + ">" + record1.Name, record1.Id.ToString()));
        }
    }
コード例 #4
0
ファイル: Default.ascx.cs プロジェクト: liqueflies/pigeoncms
    private bool checkForm()
    {
        string sErr = "";
        LitErr.Text = "";
        LitOk.Text = RenderSuccess("");
        bool res = true;

        if (!string.IsNullOrEmpty(TxtAlias.Text))
        {
            var filter = new MenuFilter();
            var list = new List<PigeonCms.Menu>();

            filter.Alias = TxtAlias.Text;
            filter.RouteId = int.Parse(DropRouteId.SelectedValue);
            list = new MenuManager().GetByFilter(filter, "");
            if (list.Count > 0)
            {
                string aliasInUseMessage = "alias in use for current route pattern<br />";
                if (this.CurrentId == 0)
                {
                    res = false;
                    sErr += aliasInUseMessage;
                }
                else
                {
                    if (list[0].Id != this.CurrentId)
                    {
                        res = false;
                        sErr += aliasInUseMessage;
                    }
                }
            }
        }
        else if (TxtAlias.Enabled)
            res = false;

        //check parentId
        int parentId = 0;
        foreach (ListItem item in ListParentId.Items)
        {
            if (item.Selected)
            {
                if (int.TryParse(item.Value, out parentId))
                {
                    if (parentId > 0)
                    {
                        if (parentId == this.CurrentId)
                        {
                            res = false;
                            sErr += "invalid parent ID<br />";
                        }
                    }
                }
            }
        }
        LitErr.Text = RenderError(sErr);

        return res;
    }
コード例 #5
0
ファイル: Default.ascx.cs プロジェクト: liqueflies/pigeoncms
    protected void ObjDs1_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
    {
        MenuFilter filter = new MenuFilter();

        switch (DropPublishedFilter.SelectedValue)
        {
            case "1":
                filter.Published = Utility.TristateBool.True;
                break;
            case "0":
                filter.Published = Utility.TristateBool.False;
                break;
            default:
                filter.Published = Utility.TristateBool.NotSet;
                break;
        }

        filter.ParentId = 0;

        if (DropMenuTypesFilter.SelectedValue != "")
            filter.MenuType = DropMenuTypesFilter.SelectedValue;
        if (DropMasterPageFilter.SelectedValue != "")
            filter.CurrMasterPage = DropMasterPageFilter.SelectedValue;
        if (DropModuleTypesFilter.SelectedValue != "")
            filter.ModuleFullName = DropModuleTypesFilter.SelectedValue;

        e.InputParameters["filter"] = filter;
    }
コード例 #6
0
        /// <summary>
        /// load recursively the hierarchical menu
        /// </summary>
        /// <param name="result">the result string (UL list)</param>
        /// <param name="menuFilter"></param>
        /// <param name="currLevel">the current level renderer</param>
        /// <param name="selectedBranch">true if we are in the branch of selected entry</param>
        private void loadTree(ref string result, MenuFilter menuFilter, int currLevel, List<int> selectedIdList, bool selectedBranch)
        {
            const int MaxLevel = 10;
            int recordCount = 0;
            string itemCssClass = "";
            string itemSelectedClass = "";
            bool hideEntry = false;

            currLevel++;
            if (currLevel < MaxLevel)
            {
                List<PigeonCms.Menu> recordList =
                    new MenuManager(true, false).GetByFilter(menuFilter, "MenuType, t.ParentId, t.Ordering");

                ParseMenuList(recordList);

                string ul = "";
                if (recordList.Count > 0)
                {
                    ul = Template.Header;

                    string menuId = "";
                    string menuStyle = "";
                    if (currLevel == 1)
                        menuId = this.MenuId; //ul += " id='" + this.MenuId + "' ";

                    if (currLevel > 1)
                    {
                        if (this.ShowChild == Utility.TristateBool.False)
                            hideEntry = true;

                        if (this.ShowChild == Utility.TristateBool.NotSet)
                        {
                            if (!selectedIdList.Exists(
                                    delegate(int id) {
                                        foreach (var record in recordList)
                                        { if (record.Id == id) return true; }
                                        return false;
                                    }
                                )
                            )
                            {
                                hideEntry = true;
                            }

                            if (selectedBranch)
                                hideEntry = false;
                        }
                    }
                    if (hideEntry)
                        menuStyle = " display:none;";

                    ul = ul
                        .Replace("[[MenuCssClass]]", this.CssClass)
                        .Replace("[[MenuId]]", menuId)
                        .Replace("[[MenuStyle]]", menuStyle);
                }

                result += ul;

                foreach (PigeonCms.Menu record1 in recordList)
                {
                    recordCount++;

                    itemCssClass = "";
                    itemSelectedClass = "";
                    if (selectedIdList.Contains(record1.Id))
                    {
                        itemSelectedClass = this.ItemSelectedClass;
                        selectedBranch = true;
                    }
                    else
                        selectedBranch = false;
                    if (!string.IsNullOrEmpty(record1.CssClass))
                    {
                        itemCssClass += " " + record1.CssClass;
                    }
                    if (/*currLevel == 0 &&*/ recordCount == recordList.Count)
                    {
                        itemCssClass += " " + this.ItemLastClass;
                    }
                    result += Template.ItemHeader
                        .Replace("[[ItemSelectedClass]]", itemSelectedClass)
                        .Replace("[[ItemCssClass]]", itemCssClass)
                        .Replace("[[ItemHref]]", record1.Url)
                        .Replace("[[ItemOnClick]]", record1.Onclick)
                        .Replace("[[ItemStyle]]", "")
                        .Replace("[[ItemContent]]", record1.Title);

                    menuFilter.ParentId = record1.Id;
                    loadTree(ref result, menuFilter, currLevel, selectedIdList, selectedBranch);

                    result += Template.ItemFooter;
                }
                if (recordList.Count > 0)
                {
                    result += Template.Footer;
                }
            }
        }
コード例 #7
0
        protected virtual string GetContent()
        {
            string result = "";
            int startLevel = 0;
            var filter = new MenuFilter();
            var menuMan = new MenuManager(true, false);
            //var currentMenu = MenuHelper.GetCurrentMenu(this.MenuType);  //hide 20110325
            var currentMenu = ((PigeonCms.BasePage)this.Page).MenuEntry;
            var selectedIdList = new List<int>();     //list of parent id for current menu

            filter.FilterContentType = false;
            filter.MenuType = this.MenuType;
            filter.Visible = Utility.TristateBool.True;
            filter.ParentId = 0;

            selectedIdList = menuMan.GetParentIdList(currentMenu.Id);

            if (this.MenuLevel > 0)
            {
                //set current page as start level (used to build context menu)
                if (currentMenu.Id > 0)
                {
                    int currentMenuLevel = menuMan.GetMenuLevel(currentMenu.Id);
                    if (currentMenuLevel < this.MenuLevel)
                    {
                        filter.ParentId = currentMenu.Id;
                    }
                    else if (currentMenuLevel == this.MenuLevel)
                    {
                        filter.ParentId = currentMenu.ParentId;
                    }
                    else if (currentMenuLevel > this.MenuLevel)
                    {
                        //TO COMPLETE
                        filter.ParentId = menuMan.GetByKey(currentMenu.ParentId).ParentId;
                    }
                }
                else
                {
                    //if not found current page in menu does not load menu
                    filter.Id = -1;
                }
            }

            loadTree(ref result, filter, startLevel, selectedIdList, false);
            return result;
        }