Exemplo n.º 1
0
        //controller version
        public static string StaticPageActionUrl(StaticPageSection section)
        {
            string result = String.Empty;
            var urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext);

            switch (section)
            {
                case StaticPageSection.College:
                    result = urlHelper.Action("College", "Info");
                    break;
                case StaticPageSection.Abiturient:
                    result = urlHelper.Action("Abiturient", "Info");
                    break;
                case StaticPageSection.Student:
                    result = urlHelper.Action("Student", "Info");
                    break;
                case StaticPageSection.Methodical:
                    result = urlHelper.Action("MethodicalRoom", "Info");
                    break;
                case StaticPageSection.Library:
                    result = urlHelper.Action("Library", "Info");
                    break;
                case StaticPageSection.Contacts:
                    result = urlHelper.Action("Contacts", "Info");
                    break;
            }

            return result;
        }
Exemplo n.º 2
0
        public static IHtmlString GenerateSidebarMenuSection(this HtmlHelper html, StaticPageSection section, IEnumerable<StaticPageViewModel> staticPages, string currentPageKey = null)
        {
            var result = String.Empty;
            var urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext);
            foreach (var page in staticPages)
            {
                var listItem = new TagBuilder("li");
                var anchor = new TagBuilder("a");
                anchor.SetInnerText(page.Title);
                if (page.Key == currentPageKey && !page.SubPages.Any())
                    listItem.AddCssClass("active");
                else
                {
                    if(page.Key == currentPageKey && page.SubPages.Any())
                        anchor.AddCssClass("active");
                }

                string listContent = string.Empty;
                if (page.SubPages.Any())
                {
                    anchor.Attributes.Add("href", "#");
                    var image = new TagBuilder("img");
                    image.Attributes.Add("src", urlHelper.Content("~/Content/images/arrow.png"));
                    image.AddCssClass("arrow");
                    anchor.InnerHtml += image.ToString(TagRenderMode.SelfClosing);

                    anchor.AddCssClass("menu-acc");
                    listItem.AddCssClass("menu-acc-li");

                    var unorderedList = new TagBuilder("ul");
                    foreach (var subPage in page.SubPages)
                    {
                        var subListItem = new TagBuilder("li");
                        var subAnchor = new TagBuilder("a");

                        subAnchor.Attributes.Add("href", urlHelper.Action("Page", Enum.GetName(typeof(StaticPageSection), section), new { key = page.Key, subkey = subPage.Key }));
                        subAnchor.SetInnerText(subPage.Title);
                        subListItem.InnerHtml = subAnchor.ToString();
                        unorderedList.InnerHtml += subListItem.ToString();
                    }
                    listContent = unorderedList.ToString();
                }
                else
                    anchor.Attributes.Add("href", urlHelper.Action("Page", Enum.GetName(typeof(StaticPageSection), section), new { key = page.Key }));

                listItem.InnerHtml = anchor.ToString() + listContent;
                result += listItem.ToString();
            }
            return new MvcHtmlString(result);
        }
Exemplo n.º 3
0
        public static IHtmlString GenerateMenuSection(this HtmlHelper html, StaticPageSection section, IEnumerable<StaticPageViewModel> staticPages, bool isCurrent = false, string currentPage = null)
        {
            var result = String.Empty;
            var urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext);

            var mainListItem = new TagBuilder("li");
            if(isCurrent)
                mainListItem.AddCssClass("active");
            var mainAnchor = String.Format(@"<a href=""#"">{0}</a>", StaticPageSectionUtility.GetSectionDescription(section));

            var unorderedList = new TagBuilder("ul");
            foreach (var page in staticPages)
            {
                var innerListItem = new TagBuilder("li");
                var innerAnchor = new TagBuilder("a");
                innerAnchor.Attributes.Add("href", urlHelper.Action("Page", Enum.GetName(typeof(StaticPageSection), section), new { key = page.Key}));
                innerAnchor.SetInnerText(page.Title);
                innerListItem.InnerHtml = innerAnchor.ToString();

                if(page.SubPages.Any())
                {
                    var innerUnorderedList = new TagBuilder("ul");
                    foreach (var subPage in page.SubPages)
                    {
                        var subListItem = new TagBuilder("li");
                        var subAnchor = new TagBuilder("a");

                        subAnchor.Attributes.Add("href", urlHelper.Action("Page", Enum.GetName(typeof(StaticPageSection), section), new { key = page.Key, subkey = subPage.Key }));
                        subAnchor.SetInnerText(subPage.Title);
                        subListItem.InnerHtml = subAnchor.ToString();
                        innerUnorderedList.InnerHtml += subListItem.ToString();
                    }
                    innerListItem.InnerHtml += innerUnorderedList.ToString();
                }

                unorderedList.InnerHtml += innerListItem.ToString();
            }
            mainListItem.InnerHtml = mainAnchor + unorderedList;

            result = mainListItem.ToString();
            return new MvcHtmlString(result);
        }
Exemplo n.º 4
0
        public static IHtmlString GenerateSitemapSection(this HtmlHelper html, StaticPageSection section, IEnumerable<StaticPageViewModel> staticPages)
        {
            var result = String.Empty;
            var urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext);

            var div = new TagBuilder("div");
            div.AddCssClass("maps-point");
            var header = String.Format("<h4>{0}</h4>", StaticPageSectionUtility.GetSectionDescription(section));
            var unorderedList = new TagBuilder("ul");
            unorderedList.AddCssClass("maps-list");
            foreach (var page in staticPages)
            {
                var listItem = new TagBuilder("li");
                var anchor = new TagBuilder("a");
                anchor.Attributes.Add("href", urlHelper.Action("Page", Enum.GetName(typeof(StaticPageSection), section), new { key = page.Key}));
                anchor.SetInnerText(page.Title);

                listItem.InnerHtml = anchor.ToString();
                unorderedList.InnerHtml += listItem.ToString();
            }

            div.InnerHtml = header + unorderedList;
            result = div.ToString();

            return new MvcHtmlString(result);
        }
Exemplo n.º 5
0
 //HtmlHelper version (for Razor)
 public static string StaticPageActionUrl(this HtmlHelper html, StaticPageSection section)
 {
     return StaticPageActionUrl(section);
 }