コード例 #1
0
ファイル: BackendController.cs プロジェクト: larswise/rCMS
        public ActionResult PageEditor(ZCMSContent<ZCMSPage> page)
        {
            if (Request.Form["delete-page"] != null && Request.Form["delete-page"] == "true")
            {
                _worker.CmsContentRepository.DeleteCmsPage(page.Instance);
                return RedirectToAction("DashBoard");
            }

            TryValidateModel(page.Instance);
            //var validato = new ZCMSModelValidatorProvider();
            //validato.GetValidators(
            ZCMSPage ravenPage = _worker.CmsContentRepository.GetCmsPage(page.Instance.PageID.ToString()).Instance;
            if (ModelState.IsValid)
            {
                if (ravenPage != null)
                {
                    ravenPage.PageID = page.Instance.PageID;
                    ravenPage.PageName = page.Instance.PageName;
                    _worker.CmsContentRepository.SetPermissionsForPage(ravenPage, Request.Form["Permissions"].ToString());
                    for (int i = 0; i < ravenPage.Properties.Count; i++)
                    {
                        if (!(ravenPage.Properties[i] is ImageListProperty))
                            ravenPage.Properties[i] = page.Instance.Properties[i];
                    }

                    ravenPage.LastModified = DateTime.Now;
                    ravenPage.LastChangedBy = _worker.AuthenticationRepository.GetCurrentUserName();
                    ravenPage.Status = page.Instance.Status;
                    ravenPage.StartPublish = page.Instance.StartPublish;
                    ravenPage.EndPublish = page.Instance.EndPublish;
                    ravenPage.TopicId = page.Instance.TopicId;
                    TempData["DocumentSaved"] = CMS_i18n.BackendResources.DocumentSaved;
                    return RedirectToAction("PageEditor", new { pageId = ravenPage.PageID });
                }
                else
                {
                    page.Instance.WrittenBy = _worker.AuthenticationRepository.GetCurrentUserName();
                    page.Instance.LastChangedBy = page.Instance.WrittenBy;
                    page.Instance.LastModified = DateTime.Now;
                    page.Instance.Created = DateTime.Now;
                    _worker.CmsContentRepository.CreateCmsPage(page.Instance, Request.Form["Permissions"].ToString());
                }
                return RedirectToAction("PageEditor", new { pageId = page.Instance.PageID });
            }
            else
            {
                ViewData["PermissionSet"] = PermissionSet.GetAvailablePermissions(string.Empty).Select(x => new SelectListItem { Value = x.PermissionValue, Text = x.PermissionDisplay, Selected = x.Selected });
                ViewData["CurrentPageId"] = page.Instance.PageID;
                return View(new ZCMSContent<ZCMSPage>(ravenPage == null ? page.Instance : ravenPage));
            }
        }
コード例 #2
0
ファイル: BackendController.cs プロジェクト: larswise/rCMS
        public ActionResult PageEditor(int ?pageId, string mParameter)
        {
            ZCMSContent<ZCMSPage> page;
            dynamic pagePublishType = ZCMSPageFactory.GetPagePublishType(mParameter);

            if (pageId.HasValue)
            {
                ViewData["CurrentPageId"] = pageId.HasValue ? pageId.Value : new Random().Next();
                page = _worker.CmsContentRepository.GetCmsPage(pageId.ToString());
                ViewData["PermissionSet"] = PermissionSet.GetAvailablePermissions(page.GetMetadataValue("Raven-Document-Authorization")).Select(x => new SelectListItem { Value = x.PermissionValue, Text = x.PermissionDisplay, Selected = x.Selected });

                if (page.Instance != null)
                {
                    TempData["ImageCollection"] = _worker.GetAttachments(page.Instance).Select(w => new WebImage(w)).ToList();
                }
                else
                {
                    page = new ZCMSContent<ZCMSPage>(new ZCMSPage(pagePublishType) { Status = PageStatus.New, PageID = Int32.Parse(ViewData["CurrentPageId"].ToString()) });
                }
            }
            else
            {
                ViewData["PermissionSet"] = PermissionSet.GetAvailablePermissions(string.Empty).Select(x => new SelectListItem { Value = x.PermissionValue, Text = x.PermissionDisplay, Selected = x.Selected });

                page = new ZCMSContent<ZCMSPage>(new ZCMSPage(pagePublishType) { Status = PageStatus.New, PageID = new Random().Next() });
                ViewData["CurrentPageId"] = page.Instance.PageID;
            }
            page.AllTopics = _worker.CmsContentRepository.GetTopics().Topics.OrderBy(o => o.Name).ToList();
            page.AllTopics.Add(new ZCMSTopic() { TopicId = 0, Name = CMS_i18n.BackendResources.TopicsNoneSelected, Color = "" });
            return View(page);
        }