示例#1
0
        /// <summary>
        /// Determines whether [is multimedia component link].
        /// </summary>
        /// <param name="field">The field.</param>
        /// <returns>
        ///   <c>true</c> if [is multimedia component link] [the specified field]; otherwise, <c>false</c>.
        /// </returns>
        public static bool IsMultimediaComponentLink(this ItemFieldDefinitionData field)
        {
            ComponentLinkFieldDefinitionData clField = field as ComponentLinkFieldDefinitionData;

            if (clField == null)
            {
                return(false);
            }
            return(clField.AllowMultimediaLinks);
        }
示例#2
0
 private FieldType GetFieldType(ItemFieldDefinitionData fieldDef)
 {
     if (fieldDef is SingleLineTextFieldDefinitionData)
     {
         return(FieldType.Text);
     }
     if (fieldDef is MultiLineTextFieldDefinitionData)
     {
         return(FieldType.Text);
     }
     if (fieldDef is DateFieldDefinitionData)
     {
         return(FieldType.Date);
     }
     if (fieldDef is ComponentLinkFieldDefinitionData)
     {
         return(FieldType.ComponentLink);
     }
     if (fieldDef is MultimediaLinkFieldDefinitionData)
     {
         return(FieldType.MultiMediaLink);
     }
     if (fieldDef is XhtmlFieldDefinitionData)
     {
         return(FieldType.Xhtml);
     }
     if (fieldDef is EmbeddedSchemaFieldDefinitionData)
     {
         return(FieldType.Embedded);
     }
     if (fieldDef is KeywordFieldDefinitionData)
     {
         return(FieldType.Keyword);
     }
     if (fieldDef is NumberFieldDefinitionData)
     {
         return(FieldType.Number);
     }
     return(FieldType.Text);
 }
    internal XmlElement AddFieldElement(ItemFieldDefinitionData definition)
    {
        var newElement = root.OwnerDocument.CreateElement(definition.Name, NamespaceUri);

        XmlNodeList nodes            = root.SelectNodes("custom:" + definition.Name, NamespaceManager);
        XmlElement  referenceElement = null;

        if (nodes.Count > 0)
        {
            referenceElement = (XmlElement)nodes[nodes.Count - 1];
        }
        else
        {
            // this is the first value for this field, find its position in the XML based on the field order in the schema
            bool foundUs = false;
            for (int i = definitions.Length - 1; i >= 0; i--)
            {
                if (!foundUs)
                {
                    if (definitions[i].Name == definition.Name)
                    {
                        foundUs = true;
                    }
                }
                else
                {
                    var values = GetFieldElements(definitions[i]);
                    if (values.Count() > 0)
                    {
                        referenceElement = values.Last();
                        break; // from for loop
                    }
                }
            } // for every definition in reverse order
        }     // no existing values found
        root.InsertAfter(newElement, referenceElement); // if referenceElement is null, will insert as first child
        return(newElement);
    }
 internal IEnumerable <XmlElement> GetFieldElements(ItemFieldDefinitionData definition)
 {
     return(root.SelectNodes("custom:" + definition.Name, NamespaceManager).OfType <XmlElement>());
 }
 public TcmFieldValueCollection(TcmFields tcmFields, ItemFieldDefinitionData _definition)
 {
     _tcmFields = tcmFields;
     definition = _definition;
 }
 public TcmField(TcmFields tcmFields, ItemFieldDefinitionData _definition)
 {
     _tcmFields = tcmFields;
     definition = _definition;
 }
示例#7
0
        /// <summary>
        /// Determines whether [is mandatory].
        /// </summary>
        /// <param name="field">The field.</param>
        /// <returns>
        ///   <c>true</c> if [is multi value] [the specified field]; otherwise, <c>false</c>.
        /// </returns>

        public static bool IsMandatory(this ItemFieldDefinitionData field)
        {
            return(field.MinOccurs == 1);
        }
示例#8
0
 /// <summary>
 /// Determines whether [is multi value].
 /// </summary>
 /// <param name="field">The field.</param>
 /// <returns>
 ///   <c>true</c> if [is multi value] [the specified field]; otherwise, <c>false</c>.
 /// </returns>
 public static bool IsMultiValue(this ItemFieldDefinitionData field)
 {
     return(field.MaxOccurs == -1 || field.MaxOccurs > 1);
 }
 public ValueCollection(Fields fields, ItemFieldDefinitionData definition)
 {
     _fields     = fields;
     _definition = definition;
 }
 public TcmIdCollection(Fields _fields, ItemFieldDefinitionData _definition)
 {
     fields     = _fields;
     definition = _definition;
 }
示例#11
0
 /// <summary>
 /// Determines whether this instance is embedded.
 /// </summary>
 /// <param name="field">The field.</param>
 /// <returns>
 ///   <c>true</c> if the specified field is embedded; otherwise, <c>false</c>.
 /// </returns>
 public static bool IsEmbedded(this ItemFieldDefinitionData field)
 {
     return(field is EmbeddedSchemaFieldDefinitionData);
 }
示例#12
0
 /// <summary>
 /// Determines whether this instance is multimedia.
 /// </summary>
 /// <param name="field">The field.</param>
 /// <returns>
 ///   <c>true</c> if the specified field is multimedia; otherwise, <c>false</c>.
 /// </returns>
 public static bool IsMultimedia(this ItemFieldDefinitionData field)
 {
     return(field is MultimediaLinkFieldDefinitionData);
 }
        private List<SchemaField> getFieldsDescription(ItemFieldDefinitionData[] schemaFields)
        {
            List<SchemaField> fieldsDescription = new List<SchemaField>();

            if (schemaFields == null)
                return fieldsDescription;

            foreach (var field in schemaFields)
            {

                SchemaField newfield = new SchemaField();
                newfield.XmlName = field.Name;
                newfield.Required = field.MinOccurs == 1;
                newfield.MultiValue = field.MaxOccurs != 1;
                newfield.Description = field.Description;
           
            
                if (field is SingleLineTextFieldDefinitionData)
                {
                    newfield.FieldType = FIELD_TYPE_TEXT;
                    StringBuilder sb = new StringBuilder();

                    if (!string.IsNullOrEmpty(((SingleLineTextFieldDefinitionData) field).DefaultValue))
                        sb.Append(TEXT_DEFAULT_VALUE);
                    sb.Append(((SingleLineTextFieldDefinitionData) field).DefaultValue);

                    if (((SingleLineTextFieldDefinitionData)field).List != null && ((SingleLineTextFieldDefinitionData)field).List.Entries.Length > 0)
                    {
                        if (sb.Length != 0)
                            sb.Append(Environment.NewLine);
                        sb.Append(TEXT_LIST_OF_VALUES);

                        foreach (string entry in ((SingleLineTextFieldDefinitionData) field).List.Entries)
                        {
                            sb.Append(Environment.NewLine);
                            sb.Append(entry);
                        }
                    }

                    newfield.Properties = sb.ToString();
                }
                else if (field is KeywordFieldDefinitionData)
                {
                    newfield.FieldType = FIELD_TYPE_TEXT;
                    newfield.Properties = TEXT_VALUES_FROM_CATEGORY + ((KeywordFieldDefinitionData)field).Category.Title;
                }
                else if (field is MultiLineTextFieldDefinitionData)
                {
                    newfield.FieldType = FIELD_TYPE_MULTILINE_TEXT;
                
                    if (!string.IsNullOrEmpty(((MultiLineTextFieldDefinitionData)field).DefaultValue))
                        newfield.Properties = TEXT_DEFAULT_VALUE + ((MultiLineTextFieldDefinitionData)field).DefaultValue;

                    newfield.Properties += TEXT_HEIGHT + ((MultiLineTextFieldDefinitionData)field).Height;
                }
                else if (field is XhtmlFieldDefinitionData)
                {
                    newfield.FieldType = FIELD_TYPE_RTF;

                    if (!string.IsNullOrEmpty(((XhtmlFieldDefinitionData)field).DefaultValue))
                        newfield.Properties = TEXT_DEFAULT_VALUE + ((XhtmlFieldDefinitionData)field).DefaultValue;

                    newfield.Properties += TEXT_HEIGHT + ((XhtmlFieldDefinitionData)field).Height;
                }
                else if (field is NumberFieldDefinitionData)
                {
                    newfield.FieldType = FIELD_TYPE_NUMBER;

                    StringBuilder sb = new StringBuilder();


                    if (((NumberFieldDefinitionData)field).DefaultValue != null)
                    {
                        sb.Append(TEXT_DEFAULT_VALUE);
                        sb.Append(((NumberFieldDefinitionData) field).DefaultValue);
                    }

                    if (((NumberFieldDefinitionData)field).List != null && ((NumberFieldDefinitionData)field).List.Entries.Length > 0)
                    {
                        if (sb.Length != 0)
                            sb.Append(Environment.NewLine);

                        sb.Append(TEXT_LIST_OF_VALUES);

                        foreach (double entry in ((NumberFieldDefinitionData)field).List.Entries)
                        {
                            sb.Append(Environment.NewLine);
                            sb.Append(entry.ToString());
                        }
                    }

                    newfield.Properties = sb.ToString();


                }
                else if (field is DateFieldDefinitionData)
                {
                    newfield.FieldType = FIELD_TYPE_DATE;
                    StringBuilder sb = new StringBuilder();

                    if (((DateFieldDefinitionData)field).DefaultValue != null)
                    {
                        sb.Append(TEXT_DEFAULT_VALUE);
                        sb.Append(((DateFieldDefinitionData) field).DefaultValue);
                    }

                    if (((DateFieldDefinitionData)field).List != null && ((DateFieldDefinitionData)field).List.Entries.Length > 0)
                    {
                        if (sb.Length != 0)
                            sb.Append(Environment.NewLine);

                        sb.Append(TEXT_LIST_OF_VALUES);

                        foreach (DateTime entry in ((DateFieldDefinitionData)field).List.Entries)
                        {
                            sb.Append(Environment.NewLine);
                            sb.Append(entry.ToString());
                        }
                    }

                    newfield.Properties = sb.ToString();

                }
            
                else if (field is ComponentLinkFieldDefinitionData)
                {
                    newfield.FieldType = FIELD_TYPE_COMPONENT_LINK;
                    StringBuilder sb = new StringBuilder(TEXT_ALLOWED_SCHEMAS);
                
                    foreach (LinkToSchemaData schemaData in ((ComponentLinkFieldDefinitionData)field).AllowedTargetSchemas)
                    {
                        sb.Append(Environment.NewLine);
                        sb.Append(schemaData.Title);
                    }
                    newfield.Properties = sb.ToString();

                }
                else if (field is MultimediaLinkFieldDefinitionData)
                {
                    newfield.FieldType = FIELD_TYPE_MULTIMEDIA_LINK;
                    StringBuilder sb = new StringBuilder(TEXT_ALLOWED_SCHEMAS);
                    foreach (LinkToSchemaData schemaData in ((MultimediaLinkFieldDefinitionData)field).AllowedTargetSchemas)
                    {
                        sb.Append(Environment.NewLine);
                        sb.Append(schemaData.Title);
                    }
                    newfield.Properties = sb.ToString();
                }
                else if (field is ExternalLinkFieldDefinitionData)
                {
                    newfield.FieldType = FIELD_TYPE_EXTERNAL_LINK;
                    if (!string.IsNullOrEmpty(((ExternalLinkFieldDefinitionData)field).DefaultValue))
                        newfield.Properties = TEXT_DEFAULT_VALUE + ((ExternalLinkFieldDefinitionData)field).DefaultValue;

                }
                else if (field is EmbeddedSchemaFieldDefinitionData)
                {
                    newfield.FieldType = FIELD_TYPE_EMBEDDED;
                    newfield.Properties = TEXT_EMBEDDED_SCHEMA +
                                          ((EmbeddedSchemaFieldDefinitionData) field).EmbeddedSchema.Title;
                }

                fieldsDescription.Add(newfield);
            }

            return fieldsDescription;
        }
 private void BindComboValues(ItemFieldDefinitionData field, ComboBox cbValueCurrent)
 {
     if (field.IsKeyword())
     {
         KeywordFieldDefinitionData keywordField = (KeywordFieldDefinitionData)field;
         List<ItemInfo> keywords = Functions.GetKeywordsByCategory(keywordField.Category.IdRef);
         cbValueCurrent.ItemsSource = keywords;
         cbValueCurrent.DisplayMemberPath = "Title";
     }
     if (field.IsTextSelect())
     {
         SingleLineTextFieldDefinitionData textField = (SingleLineTextFieldDefinitionData)field;
         cbValueCurrent.ItemsSource = textField.List.Entries;
     }
 }
 private List<Operation> GetOperations(ItemFieldDefinitionData field)
 {
     if (field.IsRichText() || field.IsEmbedded() || field.Name == "< Any Field >")
     {
         return new List<Operation> { Operation.Like };
     }
     if (field.IsText())
     {
         return new List<Operation> { Operation.Equal, Operation.Like, Operation.EqualField };
     }
     if (field.IsDate() || field.IsNumber())
     {
         return new List<Operation> { Operation.Equal, Operation.Greater, Operation.Less, Operation.EqualField, Operation.GreaterField, Operation.LessField };
     }
     if (field.IsMultimedia())
     {
         return new List<Operation> { Operation.Equal, Operation.Like, Operation.EqualField };
     }
     return new List<Operation> { Operation.Equal };
 }
示例#16
0
 private static void ProcessFields(ItemFieldDefinitionData[] fields, bool isMetadata, ref IList<FieldProperty> modelProperties)
 {
     foreach (ItemFieldDefinitionData field in fields)
     {
         var fieldProp = new FieldProperty();
         fieldProp.IsMultiValue = field.MaxOccurs != 1;
         fieldProp.IsMetadata = isMetadata;
         fieldProp.FieldName = field.Name;
         fieldProp.PropertyName = field.Name.ResolvePropertyName();
         if (field is ComponentLinkFieldDefinitionData)
         {
             //Linked component
             fieldProp.FieldType = FieldType.Linked;
             ComponentLinkFieldDefinitionData myField = field as ComponentLinkFieldDefinitionData;
             IList<string> linkedClassNames = new List<string>();
             IList<FieldProperty> linkedModelProperties = new List<FieldProperty>();
             if (myField.AllowedTargetSchemas != null)
             {
                 foreach (LinkToSchemaData link in myField.AllowedTargetSchemas)
                 {
                     fieldProp.LinkedComponentTypeNames.Add(link.Title.ResolveModelName());
                 }
             }
         }
         else if (field is EmbeddedSchemaFieldDefinitionData)
         {
             fieldProp.FieldType = FieldType.Embedded;
             EmbeddedSchemaFieldDefinitionData myField = field as EmbeddedSchemaFieldDefinitionData;
             if (myField.EmbeddedSchema != null)
             {
                 fieldProp.EmbeddedTypeName = myField.EmbeddedSchema.Title.ResolveModelName();
             }
         }
         else if (field is MultiLineTextFieldDefinitionData)
         {
             fieldProp.FieldType = FieldType.Text;
         }
         else if (field is KeywordFieldDefinitionData)
         {
             fieldProp.FieldType = FieldType.Keyword;
         }
         else if (field is NumberFieldDefinitionData)
         {
             fieldProp.FieldType = FieldType.Number;
         }
         else if (field is DateFieldDefinitionData)
         {
             fieldProp.FieldType = FieldType.Date;
         }
         else if (field is ExternalLinkFieldDefinitionData)
         {
             fieldProp.FieldType = FieldType.ExternalLink;
         }
         else if (field is MultimediaLinkFieldDefinitionData)
         {
             fieldProp.FieldType = FieldType.Multimedia;
         }
         else if (field is SingleLineTextFieldDefinitionData)
         {
             fieldProp.FieldType = FieldType.Text;
         }
         else if (field is XhtmlFieldDefinitionData)
         {
             fieldProp.FieldType = FieldType.RichText;
         }
         else if (field is ItemFieldDefinitionData)
         {
             //"Default"
             Console.WriteLine("Unknown type for Field: " + field.Name);
             continue; //don't add the property
         }
         modelProperties.Add(fieldProp);
     }
 }
示例#17
0
 /// <summary>
 /// Determines whether [is component link].
 /// </summary>
 /// <param name="field">The field.</param>
 /// <returns>
 ///   <c>true</c> if [is component link] [the specified field]; otherwise, <c>false</c>.
 /// </returns>
 public static bool IsComponentLink(this ItemFieldDefinitionData field)
 {
     return(field is ComponentLinkFieldDefinitionData);
 }
 public Field(Fields _fields, ItemFieldDefinitionData _definition)
 {
     fields     = _fields;
     definition = _definition;
 }
示例#19
0
 public Field(Fields fields, ItemFieldDefinitionData definition)
 {
     _fields     = fields;
     _definition = definition;
 }