Ejemplo n.º 1
0
        public static MvcHtmlString PageName(this HtmlHelper helper, Page page)
        {
            var url = new UrlHelper(helper.ViewContext.RequestContext);

            switch (page.TypeId)
            {
                case 1:
                    return MvcHtmlString.Create(
                        string.Format("<a href='{0}'>{1}</a>",
                            url.Action("Index", "Pages", new
                            {
                                page.SectionId,
                                parentId = page.Id
                            }),
                            page.Name)
                    );
            }

            return MvcHtmlString.Create(page.Name);
        }
Ejemplo n.º 2
0
        private void AddCategoryPage(Page page)
        {
            int maxOrder = GetSession.Query<Page>()
                .Where(x => x.Parent.Id == page.Parent.Id && x.SectionId == page.SectionId)
                .Max(x => (int?)x.PageOrder) ?? 0;

            page.PageOrder = maxOrder + 1;
            page.IsInternal = true;
            page.UpdatedDate = DateTime.Now;

            GetSession.Save(page);

            //return RedirectToAction("Index", new { model.ParentId, model.SectionId });

        }
Ejemplo n.º 3
0
        private void AddCategory(string relativePath, int sectionId, Int64 parentId,
            string categoryTemplate, string categoryItemTemplate, bool root = false)
        {
            string filePath = this.Server.MapPath("~" + relativePath);
            string[] subFolders = Directory.GetDirectories(filePath);

            DirectoryInfo directoryInfo = new DirectoryInfo(filePath);
            Int64 pageId = parentId;

            // Ignore Root
            if (!root)
            {
                // Generate page
                //Page page = this.GetSession.QueryOver<Page>()
                //                    .Where(p => p.Id == parentId && p.Name == directoryInfo.Name)
                //                    .SingleOrDefault();

                //// Get page
                //if (page == null)
                //{
                Page page = new Page()
                {
                    SectionId = sectionId,
                    Name = directoryInfo.Name
                };
                //}

                page.Parent = GetSession.Get<Page>(parentId);

                FileInfo[] files = directoryInfo.GetFiles();
                if (files.Length > 0)
                {
                    // Generate Content
                    string content = (string)categoryTemplate.Clone();
                    StringBuilder sb = new StringBuilder();

                    foreach (FileInfo file in files)
                    {
                        sb.Append(categoryItemTemplate.Replace("%%FileUrl%%", (relativePath + "/" + file.Name).Replace("//", "/"))
                        .Replace("%%FileName%%", file.Name)
                        .Replace("%%FileDescription%%", String.Empty)
                        .Replace("%%FileDateTime%%", String.Empty));
                    }

                    content = categoryTemplate.Replace("%%Items%%", sb.ToString());
                    page.Content = content;

                    sb.Clear();
                }

                if (subFolders.Length > 1)
                {
                    page.TypeId = 1;
                }
                else
                {
                    page.TypeId = 2;
                }


                // Save Page
                AddCategoryPage(page);

                pageId = page.Id;
            }


            // Recursive sub folders
            foreach (string subFolder in subFolders)
            {
                directoryInfo = new DirectoryInfo(subFolder);

                AddCategory(relativePath + "/" + directoryInfo.Name, sectionId, pageId, categoryTemplate, categoryItemTemplate);
            }
        }
Ejemplo n.º 4
0
 public Page GetFirstPage(Page oPage)
 {
     if (oPage.Parent == null)
         return oPage;
     else
         return GetFirstPage(oPage.Parent);
 }
Ejemplo n.º 5
0
        public ActionResult RightMenu(Page currentPage)
        {
            Page pageToShow = GetFirstPage(currentPage);

            var items = GetSession.QueryOver<Page>()
                .Where(x => x.Parent.Id == pageToShow.Id)
                .OrderBy(x => x.PageOrder).Asc
                .List()
                .ByPermissions(HttpContext);
            return View(items);
        }
Ejemplo n.º 6
0
        public static MvcHtmlString BreadCrumbs(this HtmlHelper helper, Page page)
        {
            var theParent = page.Parent;
            
            if (page.Parent == null)
                return MvcHtmlString.Create(page.Name);

            if (page.Parent.IsActive == false)
            {
                if (page.Parent.Parent != null)
                {
                    theParent = page.Parent.Parent;
                }
                else
                {
                    return MvcHtmlString.Create(page.Name);
                }

            }
            return MvcHtmlString.Create(string.Format("<table cellspacing='0' cellpadding='0'><tr><td> <a href='/pages/show/{2}'>{0}</a></td><td> > </td><td>{1}</td></tr></table>",
                    helper.BreadCrumbs(theParent),
                    page.Name,
                    page.Parent.Id
                ));
   


           
        }
Ejemplo n.º 7
0
        public static MvcHtmlString PageLink(this HtmlHelper helper, Page page, string type = "nav")
        {
            var url = new UrlHelper(helper.ViewContext.RequestContext);



            if (type == "main-sub")
            {
                switch (page.TypeId)
                {
                    case 1:
                    case 2:
                        return MvcHtmlString.Create(
                                string.Format("<a id='{3}-menu-{2}' href='{0}'>{1}</a>",
                                    url.Action("Show", "Pages", new
                                    {
                                        page.Id
                                    }),
                                    page.Name,
                                    page.Id,
                                    type)
                            );
                    default:
                        return MvcHtmlString.Create(
                                string.Format("<a {4} id='{3}-menu-{2}' href='{0}'>{1}</a>",
                                    page.IsIFrame ? url.Action("Show", "Pages", new { page.Id }) : page.Url,
                                    page.Name,
                                    page.Id,
                                    type,
                                    page.IsBlank ? " target='_blank'" : "")
                            );
                }
            }


            switch (page.TypeId)
            {
                case 1:
                case 2:
                    return MvcHtmlString.Create(
                        string.Format("<a id='{3}-menu-{2}' href='{0}'>{1}</a>",
                            url.Action("Show", "Pages", new
                            {
                                page.Id
                            }),
                            page.Name,
                            page.Id,
                            type)
                    );

                default:
                    return MvcHtmlString.Create(
                        string.Format("<a{2} id='right-menu-{3}' href='{0}'>{1}</a>",
                        page.IsIFrame ? url.Action("Show", "Pages", new { page.Id }) : page.Url,
                            page.Name,
                            page.IsBlank ? " target='_blank'" : "",
                            page.Id
                        )
                    );
            }
        }