private void AddSeparator(string strType, DNNNode objPrevNode, DNNNode objNextNode)
        {
            string  strLeftHTML  = SeparatorLeftHTML + SeparatorLeftHTMLBreadCrumb + SeparatorLeftHTMLActive;
            string  strRightHTML = SeparatorRightHTML + SeparatorRightHTMLBreadCrumb + SeparatorRightHTMLActive;
            string  strHTML      = SeparatorHTML + strLeftHTML + strRightHTML;
            XmlNode objBreak;

            if (!String.IsNullOrEmpty(strHTML))
            {
                string strSeparatorTable      = "";
                string strSeparator           = "";
                string strSeparatorLeftHTML   = "";
                string strSeparatorRightHTML  = "";
                string strSeparatorClass      = "";
                string strLeftSeparatorClass  = "";
                string strRightSeparatorClass = "";
                if (!String.IsNullOrEmpty(strLeftHTML))
                {
                    strLeftSeparatorClass = GetSeparatorText(CSSLeftSeparator, CSSLeftSeparatorBreadCrumb, CSSLeftSeparatorSelection, objNextNode);
                    strSeparatorLeftHTML  = GetSeparatorText(SeparatorLeftHTML, SeparatorLeftHTMLBreadCrumb, SeparatorLeftHTMLActive, objNextNode);
                }
                if (!String.IsNullOrEmpty(SeparatorHTML))
                {
                    if (!String.IsNullOrEmpty(CSSSeparator))
                    {
                        strSeparatorClass = CSSSeparator;
                    }
                    strSeparator = SeparatorHTML;
                }
                if (!String.IsNullOrEmpty(strRightHTML))
                {
                    strRightSeparatorClass = GetSeparatorText(CSSRightSeparator, CSSRightSeparatorBreadCrumb, CSSRightSeparatorSelection, objPrevNode);
                    strSeparatorRightHTML  = GetSeparatorText(SeparatorRightHTML, SeparatorRightHTMLBreadCrumb, SeparatorRightHTMLActive, objPrevNode);
                }
                strSeparatorTable = "<table summary=\"Table for menu separator design\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>";
                if (!String.IsNullOrEmpty(strSeparatorRightHTML) && strType != "Left")
                {
                    strSeparatorTable += GetSeparatorTD(strRightSeparatorClass, strSeparatorRightHTML);
                }
                if (!String.IsNullOrEmpty(strSeparator) && strType != "Left" && strType != "Right")
                {
                    strSeparatorTable += GetSeparatorTD(strSeparatorClass, strSeparator);
                }
                if (!String.IsNullOrEmpty(strSeparatorLeftHTML) && strType != "Right")
                {
                    strSeparatorTable += GetSeparatorTD(strLeftSeparatorClass, strSeparatorLeftHTML);
                }
                strSeparatorTable += "</tr></table>";
                objBreak           = Menu.AddBreak("", strSeparatorTable);
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// This function provides a central location to obtain a generic node collection of the pages/tabs included in
        /// the current context's (user) navigation hierarchy
        /// </summary>
        /// <param name="objRootNode">Node in which to add children to</param>
        /// <param name="eToolTips">Enumerator to determine what text to display in the tooltips</param>
        /// <param name="intStartTabId">If using Populate On Demand, then this is the tab id of the root element to retrieve (-1 for no POD)</param>
        /// <param name="intDepth">If Populate On Demand is enabled, then this parameter determines the number of nodes to retrieve beneath the starting tab passed in (intStartTabId) (-1 for no POD)</param>
        /// <param name="intNavNodeOptions">Bitwise integer containing values to determine what nodes to display (self, siblings, parent)</param>
        /// <returns>Collection of DNNNodes</returns>
        /// <remarks>
        /// Returns a subset of navigation nodes based off of passed in starting node id and depth
        /// </remarks>
        /// <history>
        ///     [Jon Henning]	8/9/2005	Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static DNNNodeCollection GetNavigationNodes(DNNNode objRootNode, ToolTipSource eToolTips, int intStartTabId, int intDepth, int intNavNodeOptions)
        {
            int            i;
            PortalSettings objPortalSettings = PortalController.Instance.GetCurrentPortalSettings();

            var objBreadCrumbs             = new Hashtable();
            var objTabLookup               = new Hashtable();
            DNNNodeCollection objRootNodes = objRootNode.DNNNodes;
            int intLastBreadCrumbId        = 0;

            //--- cache breadcrumbs in hashtable so we can easily set flag on node denoting it as a breadcrumb node (without looping multiple times) ---
            for (i = 0; i <= (objPortalSettings.ActiveTab.BreadCrumbs.Count - 1); i++)
            {
                objBreadCrumbs.Add(((TabInfo)objPortalSettings.ActiveTab.BreadCrumbs[i]).TabID, 1);
                intLastBreadCrumbId = ((TabInfo)objPortalSettings.ActiveTab.BreadCrumbs[i]).TabID;
            }
            List <TabInfo> portalTabs = TabController.GetTabsBySortOrder(objPortalSettings.PortalId, objPortalSettings.CultureCode, true);
            List <TabInfo> hostTabs   = TabController.GetTabsBySortOrder(Null.NullInteger, Localization.SystemLocale, true);

            foreach (TabInfo objTab in portalTabs)
            {
                objTabLookup.Add(objTab.TabID, objTab);
            }
            foreach (TabInfo objTab in hostTabs)
            {
                objTabLookup.Add(objTab.TabID, objTab);
            }
            foreach (TabInfo objTab in portalTabs)
            {
                try
                {
                    ProcessTab(objRootNode, objTab, objTabLookup, objBreadCrumbs, intLastBreadCrumbId, eToolTips, intStartTabId, intDepth, intNavNodeOptions);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            foreach (TabInfo objTab in hostTabs)
            {
                try
                {
                    ProcessTab(objRootNode, objTab, objTabLookup, objBreadCrumbs, intLastBreadCrumbId, eToolTips, intStartTabId, intDepth, intNavNodeOptions);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(objRootNodes);
        }
        private void ProcessNodes(DNNNode objParent)
        {
            if (!string.IsNullOrEmpty(objParent.JSFunction))
            {
                ClientAPI.RegisterClientVariable(this.Page, "__dnn_CSAction_" + this.Control.NavigationControl.ClientID + "_" + objParent.ID, objParent.JSFunction, true);
            }

            objParent.ClickAction = eClickAction.None; // since GO button is handling actions dont allow selected index change fire postback

            foreach (DNNNode objNode in objParent.DNNNodes)
            {
                this.ProcessNodes(objNode);
            }
        }
Exemple #4
0
        /// <summary>
        /// DNNTxtBannerGroup_PopulateOnDemand runs when something is entered on the
        /// BannerGroup field
        /// </summary>
        /// <history>
        ///     [vmasanas]	9/29/2006	Implement a callback to display current groups
        ///  to user so the BannerGroup can be easily selected
        /// </history>
        protected void DNNTxtBannerGroup_PopulateOnDemand(object source, DNNTextSuggestEventArgs e)
        {
            BannerController objBanners = new BannerController();
            DataTable        dt         = objBanners.GetBannerGroups(PortalId);

            dt.CaseSensitive = false;
            DataRow[] dr = dt.Select("GroupName like '" + e.Text + "%'");
            foreach (DataRow d in dr)
            {
                DNNNode objNode = new DNNNode(d["GroupName"].ToString());
                objNode.ID = e.Nodes.Count.ToString();
                e.Nodes.Add(objNode);
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// This function provides a central location to obtain a generic node collection of the pages/tabs included in
        /// the current context's (user) navigation hierarchy.
        /// </summary>
        /// <param name="objRootNode">Node in which to add children to.</param>
        /// <param name="eToolTips">Enumerator to determine what text to display in the tooltips.</param>
        /// <param name="intStartTabId">If using Populate On Demand, then this is the tab id of the root element to retrieve (-1 for no POD).</param>
        /// <param name="intDepth">If Populate On Demand is enabled, then this parameter determines the number of nodes to retrieve beneath the starting tab passed in (intStartTabId) (-1 for no POD).</param>
        /// <param name="intNavNodeOptions">Bitwise integer containing values to determine what nodes to display (self, siblings, parent).</param>
        /// <returns>Collection of DNNNodes.</returns>
        /// <remarks>
        /// Returns a subset of navigation nodes based off of passed in starting node id and depth.
        /// </remarks>
        /// -----------------------------------------------------------------------------
        public static DNNNodeCollection GetNavigationNodes(DNNNode objRootNode, ToolTipSource eToolTips, int intStartTabId, int intDepth, int intNavNodeOptions)
        {
            var objPortalSettings   = PortalController.Instance.GetCurrentPortalSettings();
            var objBreadCrumbs      = new Hashtable();
            var objTabLookup        = new Hashtable();
            var objRootNodes        = objRootNode.DNNNodes;
            var intLastBreadCrumbId = 0;

            //--- cache breadcrumbs in hashtable so we can easily set flag on node denoting it as a breadcrumb node (without looping multiple times) ---
            foreach (TabInfo tabInfo in objPortalSettings.ActiveTab.BreadCrumbs)
            {
                objBreadCrumbs.Add(tabInfo.TabID, 1);
                intLastBreadCrumbId = tabInfo.TabID;
            }

            var portalTabs = TabController.GetTabsBySortOrder(objPortalSettings.PortalId, objPortalSettings.CultureCode, true);
            var hostTabs   = TabController.GetTabsBySortOrder(Null.NullInteger, Localization.SystemLocale, true);

            var cachedPortalTabs = new List <TabInfo>(portalTabs);

            foreach (var objTab in cachedPortalTabs)
            {
                objTabLookup.Add(objTab.TabID, objTab);
            }

            var cachedHostTabs = new List <TabInfo>(hostTabs);

            foreach (var objTab in cachedHostTabs)
            {
                objTabLookup.Add(objTab.TabID, objTab);
            }

            // convert dnn nodes to dictionary.
            var nodesDict = new Dictionary <string, DNNNode>();

            SaveDnnNodesToDictionary(nodesDict, objRootNodes);

            foreach (var objTab in cachedPortalTabs)
            {
                ProcessTab(objRootNode, objTab, objTabLookup, objBreadCrumbs, intLastBreadCrumbId, eToolTips, intStartTabId, intDepth, intNavNodeOptions, nodesDict);
            }

            foreach (var objTab in cachedHostTabs)
            {
                ProcessTab(objRootNode, objTab, objTabLookup, objBreadCrumbs, intLastBreadCrumbId, eToolTips, intStartTabId, intDepth, intNavNodeOptions, nodesDict);
            }

            return(objRootNodes);
        }
Exemple #6
0
 protected void PopulateLocationsOnDemand(object source, DNNTextSuggestEventArgs e)
 {
     using (SelectedHotelsEntities db = new SelectedHotelsEntities())
     {
         var query = db.GeoNames.Where(gn => gn.Name.StartsWith(e.Text) && gn.FeatureClass == "P").Select(gn => gn.Name).Distinct().OrderBy(gn => gn).Take(10);
         foreach (string geoName in query)
         {
             var objNode = new DNNNode(geoName)
             {
                 ID = e.Nodes.Count.ToString()
             };
             e.Nodes.Add(objNode);
         }
     }
 }
        /// <summary>
        /// Loops through each of the nodes parents and concatenates the keys to derive its valuepath
        /// </summary>
        /// <param name="objNode">DNNNode object to obtain valuepath from</param>
        /// <returns>ValuePath of node</returns>
        /// <remarks>
        /// the ASP.NET Menu creates a unique key based off of all the menuitem's parents, delimited by a string.
        /// I wish there was a way around this, for we are already guaranteeing the uniqueness of the key since is it pulled from the
        /// database.
        /// </remarks>
        private string GetValuePath(DNNNode objNode)
        {
            DNNNode objParent = objNode.ParentNode;
            string  strPath   = objNode.Key;

            do
            {
                if (objParent == null || objParent.Level == -1)
                {
                    break;
                }
                strPath   = objParent.Key + Menu.PathSeparator + strPath;
                objParent = objParent.ParentNode;
            } while (true);
            return(strPath);
        }
Exemple #8
0
    /// <Summary>
    /// Computes valuepath necessary for ASP.NET controls to guarantee uniqueness
    /// </Summary>
    /// <Returns>ValuePath</Returns>
    private string GetValuePath(DNNNode objNode)
    {
        DNNNode objParent = objNode.ParentNode;
        string  strPath   = GetSafeValue(objNode.Key, "");

        do
        {
            if (objParent == null || objParent.Level == -1)
            {
                break;
            }
            strPath   = GetSafeValue(objParent.Key, "") + "\\" + strPath;
            objParent = objParent.ParentNode;
        }while (true);
        return(strPath);
    }
        private static bool IsActionPending(DNNNode objParentNode, DNNNode objRootNode, int intDepth)
        {
            //if we aren't restricting depth then its never pending
            if (intDepth == -1)
            {
                return(false);
            }

            //parents level + 1 = current node level
            //if current node level - (roots node level) <= the desired depth then not pending
            if (objParentNode.Level + 1 - objRootNode.Level <= intDepth)
            {
                return(false);
            }
            return(true);
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// DNNTxtBannerGroup_PopulateOnDemand runs when something is entered on the
        /// BannerGroup field
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [vmasanas]	9/29/2006	Implement a callback to display current groups
        ///  to user so the BannerGroup can be easily selected
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void PopulateBannersOnDemand(object source, DNNTextSuggestEventArgs e)
        {
            var objBanners = new BannerController();
            var dt         = objBanners.GetBannerGroups(PortalId);

            dt.CaseSensitive = false;
            var dr = dt.Select("GroupName like '" + e.Text + "%'");

            foreach (var d in dr)
            {
                var objNode = new DNNNode(d["GroupName"].ToString())
                {
                    ID = e.Nodes.Count.ToString()
                };
                e.Nodes.Add(objNode);
            }
        }
        private void AddSeparator(string strType, DNNNode objPrevNode, DNNNode objNextNode, MenuNode objMenuItem)
        {
            string strLeftHTML  = SeparatorLeftHTML + SeparatorLeftHTMLBreadCrumb + SeparatorLeftHTMLActive;
            string strRightHTML = SeparatorRightHTML + SeparatorRightHTMLBreadCrumb + SeparatorRightHTMLActive;
            string strHTML      = SeparatorHTML + strLeftHTML + strRightHTML;

            if (!String.IsNullOrEmpty(strHTML))
            {
                string strSeparator           = "";
                string strSeparatorLeftHTML   = "";
                string strSeparatorRightHTML  = "";
                string strSeparatorClass      = "";
                string strLeftSeparatorClass  = "";
                string strRightSeparatorClass = "";
                if (string.IsNullOrEmpty(strLeftHTML) == false)
                {
                    strLeftSeparatorClass = GetSeparatorText(CSSLeftSeparator, CSSLeftSeparatorBreadCrumb, CSSLeftSeparatorSelection, objNextNode);
                    strSeparatorLeftHTML  = GetSeparatorText(SeparatorLeftHTML, SeparatorLeftHTMLBreadCrumb, SeparatorLeftHTMLActive, objNextNode);
                }
                if (string.IsNullOrEmpty(SeparatorHTML) == false)
                {
                    if (!String.IsNullOrEmpty(CSSSeparator))
                    {
                        strSeparatorClass = CSSSeparator;
                    }
                    strSeparator = SeparatorHTML;
                }
                if (string.IsNullOrEmpty(strRightHTML) == false)
                {
                    strRightSeparatorClass = GetSeparatorText(CSSRightSeparator, CSSRightSeparatorBreadCrumb, CSSRightSeparatorSelection, objNextNode);
                    strSeparatorRightHTML  = GetSeparatorText(SeparatorRightHTML, SeparatorRightHTMLBreadCrumb, SeparatorRightHTMLActive, objNextNode);
                }
                if (string.IsNullOrEmpty(strSeparatorRightHTML) == false)
                {
                    objMenuItem.RightHTML += GetSeparatorMarkup(strRightSeparatorClass, strSeparatorRightHTML);
                }
                if (string.IsNullOrEmpty(strSeparator) == false && strType == "All")
                {
                    objMenuItem.LeftHTML += GetSeparatorMarkup(strSeparatorClass, strSeparator);
                }
                if (string.IsNullOrEmpty(strSeparatorLeftHTML) == false)
                {
                    objMenuItem.LeftHTML += GetSeparatorMarkup(strLeftSeparatorClass, strSeparatorLeftHTML);
                }
            }
        }
Exemple #12
0
        /// <summary>
        /// This function provides a central location to obtain a generic node collection of the actions associated
        /// to a module based off of the current user's context
        /// </summary>
        /// <param name="objActionRoot">Root module action</param>
        /// <param name="objModule">Module whose actions you wish to obtain</param>
        /// <param name="intDepth">How many levels deep should be populated</param>
        /// <returns></returns>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [Jon Henning]	5/15/2006	Created
        /// </history>
        public static DNNNodeCollection GetActionNodes(ModuleAction objActionRoot, ActionBase objModule, int intDepth)
        {
            DNNNodeCollection objCol = new DNNNodeCollection(objModule.ClientID);

            if (objActionRoot.Visible)
            {
                objCol.Add();
                DNNNode objRoot = objCol[0];
                objRoot.ID          = objActionRoot.ID.ToString();
                objRoot.Key         = objActionRoot.ID.ToString();
                objRoot.Text        = objActionRoot.Title;
                objRoot.NavigateURL = objActionRoot.Url;
                objRoot.Image       = objActionRoot.Icon;
                AddChildActions(objActionRoot, objRoot, objRoot.ParentNode, objModule, UserController.GetCurrentUserInfo(), intDepth);
            }
            return(objCol);
        }
 private void ProcessNodes(DNNNode objParent)
 {
     if (!String.IsNullOrEmpty(objParent.Image))
     {
     }
     else if (objParent.HasNodes) //imagepath applied in provider...
     {
         objParent.Image = ResolveUrl(NodeClosedImage);
     }
     else
     {
         objParent.Image = ResolveUrl(NodeLeafImage);
     }
     foreach (DNNNode objNode in objParent.DNNNodes)
     {
         ProcessNodes(objNode);
     }
 }
Exemple #14
0
        public override void Bind(DNNNodeCollection objNodes)
        {
            foreach (DNNNode dnnNode in objNodes)
            {
                DNNNode objNode = dnnNode;
                if (objNode.ClickAction == eClickAction.PostBack)
                {
                    DropDown.AutoPostBack = true; //its all or nothing...
                }

                string strLevelPrefix = new String('_', objNode.Level);
                if (objNode.IsBreak)
                {
                    DropDown.Items.Add("-------------------");
                }
                else
                {
                    DropDown.Items.Add(new ListItem(strLevelPrefix + objNode.Text, objNode.ID));
                }
                Bind(objNode.DNNNodes);
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// This function provides a central location to obtain a generic node collection of the actions associated
        /// to a module based off of the current user's context
        /// </summary>
        /// <param name="objActionRoot">Root module action</param>
        /// <param name="objControl">ActionControl to base actions off of</param>
        /// <param name="intDepth">How many levels deep should be populated</param>
        /// <returns></returns>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [Jon Henning]	5/15/2006	Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static DNNNodeCollection GetActionNodes(ModuleAction objActionRoot, Control objControl, int intDepth)
        {
            var objCol = new DNNNodeCollection(objControl.ClientID);

            var objActionControl = objControl as IActionControl;

            if (objActionControl != null)
            {
                if (objActionRoot.Visible)
                {
                    objCol.Add();
                    DNNNode objRoot = objCol[0];
                    objRoot.ID          = objActionRoot.ID.ToString();
                    objRoot.Key         = objActionRoot.ID.ToString();
                    objRoot.Text        = objActionRoot.Title;
                    objRoot.NavigateURL = objActionRoot.Url;
                    objRoot.Image       = objActionRoot.Icon;
                    objRoot.Enabled     = false;
                    AddChildActions(objActionRoot, objRoot, objRoot.ParentNode, objActionControl, intDepth);
                }
            }
            return(objCol);
        }
        /// <summary>
        /// Create a ASP.NET Menu item for a given DNNNode
        /// </summary>
        /// <param name="objNode">Node to create item off of</param>
        /// <returns></returns>
        /// <remarks>
        /// Due to ValuePath needed for postback routine, there is a HACK to replace out the
        /// id with the valuepath if a JSFunciton is specified
        /// </remarks>
        private MenuItem GetMenuItem(DNNNode objNode)
        {
            var objItem = new MenuItem();

            objItem.Text  = objNode.Text;
            objItem.Value = objNode.Key;
            if (!String.IsNullOrEmpty(objNode.JSFunction))
            {
                //HACK...  The postback event needs to have the entire ValuePath to the menu item, not just the unique id
                //__doPostBack('dnn:ctr365:dnnACTIONS:ctldnnACTIONS','6') -> __doPostBack('dnn:ctr365:dnnACTIONS:ctldnnACTIONS','0\\6')}
                objItem.NavigateUrl = "javascript:" + objNode.JSFunction.Replace(Menu.ID + "','" + objNode.Key + "'", Menu.ID + "'.'" + GetValuePath(objNode).Replace("/", "\\\\") + "'") +
                                      objNode.NavigateURL;
            }
            else
            {
                objItem.NavigateUrl = objNode.NavigateURL;
            }
            objItem.Target     = objNode.Target;
            objItem.Selectable = objNode.Enabled;
            objItem.ImageUrl   = objNode.Image; //possibly fix for path
            objItem.Selected   = objNode.Selected;
            objItem.ToolTip    = objNode.ToolTip;
            return(objItem);
        }
        private static void ProcessTab(DNNNode objRootNode, TabInfo objTab, Hashtable objTabLookup, Hashtable objBreadCrumbs, int intLastBreadCrumbId, ToolTipSource eToolTips, int intStartTabId,
                                       int intDepth, int intNavNodeOptions)
        {
            PortalSettings objPortalSettings = PortalController.Instance.GetCurrentPortalSettings();

            DNNNodeCollection objRootNodes = objRootNode.DNNNodes;

            bool showHidden = (intNavNodeOptions & (int)NavNodeOptions.IncludeHiddenNodes) == (int)NavNodeOptions.IncludeHiddenNodes;

            if (CanShowTab(objTab, TabPermissionController.CanAdminPage(), true, showHidden)) //based off of tab properties, is it shown
            {
                DNNNodeCollection objParentNodes;
                DNNNode           objParentNode = objRootNodes.FindNode(objTab.ParentId.ToString());
                bool blnParentFound             = objParentNode != null;
                if (objParentNode == null)
                {
                    objParentNode = objRootNode;
                }
                objParentNodes = objParentNode.DNNNodes;
                if (objTab.TabID == intStartTabId)
                {
                    //is this the starting tab
                    if ((intNavNodeOptions & (int)NavNodeOptions.IncludeParent) != 0)
                    {
                        //if we are including parent, make sure there is one, then add
                        if (objTabLookup[objTab.ParentId] != null)
                        {
                            AddNode((TabInfo)objTabLookup[objTab.ParentId], objParentNodes, objBreadCrumbs, objPortalSettings, eToolTips);
                            objParentNode  = objRootNodes.FindNode(objTab.ParentId.ToString());
                            objParentNodes = objParentNode.DNNNodes;
                        }
                    }
                    if ((intNavNodeOptions & (int)NavNodeOptions.IncludeSelf) != 0)
                    {
                        //if we are including our self (starting tab) then add
                        AddNode(objTab, objParentNodes, objBreadCrumbs, objPortalSettings, eToolTips);
                    }
                }
                else if (((intNavNodeOptions & (int)NavNodeOptions.IncludeSiblings) != 0) && IsTabSibling(objTab, intStartTabId, objTabLookup))
                {
                    //is this a sibling of the starting node, and we are including siblings, then add it
                    AddNode(objTab, objParentNodes, objBreadCrumbs, objPortalSettings, eToolTips);
                }
                else
                {
                    if (blnParentFound) //if tabs parent already in hierarchy (as is the case when we are sending down more than 1 level)
                    {
                        //parent will be found for siblings.  Check to see if we want them, if we don't make sure tab is not a sibling
                        if (((intNavNodeOptions & (int)NavNodeOptions.IncludeSiblings) != 0) || IsTabSibling(objTab, intStartTabId, objTabLookup) == false)
                        {
                            //determine if tab should be included or marked as pending
                            bool blnPOD = (intNavNodeOptions & (int)NavNodeOptions.MarkPendingNodes) != 0;
                            if (IsTabPending(objTab, objParentNode, objRootNode, intDepth, objBreadCrumbs, intLastBreadCrumbId, blnPOD))
                            {
                                if (blnPOD)
                                {
                                    objParentNode.HasNodes = true; //mark it as a pending node
                                }
                            }
                            else
                            {
                                AddNode(objTab, objParentNodes, objBreadCrumbs, objPortalSettings, eToolTips);
                            }
                        }
                    }
                    else if ((intNavNodeOptions & (int)NavNodeOptions.IncludeSelf) == 0 && objTab.ParentId == intStartTabId)
                    {
                        //if not including self and parent is the start id then add
                        AddNode(objTab, objParentNodes, objBreadCrumbs, objPortalSettings, eToolTips);
                    }
                }
            }
        }
        private static bool IsTabPending(TabInfo objTab, DNNNode objParentNode, DNNNode objRootNode, int intDepth, Hashtable objBreadCrumbs, int intLastBreadCrumbId, bool blnPOD)
        {
            //
            //A
            //|
            //--B
            //| |
            //| --B-1
            //| | |
            //| | --B-1-1
            //| | |
            //| | --B-1-2
            //| |
            //| --B-2
            //|   |
            //|   --B-2-1
            //|   |
            //|   --B-2-2
            //|
            //--C
            //  |
            //  --C-1
            //  | |
            //  | --C-1-1
            //  | |
            //  | --C-1-2
            //  |
            //  --C-2
            //    |
            //    --C-2-1
            //    |
            //    --C-2-2

            //if we aren't restricting depth then its never pending
            if (intDepth == -1)
            {
                return(false);
            }

            //parents level + 1 = current node level
            //if current node level - (roots node level) <= the desired depth then not pending
            if (objParentNode.Level + 1 - objRootNode.Level <= intDepth)
            {
                return(false);
            }


            //--- These checks below are here so tree becomes expands to selected node ---
            if (blnPOD)
            {
                //really only applies to controls with POD enabled, since the root passed in may be some node buried down in the chain
                //and the depth something like 1.  We need to include the appropriate parent's and parent siblings
                //Why is the check for POD required?  Well to allow for functionality like RootOnly requests.  We do not want any children
                //regardless if they are a breadcrumb

                //if tab is in the breadcrumbs then obviously not pending
                if (objBreadCrumbs.Contains(objTab.TabID))
                {
                    return(false);
                }

                //if parent is in the breadcrumb and it is not the last breadcrumb then not pending
                //in tree above say we our breadcrumb is (A, B, B-2) we want our tree containing A, B, B-2 AND B-1 AND C since A and B are expanded
                //we do NOT want B-2-1 and B-2-2, thus the check for Last Bread Crumb
                if (objBreadCrumbs.Contains(objTab.ParentId) && intLastBreadCrumbId != objTab.ParentId)
                {
                    return(false);
                }
            }
            return(true);
        }
Exemple #19
0
        public override void Bind(DNNNodeCollection objNodes)
        {
            DNNNode        objNode     = null;
            SPMenuItemNode objMenuItem = null;
            DNNNode        objPrevNode = null;
            bool           RootFlag    = false;

            if (IndicateChildren == false)
            {
            }
            else
            {
                if (!String.IsNullOrEmpty(IndicateChildImageRoot))
                {
                    Menu.RootArrow = true;
                }
            }
            foreach (DNNNode node in objNodes)
            {
                objNode = node;
                try
                {
                    if (objNode.Level == 0)
                    {
                        if (RootFlag)
                        {
                            AddSeparator("All", objPrevNode, objNode);
                        }
                        else
                        {
                            if (!String.IsNullOrEmpty(SeparatorLeftHTML) || !String.IsNullOrEmpty(SeparatorLeftHTMLBreadCrumb) || !String.IsNullOrEmpty(SeparatorLeftHTMLActive))
                            {
                                AddSeparator("Left", objPrevNode, objNode);
                            }
                            RootFlag = true;
                        }
                        if (objNode.Enabled == false)
                        {
                            objMenuItem = new SPMenuItemNode(Menu.AddMenuItem(objNode.ID, objNode.Text, ""));
                        }
                        else
                        {
                            if (!String.IsNullOrEmpty(objNode.JSFunction))
                            {
                                objMenuItem = new SPMenuItemNode(Menu.AddMenuItem(objNode.ID, objNode.Text, GetClientScriptURL(objNode.JSFunction, objNode.ID)));
                            }
                            else
                            {
                                objMenuItem = new SPMenuItemNode(Menu.AddMenuItem(objNode.ID, objNode.Text, objNode.NavigateURL));
                            }
                        }
                        if (!String.IsNullOrEmpty(StyleRoot))
                        {
                            objMenuItem.ItemStyle = StyleRoot;
                        }
                        if (!String.IsNullOrEmpty(CSSNodeRoot))
                        {
                            objMenuItem.ItemCss = CSSNodeRoot;
                        }
                        if (!String.IsNullOrEmpty(CSSNodeHoverRoot))
                        {
                            objMenuItem.ItemSelectedCss = CSSNodeHoverRoot;
                        }
                        if (!String.IsNullOrEmpty(NodeLeftHTMLRoot))
                        {
                            objMenuItem.LeftHTML = NodeLeftHTMLRoot;
                        }
                        if (objNode.BreadCrumb)
                        {
                            objMenuItem.ItemCss = objMenuItem.ItemCss + " " + CSSBreadCrumbRoot;
                            if (!String.IsNullOrEmpty(NodeLeftHTMLBreadCrumbRoot))
                            {
                                objMenuItem.LeftHTML = NodeLeftHTMLBreadCrumbRoot;
                            }
                            if (!String.IsNullOrEmpty(NodeRightHTMLBreadCrumbRoot))
                            {
                                objMenuItem.RightHTML = NodeRightHTMLBreadCrumbRoot;
                            }
                            if (objNode.Selected)
                            {
                                objMenuItem.ItemCss = objMenuItem.ItemCss + " " + CSSNodeSelectedRoot;
                            }
                        }
                        if (!String.IsNullOrEmpty(NodeRightHTMLRoot))
                        {
                            objMenuItem.RightHTML = NodeRightHTMLRoot;
                        }
                    }
                    else if (objNode.IsBreak)
                    {
                        Menu.AddBreak(objNode.ParentNode.ID);
                    }
                    else
                    {
                        try
                        {
                            if (objNode.Enabled == false)
                            {
                                objMenuItem = new SPMenuItemNode(Menu.AddMenuItem(objNode.ParentNode.ID, objNode.ID, "&nbsp;" + objNode.Text, ""));
                            }
                            else
                            {
                                if (!String.IsNullOrEmpty(objNode.JSFunction))
                                {
                                    objMenuItem = new SPMenuItemNode(Menu.AddMenuItem(objNode.ParentNode.ID, objNode.ID, "&nbsp;" + objNode.Text, GetClientScriptURL(objNode.JSFunction, objNode.ID)));
                                }
                                else
                                {
                                    objMenuItem = new SPMenuItemNode(Menu.AddMenuItem(objNode.ParentNode.ID, objNode.ID, "&nbsp;" + objNode.Text, objNode.NavigateURL));
                                }
                            }
                            if (objNode.ClickAction == eClickAction.PostBack)
                            {
                                objMenuItem.RunAtServer = true;
                            }
                            if (!String.IsNullOrEmpty(CSSNodeHoverSub))
                            {
                                objMenuItem.ItemSelectedCss = CSSNodeHoverSub;
                            }
                            if (!String.IsNullOrEmpty(NodeLeftHTMLSub))
                            {
                                objMenuItem.LeftHTML = NodeLeftHTMLSub;
                            }
                            if (objNode.BreadCrumb)
                            {
                                objMenuItem.ItemCss = CSSBreadCrumbSub;
                                if (!String.IsNullOrEmpty(NodeLeftHTMLBreadCrumbSub))
                                {
                                    objMenuItem.LeftHTML = NodeLeftHTMLBreadCrumbSub;
                                }
                                if (!String.IsNullOrEmpty(NodeRightHTMLBreadCrumbSub))
                                {
                                    objMenuItem.RightHTML = NodeRightHTMLBreadCrumbSub;
                                }
                                if (objNode.Selected)
                                {
                                    objMenuItem.ItemCss = CSSNodeSelectedSub;
                                    DNNNode objParentNode = objNode;
                                    do
                                    {
                                        objParentNode = objParentNode.ParentNode;
                                        Menu.FindMenuItem(objParentNode.ID).ItemCss = CSSNodeSelectedSub;
                                    } while (objParentNode.Level != 0);
                                    Menu.FindMenuItem(objParentNode.ID).ItemCss = CSSBreadCrumbRoot + " " + CSSNodeSelectedRoot;
                                }
                            }
                            if (!String.IsNullOrEmpty(NodeRightHTMLSub))
                            {
                                objMenuItem.RightHTML = NodeRightHTMLSub;
                            }
                        }
                        catch
                        {
                            objMenuItem = null;
                        }
                    }
                    if (!String.IsNullOrEmpty(objNode.Image))
                    {
                        if (objNode.Image.StartsWith("~/images/"))
                        {
                            objMenuItem.Image = objNode.Image.Replace("~/images/", "");
                        }
                        else if (objNode.Image.IndexOf("/") > -1)
                        {
                            string strImage = objNode.Image;
                            if (strImage.StartsWith(Menu.IconImagesPath))
                            {
                                strImage = strImage.Substring(Menu.IconImagesPath.Length);
                            }
                            if (strImage.IndexOf("/") > -1)
                            {
                                objMenuItem.Image = strImage.Substring(strImage.LastIndexOf("/") + 1);
                                if (strImage.StartsWith("/"))
                                {
                                    objMenuItem.ImagePath = strImage.Substring(0, strImage.LastIndexOf("/") + 1);
                                }
                                else if (strImage.StartsWith("~/"))
                                {
                                    objMenuItem.ImagePath = Globals.ResolveUrl(strImage.Substring(0, strImage.LastIndexOf("/") + 1));
                                }
                                else
                                {
                                    objMenuItem.ImagePath = Menu.IconImagesPath + strImage.Substring(0, strImage.LastIndexOf("/") + 1);
                                }
                            }
                            else
                            {
                                objMenuItem.Image = strImage;
                            }
                        }
                        else
                        {
                            objMenuItem.Image = objNode.Image;
                        }
                    }
                    if (!String.IsNullOrEmpty(objNode.ToolTip))
                    {
                        objMenuItem.ToolTip = objNode.ToolTip;
                    }
                    Bind(objNode.DNNNodes);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                objPrevNode = objNode;
            }
            if (objNode != null && objNode.Level == 0)
            {
                if (!String.IsNullOrEmpty(SeparatorRightHTML) || !String.IsNullOrEmpty(SeparatorRightHTMLBreadCrumb) || !String.IsNullOrEmpty(SeparatorRightHTMLActive))
                {
                    AddSeparator("Right", objPrevNode, null);
                }
            }
        }
Exemple #20
0
 public NavDataPageHierarchyData(DNNNode obj)
 {
     this.m_objNode = null;
     this.m_objNode = obj;
 }
        /// <summary>
        /// Renders the current node
        /// </summary>
        /// <param name="mainNode">
        /// The main node.
        /// </param>
        /// <param name="modulMenuUl">
        /// The module Menu UL.
        /// </param>
        private void RenderNode(DNNNode mainNode, Control modulMenuUl)
        {
            this.ctlModulMenu = new HtmlGenericControl("li");

            modulMenuUl.Controls.Add(this.ctlModulMenu);

            if (mainNode.HasNodes)
            {
                var subMenuHeading = new HtmlGenericControl("h2");
                this.ctlModulMenu.Controls.Add(subMenuHeading);

                subMenuHeading.InnerText = mainNode.Text;
            }
            else
            {
                this.ctlModulMenu.Attributes.Add("class", "MegaItem");

                if (mainNode.HasNodes)
                {
                    this.ctlModulMenuLinkImage = new HtmlImage();

                    this.ctlModulMenu.Controls.Add(this.ctlModulMenuLinkImage);

                    this.ctlModulMenuLinkImage.Attributes["class"] = "ModuleOptionsMenuArrow";

                    this.ctlModulMenuLinkImage.Attributes["src"] = this.ResolveUrl("skins/arrow.png");

                    this.ctlModulMenuLinkImage.Attributes["alt"] = "Arrow";
                }

                this.ctlModulMenuLink = new LinkButton();

                if (!string.IsNullOrEmpty(mainNode.JSFunction))
                {
                    if (mainNode.JSFunction.Contains("dnnModal.show(") && this.disablePopUps)
                    {
                        var m = Regex.Match(
                            mainNode.JSFunction, @"dnnModal.show\(\'(?<inner>[^\?]*)\?popUp", RegexOptions.Singleline);

                        if (m.Success)
                        {
                            mainNode.NavigateURL = m.Groups["inner"].Value;
                        }
                        else
                        {
                            this.ctlModulMenuLink.Attributes.Add(
                                "onClick", string.Format("javascript:return {0};", mainNode.JSFunction));
                        }
                    }
                    else
                    {
                        this.ctlModulMenuLink.Attributes.Add(
                            "onClick", string.Format("javascript:return {0};", mainNode.JSFunction));
                    }
                }

                if (!string.IsNullOrEmpty(mainNode.NavigateURL))
                {
                    this.ctlModulMenuLink.Attributes["href"] = mainNode.NavigateURL;
                }

                if (string.IsNullOrEmpty(mainNode.NavigateURL))
                {
                    this.ctlModulMenuLink.Command    += this.MenuItemClick;
                    this.ctlModulMenuLink.CommandName = "MenuItem";

                    this.ctlModulMenuLink.CommandArgument = mainNode.ID;
                }

                this.ctlModulMenuLink.Attributes["id"]    = string.Format("MenuItem{0}", mainNode.ID);
                this.ctlModulMenuLink.Attributes["title"] = !string.IsNullOrEmpty(mainNode.ToolTip)
                                                                ? mainNode.ToolTip
                                                                : mainNode.Text;

                if (!string.IsNullOrEmpty(mainNode.Image))
                {
                    this.ctlModulMenuLinkImage = new HtmlImage();

                    this.ctlModulMenuLinkImage.Attributes["src"] = this.SetIconPath(mainNode.Image, false);

                    this.ctlModulMenuLinkImage.Attributes["alt"] = !string.IsNullOrEmpty(mainNode.ToolTip)
                                                                ? mainNode.ToolTip
                                                                : mainNode.Text;

                    this.ctlModulMenuLink.Text = string.Format(
                        "<img src=\"{0}\" alt=\"{1}\" title\"{1}\" />&nbsp;{2}",
                        this.SetIconPath(mainNode.Image, false),
                        !string.IsNullOrEmpty(mainNode.ToolTip)
                                                                ? mainNode.ToolTip
                                                                : mainNode.Text,
                        !string.IsNullOrEmpty(mainNode.Text) ? mainNode.Text : "&nbsp;");
                }
                else
                {
                    this.ctlModulMenuLink.Text = !string.IsNullOrEmpty(mainNode.Text) ? mainNode.Text : "&nbsp;";
                }

                if (mainNode.IsBreak)
                {
                    this.ctlModulMenu.InnerHtml = "<hr />";
                }
                else
                {
                    this.ctlModulMenu.Controls.Add(this.ctlModulMenuLink);
                }
            }

            if (!mainNode.HasNodes)
            {
                return;
            }

            foreach (DNNNode subNode in mainNode.DNNNodes)
            {
                this.RenderNode(subNode, modulMenuUl);
            }
        }
Exemple #22
0
 public static void DNNNodeToMenuNode(DNNNode dnnNode, MenuNode menuNode)
 {
     menuNode.LargeImage = dnnNode.LargeImage;
 }
Exemple #23
0
 public NavigationEventArgs(string strID, DNNNode objNode)
 {
     this.ID   = strID;
     this.Node = objNode;
 }
        private string GetSeparatorText(string strNormal, string strBreadCrumb, string strSelection, DNNNode objNode)
        {
            string strRet = "";

            if (!String.IsNullOrEmpty(strNormal))
            {
                strRet = strNormal;
            }
            if (!String.IsNullOrEmpty(strBreadCrumb) && objNode != null && objNode.BreadCrumb)
            {
                strRet = strBreadCrumb;
            }
            if (!String.IsNullOrEmpty(strSelection) && objNode != null && objNode.Selected)
            {
                strRet = strSelection;
            }
            return(strRet);
        }
Exemple #25
0
        public override void Bind(DNNNodeCollection objNodes)
        {
            DNNNode        objNode     = null;
            SPMenuItemNode objMenuItem = null;
            DNNNode        objPrevNode = null;
            bool           isRootFlag  = false;

            if (IndicateChildren == false)
            {
                //should this be spacer.gif???
                //IndicateChildImageSub = ""
                //IndicateChildImageRoot = ""
            }
            else
            {
                if (!String.IsNullOrEmpty(IndicateChildImageRoot))
                {
                    Menu.RootArrow = true;
                }
            }

            foreach (DNNNode dnnNode in objNodes)
            {
                objNode = dnnNode;
                try
                {
                    if (objNode.Level == 0) // root menu
                    {
                        if (isRootFlag)     //first root item has already been entered
                        {
                            AddSeparator("All", objPrevNode, objNode);
                        }
                        else
                        {
                            if (!String.IsNullOrEmpty(SeparatorLeftHTML) || !String.IsNullOrEmpty(SeparatorLeftHTMLBreadCrumb) || !String.IsNullOrEmpty(SeparatorLeftHTMLActive))
                            {
                                AddSeparator("Left", objPrevNode, objNode);
                            }
                            isRootFlag = true;
                        }

                        if (objNode.Enabled == false)
                        {
                            objMenuItem = new SPMenuItemNode(Menu.AddMenuItem(objNode.ID.ToString(), objNode.Text, ""));
                        }
                        else
                        {
                            string jsFunction = objNode.JSFunction;
                            if ((jsFunction != null) && (jsFunction.Length > 0))
                            {
                                objMenuItem = new SPMenuItemNode(Menu.AddMenuItem(objNode.ID.ToString(), objNode.Text, GetClientScriptURL(objNode.JSFunction, objNode.ID)));
                            }
                            else
                            {
                                objMenuItem = new SPMenuItemNode(Menu.AddMenuItem(objNode.ID.ToString(), objNode.Text, objNode.NavigateURL));
                            }
                        }
                        if (StyleRoot != null && StyleRoot.Length > 0)
                        {
                            objMenuItem.ItemStyle = this.StyleRoot;
                        }
                        if (!String.IsNullOrEmpty(CSSNodeRoot))
                        {
                            objMenuItem.ItemCss = this.CSSNodeRoot;
                        }
                        if (!String.IsNullOrEmpty(CSSNodeHoverRoot))
                        {
                            objMenuItem.ItemSelectedCss = this.CSSNodeHoverRoot;
                        }

                        if (!String.IsNullOrEmpty(NodeLeftHTMLRoot))
                        {
                            objMenuItem.LeftHTML = this.NodeLeftHTMLRoot;
                        }

                        if (objNode.BreadCrumb)
                        {
                            objMenuItem.ItemCss = objMenuItem.ItemCss + " " + this.CSSBreadCrumbRoot;
                            if (!String.IsNullOrEmpty(NodeLeftHTMLBreadCrumbRoot))
                            {
                                objMenuItem.LeftHTML = NodeLeftHTMLBreadCrumbRoot;
                            }
                            if (!String.IsNullOrEmpty(NodeRightHTMLBreadCrumbRoot))
                            {
                                objMenuItem.RightHTML = NodeRightHTMLBreadCrumbRoot;
                            }
                            if (objNode.Selected)
                            {
                                objMenuItem.ItemCss = objMenuItem.ItemCss + " " + this.CSSNodeSelectedRoot;
                            }
                        }

                        if (!String.IsNullOrEmpty(NodeRightHTMLRoot))
                        {
                            objMenuItem.RightHTML = NodeRightHTMLRoot;
                        }
                    }
                    else if (objNode.IsBreak)
                    {
                        Menu.AddBreak(objNode.ParentNode.ID.ToString());
                    }
                    else //If Not blnRootOnly Then
                    {
                        try
                        {
                            if (objNode.Enabled == false)
                            {
                                objMenuItem = new SPMenuItemNode(Menu.AddMenuItem(objNode.ParentNode.ID.ToString(), objNode.ID.ToString(), "&nbsp;" + objNode.Text, ""));
                            }
                            else
                            {
                                string jsFunction = objNode.JSFunction;
                                if (!String.IsNullOrEmpty(jsFunction))
                                {
                                    objMenuItem = new SPMenuItemNode(Menu.AddMenuItem(objNode.ParentNode.ID.ToString(), objNode.ID.ToString(), "&nbsp;" + objNode.Text, GetClientScriptURL(objNode.JSFunction, objNode.ID)));
                                }
                                else
                                {
                                    objMenuItem = new SPMenuItemNode(Menu.AddMenuItem(objNode.ParentNode.ID.ToString(), objNode.ID.ToString(), "&nbsp;" + objNode.Text, objNode.NavigateURL));
                                }
                            }

                            if (objNode.ClickAction == eClickAction.PostBack)
                            {
                                objMenuItem.RunAtServer = true;
                            }
                            if (!String.IsNullOrEmpty(CSSNodeHoverSub))
                            {
                                objMenuItem.ItemSelectedCss = CSSNodeHoverSub;
                            }
                            if (!String.IsNullOrEmpty(NodeLeftHTMLSub))
                            {
                                objMenuItem.LeftHTML = NodeLeftHTMLSub;
                            }

                            if (objNode.BreadCrumb)
                            {
                                objMenuItem.ItemCss = this.CSSBreadCrumbSub;
                                if (!String.IsNullOrEmpty(NodeLeftHTMLBreadCrumbSub))
                                {
                                    objMenuItem.LeftHTML = NodeLeftHTMLBreadCrumbSub;
                                }
                                if (!String.IsNullOrEmpty(NodeRightHTMLBreadCrumbSub))
                                {
                                    objMenuItem.RightHTML = NodeRightHTMLBreadCrumbSub;
                                }
                                if (objNode.Selected)
                                {
                                    objMenuItem.ItemCss = this.CSSNodeSelectedSub;
                                }
                            }

                            if (!String.IsNullOrEmpty(NodeRightHTMLSub))
                            {
                                objMenuItem.RightHTML = this.NodeRightHTMLSub;
                            }
                        }
                        catch
                        {
                            // throws exception if the parent tab has not been loaded ( may be related to user role security not allowing access to a parent tab )
                            objMenuItem = null;
                        }
                        //Else
                        //	objMenuItem = Nothing
                    }


                    if (objMenuItem != null)
                    {
                        if (!String.IsNullOrEmpty(objNode.Image))
                        {
                            //if image contains a path
                            if (objNode.Image.IndexOf("/") > -1)
                            {
                                string strImage = objNode.Image;
                                //if path (or portion) is already set in header of menu truncate it off
                                if (strImage.StartsWith(Menu.IconImagesPath))
                                {
                                    strImage = strImage.Substring(Menu.IconImagesPath.Length);
                                }
                                if (strImage.IndexOf("/") > -1)     //if the image still contains path info assign it
                                {
                                    objMenuItem.Image = strImage.Substring(strImage.LastIndexOf("/") + 1);
                                    if (strImage.StartsWith("/"))    //is absolute path?
                                    {
                                        objMenuItem.ImagePath = strImage.Substring(0, strImage.LastIndexOf("/") + 1);
                                    }
                                    else
                                    {
                                        objMenuItem.ImagePath = Menu.IconImagesPath + strImage.Substring(0, strImage.LastIndexOf("/") + 1);
                                    }
                                }
                                else
                                {
                                    objMenuItem.Image = strImage;
                                }
                            }
                            else
                            {
                                objMenuItem.Image = objNode.Image;
                            }
                        }
                        if (String.IsNullOrEmpty(objNode.ToolTip))
                        {
                            objMenuItem.ToolTip = objNode.ToolTip;
                        }
                    }

                    Bind(objNode.DNNNodes);
                }
                catch (Exception ex)
                {
                    throw (ex);
                }
                objPrevNode = objNode;
            }

            if (objNode != null && objNode.Level == 0)  // root menu
            {
                if (!String.IsNullOrEmpty(SeparatorRightHTML) || !String.IsNullOrEmpty(SeparatorRightHTMLBreadCrumb) || !String.IsNullOrEmpty(SeparatorRightHTMLActive))
                {
                    AddSeparator("Right", objPrevNode, null);
                }
            }
        }
        public override void Bind(DNNNodeCollection objNodes)
        {
            DNNNode  objNode = null;
            MenuNode objMenuItem;
            DNNNode  objPrevNode = null;
            bool     RootFlag    = false;
            int      intIndex;

            if (IndicateChildren == false)
            {
                IndicateChildImageSub  = "";
                IndicateChildImageRoot = "";
            }
            if (!String.IsNullOrEmpty(CSSNodeSelectedRoot) && CSSNodeSelectedRoot == CSSNodeSelectedSub)
            {
                Menu.DefaultNodeCssClassSelected = CSSNodeSelectedRoot; //set on parent, thus decreasing overall payload
            }

            //JH - 2/5/07 - support for custom attributes
            foreach (CustomAttribute objAttr in CustomAttributes)
            {
                switch (objAttr.Name.ToLower())
                {
                case "submenuorientation":
                    Menu.SubMenuOrientation = (UI.WebControls.Orientation)Enum.Parse(Menu.SubMenuOrientation.GetType(), objAttr.Value);
                    break;

                case "usetables":
                    Menu.RenderMode = DNNMenu.MenuRenderMode.Normal;
                    break;

                case "rendermode":
                    Menu.RenderMode = (DNNMenu.MenuRenderMode)Enum.Parse(typeof(DNNMenu.MenuRenderMode), objAttr.Value);
                    break;

                case "animationtype":
                    Menu.Animation.AnimationType = (AnimationType)Enum.Parse(typeof(AnimationType), objAttr.Value);
                    break;

                case "easingdirection":
                    Menu.Animation.EasingDirection = (EasingDirection)Enum.Parse(typeof(EasingDirection), objAttr.Value);
                    break;

                case "easingtype":
                    Menu.Animation.EasingType = (EasingType)Enum.Parse(typeof(EasingType), objAttr.Value);
                    break;

                case "animationinterval":
                    Menu.Animation.Interval = int.Parse(objAttr.Value);
                    break;

                case "animationlength":
                    Menu.Animation.Length = int.Parse(objAttr.Value);
                    break;
                }
            }
            foreach (DNNNode node in objNodes)
            {
                objNode = node;
                if (objNode.Level == 0) //root menu
                {
                    intIndex    = Menu.MenuNodes.Import(objNode, false);
                    objMenuItem = Menu.MenuNodes[intIndex];
                    if (objNode.BreadCrumb && string.IsNullOrEmpty(NodeRightHTMLBreadCrumbRoot) == false)
                    {
                        objMenuItem.RightHTML += NodeRightHTMLBreadCrumbRoot;
                    }
                    else if (string.IsNullOrEmpty(NodeRightHTMLRoot) == false)
                    {
                        objMenuItem.RightHTML = NodeRightHTMLRoot;
                    }
                    if (RootFlag) //first root item has already been entered
                    {
                        AddSeparator("All", objPrevNode, objNode, objMenuItem);
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(SeparatorLeftHTML) == false || string.IsNullOrEmpty(SeparatorLeftHTMLBreadCrumb) == false || string.IsNullOrEmpty(SeparatorLeftHTMLActive) == false)
                        {
                            AddSeparator("Left", objPrevNode, objNode, objMenuItem);
                        }
                        RootFlag = true;
                    }
                    if (objNode.BreadCrumb && string.IsNullOrEmpty(NodeLeftHTMLBreadCrumbRoot) == false)
                    {
                        objMenuItem.LeftHTML += NodeLeftHTMLBreadCrumbRoot;
                    }
                    else if (string.IsNullOrEmpty(NodeLeftHTMLRoot) == false)
                    {
                        objMenuItem.LeftHTML += NodeLeftHTMLRoot;
                    }
                    if (!String.IsNullOrEmpty(CSSNodeRoot))
                    {
                        objMenuItem.CSSClass = CSSNodeRoot;
                    }
                    if (!String.IsNullOrEmpty(CSSNodeHoverRoot) && CSSNodeHoverRoot != CSSNodeHoverSub)
                    {
                        objMenuItem.CSSClassHover = CSSNodeHoverRoot;
                    }
                    objMenuItem.CSSIcon = " "; //< ignore for root...???
                    if (objNode.BreadCrumb)
                    {
                        if (!String.IsNullOrEmpty(CSSBreadCrumbRoot))
                        {
                            objMenuItem.CSSClass = CSSBreadCrumbRoot;
                        }
                        if (objNode.Selected && String.IsNullOrEmpty(Menu.DefaultNodeCssClassSelected))
                        {
                            objMenuItem.CSSClassSelected = CSSNodeSelectedRoot;
                        }
                    }
                }
                else //If Not blnRootOnly Then
                {
                    try
                    {
                        MenuNode objParent = Menu.MenuNodes.FindNode(objNode.ParentNode.ID);
                        if (objParent == null) //POD
                        {
                            objParent = Menu.MenuNodes[Menu.MenuNodes.Import(objNode.ParentNode.Clone(), true)];
                        }
                        objMenuItem = objParent.MenuNodes.FindNode(objNode.ID);
                        if (objMenuItem == null) //POD
                        {
                            objMenuItem = objParent.MenuNodes[objParent.MenuNodes.Import(objNode.Clone(), true)];
                        }
                        if (!String.IsNullOrEmpty(NodeLeftHTMLSub))
                        {
                            objMenuItem.LeftHTML = NodeLeftHTMLSub;
                        }
                        if (!String.IsNullOrEmpty(NodeRightHTMLSub))
                        {
                            objMenuItem.RightHTML = NodeRightHTMLSub;
                        }
                        if (!String.IsNullOrEmpty(CSSNodeHoverSub) && CSSNodeHoverRoot != CSSNodeHoverSub)
                        {
                            objMenuItem.CSSClassHover = CSSNodeHoverSub;
                        }
                        if (objNode.BreadCrumb)
                        {
                            if (!String.IsNullOrEmpty(CSSBreadCrumbSub))
                            {
                                objMenuItem.CSSClass = CSSBreadCrumbSub;
                            }
                            if (!String.IsNullOrEmpty(NodeLeftHTMLBreadCrumbSub))
                            {
                                objMenuItem.LeftHTML = NodeLeftHTMLBreadCrumbSub;
                            }
                            if (!String.IsNullOrEmpty(NodeRightHTMLBreadCrumbSub))
                            {
                                objMenuItem.RightHTML = NodeRightHTMLBreadCrumbSub;
                            }
                            if (objNode.Selected && String.IsNullOrEmpty(Menu.DefaultNodeCssClassSelected))
                            {
                                objMenuItem.CSSClass = CSSNodeSelectedSub;
                            }
                        }
                    }
                    catch
                    {
                        //throws exception if the parent tab has not been loaded ( may be related to user role security not allowing access to a parent tab )
                        objMenuItem = null;
                    }
                }
                if (!String.IsNullOrEmpty(objNode.Image))
                {
                    if (objNode.Image.StartsWith("~/images/"))
                    {
                        objNode.Image = objNode.Image.Replace("~/images/", PathSystemImage);
                    }
                    else if (objNode.Image.StartsWith("~/"))
                    {
                        objNode.Image = Globals.ResolveUrl(objNode.Image);
                    }
                    else if (!objNode.Image.Contains("://") && objNode.Image.StartsWith("/") == false && !String.IsNullOrEmpty(PathImage))
                    {
                        objNode.Image = PathImage + objNode.Image;
                    }
                    objMenuItem.Image = objNode.Image;
                }
                if (objMenuItem.IsBreak)
                {
                    objMenuItem.CSSClass = CSSBreak;
                }
                objMenuItem.ToolTip = objNode.ToolTip;
                Bind(objNode.DNNNodes);
                objPrevNode = objNode;
            }
            if (objNode != null && objNode.Level == 0) //root menu
            {
                //solpartactions has a hardcoded image with no path information.  Assume if value is present and no path we need to add one.
                if (!String.IsNullOrEmpty(IndicateChildImageSub) && IndicateChildImageSub.IndexOf("/") == -1)
                {
                    IndicateChildImageSub = PathSystemImage + IndicateChildImageSub;
                }
                if (!String.IsNullOrEmpty(IndicateChildImageRoot) && IndicateChildImageRoot.IndexOf("/") == -1)
                {
                    IndicateChildImageRoot = PathSystemImage + IndicateChildImageRoot;
                }
            }
        }
Exemple #27
0
        /// <summary>
        /// Renders the current node
        /// </summary>
        /// <param name="mainNode">
        /// The main node.
        /// </param>
        /// <param name="modulMenuUl">
        /// The module Menu UL.
        /// </param>
        private void RenderNode(DNNNode mainNode, HtmlGenericControl modulMenuUl)
        {
            this.ctlModulMenu = new HtmlGenericControl("li");

            var modulSubMenuUl = new HtmlGenericControl("ul");

            modulMenuUl.Controls.Add(this.ctlModulMenu);

            if (this.userAgent.IndexOf("MSIE") > -1)
            {
                this.ctlModulMenu.Attributes["onmouseover"] = "this.className+=' sfhover'";
                this.ctlModulMenu.Attributes["onmouseout"]  = "this.className-=' sfhover'";
            }

            if (mainNode.HasNodes)
            {
                this.ctlModulMenuLinkImage = new HtmlImage();

                this.ctlModulMenu.Controls.Add(this.ctlModulMenuLinkImage);

                this.ctlModulMenuLinkImage.Attributes["class"] = "ModuleOptionsMenuArrow";

                this.ctlModulMenuLinkImage.Attributes["src"] = this.ResolveUrl("skins/arrow.png");

                this.ctlModulMenuLinkImage.Attributes["alt"] = "Arrow";
            }

            this.ctlModulMenuLink = new LinkButton();

            if (!string.IsNullOrEmpty(mainNode.NavigateURL))
            {
                this.ctlModulMenuLink.Attributes["href"] = mainNode.NavigateURL;
            }
            else
            {
                this.ctlModulMenuLink.Command    += this.MenuItemClick;
                this.ctlModulMenuLink.CommandName = "MenuItem";

                this.ctlModulMenuLink.CommandArgument = mainNode.ID;
            }

            if (!string.IsNullOrEmpty(mainNode.JSFunction))
            {
                this.ctlModulMenuLink.Attributes.Add(
                    "onClick", string.Format("javascript:return {0};", mainNode.JSFunction));
            }

            this.ctlModulMenuLink.Attributes["id"]    = string.Format("MenuItem{0}", mainNode.ID);
            this.ctlModulMenuLink.Attributes["title"] = !string.IsNullOrEmpty(mainNode.ToolTip)
                                                            ? mainNode.ToolTip
                                                            : mainNode.Text;

            if (!string.IsNullOrEmpty(mainNode.Image))
            {
                this.ctlModulMenuLinkImage = new HtmlImage();

                this.ctlModulMenuLinkImage.Attributes["src"] = this.SetIconPath(mainNode.Image, false);

                this.ctlModulMenuLinkImage.Attributes["alt"] = !string.IsNullOrEmpty(mainNode.ToolTip)
                                                            ? mainNode.ToolTip
                                                            : mainNode.Text;

                this.ctlModulMenuLink.Text = string.Format(
                    "<img src=\"{0}\" alt=\"{1}\" title\"{1}\" />&nbsp;{2}",
                    this.SetIconPath(mainNode.Image, false),
                    !string.IsNullOrEmpty(mainNode.ToolTip)
                                                            ? mainNode.ToolTip
                                                            : mainNode.Text,
                    !string.IsNullOrEmpty(mainNode.Text) ? mainNode.Text : "&nbsp;");
            }
            else
            {
                this.ctlModulMenuLink.Text = !string.IsNullOrEmpty(mainNode.Text) ? mainNode.Text : "&nbsp;";
            }

            if (mainNode.IsBreak)
            {
                this.ctlModulMenu.InnerHtml = "<hr />";
            }
            else
            {
                this.ctlModulMenu.Controls.Add(this.ctlModulMenuLink);
            }

            if (!mainNode.HasNodes)
            {
                return;
            }

            this.ctlModulMenu.Controls.Add(modulSubMenuUl);
            modulSubMenuUl.Attributes["class"] = mainNode.Text;

            foreach (DNNNode subNode in mainNode.DNNNodes)
            {
                this.RenderNode(subNode, modulSubMenuUl);
            }
        }
Exemple #28
0
 public NavigationEventArgs(string strID, DNNNode objNode)
 {
     ID   = strID;
     Node = objNode;
 }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Recursive function to add module's actions to the DNNNodeCollection based off of passed in ModuleActions
 /// </summary>
 /// <param name="parentAction">Parent action</param>
 /// <param name="parentNode">Parent node</param>
 /// <param name="rootNode">Root Node.</param>
 /// <param name="actionControl">ActionControl to base actions off of</param>
 /// <param name="intDepth">How many levels deep should be populated</param>
 /// <remarks>
 /// </remarks>
 /// <history>
 ///     [Jon Henning]	5/15/2006	Created
 /// </history>
 /// -----------------------------------------------------------------------------
 private static void AddChildActions(ModuleAction parentAction, DNNNode parentNode, DNNNode rootNode, IActionControl actionControl, int intDepth)
 {
     //Add Menu Items
     foreach (ModuleAction action in parentAction.Actions)
     {
         bool isActionPending = IsActionPending(parentNode, rootNode, intDepth);
         if (action.Title == "~")
         {
             if (isActionPending == false)
             {
                 //A title (text) of ~ denotes a break
                 parentNode.DNNNodes.AddBreak();
             }
         }
         else
         {
             //if action is visible and user has permission
             if (action.Visible &&
                 (action.Secure != SecurityAccessLevel.Anonymous ||
                  (!ModuleHost.IsViewMode(actionControl.ModuleControl.ModuleContext.Configuration, PortalSettings.Current)) &&
                  ModulePermissionController.HasModuleAccess(action.Secure, Null.NullString, actionControl.ModuleControl.ModuleContext.Configuration)))
             {
                 if (isActionPending)
                 {
                     parentNode.HasNodes = true;
                 }
                 else
                 {
                     int     i    = parentNode.DNNNodes.Add();
                     DNNNode node = parentNode.DNNNodes[i];
                     node.ID   = action.ID.ToString();
                     node.Key  = action.ID.ToString();
                     node.Text = action.Title; //no longer including SPACE in generic node collection, each control must handle how they want to display
                     if (string.IsNullOrEmpty(action.ClientScript) && string.IsNullOrEmpty(action.Url) && string.IsNullOrEmpty(action.CommandArgument))
                     {
                         node.Enabled = false;
                     }
                     else if (!string.IsNullOrEmpty(action.ClientScript))
                     {
                         node.JSFunction  = action.ClientScript;
                         node.ClickAction = eClickAction.None;
                     }
                     else
                     {
                         node.NavigateURL = action.Url;
                         if (action.UseActionEvent == false && !String.IsNullOrEmpty(node.NavigateURL))
                         {
                             node.ClickAction = eClickAction.Navigate;
                             if (action.NewWindow)
                             {
                                 node.Target = "_blank";
                             }
                         }
                         else
                         {
                             node.ClickAction = eClickAction.PostBack;
                         }
                     }
                     node.Image = action.Icon;
                     if (action.HasChildren()) //if action has children then call function recursively
                     {
                         AddChildActions(action, node, rootNode, actionControl, intDepth);
                     }
                 }
             }
         }
     }
 }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The BuildTree helper method is used to build the tree.
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// -----------------------------------------------------------------------------
        private void BuildTree(DNNNode objNode, bool blnPODRequest)
        {
            bool blnAddUpNode = false;
            DNNNodeCollection objNodes;

            objNodes = this.GetNavigationNodes(objNode);

            if (blnPODRequest == false)
            {
                if (!string.IsNullOrEmpty(this.Level))
                {
                    switch (this.Level.ToLowerInvariant())
                    {
                    case "root":
                        break;

                    case "child":
                        blnAddUpNode = true;
                        break;

                    default:
                        if (this.Level.ToLowerInvariant() != "root" && this.PortalSettings.ActiveTab.BreadCrumbs.Count > 1)
                        {
                            blnAddUpNode = true;
                        }

                        break;
                    }
                }
            }

            // add goto Parent node
            if (blnAddUpNode)
            {
                var objParentNode = new DNNNode();
                objParentNode.ID          = this.PortalSettings.ActiveTab.ParentId.ToString();
                objParentNode.Key         = objParentNode.ID;
                objParentNode.Text        = Localization.GetString("Parent", Localization.GetResourceFile(this, MyFileName));
                objParentNode.ToolTip     = Localization.GetString("GoUp", Localization.GetResourceFile(this, MyFileName));
                objParentNode.CSSClass    = this.NodeCssClass;
                objParentNode.Image       = this.ResolveUrl(this.TreeGoUpImage);
                objParentNode.ClickAction = eClickAction.PostBack;
                objNodes.InsertBefore(0, objParentNode);
            }

            foreach (DNNNode objPNode in objNodes) // clean up to do in processnodes???
            {
                this.ProcessNodes(objPNode);
            }

            this.Bind(objNodes);

            // technically this should always be a dnntree.  If using dynamic controls Nav.ascx should be used.  just being safe.
            if (this.Control.NavigationControl is DnnTree)
            {
                var objTree = (DnnTree)this.Control.NavigationControl;
                if (objTree.SelectedTreeNodes.Count > 0)
                {
                    var objTNode = (TreeNode)objTree.SelectedTreeNodes[1];
                    if (objTNode.DNNNodes.Count > 0) // only expand it if nodes are not pending
                    {
                        objTNode.Expand();
                    }
                }
            }
        }