Пример #1
0
 public ActionResult Edit(EditModel m)
 {
     if (m.SaveAll())
     {
         ViewBag.Folder = m.Content.IsFolder;
         if (m.Content.IsImage)
         {
             ViewBag.Title = Piranha.Resources.Content.EditTitleExistingImage;
             SuccessMessage(Piranha.Resources.Content.MessageImageSaved);
         }
         else if (m.Content.IsFolder)
         {
             ViewBag.Title = Piranha.Resources.Content.EditTitleExistingFolder;
             SuccessMessage(Piranha.Resources.Content.MessageFolderSaved);
         }
         else
         {
             ViewBag.Title = Piranha.Resources.Content.EditTitleExistingDocument;
             SuccessMessage(Piranha.Resources.Content.MessageDocumentSaved);
         }
         ModelState.Clear();
         m.Refresh();
         return(View("Edit", m));
     }
     else
     {
         ViewBag.Title = Piranha.Resources.Content.EditTitleNew;
         ErrorMessage(Piranha.Resources.Content.MessageNotSaved);
         return(View("Edit", m));
     }
 }
Пример #2
0
        public ActionResult Edit(bool draft, EditModel m)
        {
            if (ModelState.IsValid)
            {
                if (m.SaveAll(draft))
                {
                    ModelState.Clear();
                    if (!draft)
                    {
                        SuccessMessage(Piranha.Resources.Post.MessagePublished);
                    }
                    else
                    {
                        SuccessMessage(Piranha.Resources.Post.MessageSaved);
                    }
                }
                else
                {
                    ErrorMessage(Piranha.Resources.Post.MessageNotSaved);
                }
            }
            m.Refresh();

            if (m.Post.IsNew)
            {
                ViewBag.Title = Piranha.Resources.Post.EditTitleNew + m.Template.Name.ToLower();
            }
            else
            {
                ViewBag.Title = Piranha.Resources.Post.EditTitleExisting;
            }

            return(View("Edit", m));
        }
Пример #3
0
        public ActionResult Edit(bool draft, EditModel m)
        {
            if (ModelState.IsValid)
            {
                if (m.SaveAll(draft))
                {
                    ModelState.Clear();
                    if (!draft)
                    {
                        if (m.Post.Published == m.Post.LastPublished)
                        {
                            SuccessMessage(Piranha.Resources.Post.MessagePublished, true);
                        }
                        else
                        {
                            SuccessMessage(Piranha.Resources.Post.MessageUpdated, true);
                        }
                    }
                    else
                    {
                        SuccessMessage(Piranha.Resources.Post.MessageSaved, true);
                    }

                    return(RedirectToAction("edit", new { id = m.Post.Id, returl = ViewBag.ReturnUrl }));
                }
                else
                {
                    ErrorMessage(Piranha.Resources.Post.MessageNotSaved);
                }
            }
            m.Refresh();

            // Executes the post edit loaded hook, if registered
            if (WebPages.Hooks.Manager.PostEditModelLoaded != null)
            {
                WebPages.Hooks.Manager.PostEditModelLoaded(this, WebPages.Manager.GetActiveMenuItem(), m);
            }

            if (m.Post.IsNew)
            {
                ViewBag.Title = Piranha.Resources.Post.EditTitleNew + m.Template.Name.ToLower();
            }
            else
            {
                ViewBag.Title = Piranha.Resources.Post.EditTitleExisting;
            }

            return(View(@"~/Areas/Manager/Views/Post/Edit.cshtml", m));
        }
Пример #4
0
        public ActionResult Edit(bool draft, EditModel pm)
        {
            if (ModelState.IsValid)
            {
                try {
                    if (pm.SaveAll(draft))
                    {
                        ModelState.Clear();
                        if (!draft)
                        {
                            SuccessMessage(Piranha.Resources.Page.MessagePublished);
                        }
                        else
                        {
                            SuccessMessage(Piranha.Resources.Page.MessageSaved);
                        }
                    }
                    else
                    {
                        ErrorMessage(Piranha.Resources.Page.MessageNotSaved);
                    }
                } catch (DuplicatePermalinkException e) {
                    // Manually set the duplicate error.
                    ModelState.AddModelError("Permalink", @Piranha.Resources.Global.PermalinkDuplicate);
                    // If this is the default permalink, remove the model state so it will be shown.
                    if (Permalink.Generate(pm.Page.Title) == pm.Permalink.Name)
                    {
                        ModelState.Remove("Permalink.Name");
                    }
                } catch (Exception e) {
                    ErrorMessage(e.ToString());
                }
            }
            pm.Refresh();

            if (pm.Page.IsNew)
            {
                ViewBag.Title = Piranha.Resources.Page.EditTitleNew + pm.Template.Name.ToLower();
            }
            else
            {
                ViewBag.Title = Piranha.Resources.Page.EditTitleExisting;
            }

            return(View("Edit", pm));
        }
Пример #5
0
        public ActionResult Edit(bool draft, EditModel pm)
        {
            if (ModelState.IsValid)
            {
                try {
                    // Executes the page edit before save hook, if registered
                    if (Hooks.Manager.Page.Model.OnBeforeSave != null)
                    {
                        Hooks.Manager.Page.Model.OnBeforeSave(this, WebPages.Manager.GetActiveMenuItem(), pm);
                    }

                    if (pm.SaveAll(draft))
                    {
                        // Executes the page edit after save hook, if registered
                        if (Hooks.Manager.Page.Model.OnAfterSave != null)
                        {
                            Hooks.Manager.Page.Model.OnAfterSave(this, WebPages.Manager.GetActiveMenuItem(), pm);
                        }

                        ModelState.Clear();
                        if (!draft)
                        {
                            if (pm.Page.Published == pm.Page.LastPublished)
                            {
                                SuccessMessage(Piranha.Resources.Page.MessagePublished);
                            }
                            else
                            {
                                SuccessMessage(Piranha.Resources.Page.MessageUpdated);
                            }
                        }
                        else
                        {
                            SuccessMessage(Piranha.Resources.Page.MessageSaved);
                        }
                    }
                    else
                    {
                        ErrorMessage(Piranha.Resources.Page.MessageNotSaved);
                    }
                } catch (DuplicatePermalinkException) {
                    // Manually set the duplicate error.
                    ModelState.AddModelError("Permalink", @Piranha.Resources.Global.PermalinkDuplicate);
                    // If this is the default permalink, remove the model state so it will be shown.
                    if (Permalink.Generate(pm.Page.Title) == pm.Permalink.Name)
                    {
                        ModelState.Remove("Permalink.Name");
                    }
                } catch (Exception e) {
                    ErrorMessage(e.ToString());
                }
            }
            pm.Refresh();

            // Executes the page list loaded hook, if registered
            if (Hooks.Manager.Page.Model.OnLoad != null)
            {
                Hooks.Manager.Page.Model.OnLoad(this, WebPages.Manager.GetActiveMenuItem(), pm);
            }

            if (!pm.IsSite)
            {
                if (pm.Page.IsNew)
                {
                    ViewBag.Title = Piranha.Resources.Page.EditTitleNew + pm.Template.Name.ToLower();
                }
                else
                {
                    ViewBag.Title = Piranha.Resources.Page.EditTitleExisting;
                }
            }
            else
            {
                ViewBag.Title = Piranha.Resources.Global.Edit + " " + pm.SiteTree.Name.ToLower();
            }

            if (pm.Page.OriginalId != Guid.Empty)
            {
                return(View(@"~/Areas/Manager/Views/Page/EditCopy.cshtml", pm));
            }
            return(View(@"~/Areas/Manager/Views/Page/Edit.cshtml", pm));
        }
Пример #6
0
        public ActionResult Edit(bool draft, EditModel m)
        {
            if (ModelState.IsValid)
            {
                try {
                    if (m.SaveAll(draft))
                    {
                        ModelState.Clear();
                        if (!draft)
                        {
                            if (m.Post.Published == m.Post.LastPublished)
                            {
                                SuccessMessage(Piranha.Resources.Post.MessagePublished, true);
                            }
                            else
                            {
                                SuccessMessage(Piranha.Resources.Post.MessageUpdated, true);
                            }
                        }
                        else
                        {
                            SuccessMessage(Piranha.Resources.Post.MessageSaved, true);
                        }

                        return(RedirectToAction("edit", new { id = m.Post.Id, returl = ViewBag.ReturnUrl }));
                    }
                    else
                    {
                        ErrorMessage(Piranha.Resources.Post.MessageNotSaved);
                    }
                } catch (DuplicatePermalinkException) {
                    // Manually set the duplicate error.
                    ModelState.AddModelError("Permalink", @Piranha.Resources.Global.PermalinkDuplicate);
                    // If this is the default permalink, remove the model state so it will be shown.
                    if (Permalink.Generate(m.Post.Title) == m.Permalink.Name)
                    {
                        ModelState.Remove("Permalink.Name");
                    }
                } catch (Exception e) {
                    ErrorMessage(e.ToString());
                }
            }
            m.Refresh();

            // Executes the post edit loaded hook, if registered
            if (WebPages.Hooks.Manager.PostEditModelLoaded != null)
            {
                WebPages.Hooks.Manager.PostEditModelLoaded(this, WebPages.Manager.GetActiveMenuItem(), m);
            }

            if (m.Post.IsNew)
            {
                ViewBag.Title = Piranha.Resources.Post.EditTitleNew + m.Template.Name.ToLower();
            }
            else
            {
                ViewBag.Title = Piranha.Resources.Post.EditTitleExisting;
            }

            return(View(@"~/Areas/Manager/Views/Post/Edit.cshtml", m));
        }
Пример #7
0
        public ActionResult Edit(bool draft, EditModel m)
        {
            try {
                // Executes the media edit before save hook, if registered
                if (WebPages.Hooks.Manager.MediaEditModelBeforeSave != null)
                {
                    WebPages.Hooks.Manager.MediaEditModelBeforeSave(this, WebPages.Manager.GetActiveMenuItem(), m, !draft);
                }

                if (m.SaveAll(draft))
                {
                    // Executes the media edit after save hook, if registered
                    if (WebPages.Hooks.Manager.MediaEditModelAfterSave != null)
                    {
                        WebPages.Hooks.Manager.MediaEditModelAfterSave(this, WebPages.Manager.GetActiveMenuItem(), m, !draft);
                    }

                    ViewBag.Folder = m.Content.IsFolder;
                    if (m.Content.IsImage)
                    {
                        ViewBag.Title = Piranha.Resources.Content.EditTitleExistingImage;
                        if (draft)
                        {
                            SuccessMessage(Piranha.Resources.Content.MessageImageSaved, true);
                        }
                        else
                        {
                            if (m.Content.Published == m.Content.LastPublished)
                            {
                                SuccessMessage(Piranha.Resources.Content.MessageImagePublished, true);
                            }
                            else
                            {
                                SuccessMessage(Piranha.Resources.Content.MessageUpdated, true);
                            }
                        }
                    }
                    else if (m.Content.IsFolder)
                    {
                        ViewBag.Title = Piranha.Resources.Content.EditTitleExistingFolder;
                        if (draft)
                        {
                            SuccessMessage(Piranha.Resources.Content.MessageFolderSaved, true);
                        }
                        else
                        {
                            if (m.Content.Published == m.Content.LastPublished)
                            {
                                SuccessMessage(Piranha.Resources.Content.MessageFolderPublished, true);
                            }
                            else
                            {
                                SuccessMessage(Piranha.Resources.Content.MessageUpdated, true);
                            }
                        }
                    }
                    else
                    {
                        ViewBag.Title = Piranha.Resources.Content.EditTitleExistingDocument;
                        if (draft)
                        {
                            SuccessMessage(Piranha.Resources.Content.MessageDocumentSaved, true);
                        }
                        else
                        {
                            if (m.Content.Published == m.Content.LastPublished)
                            {
                                SuccessMessage(Piranha.Resources.Content.MessageDocumentPublished, true);
                            }
                            else
                            {
                                SuccessMessage(Piranha.Resources.Content.MessageUpdated, true);
                            }
                        }
                    }
                    return(RedirectToAction("edit", new { id = m.Content.Id, returl = ViewBag.ReturnUrl }));
                }
                else
                {
                    ViewBag.Title = Piranha.Resources.Content.EditTitleNew;
                    ErrorMessage(Piranha.Resources.Content.MessageNotSaved);
                    return(View("Edit", m));
                }
            } catch (DuplicatePermalinkException) {
                // Manually set the duplicate error.
                ModelState.AddModelError("Permalink", @Piranha.Resources.Global.PermalinkDuplicate);
            } catch (Exception e) {
                ErrorMessage(e.ToString());
            }
            m.Refresh();
            ViewBag.Folder = m.Content.IsFolder;
            return(View("Edit", m));
        }
Пример #8
0
 public ActionResult Edit(bool draft, EditModel m)
 {
     try {
         if (m.SaveAll(draft))
         {
             ViewBag.Folder = m.Content.IsFolder;
             if (m.Content.IsImage)
             {
                 ViewBag.Title = Piranha.Resources.Content.EditTitleExistingImage;
                 if (draft)
                 {
                     SuccessMessage(Piranha.Resources.Content.MessageImageSaved, true);
                 }
                 else
                 {
                     if (m.Content.Published == m.Content.LastPublished)
                     {
                         SuccessMessage(Piranha.Resources.Content.MessageImagePublished, true);
                     }
                     else
                     {
                         SuccessMessage(Piranha.Resources.Content.MessageUpdated, true);
                     }
                 }
             }
             else if (m.Content.IsFolder)
             {
                 ViewBag.Title = Piranha.Resources.Content.EditTitleExistingFolder;
                 if (draft)
                 {
                     SuccessMessage(Piranha.Resources.Content.MessageFolderSaved, true);
                 }
                 else
                 {
                     if (m.Content.Published == m.Content.LastPublished)
                     {
                         SuccessMessage(Piranha.Resources.Content.MessageFolderPublished, true);
                     }
                     else
                     {
                         SuccessMessage(Piranha.Resources.Content.MessageUpdated, true);
                     }
                 }
             }
             else
             {
                 ViewBag.Title = Piranha.Resources.Content.EditTitleExistingDocument;
                 if (draft)
                 {
                     SuccessMessage(Piranha.Resources.Content.MessageDocumentSaved, true);
                 }
                 else
                 {
                     if (m.Content.Published == m.Content.LastPublished)
                     {
                         SuccessMessage(Piranha.Resources.Content.MessageDocumentPublished, true);
                     }
                     else
                     {
                         SuccessMessage(Piranha.Resources.Content.MessageUpdated, true);
                     }
                 }
             }
             return(RedirectToAction("edit", new { id = m.Content.Id, returl = ViewBag.ReturnUrl }));
         }
         else
         {
             ViewBag.Title = Piranha.Resources.Content.EditTitleNew;
             ErrorMessage(Piranha.Resources.Content.MessageNotSaved);
             return(View("Edit", m));
         }
     } catch (DuplicatePermalinkException) {
         // Manually set the duplicate error.
         ModelState.AddModelError("Permalink", @Piranha.Resources.Global.PermalinkDuplicate);
     } catch (Exception e) {
         ErrorMessage(e.ToString());
     }
     m.Refresh();
     ViewBag.Folder = m.Content.IsFolder;
     return(View("Edit", m));
 }