public void StorePartDefinition(ContentPartDefinition contentPartDefinition)
 {
     _signals.Trigger(ContentDefinitionSignal);
     Apply(contentPartDefinition, Acquire(contentPartDefinition));
 }
        public void ApplySortCriterion(SortCriterionContext context, IFieldTypeEditor fieldTypeEditor, string storageName, Type storageType, ContentPartDefinition part, ContentPartFieldDefinition field)
        {
            bool ascending    = (bool)context.State.Sort;
            var  propertyName = String.Join(".", part.Name, field.Name, storageName ?? "");

            // use an alias with the join so that two filters on the same Field Type wont collide
            var relationship = fieldTypeEditor.GetFilterRelationship(propertyName.ToSafeName());

            // generate the predicate based on the editor which has been used
            Action <IHqlExpressionFactory> predicate = y => y.Eq("PropertyName", propertyName);

            // combines the predicate with a filter on the specific property name of the storage, as implemented in FieldIndexService

            // apply where clause
            context.Query = context.Query.Where(relationship, predicate);

            // apply sort
            context.Query = ascending
                ? context.Query.OrderBy(relationship, x => x.Asc("Value"))
                : context.Query.OrderBy(relationship, x => x.Desc("Value"));
        }
Exemplo n.º 3
0
 public virtual bool CanSync(string contentType, ContentPartDefinition contentPartDefinition)
 {
     return(contentPartDefinition.Name == PartName);
 }
Exemplo n.º 4
0
 public void StorePartDefinition(ContentPartDefinition contentPartDefinition) => throw new System.NotImplementedException();
 public static bool IsAttachable(this ContentPartDefinition part)
 {
     return(part.Settings.ToObject <ContentPartSettings>().Attachable);
 }
Exemplo n.º 6
0
 public void StorePartDefinition(ContentPartDefinition contentPartDefinition)
 {
     Apply(contentPartDefinition, Acquire(contentPartDefinition));
 }
Exemplo n.º 7
0
 public PartConfigurerImpl(ContentTypePartDefinition part)
     : base(part)
 {
     Current         = part;
     _partDefinition = part.PartDefinition;
 }
Exemplo n.º 8
0
        public dynamic Render(PropertyContext context, ContentItem contentItem, IFieldTypeEditor fieldTypeEditor, string storageName, Type storageType, ContentPartDefinition part, ContentPartFieldDefinition field)
        {
            var p = contentItem.Parts.FirstOrDefault(x => x.PartDefinition.Name == part.Name);

            if (p == null)
            {
                return(String.Empty);
            }

            var f = p.Fields.FirstOrDefault(x => x.Name == field.Name);

            if (f == null)
            {
                return(String.Empty);
            }

            var value = f.Storage.Get <object>(storageName);

            if (value == null)
            {
                return(null);
            }

            // call specific formatter rendering
            return(_propertyFormater.Format(storageType, value, context.State));
        }
Exemplo n.º 9
0
 public ContentPartDefinitionModel(ContentPartDefinition contentPartDefinition)
 {
     Fields   = new List <ContentFieldDefinitionModel>();
     Settings = new Dictionary <string, string>(contentPartDefinition.Settings);
     Name     = contentPartDefinition.Name;
 }
Exemplo n.º 10
0
 public override void ApplySortCriterion(Orchard.Projections.Descriptors.SortCriterion.SortCriterionContext context, string storageName, Type storageType, ContentPartDefinition part, ContentPartFieldDefinition field)
 {
 }
Exemplo n.º 11
0
 public LocalizedString DisplayFilter(PropertyContext context, ContentPartDefinition part, ContentPartFieldDefinition fieldDefinition, string storageName)
 {
     return(T("Field {0}: {1}", fieldDefinition.Name, String.IsNullOrEmpty(storageName) ? T("Default value").Text : storageName));
 }
Exemplo n.º 12
0
        public override void ApplyFilter(FilterContext context, string storageName, Type storageType, ContentPartDefinition part, ContentPartFieldDefinition field)
        {
            var    op       = (OptionSetOperator)Enum.Parse(typeof(OptionSetOperator), (string)context.State.Operator);
            string value    = context.State.Value;
            var    valueArr = value != null
                ? value.Split('&').Select(int.Parse).ToArray()
                : new[] { 0 };

            switch (op)
            {
            case OptionSetOperator.MatchesAny:
                Action <IAliasFactory>         selectorAny = alias => alias.ContentPartRecord <OptionItemContainerPartRecord>().Property("OptionItems", "opits").Property("OptionItemRecord", "opcpr");
                Action <IHqlExpressionFactory> filterAny   = x => x.InG("Id", valueArr);
                context.Query.Where(selectorAny, filterAny);
                break;

            case OptionSetOperator.MatchesAll:
                foreach (var id in valueArr)
                {
                    var optionId = id;
                    Action <IAliasFactory> selectorAll =
                        alias => alias.ContentPartRecord <OptionItemContainerPartRecord>().Property("OptionItems", "opit" + optionId);
                    Action <IHqlExpressionFactory> filterAll = x => x.Eq("OptionItemRecord.Id", optionId);
                    context.Query.Where(selectorAll, filterAll);
                }
                break;

            case OptionSetOperator.NotMatchesAny:
                Action <IAliasFactory>         selectorNotAny = alias => alias.ContentPartRecord <OptionItemContainerPartRecord>().Property("OptionItems", "opits").Property("OptionItemRecord", "opcpr");
                Action <IHqlExpressionFactory> filterNotAny   = x => x.Not(y => y.InG("Id", valueArr));
                context.Query.Where(selectorNotAny, filterNotAny);
                break;
            }
        }
Exemplo n.º 13
0
 public EditPartViewModel(ContentPartDefinition contentPartDefinition)
 {
     Name           = contentPartDefinition.Name;
     PartDefinition = contentPartDefinition;
     _displayName   = contentPartDefinition.DisplayName();
 }
 public EditPartViewModel(ContentPartDefinition contentPartDefinition)
 {
     Name           = contentPartDefinition.Name;
     PartDefinition = contentPartDefinition;
 }
 public void StorePartDefinition(ContentPartDefinition contentPartDefinition)
 {
     Apply(contentPartDefinition, Acquire(contentPartDefinition));
     TriggerContentDefinitionSignal();
 }
Exemplo n.º 16
0
 public virtual IEnumerable <TemplateViewModel> PartEditor(ContentPartDefinition definition)
 {
     return(Enumerable.Empty <TemplateViewModel>());
 }
Exemplo n.º 17
0
 public ContentTypePartDefinition(ContentPartDefinition contentPartDefinition, SettingsDictionary settings)
 {
     PartDefinition = contentPartDefinition;
     Settings       = settings;
 }
Exemplo n.º 18
0
        public void ApplyFilter(FilterContext context, IFieldTypeEditor fieldTypeEditor, string storageName, Type storageType, ContentPartDefinition part, ContentPartFieldDefinition field)
        {
            var propertyName = String.Join(".", part.Name, field.Name, storageName ?? "");

            // use an alias with the join so that two filters on the same Field Type wont collide
            var relationship = fieldTypeEditor.GetFilterRelationship(propertyName.ToSafeName());

            // generate the predicate based on the editor which has been used
            Action <IHqlExpressionFactory> predicate = fieldTypeEditor.GetFilterPredicate(context.State);

            // combines the predicate with a filter on the specific property name of the storage, as implemented in FieldIndexService
            Action <IHqlExpressionFactory> andPredicate = x => x.And(y => y.Eq("PropertyName", propertyName), predicate);

            // apply where clause
            context.Query = context.Query.Where(relationship, andPredicate);
        }
Exemplo n.º 19
0
        public override IEnumerable <TemplateViewModel> PartEditor(ContentPartDefinition definition)
        {
            var model = definition.Settings.GetModel <ContentPartSettings>();

            yield return(DefinitionTemplate(model));
        }
 public static bool IsReusable(this ContentPartDefinition part)
 {
     return(part.GetSettings <ContentPartSettings>().Reusable);
 }
Exemplo n.º 21
0
 public void StorePartDefinition(ContentPartDefinition contentPartDefinition)
 {
     Apply(contentPartDefinition, Acquire(contentPartDefinition));
     UpdateContentDefinitionRecord();
 }
 public static string Description(this ContentPartDefinition part)
 {
     return(part.GetSettings <ContentPartSettings>().Description);
 }
Exemplo n.º 23
0
 public ContentTypePartDefinition(ContentPartDefinition contentPartDefinition, SettingsDictionary settings) {
     PartDefinition = contentPartDefinition;
     Settings = settings;
 }
 public void AlterPartFieldsOrder(ContentPartDefinition partDefinition, string[] fieldNames) => throw new NotImplementedException();