예제 #1
0
 public ModuleUrlContext(PageRequestContext pageRequextContext, string moduleUrl, int moduleCount)
 {
     this.PageRequestContext = pageRequextContext;
     this.ModuleUrl          = moduleUrl;
     this.ModuleCountInPage  = moduleCount;
     ParseModuleRouteValues(moduleUrl);
 }
예제 #2
0
        public void InitContext(PageRequestContext pageRequestContext, ControllerContext controllerContext)
        {
            this.PageRequestContext = pageRequestContext;
            this.ControllerContext  = controllerContext;

            var page = pageRequestContext.Page.AsActual();

            this.PageLayout = page.Layout;
            if (page.EnableTheming)
            {
                this.PageTheme = pageRequestContext.Site.AsActual().Theme;
                if (string.IsNullOrEmpty(this.PageTheme))
                {
                    var themes = ServiceFactory.ThemeManager.GetDirectories(pageRequestContext.Site, "").ToArray();
                    if (themes.Length > 0)
                    {
                        this.PageTheme = themes.First().Name;
                    }
                }
            }

            // Enable by Model == Debug and url start with dev~
            this.EnableTrace = pageRequestContext.Site.Mode == ReleaseMode.Debug && pageRequestContext.RequestChannel == Web.FrontRequestChannel.Debug;

            this.Initialized = true;
        }
예제 #3
0
 public ModuleUrlContext(PageRequestContext pageRequextContext, string moduleUrl, int moduleCount)
 {
     this.PageRequestContext = pageRequextContext;
     this.ModuleUrl = moduleUrl;
     this.ModuleCountInPage = moduleCount;
     ParseModuleRouteValues(moduleUrl);
 }
예제 #4
0
        public static void InitPageContext(ControllerContext controllerContext)
        {
            if(Page_Context.Current.PageRequestContext == null)
            {
                var site = Site.Current;
                var page = ServiceFactory.PageManager.GetDefaultPage(site);
                var pageRequestContext = new PageRequestContext(
                        controllerContext,
                        site,
                        page,
                        site.FrontRequestChannel(),
                        "/");

                Page_Context.Current.InitContext(pageRequestContext, controllerContext);
                Page_Context.Current.DisableInlineEditing = true;
            }
        }
예제 #5
0
파일: Page_Context.cs 프로젝트: Epitomy/CMS
        public void InitContext(PageRequestContext pageRequestContext, ControllerContext controllerContext)
        {
            this.PageRequestContext = pageRequestContext;
            this.ControllerContext  = controllerContext;

            var page = pageRequestContext.Page.AsActual();

            this.PageLayout = page.Layout;
            if (page.EnableTheming)
            {
                this.PageTheme = pageRequestContext.Site.AsActual().Theme;
            }

            // Enable by Model == Debug and url start with dev~
            this.EnableTrace = pageRequestContext.Site.Mode == ReleaseMode.Debug && pageRequestContext.RequestChannel == Web.FrontRequestChannel.Debug;

            this.Initialized = true;
        }
예제 #6
0
        public virtual void ExecuteDataRules()
        {
            var pageViewData = ControllerContext.Controller.ViewData;

            var site = PageRequestContext.Site.AsActual();
            var page = PageRequestContext.Page.AsActual();

            var dataRuleContext = new DataRuleContext(PageRequestContext.Site, PageRequestContext.Page)
            {
                ValueProvider = PageRequestContext.GetValueProvider()
            };

            if (page.DataRules != null)
            {
                DataRuleExecutor.Execute(pageViewData, dataRuleContext, page.DataRules);
            }
            var viewPositions = page.PagePositions.Where(it => it is ViewPosition).OrderBy(it => it.Order);

            foreach (ViewPosition viewPosition in viewPositions)
            {
                var view = new Models.View(site, viewPosition.ViewName).LastVersion().AsActual();
                if (view != null)
                {
                    var positionViewData = (ViewDataDictionary)GetPositionViewData(viewPosition.PagePositionId).Merge(pageViewData);
                    var viewDataContext  = new PagePositionContext(view, viewPosition.ToParameterDictionary(), positionViewData);
                    var dataRules        = view.DataRules;
                    if (dataRules != null)
                    {
                        var valueProvider = PageRequestContext.GetValueProvider();
                        valueProvider.Insert(0, new ViewParameterValueProvider(viewDataContext.Parameters));
                        dataRuleContext.ValueProvider = valueProvider;
                        DataRuleExecutor.Execute(positionViewData, dataRuleContext, dataRules);
                    }
                    if (positionViewData.Model == null)
                    {
                        positionViewData.Model = positionViewData.Values.FirstOrDefault();
                    }
                    SetPositionViewData(viewPosition.PagePositionId, positionViewData);
                }
            }
        }
 public override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     base.OnActionExecuting(filterContext);
     var controllerContext = filterContext.Controller.ControllerContext;
     //
     var siteName = controllerContext.RequestContext.GetRequestValue("siteName");
     var site = new Kooboo.CMS.Sites.Models.Site(siteName);
     Kooboo.CMS.Sites.Models.Site.Current = site;
     //
     var pageName = controllerContext.RequestContext.GetRequestValue("pageName");
     Kooboo.CMS.Sites.Models.Page page = null;
     if (string.IsNullOrEmpty(pageName)) {
         page = Kooboo.CMS.Sites.Services.ServiceFactory.PageManager.All(site, string.Empty).First();
     } else {
         page = new Kooboo.CMS.Sites.Models.Page(site, pageName).LastVersion();
     }
     //
     var channel = Kooboo.CMS.Sites.Web.FrontRequestChannel.Unknown;
     var pageRequestContext = new PageRequestContext(controllerContext, site, page, channel, "");
     Page_Context.Current.InitContext(pageRequestContext, controllerContext);
 }
예제 #8
0
        public virtual ActionResult ViewEntry(string viewName)
        {
            viewName = Server.UrlDecode(viewName);
            var viewPosition = new ViewPosition()
            {
                LayoutPositionId = Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(5),
                ViewName = viewName,
                PagePositionId = Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(5)
            };
            //pageUrl: product/detail/product1
            var rawPage = new Page(Site, "____VisitViewPage_____") { IsDummy = false };
            rawPage.PagePositions.Add(viewPosition);

            var requestUrl = "";

            var pageRequestContext = new PageRequestContext(this.ControllerContext, FrontHttpRequest.RawSite, FrontHttpRequest.Site, rawPage, rawPage,
                FrontHttpRequest.RequestChannel, requestUrl);

            Page_Context.Current.InitContext(pageRequestContext, ControllerContext);

            var actionResult = Page_Context.Current.ExecutePlugins();
            if (actionResult != null)
            {
                return actionResult;
            }

            Page_Context.Current.ExecuteDataRules();

            var viewMock = new ViewMock() { ViewData = new ViewDataDictionary(ViewData) };
            ViewContext viewContext = new ViewContext(this.ControllerContext, viewMock, ViewData, this.TempData, Response.Output);

            HtmlHelper html = new HtmlHelper(viewContext, viewMock);

            return Content(html.FrontHtml().RenderView(viewPosition).ToString());
        }
예제 #9
0
 public ModuleUrlContext(PageRequestContext pageRequextContext, string moduleUrl)
 {
     this.PageRequestContext = pageRequextContext;
     this.ModuleUrl = moduleUrl;
     ParseModuleRouteValues(moduleUrl);
 }
예제 #10
0
        public void InitContext(PageRequestContext pageRequestContext, ControllerContext controllerContext)
        {
            this.PageRequestContext = pageRequestContext;
            this.ControllerContext = controllerContext;

            var page = pageRequestContext.Page.AsActual();
            this.PageLayout = page.Layout;
            if (page.EnableTheming)
            {
                this.PageTheme = pageRequestContext.Site.AsActual().Theme;
                if (string.IsNullOrEmpty(this.PageTheme))
                {
                    var themes = ServiceFactory.ThemeManager.GetDirectories(pageRequestContext.Site, "").ToArray();
                    if (themes.Length > 0)
                    {
                        this.PageTheme = themes.First().Name;
                    }
                }
            }

            // Enable by Model == Debug and url start with dev~
            this.EnableTrace = pageRequestContext.Site.Mode == ReleaseMode.Debug && pageRequestContext.RequestChannel == Web.FrontRequestChannel.Debug;

            this.Initialized = true;
        }
예제 #11
0
 public ModuleUrlContext(PageRequestContext pageRequextContext, string moduleUrl)
 {
     this.PageRequestContext = pageRequextContext;
     this.ModuleUrl          = moduleUrl;
     ParseModuleRouteValues(moduleUrl);
 }
예제 #12
0
파일: Page_Context.cs 프로젝트: Epitomy/CMS
        public void InitContext(PageRequestContext pageRequestContext, ControllerContext controllerContext)
        {
            this.PageRequestContext = pageRequestContext;
            this.ControllerContext = controllerContext;

            var page = pageRequestContext.Page.AsActual();
            this.PageLayout = page.Layout;
            if (page.EnableTheming)
            {
                this.PageTheme = pageRequestContext.Site.AsActual().Theme;
            }

            // Enable by Model == Debug and url start with dev~
            this.EnableTrace = pageRequestContext.Site.Mode == ReleaseMode.Debug && pageRequestContext.RequestChannel == Web.FrontRequestChannel.Debug;

            this.Initialized = true;
        }
예제 #13
0
 public FrontUrlHelper(PageRequestContext pageRequestContext, UrlHelper url)
 {
     this.PageRequestContext = pageRequestContext;
     this.Url = url;
 }
예제 #14
0
 public virtual void OnResolvedPage(ControllerContext controllerContext, PageRequestContext pageRequestContext)
 {
 }
예제 #15
0
 public FrontUrlHelper(PageRequestContext pageRequestContext, UrlHelper url)
 {
     this.PageRequestContext = pageRequestContext;
     this.Url = url;
 }
예제 #16
0
 internal static void OnResolvedPage(ControllerContext controllerContext, PageRequestContext pageRequestContext)
 {
     ExecuteModules((module) => module.OnResolvedPage(controllerContext, pageRequestContext));
 }