public void Process(GetFieldModelArgs args)
        {
            if (args.Result != null || !args.Field.HasValue)
            {
                return;
            }

            if (!(FieldTypeManager.GetField(args.Field) is ImageField imagefield))
            {
                return;
            }

            args.Result = new
            {
                @class = imagefield.Class.ToJsonValueString(),
                alt    = imagefield.Alt.ToJsonValueString(),
                src    = imagefield.MediaItem != null
                    ? MediaManager.GetMediaUrl(imagefield.MediaItem, new MediaUrlOptions
                {
                    AlwaysIncludeServerUrl = false,
                    IncludeExtension       = true,
                    LowercaseUrls          = true
                })
                    : null,
                linkType = imagefield.LinkType.ToJsonValueString(),
                border   = imagefield.Border.ToJsonValueString(),
                hspace   = imagefield.HSpace.ToJsonValueString(),
                height   = imagefield.Height.ToJsonValueString(),
                width    = imagefield.Width.ToJsonValueString(),
                type     = imagefield.InnerField.Type
            };
        }
        public void Process(GetFieldModelArgs args)
        {
            if (args.RecursionLevel > 5 || args.Result != null || !args.Field.HasValue)
            {
                return;
            }

            if (!(FieldTypeManager.GetField(args.Field) is MultilistField listField))
            {
                return;
            }

            var items = new List <object>();

            foreach (var item in listField.GetItems())
            {
                var dict = item.ToFieldsDictionary(args.RecursionLevel + 1);
                var path = LinkManager.GetItemUrl(item, new UrlOptions
                {
                    AddAspxExtension       = false,
                    AlwaysIncludeServerUrl = false,
                    EncodeNames            = true,
                    LanguageEmbedding      = LanguageEmbedding.Never,
                    LowercaseUrls          = true
                });
                items.Add(new { name = item.Name, displayName = item.DisplayName, path, fields = dict });
            }

            args.Result = new { items, type = listField.InnerField.Type }
            ;
        }
 public void Process(GetFieldModelArgs args)
 {
     if (args.Field.Name.StartsWith("_", true, CultureInfo.InvariantCulture) || !args.Field.HasValue)
     {
         args.AbortPipeline();
     }
 }
        public void Process(GetFieldModelArgs args)
        {
            if (args.RecursionLevel > 5 || args.Result != null || !args.Field.HasValue)
            {
                return;
            }
            var lookupField = FieldTypeManager.GetField(args.Field) as LookupField;
            var itemField   = FieldTypeManager.GetField(args.Field) as ReferenceField;

            if (lookupField == null && itemField == null)
            {
                return;
            }

            var item = itemField?.TargetItem ?? lookupField?.TargetItem;

            if (item == null)
            {
                args.AbortPipeline();
                return;
            }
            var dict = item.ToFieldsDictionary(args.RecursionLevel + 1);
            var path = LinkManager.GetItemUrl(item, new UrlOptions
            {
                AddAspxExtension       = false,
                AlwaysIncludeServerUrl = false,
                EncodeNames            = true,
                LanguageEmbedding      = LanguageEmbedding.Never,
                LowercaseUrls          = true
            });

            args.Result = new { name = item.Name, displayName = item.DisplayName, path, fields = dict };
        }
 public void Process(GetFieldModelArgs args)
 {
     if (args.Result != null || !args.Field.HasValue)
     {
         return;
     }
     args.Result = new Field {
         FieldType = args.Field.Type, Value = args.Field.Value
     };
 }
Exemple #6
0
        public void Process(GetFieldModelArgs args)
        {
            if (args.Result != null || !args.Field.HasValue)
            {
                return;
            }

            if (!(FieldTypeManager.GetField(args.Field) is NameValueListField valueListField))
            {
                return;
            }

            args.Result = new
            {
                values = valueListField.NameValues,
                type   = valueListField.InnerField.Type
            };
        }
        public void Process(GetFieldModelArgs args)
        {
            if (args.Result != null || !args.Field.HasValue)
            {
                return;
            }

            if (!(FieldTypeManager.GetField(args.Field) is HtmlField))
            {
                return;
            }

            args.Result = new Field
            {
                FieldType = args.Field.Type,
                Value     = new HtmlHelper(new HeadlessViewContext(), new ViewDataContainer(new ViewDataDictionary()))
                            .Sitecore().Field(args.Field.Name, args.Field.Item).ToHtmlString()
            };
        }
Exemple #8
0
        public void Process(GetFieldModelArgs args)
        {
            if (args.Result != null || !args.Field.HasValue)
            {
                return;
            }

            if (!(FieldTypeManager.GetField(args.Field) is LinkField linkfield))
            {
                return;
            }

            args.Result = new
            {
                @class   = linkfield.Class.ToJsonValueString(),
                anchor   = linkfield.Anchor.ToJsonValueString(),
                href     = linkfield.GetFriendlyUrl().ToJsonValueString(),
                linkType = linkfield.LinkType.ToJsonValueString(),
                text     = linkfield.Text.ToJsonValueString(),
                title    = linkfield.Title.ToJsonValueString(),
                target   = linkfield.Target.ToJsonValueString(),
                type     = linkfield.InnerField.Type
            };
        }