/// <summary> /// Initializes a new instance based on the specified <paramref name="control"/>. /// </summary> /// <param name="control">An instance of <see cref="GridControl"/> representing the control.</param> protected GridControlDtgeValue(GridControl control) : base(control, control.JObject) { JObject value = control.JObject.GetObject("value"); string docTypeAlias = value.GetString("dtgeContentTypeAlias"); string contentValue = value.GetObject("value").ToString(); string controlId = GetControlId(contentValue); Content = DocTypeGridEditorHelper.ConvertValueToContent(controlId, docTypeAlias, contentValue); }
/// <summary> /// Initializes a new instance based on the specified <paramref name="control"/>. /// </summary> /// <param name="control">An instance of <see cref="GridControl"/> representing the control.</param> protected GridControlDtgeValue(GridControl control) : base(control, control.JObject) { JObject value = control.JObject.GetObject("value"); Id = value.GetGuid("id"); DtgeContentTypeAlias = value.GetString("dtgeContentTypeAlias"); string contentValue = value.GetObject("value").ToString(); Element = DocTypeGridEditorHelper.ConvertValueToContent(Id.ToString(), DtgeContentTypeAlias, contentValue); }
public static HtmlString RenderDocTypeGridEditorItem(this HtmlHelper helper, string id, string docType, string value, string viewPath = "", string actionName = "", object model = null) { var content = DocTypeGridEditorHelper.ConvertValueToContent(id, docType, value); return(helper.RenderDocTypeGridEditorItem(content, viewPath, actionName, model)); }
public DocTypeGridEditorApiController(IUmbracoContextAccessor umbracoContext, IContentTypeService contentTypeService, IContentService contentService, IDataTypeService dataTypeService, IShortStringHelper shortStringHelper, IPublishedContentQuery contentQuery, IPublishedRouter router, ServiceContext serviceContext, IPublishedContentTypeFactory publishedContentTypeFactory, PropertyEditorCollection propertyEditorCollection, DocTypeGridEditorHelper dtgeHelper) { _umbracoContext = umbracoContext; _contentTypeService = contentTypeService; _contentService = contentService; _dataTypeService = dataTypeService; _shortStringHelper = shortStringHelper; _contentQuery = contentQuery; _router = router; _dtgeHelper = dtgeHelper; _serviceContext = serviceContext; _publishedContentTypeFactory = publishedContentTypeFactory; _propertyEditorCollection = propertyEditorCollection; }
public HttpResponseMessage GetPreviewMarkup([FromBody] PreviewData data, [FromUri] int pageId) { var page = default(IPublishedContent); // If the page is new, then the ID will be zero if (pageId > 0) { // Get page container node page = UmbracoContext.ContentCache.GetById(pageId); if (page == null) { // If unpublished, then fake PublishedContent (with IContent object) page = new UnpublishedContent(pageId, Services); } } // NOTE: The previous previewer had a content node associated with the request, // meaning that an implementation may have used this to traverse the content-tree. // In order to maintain backward-compatibility, we must ensure the PublishedContentRequest context. if (UmbracoContext.PublishedContentRequest == null) { UmbracoContext.PublishedContentRequest = new PublishedContentRequest( Request.RequestUri, UmbracoContext.RoutingContext, UmbracoConfig.For.UmbracoSettings().WebRouting, null) { PublishedContent = page }; } // Set the culture for the preview if (page != null) { var culture = page.GetCulture(); System.Threading.Thread.CurrentThread.CurrentCulture = culture; System.Threading.Thread.CurrentThread.CurrentUICulture = culture; } // Get content node object var content = DocTypeGridEditorHelper.ConvertValueToContent(data.Id, data.ContentTypeAlias, data.Value); // Construct preview model var model = new PreviewModel { Page = page, Item = content, EditorAlias = data.EditorAlias, PreviewViewPath = data.PreviewViewPath, ViewPath = data.ViewPath }; // Render view var partialName = "~/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditorPreviewer.cshtml"; var markup = Helpers.ViewHelper.RenderPartial(partialName, model, UmbracoContext.HttpContext); // Return response var response = new HttpResponseMessage { Content = new StringContent(markup ?? string.Empty) }; response.Content.Headers.ContentType = new MediaTypeHeaderValue(MediaTypeNames.Text.Html); return(response); }
public HttpResponseMessage GetPreviewMarkup([FromBody] PreviewData data, [FromUri] int pageId) { var page = default(IPublishedContent); // If the page is new, then the ID will be zero if (pageId > 0) { // Get page container node page = Umbraco.Content(pageId); if (page == null) { // If unpublished, then fake PublishedContent page = new UnpublishedContent(pageId, Services); } } if (UmbracoContext.PublishedRequest == null) { var router = Current.Factory.GetInstance(typeof(IPublishedRouter)) as IPublishedRouter; UmbracoContext.PublishedRequest = router.CreateRequest(UmbracoContext, Request.RequestUri); UmbracoContext.PublishedRequest.PublishedContent = page; } // Set the culture for the preview if (page != null && page.Cultures != null) { var currentCulture = string.IsNullOrWhiteSpace(data.Culture) ? page.GetCultureFromDomains() : data.Culture; if (currentCulture != null && page.Cultures.ContainsKey(currentCulture)) { var culture = new CultureInfo(page.Cultures[currentCulture].Culture); UmbracoContext.PublishedRequest.Culture = culture; System.Threading.Thread.CurrentThread.CurrentCulture = culture; System.Threading.Thread.CurrentThread.CurrentUICulture = culture; } } // Get content node object var content = DocTypeGridEditorHelper.ConvertValueToContent(data.Id, data.ContentTypeAlias, data.Value); // Construct preview model var model = new PreviewModel { Page = page, Item = content, EditorAlias = data.EditorAlias, PreviewViewPath = data.PreviewViewPath, ViewPath = data.ViewPath }; // Render view var partialName = "~/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditorPreviewer.cshtml"; var markup = Helpers.ViewHelper.RenderPartial(partialName, model, UmbracoContext.HttpContext, UmbracoContext); // Return response var response = new HttpResponseMessage { Content = new StringContent(markup ?? string.Empty) }; response.Content.Headers.ContentType = new MediaTypeHeaderValue(MediaTypeNames.Text.Html); return(response); }