Beispiel #1
0
        private void OnPublishedContent(object sender, ContentEventArgs e)
        {
            var content = e.Content;

            CleanupOldTags(content);

            var contentType = _contentTypeRepository.Load(content.ContentTypeID);

            var tagProperties = contentType.PropertyDefinitions.Where(p => p.TemplateHint == "Tags").ToArray();

            if (!tagProperties.Any())
            {
                return;
            }

            foreach (var tagProperty in tagProperties)
            {
                var tagPropertyInfo = contentType.ModelType.GetProperty(tagProperty.Name);
                var tags = GetPropertyTags(content as ContentData, tagProperty);

                if (tagPropertyInfo == null)
                {
                    return;
                }

                var groupKeyAttribute =
                    tagPropertyInfo.GetCustomAttribute(typeof(TagsGroupKeyAttribute)) as TagsGroupKeyAttribute;
                var cultureSpecificAttribute
                    = tagPropertyInfo.GetCustomAttribute(typeof(CultureSpecificAttribute)) as CultureSpecificAttribute;

                var groupKey = TagsHelper.GetGroupKeyFromAttributes(groupKeyAttribute, cultureSpecificAttribute, content);

                _tagService.Save(content.ContentGuid, tags, groupKey);
            }
        }
Beispiel #2
0
        public virtual void OnMetadataCreated(ModelMetadata metadata)
        {
            var extendedMetadata = metadata as ExtendedMetadata;

            if (extendedMetadata == null)
            {
                return;
            }

            var groupKeyAttribute = extendedMetadata
                                    .Attributes
                                    .FirstOrDefault(a => typeof(TagsGroupKeyAttribute) == a.GetType()) as TagsGroupKeyAttribute;
            var cultureSpecificAttribute = extendedMetadata
                                           .Attributes
                                           .FirstOrDefault(a => typeof(CultureSpecificAttribute) == a.GetType()) as CultureSpecificAttribute;
            var ownerContent = extendedMetadata.FindOwnerContent();

            extendedMetadata.ClientEditingClass                    = "geta-tags/TagsSelection";
            extendedMetadata.CustomEditorSettings["uiType"]        = extendedMetadata.ClientEditingClass;
            extendedMetadata.CustomEditorSettings["uiWrapperType"] = UiWrapperType.Floating;
            extendedMetadata.EditorConfiguration["GroupKey"]       =
                TagsHelper.GetGroupKeyFromAttributes(groupKeyAttribute, cultureSpecificAttribute, ownerContent);
            extendedMetadata.EditorConfiguration["allowSpaces"]     = AllowSpaces;
            extendedMetadata.EditorConfiguration["allowDuplicates"] = AllowDuplicates;
            extendedMetadata.EditorConfiguration["caseSensitive "]  = CaseSensitive;
            extendedMetadata.EditorConfiguration["readOnly "]       = ReadOnly;
            extendedMetadata.EditorConfiguration["tagLimit"]        = TagLimit;
        }
Beispiel #3
0
        public override void ModifyMetadata(ExtendedMetadata metadata,
                                            IEnumerable <Attribute> attributes)
        {
            var attrs = attributes.ToArray();

            base.ModifyMetadata(metadata, attrs);
            var groupKeyAttribute = attrs.FirstOrDefault(
                a => typeof(TagsGroupKeyAttribute) == a.GetType()) as TagsGroupKeyAttribute;
            var cultureSpecificAttribute = attrs.FirstOrDefault(
                a => typeof(CultureSpecificAttribute) == a.GetType()) as CultureSpecificAttribute;
            var getaAttribute = attrs.FirstOrDefault(
                a => typeof(GetaTagsAttribute) == a.GetType()) as GetaTagsAttribute;
            var ownerContent = metadata.FindOwnerContent();

            metadata.EditorConfiguration["GroupKey"] =
                TagsHelper.GetGroupKeyFromAttributes(groupKeyAttribute, cultureSpecificAttribute, ownerContent);
            metadata.EditorConfiguration["allowSpaces"]     = getaAttribute?.AllowSpaces ?? false;
            metadata.EditorConfiguration["allowDuplicates"] = getaAttribute?.AllowDuplicates ?? false;
            metadata.EditorConfiguration["readOnly"]        = getaAttribute?.ReadOnly ?? false;
            metadata.EditorConfiguration["caseSensitive"]   = getaAttribute?.CaseSensitive ?? true;
        }