예제 #1
0
 public System.Web.Mvc.ActionResult HttpPost(View.Page_Context context, View.PagePositionContext positionContext)
 {
     System.Web.Helpers.AntiForgery.Validate();
     string redirectUrl;
     context.ControllerContext.Controller.ViewBag.MembershipSuccess = RegisterCore(context.ControllerContext, null, out redirectUrl);
     if (!string.IsNullOrEmpty(redirectUrl))
     {
         return new RedirectResult(redirectUrl);
     }
     return null;
 }
예제 #2
0
        public System.Web.Mvc.ActionResult HttpGet(View.Page_Context context, View.PagePositionContext positionContext)
        {
            string redirectUrl;

            var isValid = ActivateCore(context.ControllerContext, null, out redirectUrl);

            if (isValid && !string.IsNullOrEmpty(redirectUrl))
            {
                return new RedirectResult(redirectUrl);
            }
            context.ControllerContext.Controller.ViewBag.MembershipSuccess = isValid;
            return null;
        }
예제 #3
0
파일: ViewTests.cs 프로젝트: Epitomy/CMS
        public void TestParseFromPhysicalPath()
        {
            string siteName     = "site1";
            string templateName = "template1";
            string physicalPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "sites", siteName, "templates", "views", templateName);

            var template = new Kooboo.CMS.Sites.Models.View(physicalPath);

            Assert.AreEqual(templateName, template.Name);
            Assert.IsTrue(template.IsDummy);

            Assert.IsTrue(template.Site.IsDummy);
            Assert.AreEqual(siteName, template.Site.Name);
        }
예제 #4
0
파일: ViewTests.cs 프로젝트: Epitomy/CMS
        public void TestVirtualPath()
        {
            string templateName = "template1";
            var site = new Site("Site1");
            var template = new Kooboo.CMS.Sites.Models.View(site, templateName);

            string expected1 = Kooboo.Web.Url.UrlUtility.Combine(site.VirtualPath, "templates", "views", templateName);

            Assert.AreEqual(expected1, template.VirtualPath, true);

            string expected2 = Kooboo.Web.Url.UrlUtility.Combine(expected1, "template.ascx");

            Assert.AreEqual(expected2, template.TemplateFileVirutalPath, true);
        }
예제 #5
0
        public System.Web.Mvc.ActionResult HttpPost(View.Page_Context context, View.PagePositionContext positionContext)
        {
            System.Web.Helpers.AntiForgery.Validate();

            var isValid = ChangePasswordCore(context.ControllerContext);
            var redirectUrl = MemberPluginHelper.GetReturnUrl(context.ControllerContext);

            if (isValid && !string.IsNullOrEmpty(redirectUrl))
            {
                return new RedirectResult(redirectUrl);
            }
            context.ControllerContext.Controller.ViewBag.MembershipSuccess = isValid;
            return null;
        }
예제 #6
0
파일: ViewTests.cs 프로젝트: Epitomy/CMS
        public void TestParseFromPhysicalPath()
        {
            string siteName = "site1";
            string templateName = "template1";
            string physicalPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "sites", siteName, "templates", "views", templateName);

            var template = new Kooboo.CMS.Sites.Models.View(physicalPath);

            Assert.AreEqual(templateName, template.Name);
            Assert.IsTrue(template.IsDummy);

            Assert.IsTrue(template.Site.IsDummy);
            Assert.AreEqual(siteName, template.Site.Name);
        }
예제 #7
0
파일: ViewTests.cs 프로젝트: Epitomy/CMS
        public void TestPhysicalPath()
        {
            string templateName = "template1";
            var    site         = new Site("Site1");
            var    template     = new Kooboo.CMS.Sites.Models.View(site, templateName);

            string expected1 = Path.Combine(site.PhysicalPath, "templates", "views", templateName);

            Assert.AreEqual(expected1, template.PhysicalPath, true);

            string expected2 = Path.Combine(expected1, "template.ascx");

            Assert.AreEqual(expected2, template.PhysicalTemplateFileName, true);
        }
예제 #8
0
        public System.Web.Mvc.ActionResult HttpPost(View.Page_Context context, View.PagePositionContext positionContext)
        {
            System.Web.Helpers.AntiForgery.Validate();
            ValidateMemberModel model;

            var isValid = LoginCore(context.ControllerContext, null, out model);

            if (isValid && !string.IsNullOrEmpty(model.RedirectUrl))
            {
                return new RedirectResult(model.RedirectUrl);
            }
            context.ControllerContext.Controller.ViewBag.MembershipSuccess = isValid;
            return null;
        }
예제 #9
0
파일: ViewTests.cs 프로젝트: Epitomy/CMS
        public void TestPhysicalPath()
        {
            string templateName = "template1";
            var site = new Site("Site1");
            var template = new Kooboo.CMS.Sites.Models.View(site, templateName);

            string expected1 = Path.Combine(site.PhysicalPath, "templates", "views", templateName);

            Assert.AreEqual(expected1, template.PhysicalPath, true);

            string expected2 = Path.Combine(expected1, "template.ascx");

            Assert.AreEqual(expected2, template.PhysicalTemplateFileName, true);
        }
예제 #10
0
파일: ViewTests.cs 프로젝트: Epitomy/CMS
        public void TestVirtualPath()
        {
            string templateName = "template1";
            var    site         = new Site("Site1");
            var    template     = new Kooboo.CMS.Sites.Models.View(site, templateName);


            string expected1 = Kooboo.Web.Url.UrlUtility.Combine(site.VirtualPath, "templates", "views", templateName);

            Assert.AreEqual(expected1, template.VirtualPath, true);

            string expected2 = Kooboo.Web.Url.UrlUtility.Combine(expected1, "template.ascx");

            Assert.AreEqual(expected2, template.TemplateFileVirutalPath, true);
        }
예제 #11
0
        /// <summary>
        /// Renders the view.
        /// </summary>
        /// <param name="viewName">Name of the view.</param>
        /// <param name="viewData">The view data.</param>
        /// <param name="parameters">The parameters.</param>
        /// <param name="executeDataRule">if set to <c>true</c> [execute data rule].</param>
        /// <returns></returns>
        public virtual IHtmlString RenderView(string viewName, ViewDataDictionary viewData, object parameters, bool executeDataRule)
        {
            Kooboo.CMS.Sites.Models.View view = Kooboo.CMS.Sites.Models.IPersistableExtensions.AsActual(new Kooboo.CMS.Sites.Models.View(this.PageContext.PageRequestContext.Site, viewName).LastVersion());

            if (view != null)
            {
                //backup the parent view context
                var parentPositionContext = PageContext.ViewDataContext;

                var parameters1 = parameters is IDictionary <string, object>?((IDictionary <string, object>)parameters) : new RouteValueDictionary(parameters);
                PageContext.ViewDataContext = new PagePositionContext(view, parameters1, viewData);

                if (executeDataRule)
                {
                    viewData = new ViewDataDictionary(viewData);
                    var pageRequestContext = this.PageContext.PageRequestContext;
                    if (view.DataRules != null)
                    {
                        var valueProvider = pageRequestContext.GetValueProvider();
                        valueProvider.Insert(0, new ViewParameterValueProvider(PageContext.ViewDataContext.Parameters));
                        var dataRuleContext = new DataRuleContext(pageRequestContext.Site, pageRequestContext.Page)
                        {
                            ValueProvider = valueProvider
                        };
                        DataRuleExecutor.Execute(viewData, dataRuleContext, view.DataRules);
                    }
                }

                var html = RenderViewInternal(this.Html, view.TemplateFileVirutalPath, viewData, null);


                if (PageContext.EnableTrace)
                {
                    html = new HtmlString(string.Format(GeneratedByViewComment, viewName, html.ToString()));
                }

                //restore the parent view context
                PageContext.ViewDataContext = parentPositionContext;

                return(html);
            }
            else
            {
                return(new HtmlString(""));
            }
        }
예제 #12
0
 protected abstract void BySchema(Page_Context pageContext, View.PagePositionContext positionContext, Repository repository, Schema schema);
예제 #13
0
 public System.Web.Mvc.ActionResult HttpGet(View.Page_Context context, View.PagePositionContext positionContext)
 {
     return null;
 }
예제 #14
0
 public System.Web.Mvc.ActionResult HttpPost(View.Page_Context context, View.PagePositionContext positionContext)
 {
     System.Web.Helpers.AntiForgery.Validate();
     return HttpGet(context, positionContext);
 }
예제 #15
0
 protected override void ByFolder(Page_Context pageContext, View.PagePositionContext positionContext, Repository repository, TextFolder folder)
 {
     string uuid = pageContext.ControllerContext.RequestContext.GetRequestValue("uuid");
     try
     {
         Content.Services.ServiceFactory.TextContentManager.Delete(repository, folder, uuid);
     }
     catch (RuleViolationException violationException)
     {
         violationException.FillIssues(positionContext == null ? pageContext.ControllerContext.Controller.ViewData.ModelState : positionContext.ViewData.ModelState);
     }
 }
예제 #16
0
        protected override void BySchema(Page_Context pageContext, View.PagePositionContext positionContext, Repository repository, Schema schema)
        {
            var httpContext = pageContext.ControllerContext.RequestContext.HttpContext;
            string uuid = pageContext.ControllerContext.RequestContext.GetRequestValue("uuid");

            try
            {
                Content.Services.ServiceFactory.TextContentManager.Update(repository, schema, uuid, httpContext.Request.Form
                    , httpContext.Request.Files, httpContext.User.Identity.Name);
            }
            catch (RuleViolationException violationException)
            {
                violationException.FillIssues(positionContext == null ? pageContext.ControllerContext.Controller.ViewData.ModelState : positionContext.ViewData.ModelState);
            }
        }
예제 #17
0
 protected abstract void ByFolder(Page_Context pageContext, View.PagePositionContext positionContext, Repository repository, TextFolder folder);
예제 #18
0
        /// <summary>
        /// <example>
        /// <div>
        //        <div>
        //    <form method="post">
        //    <input type="hidden" name="FolderName" value="news" />
        //    <input type="hidden" name="Published" value="true" />
        //    <input type="hidden" name="Categories[0].FolderName" value="<%: ViewBag.category.FolderName %>" />
        //    <input type="hidden" name="Categories[0].UUID" value="<%: ViewBag.category.UUID %>" />
        //    <table>
        //        <tr>
        //            <td>
        //                title:
        //            </td>
        //            <td>
        //                <input type="text" name="title" data-val-required="title is required" data-val="true" />
        //                <%: Html.ValidationMessageForInput("title") %>
        //            </td>
        //        </tr>
        //        <tr>
        //            <td>
        //                body:
        //            </td>
        //            <td>
        //                <textarea name="body" cols="20" rows="10"></textarea>
        //            </td>
        //        </tr>
        //    </table>
        //    <input type="submit" name="submit" value="submit" />
        //    </form>
        //</div>
        /// </example>
        /// </summary>
        /// <param name="pageContext"></param>
        /// <param name="repository"></param>
        /// <param name="folder"></param>
        protected override void ByFolder(Page_Context pageContext, View.PagePositionContext positionContext, Repository repository, TextFolder folder)
        {
            var httpContext = pageContext.ControllerContext.RequestContext.HttpContext;

            var categories = GetCategories("Categories", pageContext.ControllerContext);

            try
            {
                var parentFolder = httpContext.Request.Form["ParentFolder"];
                var parentUUID = httpContext.Request.Form["ParentUUID"];
                Content.Services.ServiceFactory.TextContentManager.Add(repository, folder, parentFolder, parentUUID,
                  httpContext.Request.Form, httpContext.Request.Files, categories, httpContext.User.Identity.Name);
            }
            catch (RuleViolationException violationException)
            {
                violationException.FillIssues(positionContext == null ? pageContext.ControllerContext.Controller.ViewData.ModelState : positionContext.ViewData.ModelState);
            }
        }
예제 #19
0
 public virtual System.Web.Mvc.ActionResult Execute(View.Page_Context pageContext, View.PagePositionContext positionContext)
 {
     return null;
 }
예제 #20
0
        public virtual System.Web.Mvc.ActionResult Execute(View.Page_Context pageContext, View.PagePositionContext positionContext)
        {
            var httpContext = pageContext.ControllerContext.RequestContext.HttpContext;

            if (httpContext.Request.HttpMethod.ToUpper() == "POST")
            {
                var site = pageContext.PageRequestContext.Site;

                var repository = site.GetRepository();
                if (repository == null)
                {
                    throw new SiteRepositoryNotExists();
                }
                var folderName = pageContext.ControllerContext.RequestContext.GetRequestValue("FolderName");
                if (!string.IsNullOrEmpty(folderName))
                {
                    var folder = FolderHelper.Parse<TextFolder>(repository, folderName);
                    ByFolder(pageContext, positionContext, repository, folder);
                }
                else
                {
                    var schemaName = pageContext.ControllerContext.RequestContext.GetRequestValue("SchemaName");
                    if (!string.IsNullOrEmpty(schemaName))
                    {
                        var schema = new Schema(repository, schemaName);

                        BySchema(pageContext, positionContext, repository, schema);
                    }
                }
            }

            return null;
        }
예제 #21
0
        protected override void ByFolder(Page_Context pageContext, View.PagePositionContext positionContext, Repository repository, TextFolder folder)
        {
            var httpContext = pageContext.ControllerContext.RequestContext.HttpContext;
            string uuid = pageContext.ControllerContext.RequestContext.GetRequestValue("uuid");

            var addCategories = GetCategories("AddCategories", pageContext.ControllerContext);
            var removeCategories = GetCategories("RemoveCategories", pageContext.ControllerContext);
            try
            {
                Content.Services.ServiceFactory.TextContentManager.Update(repository, folder, uuid, httpContext.Request.Form
                    , httpContext.Request.Files, DateTime.UtcNow, addCategories, removeCategories, httpContext.User.Identity.Name);
            }
            catch (RuleViolationException violationException)
            {
                violationException.FillIssues(positionContext == null ? pageContext.ControllerContext.Controller.ViewData.ModelState : positionContext.ViewData.ModelState);
            }
        }