Ejemplo n.º 1
0
        private void BuildMenus()
        {
            ActionCollection allItems = (this.DataSource as ActionCollection);

            if (allItems == null)
            {
                if ((this.ParentAction == null) || (this.ParentAction.ActionType != ActionType.Page))
                {
                    return;
                }

                allItems = m_ParentAction.GetAvailableChildActions(m_ActionIdList, m_IsFrameworkAdmin, m_IsAuthenticated);

                bool flag = false;
                if (MasterPage != null)
                {
                    flag = (MasterPage.IsHomepage && ((!MasterPage.VisibleMainMenu) || allItems.Count == 0));
                }

                if (flag || (this.VisibleSiblingItems.HasValue && this.VisibleSiblingItems.Value))
                {
                    ActionCollection siblingActions = new ActionCollection();
                    foreach (Micajah.Common.Bll.Action item in ActionProvider.PagesAndControls.GetAvailableSiblingActions(m_ParentAction))
                    {
                        if (ActionProvider.ShowAction(item, m_ActionIdList, m_IsFrameworkAdmin, m_IsAuthenticated))
                        {
                            siblingActions.Add(item);
                        }
                    }
                    allItems.AddRange(siblingActions);
                }
            }

            if (allItems != null)
            {
                foreach (Micajah.Common.Bll.Action item in allItems)
                {
                    if (item.ShowInDetailMenu)
                    {
                        m_PrimaryMenuItems.Add(item);
                    }
                    else
                    {
                        m_OtherMenuItems.Add(item);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private Control CreateChildItems(Micajah.Common.Bll.Action item)
        {
            HtmlGenericControl div = null;

            if (item.ShowChildrenInDetailMenu)
            {
                ActionCollection availableChildActions = item.GetAvailableChildActions(m_ActionIdList, m_IsFrameworkAdmin, m_IsAuthenticated);
                if (availableChildActions.Count > 0)
                {
                    ControlList list = null;
                    try
                    {
                        div = new HtmlGenericControl("div");
                        div.Attributes["class"] = "C";
                        list           = new ControlList();
                        list.Delimiter = ", ";

                        foreach (Micajah.Common.Bll.Action childItem in availableChildActions)
                        {
                            if (list.Count < MaxChildItems)
                            {
                                list.Add(CreateItemLink(childItem));
                            }
                            else
                            {
                                list.Add(CreateItemLink(item, Resources.DetailMenu_Ellipsis, false));
                                break;
                            }
                        }

                        div.Controls.Add(list);
                    }
                    finally
                    {
                        if (div != null)
                        {
                            div.Dispose();
                        }
                        if (list != null)
                        {
                            list.Dispose();
                        }
                    }
                }
            }
            return(div);
        }
Ejemplo n.º 3
0
        private bool FindWarningMessage(Micajah.Common.Bll.Action action)
        {
            ActionCollection accColl = action.GetAvailableChildActions(Micajah.Common.Security.UserContext.Current.ActionIdList, false, true);

            foreach (Micajah.Common.Bll.Action act in accColl)
            {
                if (act.Description == "DispayAsWarningMessage")
                {
                    if ((m_StartMenuCheckedItems != null) && m_StartMenuCheckedItems.Contains(act.ActionId))
                    {
                        ((Micajah.Common.Pages.MasterPage)Page.Master).MessageType = NoticeMessageType.Warning;
                        ((Micajah.Common.Pages.MasterPage)Page.Master).Message     = act.CustomName;
                    }
                    return(true);
                }
                if (FindWarningMessage(act))
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates the global navigation links.
        /// </summary>
        /// <param name="isSecureConnection">The flag indicating whether the HTTP connection uses secure sockets.</param>
        /// <returns>The control that represents the global navigation links.</returns>
        private Control CreateGlobalNavigation(bool isSecureConnection)
        {
            ControlList        links = null;
            HyperLink          link  = null;
            HyperLink          link2 = null;
            HtmlGenericControl ul    = null;
            HtmlGenericControl ul2   = null;
            HtmlGenericControl li    = null;
            HtmlGenericControl li2   = null;

            try
            {
                if (m_ModernTheme)
                {
                    ul = new HtmlGenericControl("ul");
                    ul.Attributes["class"] = "nav pull-right";
                }
                else
                {
                    links = new ControlList();
                }

                Micajah.Common.Bll.ActionCollection items = ActionProvider.GlobalNavigationLinks.FindByActionId(ActionProvider.GlobalNavigationLinksActionId).GetAvailableChildActions(m_ActionIdList, m_IsFrameworkAdmin, m_IsAuthenticated);

                if (m_ModernTheme)
                {
                    li = (HtmlGenericControl)CreateApplicationLogoListItem("Al");

                    ul.Controls.Add(li);
                }
                else
                {
                    Micajah.Common.Bll.Action item = items.FindByActionId(ActionProvider.MyAccountMenuGlobalNavigationLinkActionId);

                    if (item != null)
                    {
                        Micajah.Common.Bll.ActionCollection items2 = item.GetAvailableChildActions(m_ActionIdList, m_IsFrameworkAdmin, m_IsAuthenticated);

                        items.AddRange(items2);

                        items.Sort();
                    }
                }

                foreach (Micajah.Common.Bll.Action item in items)
                {
                    link             = new HyperLink();
                    link.NavigateUrl = item.CustomAbsoluteNavigateUrl;
                    link.ToolTip     = item.Description;

                    if (m_ModernTheme)
                    {
                        li = new HtmlGenericControl("li");

                        string iconUrl  = null;
                        string text     = item.CustomName;
                        string cssClass = "Icon";

                        if (item.ActionId == ActionProvider.MyAccountMenuGlobalNavigationLinkActionId)
                        {
                            iconUrl = string.Format(CultureInfo.InvariantCulture, "{0}{1}www.gravatar.com/avatar/{2}?s=24"
                                                    , (isSecureConnection ? Uri.UriSchemeHttps : Uri.UriSchemeHttp), Uri.SchemeDelimiter, Support.CalculateMD5Hash(m_UserContext.Email.ToLowerInvariant()));

                            cssClass += " Avtr";
                        }
                        else
                        {
                            if (item.ActionId == ActionProvider.PageHelpGlobalNavigationLinkActionId)
                            {
                                if (!m_MasterPage.VisibleHelpLink)
                                {
                                    continue;
                                }

                                link.Attributes["onclick"] = m_MasterPage.HelpLinkOnClick;
                            }

                            if (!string.IsNullOrEmpty(item.IconUrl))
                            {
                                iconUrl = item.IconUrl;
                                if (iconUrl.IndexOf("glyphicon", StringComparison.OrdinalIgnoreCase) == -1)
                                {
                                    iconUrl = CustomUrlProvider.CreateApplicationAbsoluteUrl(iconUrl);
                                }
                                else
                                {
                                    using (Label label = new Label())
                                    {
                                        label.CssClass = "glyphicon " + iconUrl;

                                        if (string.IsNullOrEmpty(text))
                                        {
                                            label.CssClass += " no-margin";
                                        }

                                        link.Controls.Add(label);
                                    }

                                    iconUrl = null;
                                }
                            }
                        }

                        if (!string.IsNullOrEmpty(iconUrl))
                        {
                            using (Image image = new Image())
                            {
                                image.ImageUrl = iconUrl;
                                image.CssClass = cssClass;

                                link.Controls.Add(image);
                            }
                        }

                        if (!string.IsNullOrEmpty(text))
                        {
                            using (LiteralControl literal = new LiteralControl(text))
                            {
                                link.Controls.Add(literal);
                            }
                        }

                        li.Controls.Add(link);
                        ul.Controls.Add(li);

                        ActionCollection childActions = item.GetAvailableChildActions(m_ActionIdList, m_IsFrameworkAdmin, m_IsAuthenticated);
                        if (childActions.Count > 0)
                        {
                            link.CssClass = "dropdown-toggle";
                            link.Attributes["data-toggle"] = "dropdown";

                            using (Label label = new Label())
                            {
                                label.CssClass = "caret";
                                link.Controls.Add(label);
                            }

                            ul2 = new HtmlGenericControl("ul");
                            ul2.Attributes["class"] = "dropdown-menu blue";

                            foreach (Micajah.Common.Bll.Action item2 in childActions)
                            {
                                li2 = new HtmlGenericControl("li");

                                link2             = new HyperLink();
                                link2.Text        = item2.CustomName;
                                link2.NavigateUrl = item2.CustomAbsoluteNavigateUrl;
                                link2.ToolTip     = item2.Description;

                                li2.Controls.Add(link2);
                                ul2.Controls.Add(li2);
                            }

                            li.Attributes["class"] = "dropdown";
                            li.Controls.Add(ul2);
                        }
                    }
                    else
                    {
                        if (item.ActionId == ActionProvider.MyAccountMenuGlobalNavigationLinkActionId)
                        {
                            if ((m_UserContext != null) && (m_UserContext.OrganizationId == Guid.Empty))
                            {
                                continue;
                            }
                        }

                        link.Text = item.CustomName;

                        links.Add(link);
                    }
                }

                if (m_ModernTheme)
                {
                    return(ul);
                }
                else
                {
                    return((links.Count > 0) ? links : null);
                }
            }
            finally
            {
                if (ul2 != null)
                {
                    ul2.Dispose();
                }
                if (li2 != null)
                {
                    li2.Dispose();
                }
                if (ul != null)
                {
                    ul.Dispose();
                }
                if (li != null)
                {
                    li.Dispose();
                }
                if (link != null)
                {
                    link.Dispose();
                }
                if (links != null)
                {
                    links.Dispose();
                }
            }
        }