public override void UpdateEditor(UpdateEditorContext context) {
     _drivers.Invoke(driver => {
         var result = driver.UpdateEditor(context);
         if (result != null)
             result.Apply(context);
     }, Logger);
 }
        protected override void UpdateEditorShape(UpdateEditorContext context) {
            if (!string.Equals("markdown", context.GroupId, StringComparison.OrdinalIgnoreCase))
                return;

            var part = context.ContentItem.As<MarkdownSiteSettingsPart>();
            if (part == null) {
                return;
            }

            base.UpdateEditorShape(context);
            
            var blogPost = _contentDefinitionManager.GetTypeDefinition("BlogPost");
            if (blogPost == null) {
                return;
            }

            var bodyPart = blogPost.Parts.FirstOrDefault(x => x.PartDefinition.Name == "BodyPart");
            if (bodyPart == null) {
                return;
            }

            _contentDefinitionManager.AlterTypeDefinition("BlogPost", build => build
                .WithPart("BodyPart", cfg => cfg
                    .WithSetting("BodyTypePartSettings.Flavor", part.UseMarkdownForBlogs ? "markdown" : "html")
                )
            );
        }
        protected override void UpdateEditorShape(UpdateEditorContext context) {
            var part = context.ContentItem.As<TwitterPart>();

            if (part != null)
                _signals.Trigger(WellKnownSignals.TwitterPartChanged);

            base.UpdateEditorShape(context);
        }
Example #4
0
        protected override void UpdateEditorShape(UpdateEditorContext context, ContentPart part)
        {
            if (!_groupId.SafeNameEquals(context.GroupId, StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            var templatePart = part.As <TPart>();

            context.Updater.TryUpdateModel(templatePart, _prefix, null, null);
            BuildEditorShape(context, part);
        }
Example #5
0
 private void AssignUpdateDates(UpdateEditorContext context, CommonPart part) {
     var utcNow = _clock.UtcNow;
     part.ModifiedUtc = utcNow;
     part.VersionModifiedUtc = utcNow;
 }
        public dynamic UpdateEditor(IContent content, IUpdateModel updater, string groupInfoId) {
            var contentTypeDefinition = content.ContentItem.TypeDefinition;
            string stereotype;
            if (!contentTypeDefinition.Settings.TryGetValue("Stereotype", out stereotype))
                stereotype = "Content";

            var actualShapeType = stereotype + "_Edit";

            dynamic itemShape = CreateItemShape(actualShapeType);
            itemShape.ContentItem = content.ContentItem;

            var workContext = _workContextAccessor.GetContext(_requestContext.HttpContext);

            var theme = workContext.CurrentTheme;
            var shapeTable = _shapeTableLocator.Value.Lookup(theme.Id);

            // adding an alternate for [Stereotype]_Edit__[ContentType] e.g. Content-Menu.Edit
            ((IShape)itemShape).Metadata.Alternates.Add(actualShapeType + "__" + content.ContentItem.ContentType);

            var context = new UpdateEditorContext(itemShape, content, updater, groupInfoId, _shapeFactory, shapeTable);
            BindPlacement(context, null, stereotype);

            _handlers.Value.Invoke(handler => handler.UpdateEditor(context), Logger);
            
            return context.Shape;
        }
Example #7
0
 protected virtual void UpdateEditorShape(UpdateEditorContext context)
 {
 }
 protected override void UpdateEditorShape(UpdateEditorContext context)
 {
     TryInvokeEventHandler(context.ContentItem.ContentType, graphDescriptor => _graphEventHandler.Value.NodeChanged(graphDescriptor, context.ContentItem));
 }
 public void UpdateEditor(UpdateEditorContext context)
 {
 }
        public dynamic UpdateEditor(IContent content, IUpdateModel updater, string groupInfoId) {
            var contentTypeDefinition = content.ContentItem.TypeDefinition;
            string stereotype;
            if (!contentTypeDefinition.Settings.TryGetValue("Stereotype", out stereotype))
                stereotype = "Content";

            var actualShapeType = stereotype + "_Edit";

            dynamic itemShape = CreateItemShape(actualShapeType);
            itemShape.ContentItem = content.ContentItem;

            var context = new UpdateEditorContext(itemShape, content, updater, groupInfoId, _shapeFactory);
            BindPlacement(context, null, stereotype);

            _handlers.Value.Invoke(handler => handler.UpdateEditor(context), Logger);
            
            return context.Shape;
        }
        public dynamic UpdateEditor(IContent content, string metadataType, string modelType, string partTypeName, string fieldTypeName, IUpdateModel updateModel) {
            dynamic itemShape = CreateItemShape(metadataType);

            itemShape.ContentItem = content.ContentItem;

            var workContext = _workContextAccessor.GetContext(_requestContext.HttpContext);
            
            var theme = workContext.CurrentTheme;
            var shapeTable = _shapeTableLocator.Value.Lookup(theme.Id);

            var context = new UpdateEditorContext(itemShape, content, updateModel, string.Empty, _shapeFactory, shapeTable, string.Empty);

            if (string.Equals(modelType, "Part", StringComparison.OrdinalIgnoreCase)) {
                var drivers = FindPartDrivers(partTypeName);

                foreach (var driver in drivers) {
                    var result = driver.UpdateEditor(context);

                    if (result != null) {
                        result.Apply(context);
                    }
                }
            }
            if (string.Equals(modelType , "Field", StringComparison.OrdinalIgnoreCase)) {
                var contentPart =  content.ContentItem.Parts.Single(o => o.GetType().Name == partTypeName);
                var drivers = FindFieldDrivers(contentPart, fieldTypeName);

                foreach (var driver in drivers) {
                    var result = driver.UpdateEditorShape(context);

                    if (result != null) {
                        result.Apply(context);
                    }
                }
            }
            
            // Get the Drivers for the Field or the Part that we are trying to talk to.
            return itemShape;
        }
Example #12
0
        public bool WasDisplayed(UpdateEditorContext context) {
            ShapeDescriptor descriptor;
            if (context.ShapeTable.Descriptors.TryGetValue(_shapeType, out descriptor)) {
                var placementContext = new ShapePlacementContext {
                    Content = context.ContentItem,
                    ContentType = context.ContentItem.ContentType,
                    Differentiator = _differentiator,
                    DisplayType = null,
                    Path = context.Path
                };

                var placementInfo = descriptor.Placement(placementContext);

                var location = placementInfo.Location;

                if (String.IsNullOrEmpty(location) || location == "-") {
                    return false;
                }

                var editorGroup = _groupId;
                if (String.IsNullOrEmpty(editorGroup)) {
                    editorGroup = placementInfo.GetGroup() ?? "";
                }

                var contextGroup = context.GroupId ?? "";

                if (!String.Equals(editorGroup, contextGroup, StringComparison.OrdinalIgnoreCase)) {
                    return false;
                }
            }

            return true;
        }
Example #13
0
 public virtual void UpdateEditor(UpdateEditorContext context)
 {
 }
Example #14
0
 public virtual void UpdateEditor(UpdateEditorContext context)
 {
 }
Example #15
0
        public string UpdateEditor(IContent content, IUpdateModel updater)
        {
            var contentTypeDefinition = content.ContentItem.TypeDefinition;
            string stereotype;
            //if (!contentTypeDefinition.Settings.TryGetValue("Stereotype", out stereotype))
            //    stereotype = "Content";

            //var actualShapeType = stereotype + "_Edit";

            //itemShape.ContentItem = content.ContentItem;

            var workContext = _workContextAccessor.GetContext(_requestContext.HttpContext);

            //var theme = workContext.CurrentTheme;
            //var shapeTable = _shapeTableLocator.Value.Lookup(theme.Id);

            // adding an alternate for [Stereotype]_Edit__[ContentType] e.g. Content-Menu.Edit
            //((IShape)itemShape).Metadata.Alternates.Add(actualShapeType + "__" + content.ContentItem.ContentType);

            var context = new UpdateEditorContext(content, updater, GetPath());
            //BindPlacement(context, null, stereotype);
            _handlers.Value.Invoke(handler => handler.UpdateEditor(context), Logger);
            return string.Empty;
        }
Example #16
0
 protected override void UpdateEditorShape(UpdateEditorContext context, TContent instance)
 {
 }