private void RenderResizable(Control parent, Editor.Field field)
        {
            var type = field.TemplateField.Type;

            if (string.IsNullOrEmpty(type))
            {
                return;
            }

            var fieldType = FieldTypeManager.GetFieldType(type);

            if (fieldType == null || !fieldType.Resizable)
            {
                return;
            }

            var text1 =
                "<div style=\"cursor:row-resize; position: relative; height: 5px; width: 100%; top: 0px; left: 0px;\" onmousedown=\"scContent.fieldResizeDown(this, event)\" onmousemove=\"scContent.fieldResizeMove(this, event)\" onmouseup=\"scContent.fieldResizeUp(this, event, '" +
                field.TemplateField.ID.ToShortID() + "')\">" + Images.GetSpacer(1, 4) + "</div>";

            AddLiteralControl(parent, text1);
            var text2 = "<div class style=\"display:none\" \">" + Images.GetSpacer(1, 4) + "</div>";

            AddLiteralControl(parent, text2);
        }
        public static Type GetFieldType(this TemplateFieldItem field)
        {
            FieldType fieldType = FieldTypeManager.GetFieldType(field.Type);
            Type      result;

            if (field.Type == "Number")
            {
                result = typeof(double);
            }
            else
            {
                if (field.Type == "Integer")
                {
                    result = typeof(int);
                }
                else
                {
                    if (fieldType != null)
                    {
                        string fullName = fieldType.Type.FullName;
                        switch (fullName)
                        {
                        case "Sitecore.Data.Fields.TextField":
                        case "Sitecore.Data.Fields.HtmlField":
                        case "Sitecore.Data.Fields.ValueLookupField":
                            result = typeof(string);
                            return(result);

                        case "Sitecore.Data.Fields.DateField":
                            result = typeof(DateTime);
                            return(result);

                        case "Sitecore.Data.Fields.LookupField":
                        case "Sitecore.Data.Fields.ReferenceField":
                        case "Sitecore.Data.Fields.GroupedDroplinkField":
                        case "Sitecore.Data.Fields.GroupedDroplistField":
                            result = typeof(Item);
                            return(result);

                        case "Sitecore.Data.Fields.MultilistField":
                            result = typeof(IEnumerable <Item>);
                            return(result);

                        case "Sitecore.Data.Fields.CheckboxField":
                            result = typeof(bool);
                            return(result);
                        }
                        result = fieldType.Type;
                    }
                    else
                    {
                        result = typeof(string);
                    }
                }
            }
            return(result);
        }
Beispiel #3
0
        public void ShouldGetLayoutField()
        {
            using (var db = new Db {
                new DbItem("home")
            })
            {
                var home = db.GetItem("/sitecore/content/home");

                FieldTypeManager.GetField(home.Fields[FieldIDs.LayoutField]).Should().BeOfType <LayoutField>();
                FieldTypeManager.GetFieldType("Layout").Type.Should().Be <LayoutField>();
            }
        }
        public void ShouldGetTrackingField()
        {
            // arrange
            using (var db = new Db {
                new DbItem("home")
            })
            {
                var home = db.GetItem("/sitecore/content/home");

                // act & assert
                FieldTypeManager.GetField(home.Fields["__Tracking"]).Should().BeOfType <TrackingField>();
                FieldTypeManager.GetFieldType("Tracking").Type.Should().Be <TrackingField>();
            }
        }
Beispiel #5
0
        public void ShouldGetField(string name, Type type)
        {
            using (var db = new Db
            {
                new DbItem("home")
                {
                    new DbField("field")
                    {
                        Type = name
                    }
                }
            })
            {
                var home = db.GetItem("/sitecore/content/home");

                FieldTypeManager.GetField(home.Fields["field"]).Should().BeOfType(type);
                FieldTypeManager.GetFieldType(name).Type.Should().Be(type);
            }
        }
        private void RenderResizable(Control parent, Sitecore.Shell.Applications.ContentManager.Editor.Field field)
        {
            string str = field.TemplateField.Type;

            if (!string.IsNullOrEmpty(str))
            {
                FieldType fieldType = FieldTypeManager.GetFieldType(str);
                if ((fieldType != null) && fieldType.Resizable)
                {
                    string text =
                        string.Concat(new object[]
                    {
                        "<div style=\"cursor:row-resize\" onmousedown=\"scContent.fieldResizeDown(this, event)\" onmousemove=\"scContent.fieldResizeMove(this, event)\" onmouseup=\"scContent.fieldResizeUp(this, event, '"
                        , field.TemplateField.ID.ToShortID(), "')\">", Images.GetSpacer(1, 4), "</div>"
                    });
                    this.AddLiteralControl(parent, text);
                }
            }
        }