Exemplo n.º 1
0
        public override void ExecuteResult(ControllerContext context)
        {
            string siteName = context.HttpContext.Request.QueryString["cms_siteName"];
            string pageName = context.HttpContext.Request.QueryString["cms_pageName"];

            if (string.IsNullOrEmpty(siteName) || string.IsNullOrEmpty(pageName))
            {
                context.HttpContext.Response.StatusCode = 404;
                return;
            }
            var site = new Site(siteName).AsActual();
            if (site == null)
            {
                context.HttpContext.Response.StatusCode = 404;
                return;
            }
            var page = new Page(site, pageName).AsActual();
            if (page == null || page.PagePositions == null)
            {
                context.HttpContext.Response.StatusCode = 404;
                return;
            }
            var proxyPosition = page.PagePositions.OfType<ProxyPosition>().FirstOrDefault();
            if (proxyPosition == null)
            {
                context.HttpContext.Response.StatusCode = 404;
                return;
            }
            var remoteUrl = context.HttpContext.Request.RawUrl;
            var content = _proxyRender.Render(new ProxyRenderContext(context, null, proxyPosition, remoteUrl));
            if (content != null && !string.IsNullOrEmpty(content.ToString()))
            {
                context.HttpContext.Response.Write(content.ToString());
            }
        }
Exemplo n.º 2
0
        public PageMenuItem(Page page)
        {
            base.Action = "Index";
            base.Controller = "Page";
            base.Area = "Sites";
            base.Text = page.Name;
            if (page.Navigation != null && !string.IsNullOrEmpty(page.Navigation.DisplayText))
            {
                base.Text = page.Navigation.DisplayText;
            }
            base.Tips = page.Name;

            base.Visible = true;
            RouteValues = new System.Web.Routing.RouteValueDictionary();
            RouteValues.Add("parentPage", page.FullName);

            HtmlAttributes = new System.Web.Routing.RouteValueDictionary();
            if (page.IsDefault)
            {
                HtmlAttributes.Add("class", "home");
            }

            //this.Page = page;
            Initializer = new PageMenuItemInitializer();
        }
Exemplo n.º 3
0
        public string GetModulePositionIdForUrl(ModulePosition modulePosition, RouteValueDictionary routeValues, out Page page)
        {
            page = this.PageRequestContext.Page;
            string modulePositionId = modulePosition.PagePositionId;

            if (!string.IsNullOrEmpty(modulePosition.Entry.LinkToEntryName))
            {
                foreach (var item in Kooboo.CMS.Sites.Services.ServiceFactory.PageManager.All(this.PageRequestContext.Site, null))
                {
                    foreach (var position in item.PagePositions.OfType<ModulePosition>())
                    {
                        if (position.Entry != null && !string.IsNullOrEmpty(position.Entry.Name)
                            && position.Entry.Name.EqualsOrNullEmpty(modulePosition.Entry.LinkToEntryName, StringComparison.OrdinalIgnoreCase))
                        {
                            page = item;
                            modulePositionId = position.PagePositionId;
                        }
                    }
                }
            }
            else
            {
                modulePositionId = GetModulePositionIdForUrl(modulePosition.ModuleName, modulePosition.PagePositionId, routeValues);
            }

            return modulePositionId;
        }
Exemplo n.º 4
0
 public virtual void AddCaching(HttpContextBase httpContext, Page page, string html)
 {
     var filePath = GetFilePath(page, httpContext.Request.Path);
     if (!File.Exists(filePath))
     {
         IOUtility.SaveStringToFile(filePath, html);
     }
 }
Exemplo n.º 5
0
 public static string GetAbsolutePageUrl(Site site, Page page, object values)
 {
     UrlHelper urlHelper = MvcUtility.GetUrlHelper();
     FrontRequestChannel requestChannel = site.FrontRequestChannel();
     string pageUrl = FrontUrlHelper.GeneratePageUrl(urlHelper, site, page, values, requestChannel).ToString();
     string host = GetHost(site);
     return HttpContext.Current.Request.ToAbsoluteUrl(host, pageUrl);
 }
Exemplo n.º 6
0
 protected override void CreateSelectItemTreeNode(RequestContext requestContext, Page page, List<System.Web.Mvc.SelectListItem> list)
 {
     string uuid = requestContext.GetRequestValue("UUID");
     if (uuid.ToLower() != page.UUID.ToLower())
     {
         base.CreateSelectItemTreeNode(requestContext,page, list);
     }
 }
Exemplo n.º 7
0
 private void GetPageItems(Page page, List<SelectListItem> items)
 {
     items.Add(new SelectListItem() { Text = page.FriendlyName, Value = page.FriendlyName });
     foreach (var child in Kooboo.CMS.Sites.Persistence.Providers.PageProvider.ChildPages(page))
     {
         GetPageItems(child, items);
     }
 }
Exemplo n.º 8
0
 protected virtual string GetFilePath(Page page, string requestPath)
 {
     requestPath = requestPath.TrimEnd('/');
     var extension = Path.GetExtension(requestPath);
     if (string.IsNullOrEmpty(extension))
     {
         requestPath = requestPath + "/default.html";
     }
     return Path.Combine(GetPageCachingPath(page), requestPath.TrimStart('/'));
 }
Exemplo n.º 9
0
 protected virtual void EnsurePagePublished(Controller controller, Page page)
 {
     if (page.Published.Value == false)
     {
         if (!HttpContext.Current.User.Identity.IsAuthenticated)
         {
             throw new HttpException(0x194, string.Format(SR.GetString("Path_not_found"), new object[] { controller.Request.Path }));
         }
     }
 }
Exemplo n.º 10
0
 public virtual string GetCaching(HttpContextBase httpContext, Page page)
 {
     string html = null;
     var filePath = GetFilePath(page, httpContext.Request.Path);
     if (File.Exists(filePath))
     {
         html = IOUtility.ReadAsString(filePath);
     }
     return html;
 }
Exemplo n.º 11
0
        public void TestPhysicalPath()
        {
            string pageName = "page1";
            var site = new Site("Site1");
            var page = new Page(site, new string[] { pageName });

            string expected1 = Path.Combine(site.PhysicalPath, "pages", pageName);

            Assert.AreEqual(expected1, page.PhysicalPath, true);
        }
Exemplo n.º 12
0
        public void TestParseFromPhysicalPath()
        {
            string siteName = "site1";
            string pageName = "page1";
            string physicalPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "sites", siteName, "pages", pageName);

            var page = new Page(physicalPath);

            Assert.AreEqual(pageName, page.Name);
            Assert.IsTrue(page.IsDummy);
        }
Exemplo n.º 13
0
        private void GenerateList(Site site, Page page, ref IEnumerable<Page> pageList)
        {
            var children = Kooboo.CMS.Sites.Services.ServiceFactory.PageManager.ChildPages(site, page.FullName, null);

            pageList = pageList.Concat(children);

            foreach (var s in children)
            {
                this.GenerateList(site, s, ref pageList);
            }
        }
Exemplo n.º 14
0
        public string UpdatePage(string repositoryId, string pageId, Page properties)
        {
            var site = ModelHelper.GetSite(repositoryId);

            var page = new Page(site, pageId);

            MapProperties(properties, page);

            _incomeDataManager.UpdatePage(site, page, ContextHelper.GetVendor());

            return page.FullName;
        }
Exemplo n.º 15
0
        public void TestChildVirtualPath()
        {
            string parentPageName = "page1";
            var site = new Site("Site1");
            var parent = new Page(site, new string[] { parentPageName });
            string childPageName = "childPage";
            var child = new Page(parent, childPageName);

            string expected1 = "page1/childPage";// Kooboo.Web.Url.UrlUtility.Combine(site.VirtualPath, "pages", parentPageName, childPageName);

            Assert.AreEqual(expected1, child.VirtualPath, true);
        }
Exemplo n.º 16
0
        public void TestChildPhysicalPath()
        {
            string parentPageName = "page1";
            var site = new Site("Site1");
            var parent = new Page(site, new string[] { parentPageName });
            string childPageName = "childPage";
            var child = new Page(parent, childPageName);

            string expected1 = Path.Combine(site.PhysicalPath, "pages", parentPageName, childPageName);

            Assert.AreEqual(expected1, child.PhysicalPath, true);
        }
Exemplo n.º 17
0
        public static Page Copy(this Page page)
        {
            //var tempPage = CloneUtility.DeepClone(page);
            var tempPage = new Page();
            tempPage.Name = page.Name;
            tempPage.FullName = page.FullName;
            tempPage.ContentTitle = page.ContentTitle;

            tempPage.Layout = page.Layout;
            tempPage.PagePositions = page.PagePositions;
            tempPage.EnableTheming = page.EnableTheming;
            tempPage.EnableScript = page.EnableScript;
            tempPage.Searchable = page.Searchable;
            tempPage.OutputCache = page.OutputCache;
            tempPage.PageType = page.PageType;
            tempPage.IsDefault = page.IsDefault;
            tempPage.IsDummy = page.IsDummy;

            tempPage.Navigation = new Navigation();
            tempPage.Navigation.Show = page.Navigation.Show;
            tempPage.Navigation.DisplayText = page.Navigation.DisplayText;
            tempPage.Navigation.Order = page.Navigation.Order;
            tempPage.Navigation.ShowInCrumb = page.Navigation.ShowInCrumb;

            tempPage.HtmlMeta = page.HtmlMeta;
            //tempPage.Route = page.Route;
            tempPage.Route = new PageRoute();
            tempPage.Route.ExternalUrl = page.Route.ExternalUrl;
            tempPage.Route.Identifier = page.Route.Identifier;
            tempPage.Route.RoutePath = page.Route.RoutePath;
            tempPage.Route.Defaults = page.Route.Defaults;

            tempPage.DataRules = page.DataRules;
            tempPage.Plugins = page.Plugins;
            //tempPage.CustomFields = page.CustomFields;
            tempPage.CustomFields = new Dictionary<string, string>();
            if(page.CustomFields != null)
            {
                foreach(var customField in page.CustomFields)
                {
                    tempPage.CustomFields.Add(customField.Key, customField.Value);
                }
            }

            tempPage.Published = page.Published;
            tempPage.Site = page.Site;
            tempPage.Parent = page.Parent;
            tempPage.Permission = page.Permission;
            tempPage.UserName = page.UserName;

            return tempPage;
        }
Exemplo n.º 18
0
        protected virtual void CreateSelectItemTreeNode(RequestContext requestContext, Page page, List<SelectListItem> list)
        {
            var item = new SelectListItem();
            item.Text = page.FriendlyName;
            item.Value = page.FullName;
            list.Add(item);

            var children = ServiceFactory.PageManager.ChildPages(Site.Current, page.FullName, null);

            children.ForEach((p, index) =>
            {
                CreateSelectItemTreeNode(requestContext, p, list);
            });
        }
Exemplo n.º 19
0
 public static IEnumerable<Page> Sibling(Page page)
 {
     if (page.Parent == null)
     {
         return Top();
     }
     else
     {
         return ServiceFactory.PageManager.ChildPages(Site.Current, page.Parent.FullName, "")
             .Select(it => it.AsActual())
             .Where(it => it.Navigation.Show)
             .Where(it => it.Published.HasValue && it.Published.Value == true)
             .OrderBy(it => it.Navigation.Order);
     }
 }
Exemplo n.º 20
0
 public static bool IsCurrent(Page page)
 {
     var isCurrent = false;
     var currentPage = Page_Context.Current.PageRequestContext.Page;
     while (isCurrent == false && currentPage != null)
     {
         isCurrent = currentPage == page;
         if (isCurrent == true)
         {
             return isCurrent;
         }
         currentPage = currentPage.Parent;
     }
     return isCurrent;
 }
Exemplo n.º 21
0
        public ActionResult Discard(string uuid, string @return)
        {
            ModelState.Clear();
            var data = new JsonResultData(ModelState);
            data.RunWithTry((resultData) =>
            {
                var page = new Page(Site, uuid);

                _pageManager.Provider.RemoveDraft(page);

                data.RedirectUrl = @return;
            });

            return Json(data);
        }
Exemplo n.º 22
0
        public virtual string GetCaching(HttpContextBase httpContext, Page page)
        {
            string html = null;
            var filePath = GetFilePath(page, httpContext.Request.Path);
            if (File.Exists(filePath))
            {
                var expired = false;
                if (page.OutputCache != null && page.OutputCache.Duration != 0)
                {
                    DateTime cacheTime = DateTime.Now;
                    switch (page.OutputCache.ExpirationPolicy)
                    {
                        case ExpirationPolicy.AbsoluteExpiration:
                            cacheTime = File.GetCreationTime(filePath);
                            break;
                        case ExpirationPolicy.SlidingExpiration:
                            cacheTime = File.GetLastAccessTime(filePath);
                            break;
                    }

                    expired = (DateTime.Now - cacheTime).TotalSeconds > page.OutputCache.Duration;
                }

                try
                {
                    if (File.Exists(filePath))
                    {
                        if (expired == true)
                        {

                            File.Delete(filePath);
                        }
                        else
                        {
                            html = IOUtility.ReadAsString(filePath);
                        }
                    }
                }
                catch (Exception e)
                {
                    Kooboo.HealthMonitoring.Log.LogException(e);
                }

            }
            return html;
        }
Exemplo n.º 23
0
        public static IHtmlString GeneratePageUrl(UrlHelper urlHelper, Site site, Page page, object values, FrontRequestChannel channel)
        {
            RouteValueDictionary routeValues = RouteValuesHelpers.GetRouteValues(values);

            page = page.AsActual();

            if (page == null)
            {
                return new HtmlString("");
            }
            if (page.Route != null && !string.IsNullOrEmpty(page.Route.ExternalUrl))
            {
                return new HtmlString(page.Route.ExternalUrl);
            }

            var pageRoute = page.Route.ToMvcRoute();

            routeValues = RouteValuesHelpers.MergeRouteValues(pageRoute.Defaults, routeValues);

            var routeVirtualPath = pageRoute.GetVirtualPath(urlHelper.RequestContext, routeValues);
            if (routeVirtualPath == null)
            {
                throw new InvalidPageRouteException(page);
            }
            //string contentUrl = routeVirtualPath.VirtualPath;//don't decode the url. why??
            //if do not decode the url, the route values contains Chinese character will cause bad request.
            string contentUrl = HttpUtility.UrlDecode(routeVirtualPath.VirtualPath);
            string pageUrl = contentUrl;
            if (!string.IsNullOrEmpty(contentUrl) || (string.IsNullOrEmpty(pageUrl) && !page.IsDefault))
            {
                pageUrl = Kooboo.Web.Url.UrlUtility.Combine(page.VirtualPath, contentUrl);
            }
            if (string.IsNullOrEmpty(pageUrl))
            {
                pageUrl = urlHelper.Content("~/");
            }
            else
            {
                pageUrl = HttpUtility.UrlDecode(
                urlHelper.RouteUrl("Page", new { PageUrl = new HtmlString(pageUrl) }));
            }
            var url = FrontUrlHelper.WrapperUrl(pageUrl, site, channel, page.RequireHttps);

            return url;
        }
Exemplo n.º 24
0
        private void PublishSitePages(Site site)
        {
            var queue = ServiceFactory.PageManager.PagePublishingProvider.All(site).Select(it => it.AsActual());
            foreach (var item in queue)
            {
                var removeQueueItem = false;
                var page = new Page(site, item.PageName).AsActual();
                if (page != null)
                {
                    if (DateTime.UtcNow > item.UtcDateToPublish)
                    {
                        if (page.Published == false)
                        {
                            ServiceFactory.PageManager.Publish(page, item.PublishDraft, item.UserName);
                            removeQueueItem = true;
                        }

                        if (item.Period)
                        {
                            removeQueueItem = false;
                            if (DateTime.UtcNow > item.UtcDateToOffline)
                            {
                                if (page.Published == true)
                                {
                                    ServiceFactory.PageManager.Unpublish(page, item.UserName);
                                    removeQueueItem = true;
                                }
                            }
                        }
                    }
                }
                else
                {
                    removeQueueItem = true;
                }
                if (removeQueueItem)
                {
                    ServiceFactory.PageManager.PagePublishingProvider.Remove(item);
                }
            }
        }
Exemplo n.º 25
0
        protected override void CreateSelectItemTreeNode(RequestContext requestContext, Page page, List<System.Web.Mvc.SelectListItem> list)
        {
            string uuid = requestContext.GetRequestValue("UUID");
            var sourcePage = new Page(page.Site, uuid);

            var item = new SelectListItem();

            if (sourcePage != page && sourcePage.Parent != page)
            {
                item.Text = page.FriendlyName;
                item.Value = page.FullName;
                list.Add(item);
            }

            var children = ServiceFactory.PageManager.ChildPages(Site.Current, page.FullName, null);

            children.ForEach((p, index) =>
            {
                CreateSelectItemTreeNode(requestContext, p, list);
            });
        }
        public string AddPage(Site site, Page page, string vendor)
        {
            IncomingQueue incomeQueue = new IncomingQueue()
            {
                Message = null,
                Object = page,
                ObjectUUID = page.FullName,
                ObjectTitle = page.FullName,
                Vendor = vendor,
                PublishingObject = PublishingObject.Page,
                Action = PublishingAction.Publish,
                SiteName = site.FullName,
                Status = QueueStatus.Pending,
                UtcCreationDate = DateTime.UtcNow,
                UtcProcessedTime = null,
                UUID = Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(10)
            };
            _incomeQueueProvider.Add(incomeQueue);

            return page.FullName;
        }
Exemplo n.º 27
0
 private static void MapProperties(Page properties, Page page)
 {
     page.IsDefault = properties.IsDefault;
     page.EnableTheming = properties.EnableTheming;
     page.EnableScript = properties.EnableScript;
     page.HtmlMeta = properties.HtmlMeta;
     page.Route = properties.Route;
     page.Navigation = properties.Navigation;
     page.Permission = properties.Permission;
     page.Layout = properties.Layout;
     page.PagePositions = properties.PagePositions;
     page.DataRules = properties.DataRules;
     page.Plugins = properties.Plugins;
     page.PageType = properties.PageType;
     page.OutputCache = properties.OutputCache;
     page.CustomFields = properties.CustomFields;
     page.Published = properties.Published;
     page.UserName = properties.UserName;
     page.ContentTitle = properties.ContentTitle;
     page.Searchable = properties.Searchable;
     page.RequireHttps = properties.RequireHttps;
     page.CacheToDisk = properties.CacheToDisk;
 }
Exemplo n.º 28
0
 public static Page Parent(Page page)
 {
     return page.Parent.AsActual();
 }
Exemplo n.º 29
0
 private static bool ShowInMenu(Page page)
 {
     var show = page.Published.HasValue && page.Published.Value == true;
     if (show == true)
     {
         show = page.Navigation.Show;
     }
     if (show == true)
     {
         var permission = page.Permission;
         if (permission != null && permission.AuthorizeMenu)
         {
             show = permission.Authorize(Page_Context.Current.ControllerContext.HttpContext.Membership().GetMember());
         }
     }
     return show;
 }
Exemplo n.º 30
0
 public static IEnumerable<Page> Sub(Page page)
 {
     return ServiceFactory.PageManager.ChildPages(Site.Current, page.FullName, "")
         .Select(it => it.AsActual())
         .Where(it => ShowInMenu(it))
         .OrderBy(it => it.Navigation.Order);
 }
Exemplo n.º 31
0
        public void DeletePage(Site site, string pageId, string vendor)
        {
            var page = new Kooboo.CMS.Sites.Models.Page(site, pageId);

            _pageManager.Remove(site, page);
        }