示例#1
0
        public ActionResult EditorForPageContent(PageContentModel model)
        {
            // setting dummy content id right here, if it is still null
            model.Id = model.Id ?? Guid.NewGuid();

            return View("Editors/ContentEditor", model);
        }
示例#2
0
        /// <summary>
        /// Renders editor for the specified page content item.
        /// </summary>
        public static MvcHtmlString EditorFor(this HtmlHelper html, PageContentModel content)
        {
            var settings = PageContentSerializer.Deserialize<PageContentDescription>(content.Settings);

            // if action or controller is not specified we will show default content editor
            if (string.IsNullOrWhiteSpace(settings.Edit.Action) || string.IsNullOrWhiteSpace(settings.Edit.Controller))
            {
                return html.Action("DefaultContentEditor", "Page", new {settings});
            }

            return html.Action(settings.Edit.Action, settings.Edit.Controller, new {content = content.Content, pageContentModel = content});
        }
示例#3
0
        public static void RenderDisplayFor(this HtmlHelper html, PageContentModel content)
        {
            var description = PageContentSerializer.Deserialize<PageContentDescription>(content.Settings);

            // if action or controller is not specified we will show default content editor
            if (string.IsNullOrWhiteSpace(description.View.Action) || string.IsNullOrWhiteSpace(description.View.Controller))
            {
                html.RenderAction("DefaultContentView", "Front", new {text = description.Description});
                return;
            }

            var dictionary = new RouteValueDictionary();
            // we override 'content' field all the time, so we should avoid naming routes like that
            dictionary["content"] = content.Content;
            dictionary["pageContentModel"] = content;
            html.RenderAction(description.View.Action, description.View.Controller, dictionary);
        }
示例#4
0
        public ActionResult Html(string content, PageContentModel pageContentModel)
        {
            ViewBag.ContentModel = pageContentModel;

            return View("Editors/Html", new TextModel {Text = content.Either("Html content")});
        }
示例#5
0
 /// <summary>
 /// Returns description for given content model
 /// </summary>
 public static string DescriptionFor(this HtmlHelper html, PageContentModel content)
 {
     var settings = PageContentSerializer.Deserialize<PageContentDescription>(content.Settings);
     return settings.Description;
 }