示例#1
0
 protected void gpw_Delete(object sender, System.EventArgs e)
 {
     GenericProperties.GenericPropertyWrapper gpw = (GenericProperties.GenericPropertyWrapper)sender;
     gpw.GenricPropertyControl.PropertyType.delete();
     cType = ContentType.GetContentType(cType.Id);
     this.bindDataGenericProperties(true);
 }
        private void BindDataGenericProperties(bool refresh)
        {
            var tabs = _contentType.getVirtualTabs;
            var propertyTypeGroups = _contentType.PropertyTypeGroups.ToList();
            var dtds = cms.businesslogic.datatype.DataTypeDefinition.GetAll();

            PropertyTypes.Controls.Clear();

            // Add new property
            if (PropertyTypeNew.Controls.Count == 0)
            {
                PropertyTypeNew.Controls.Add(new LiteralControl("<h2 class=\"propertypaneTitel\">Add New Property</h2><ul class='genericPropertyList addNewProperty'>"));
                gp = new GenericPropertyWrapper();
                gp.ID = "GenericPropertyNew";
                gp.Tabs = tabs;
                gp.DataTypeDefinitions = dtds;
                PropertyTypeNew.Controls.Add(gp);
                PropertyTypeNew.Controls.Add(new LiteralControl("</ul>"));
            }
            else if (refresh)
            {
                gp = (GenericPropertyWrapper)PropertyTypeNew.Controls[1];
                gp.ID = "GenericPropertyNew";
                gp.Tabs = tabs;
                gp.DataTypeDefinitions = dtds;
                gp.UpdateEditControl();
                gp.GenricPropertyControl.UpdateInterface();
                gp.GenricPropertyControl.Clear();
            }

            _genericProperties.Clear();
            var inTab = new Hashtable();
            int counter = 0;

            PropertyTypes.Controls.Add(new LiteralControl("<div id='tabs-container'>"));  // opens draggable container for properties on tabs

            foreach (ContentType.TabI tab in tabs)
            {
                string tabName = tab.GetRawCaption();
                string tabCaption = tabName;
                if (tab.ContentType != _contentType.Id) 
                {
                    tabCaption += " (inherited from " + new ContentType(tab.ContentType).Text + ")";
                }

                PropertyTypes.Controls.Add(new LiteralControl("<div class='genericPropertyListBox'><h2 data-tabname='" + tabName + "' class=\"propertypaneTitel\">Tab: " + tabCaption + "</h2>"));

                var propertyGroup = propertyTypeGroups.SingleOrDefault(x => x.ParentId == tab.Id);
                var propertyTypes = propertyGroup == null
                                        ? tab.GetPropertyTypes(_contentType.Id, false)
                                        : propertyGroup.GetPropertyTypes();

                var propertyGroupId = tab.Id;

                var propSort = new HtmlInputHidden();
                propSort.ID = "propSort_" + propertyGroupId.ToString() + "_Content";
                PropertyTypes.Controls.Add(propSort);
                _sortLists.Add(propSort);

                if (propertyTypes.Any(x => x.ContentTypeId == _contentType.Id))
                {
                    PropertyTypes.Controls.Add(new LiteralControl("<ul class='genericPropertyList' id=\"t_" + propertyGroupId.ToString() + "_Contents\">"));

                    foreach (cms.businesslogic.propertytype.PropertyType pt in propertyTypes)
                    {
                        //If the PropertyType doesn't belong on this ContentType skip it and continue to the next one
                        if (pt.ContentTypeId != _contentType.Id) continue;

                        var gpw = new GenericPropertyWrapper();
                        gpw.ID = "gpw_" + pt.Id;
                        gpw.PropertyType = pt;
                        gpw.Tabs = tabs;
                        gpw.TabId = propertyGroupId;
                        gpw.DataTypeDefinitions = dtds;
                        gpw.Delete += new EventHandler(gpw_Delete);
                        gpw.FullId = "t_" + propertyGroupId.ToString() + "_Contents_" + +pt.Id;

                        PropertyTypes.Controls.Add(gpw);
                        _genericProperties.Add(gpw);
                        if (refresh)
                            gpw.GenricPropertyControl.UpdateInterface();

                        inTab.Add(pt.Id.ToString(), "");
                        counter++;
                    }

                    PropertyTypes.Controls.Add(new LiteralControl("</ul>"));
                }
                else
                {
                    AddNoPropertiesDefinedMessage();
                }

                var jsSortable = GetJavaScriptForPropertySorting(propSort.ClientID);
                Page.ClientScript.RegisterStartupScript(this.GetType(), propSort.ClientID, jsSortable, true);

                PropertyTypes.Controls.Add(new LiteralControl("</div>"));
            }

            // Generic properties tab
            counter = 0;
            bool propertyTabHasProperties = false;
            var propertiesPH = new PlaceHolder();
            propertiesPH.ID = "propertiesPH";
            PropertyTypes.Controls.Add(new LiteralControl("<h2 data-tabname=\"Generic Properties\" class=\"propertypaneTitel\">Tab: Generic Properties</h2>"));
            PropertyTypes.Controls.Add(propertiesPH);

            var propSort_gp = new HtmlInputHidden();
            propSort_gp.ID = "propSort_general_Content";
            PropertyTypes.Controls.Add(propSort_gp);
            _sortLists.Add(propSort_gp);
            
            propertiesPH.Controls.Add(new LiteralControl("<ul class='genericPropertyList' id=\"t_general_Contents\">"));
            foreach (cms.businesslogic.propertytype.PropertyType pt in _contentType.PropertyTypes)
            {
                //This use to be:
                if (pt.ContentTypeId == _contentType.Id && inTab.ContainsKey(pt.Id.ToString()) == false)
                //But seriously, if it's not on a tab the tabId is 0, it's a lot easier to read IMO
                //if (pt.ContentTypeId == _contentType.Id && pt.TabId == 0)
                {
                    var gpw = new GenericPropertyWrapper();

                    // Changed by duckie, was:
                    // gpw.ID = "gpw_" + editPropertyType.Alias;
                    // Which is NOT unique!
                    gpw.ID = "gpw_" + pt.Id;

                    gpw.PropertyType = pt;
                    gpw.Tabs = tabs;
                    gpw.DataTypeDefinitions = dtds;
                    gpw.Delete += new EventHandler(gpw_Delete);
                    gpw.FullId = "t_general_Contents_" + pt.Id;

                    propertiesPH.Controls.Add(gpw);
                    _genericProperties.Add(gpw);
                    if (refresh)
                        gpw.GenricPropertyControl.UpdateInterface();
                    inTab.Add(pt.Id, "");
                    propertyTabHasProperties = true;
                    counter++;
                }
            }

            propertiesPH.Controls.Add(new LiteralControl("</ul>"));

            var jsSortable_gp = GetJavaScriptForPropertySorting(propSort_gp.ClientID);

            Page.ClientScript.RegisterStartupScript(this.GetType(), "propSort_gp", jsSortable_gp, true);


            if (!propertyTabHasProperties)
            {
                AddNoPropertiesDefinedMessage();
                PropertyTypes.Controls.Remove(PropertyTypes.FindControl("propertiesPH"));
            }
            else
            {
                PropertyTypes.Controls.Add(propertiesPH);
            }

            PropertyTypes.Controls.Add(new LiteralControl("</div>")); // closes draggable container for properties on tabs

        }
 public DeleteAsyncState(
     Umbraco.Web.UmbracoContext umbracoContext,
     GenericPropertyWrapper genericPropertyWrapper)
 {
     UmbracoContext = umbracoContext;
     GenericPropertyWrapper = genericPropertyWrapper;
 }
示例#4
0
        private void bindDataGenericProperties(bool Refresh)
        {
            cms.businesslogic.ContentType.TabI[]            tabs = cType.getVirtualTabs;
            cms.businesslogic.datatype.DataTypeDefinition[] dtds = cms.businesslogic.datatype.DataTypeDefinition.GetAll();

            PropertyTypes.Controls.Clear();

            // Remove any tab from list that's from a master content type (shouldn't be able to configure those from a child)

            /*            System.Collections.Generic.List<cms.businesslogic.ContentType.TabI> localTabs = new System.Collections.Generic.List<umbraco.cms.businesslogic.ContentType.TabI>();
             *          foreach (cms.businesslogic.ContentType.TabI t in tabs)
             *          {
             *              if (t.ContentType == cType.Id)
             *                  localTabs.Add(t);
             *          }
             *          tabs = localTabs.ToArray();
             */
            // Add new property
            if (PropertyTypeNew.Controls.Count == 0)
            {
                PropertyTypeNew.Controls.Add(new LiteralControl("<h2 class=\"propertypaneTitel\">Add New Property</h2><ul class='genericPropertyList addNewProperty'>"));
                gp      = new controls.GenericProperties.GenericPropertyWrapper();
                gp.ID   = "GenericPropertyNew";
                gp.Tabs = tabs;
                gp.DataTypeDefinitions = dtds;
                PropertyTypeNew.Controls.Add(gp);
                PropertyTypeNew.Controls.Add(new LiteralControl("</ul>"));
            }
            else if (Refresh)
            {
                gp      = (controls.GenericProperties.GenericPropertyWrapper)PropertyTypeNew.Controls[1];
                gp.ID   = "GenericPropertyNew";
                gp.Tabs = tabs;
                gp.DataTypeDefinitions = dtds;
                gp.UpdateEditControl();
                gp.GenricPropertyControl.UpdateInterface();
                gp.GenricPropertyControl.Clear();
            }

            _genericProperties.Clear();
            Hashtable inTab         = new Hashtable();
            int       counter       = 0;
            string    scrollLayerId = GenericPropertiesTabPage.ClientID + "_contentlayer";

            foreach (cms.businesslogic.ContentType.TabI t in tabs)
            {
                bool   hasProperties = false;
                string tabCaption    = t.ContentType == cType.Id ? t.GetRawCaption() : t.GetRawCaption() + " (inherited from " + new ContentType(t.ContentType).Text + ")";
                PropertyTypes.Controls.Add(new LiteralControl("<div class='genericPropertyListBox'><h2 class=\"propertypaneTitel\">Tab: " + tabCaption + "</h2>"));

                // zb-00036 #29889 : fix property types getter
                var propertyTypes = t.GetPropertyTypes(cType.Id, false);

                if (propertyTypes.Length > 0)
                {
                    HtmlInputHidden propSort = new HtmlInputHidden();
                    propSort.ID = "propSort_" + t.Id.ToString() + "_Content";
                    PropertyTypes.Controls.Add(propSort);
                    _sortLists.Add(propSort);

                    // zb-00036 #29889 : remove filter, not needed anymore

                    if (propertyTypes.Count() > 0)
                    {
                        PropertyTypes.Controls.Add(new LiteralControl("<ul class='genericPropertyList' id=\"t_" + t.Id.ToString() + "_Contents\">"));

                        foreach (cms.businesslogic.propertytype.PropertyType pt in propertyTypes)
                        {
                            GenericProperties.GenericPropertyWrapper gpw = new umbraco.controls.GenericProperties.GenericPropertyWrapper();

                            // Changed by duckie, was:
                            // gpw.ID = "gpw_" + editPropertyType.Alias;
                            // Which is NOT unique!
                            gpw.ID = "gpw_" + pt.Id;

                            gpw.PropertyType        = pt;
                            gpw.Tabs                = tabs;
                            gpw.TabId               = t.Id;
                            gpw.DataTypeDefinitions = dtds;
                            gpw.Delete             += new EventHandler(gpw_Delete);
                            gpw.FullId              = "t_" + t.Id.ToString() + "_Contents_" + +pt.Id;

                            PropertyTypes.Controls.Add(gpw);
                            _genericProperties.Add(gpw);
                            if (Refresh)
                            {
                                gpw.GenricPropertyControl.UpdateInterface();
                            }
                            inTab.Add(pt.Id.ToString(), "");
                            counter++;
                            hasProperties = true;
                        }

                        PropertyTypes.Controls.Add(new LiteralControl("</ul>"));
                    }

                    var jsSortable = @"                            
                                (function($) {
                                    var propSortId = ""#" + propSort.ClientID + @""";
                                    $(document).ready(function() {
                                        $(propSortId).next("".genericPropertyList"").sortable({containment: 'parent', tolerance: 'pointer',
                                            update: function(event, ui) { 
                                                $(propSortId).val($(this).sortable('serialize'));
                                            }});
                                    });
                                })(jQuery);";

                    Page.ClientScript.RegisterStartupScript(this.GetType(), propSort.ClientID, jsSortable, true);

                    if (!hasProperties)
                    {
                        addNoPropertiesDefinedMessage();
                    }

                    PropertyTypes.Controls.Add(new LiteralControl("</div>"));
                }
                else
                {
                    addNoPropertiesDefinedMessage();
                    PropertyTypes.Controls.Add(new LiteralControl("</div>"));
                }
            }

            // Generic properties tab
            counter = 0;
            bool        propertyTabHasProperties = false;
            PlaceHolder propertiesPH             = new PlaceHolder();

            propertiesPH.ID = "propertiesPH";
            PropertyTypes.Controls.Add(new LiteralControl("<h2 class=\"propertypaneTitel\">Tab: Generic Properties</h2>"));
            PropertyTypes.Controls.Add(propertiesPH);

            HtmlInputHidden propSort_gp = new HtmlInputHidden();

            propSort_gp.ID = "propSort_general_Content";
            propertiesPH.Controls.Add(propSort_gp);
            _sortLists.Add(propSort_gp);


            propertiesPH.Controls.Add(new LiteralControl("<ul class='genericPropertyList' id=\"t_general_Contents\">"));
            foreach (cms.businesslogic.propertytype.PropertyType pt in cType.PropertyTypes)
            {
                //This use to be:
                //if (pt.ContentTypeId == cType.Id && !inTab.ContainsKey(pt.Id.ToString())
                //But seriously, if it's not on a tab the tabId is 0, it's a lot easier to read IMO
                if (pt.ContentTypeId == cType.Id && pt.TabId == 0)
                {
                    GenericProperties.GenericPropertyWrapper gpw = new umbraco.controls.GenericProperties.GenericPropertyWrapper();

                    // Changed by duckie, was:
                    // gpw.ID = "gpw_" + editPropertyType.Alias;
                    // Which is NOT unique!
                    gpw.ID = "gpw_" + pt.Id;

                    gpw.PropertyType        = pt;
                    gpw.Tabs                = tabs;
                    gpw.DataTypeDefinitions = dtds;
                    gpw.Delete             += new EventHandler(gpw_Delete);
                    gpw.FullId              = "t_general_Contents_" + pt.Id;

                    propertiesPH.Controls.Add(gpw);
                    _genericProperties.Add(gpw);
                    if (Refresh)
                    {
                        gpw.GenricPropertyControl.UpdateInterface();
                    }
                    inTab.Add(pt.Id, "");
                    propertyTabHasProperties = true;
                    counter++;
                }
            }


            propertiesPH.Controls.Add(new LiteralControl("</ul>"));
            //propertiesPH.Controls.Add(new LiteralControl("<script>\n Sortable.create(\"generalPropertiesContents\",{scroll: '" + scrollLayerId + "',dropOnEmpty:false,containment:[\"generalPropertiesContents\"],constraint:'vertical',onUpdate:function(element) {document.getElementById('" + propSort_gp.ClientID + "').value = Sortable.serialize('generalPropertiesContents');}});\n</script>"));

            var jsSortable_gp = @"                
                    (function($) {
                        var propSortId = ""#" + propSort_gp.ClientID + @""";
                        $(document).ready(function() {
                            $(propSortId).next("".genericPropertyList"").sortable({containment: 'parent', tolerance: 'pointer',
                                update: function(event, ui) { 
                                    $(propSortId).val($(this).sortable('serialize'));
                                }});
                        });
                    })(jQuery);";

            Page.ClientScript.RegisterStartupScript(this.GetType(), "propSort_gp", jsSortable_gp, true);


            if (!propertyTabHasProperties)
            {
                PropertyTypes.Controls.Add(new LiteralControl("<div style=\"margin: 10px; padding: 4px; border: 1px solid #ccc;\">No properties defined on this tab. Click on the \"add a new property\" link at the top to create a new property.</div>"));
                PropertyTypes.Controls.Remove(PropertyTypes.FindControl("propertiesPH"));
            }
            else
            {
                PropertyTypes.Controls.Add(propertiesPH);
            }
        }
        private void bindDataGenericProperties(bool Refresh)
        {
            cms.businesslogic.ContentType.TabI[] tabs = cType.getVirtualTabs;
            cms.businesslogic.datatype.DataTypeDefinition[] dtds = cms.businesslogic.datatype.DataTypeDefinition.GetAll();

            PropertyTypes.Controls.Clear();

            // Remove any tab from list that's from a master content type (shouldn't be able to configure those from a child)
            /*            System.Collections.Generic.List<cms.businesslogic.ContentType.TabI> localTabs = new System.Collections.Generic.List<umbraco.cms.businesslogic.ContentType.TabI>();
                        foreach (cms.businesslogic.ContentType.TabI t in tabs)
                        {
                            if (t.ContentType == cType.Id)
                                localTabs.Add(t);
                        }
                        tabs = localTabs.ToArray();
            */
            // Add new property
            if (PropertyTypeNew.Controls.Count == 0)
            {
                PropertyTypeNew.Controls.Add(new LiteralControl("<h2 class=\"propertypaneTitel\">Add New Property</h2><ul class='genericPropertyList addNewProperty'>"));
                gp = new controls.GenericProperties.GenericPropertyWrapper();
                gp.ID = "GenericPropertyNew";
                gp.Tabs = tabs;
                gp.DataTypeDefinitions = dtds;
                PropertyTypeNew.Controls.Add(gp);
                PropertyTypeNew.Controls.Add(new LiteralControl("</ul>"));
            }
            else if (Refresh)
            {
                gp = (controls.GenericProperties.GenericPropertyWrapper)PropertyTypeNew.Controls[1];
                gp.ID = "GenericPropertyNew";
                gp.Tabs = tabs;
                gp.DataTypeDefinitions = dtds;
                gp.UpdateEditControl();
                gp.GenricPropertyControl.UpdateInterface();
                gp.GenricPropertyControl.Clear();
            }

            _genericProperties.Clear();
            Hashtable inTab = new Hashtable();
            int counter = 0;
            string scrollLayerId = GenericPropertiesTabPage.ClientID + "_contentlayer";

            foreach (cms.businesslogic.ContentType.TabI t in tabs)
            {
                bool hasProperties = false;
                string tabCaption = t.ContentType == cType.Id ? t.GetRawCaption() : t.GetRawCaption() + " (inherited from " + new ContentType(t.ContentType).Text + ")";
                PropertyTypes.Controls.Add(new LiteralControl("<div class='genericPropertyListBox'><h2 class=\"propertypaneTitel\">Tab: " + tabCaption + "</h2>"));

                // zb-00036 #29889 : fix property types getter
                var propertyTypes = t.GetPropertyTypes(cType.Id, false);

                if (propertyTypes.Length > 0)
                {
                    HtmlInputHidden propSort = new HtmlInputHidden();
                    propSort.ID = "propSort_" + t.Id.ToString() + "_Content";
                    PropertyTypes.Controls.Add(propSort);
                    _sortLists.Add(propSort);

                    // zb-00036 #29889 : remove filter, not needed anymore

                    if (propertyTypes.Count() > 0)
                    {
                        PropertyTypes.Controls.Add(new LiteralControl("<ul class='genericPropertyList' id=\"t_" + t.Id.ToString() + "_Contents\">"));

                        foreach (cms.businesslogic.propertytype.PropertyType pt in propertyTypes)
                        {
                            GenericProperties.GenericPropertyWrapper gpw = new umbraco.controls.GenericProperties.GenericPropertyWrapper();

                            // Changed by duckie, was:
                            // gpw.ID = "gpw_" + editPropertyType.Alias;
                            // Which is NOT unique!
                            gpw.ID = "gpw_" + pt.Id;

                            gpw.PropertyType = pt;
                            gpw.Tabs = tabs;
                            gpw.TabId = t.Id;
                            gpw.DataTypeDefinitions = dtds;
                            gpw.Delete += new EventHandler(gpw_Delete);
                            gpw.FullId = "t_" + t.Id.ToString() + "_Contents_" + +pt.Id;

                            PropertyTypes.Controls.Add(gpw);
                            _genericProperties.Add(gpw);
                            if (Refresh)
                                gpw.GenricPropertyControl.UpdateInterface();
                            inTab.Add(pt.Id.ToString(), "");
                            counter++;
                            hasProperties = true;
                        }

                        PropertyTypes.Controls.Add(new LiteralControl("</ul>"));
                    }

                    var jsSortable = @"                            
                                (function($) {
                                    var propSortId = ""#" + propSort.ClientID + @""";
                                    $(document).ready(function() {
                                        $(propSortId).next("".genericPropertyList"").sortable({containment: 'parent', tolerance: 'pointer',
                                            update: function(event, ui) { 
                                                $(propSortId).val($(this).sortable('serialize'));
                                            }});
                                    });
                                })(jQuery);";

                    Page.ClientScript.RegisterStartupScript(this.GetType(), propSort.ClientID, jsSortable, true);

                    if (!hasProperties)
                    {
                        addNoPropertiesDefinedMessage();
                    }

                    PropertyTypes.Controls.Add(new LiteralControl("</div>"));
                }
                else
                {
                    addNoPropertiesDefinedMessage();
                    PropertyTypes.Controls.Add(new LiteralControl("</div>"));
                }
            }

            // Generic properties tab
            counter = 0;
            bool propertyTabHasProperties = false;
            PlaceHolder propertiesPH = new PlaceHolder();
            propertiesPH.ID = "propertiesPH";
            PropertyTypes.Controls.Add(new LiteralControl("<h2 class=\"propertypaneTitel\">Tab: Generic Properties</h2>"));
            PropertyTypes.Controls.Add(propertiesPH);

            HtmlInputHidden propSort_gp = new HtmlInputHidden();
            propSort_gp.ID = "propSort_general_Content";
            propertiesPH.Controls.Add(propSort_gp);
            _sortLists.Add(propSort_gp);


            propertiesPH.Controls.Add(new LiteralControl("<ul class='genericPropertyList' id=\"t_general_Contents\">"));
            foreach (cms.businesslogic.propertytype.PropertyType pt in cType.PropertyTypes)
            {
                //This use to be:
                //if (pt.ContentTypeId == cType.Id && !inTab.ContainsKey(pt.Id.ToString())
                //But seriously, if it's not on a tab the tabId is 0, it's a lot easier to read IMO
                if (pt.ContentTypeId == cType.Id && pt.TabId == 0)
                {
                    GenericProperties.GenericPropertyWrapper gpw = new umbraco.controls.GenericProperties.GenericPropertyWrapper();

                    // Changed by duckie, was:
                    // gpw.ID = "gpw_" + editPropertyType.Alias;
                    // Which is NOT unique!
                    gpw.ID = "gpw_" + pt.Id;

                    gpw.PropertyType = pt;
                    gpw.Tabs = tabs;
                    gpw.DataTypeDefinitions = dtds;
                    gpw.Delete += new EventHandler(gpw_Delete);
                    gpw.FullId = "t_general_Contents_" + pt.Id;

                    propertiesPH.Controls.Add(gpw);
                    _genericProperties.Add(gpw);
                    if (Refresh)
                        gpw.GenricPropertyControl.UpdateInterface();
                    inTab.Add(pt.Id, "");
                    propertyTabHasProperties = true;
                    counter++;
                }
            }


            propertiesPH.Controls.Add(new LiteralControl("</ul>"));
            //propertiesPH.Controls.Add(new LiteralControl("<script>\n Sortable.create(\"generalPropertiesContents\",{scroll: '" + scrollLayerId + "',dropOnEmpty:false,containment:[\"generalPropertiesContents\"],constraint:'vertical',onUpdate:function(element) {document.getElementById('" + propSort_gp.ClientID + "').value = Sortable.serialize('generalPropertiesContents');}});\n</script>"));

            var jsSortable_gp = @"                
                    (function($) {
                        var propSortId = ""#" + propSort_gp.ClientID + @""";
                        $(document).ready(function() {
                            $(propSortId).next("".genericPropertyList"").sortable({containment: 'parent', tolerance: 'pointer',
                                update: function(event, ui) { 
                                    $(propSortId).val($(this).sortable('serialize'));
                                }});
                        });
                    })(jQuery);";

            Page.ClientScript.RegisterStartupScript(this.GetType(), "propSort_gp", jsSortable_gp, true);


            if (!propertyTabHasProperties)
            {
                PropertyTypes.Controls.Add(new LiteralControl("<div style=\"margin: 10px; padding: 4px; border: 1px solid #ccc;\">No properties defined on this tab. Click on the \"add a new property\" link at the top to create a new property.</div>"));
                PropertyTypes.Controls.Remove(PropertyTypes.FindControl("propertiesPH"));
            }
            else
                PropertyTypes.Controls.Add(propertiesPH);

        }
        private void BindDataGenericProperties(bool refresh)
        {
            var tabs = _contentType.getVirtualTabs;
            var propertyTypeGroups = _contentType.PropertyTypeGroups.ToList();
            var dtds = cms.businesslogic.datatype.DataTypeDefinition.GetAll();

            PropertyTypes.Controls.Clear();

            // Add new property
            if (PropertyTypeNew.Controls.Count == 0)
            {
                PropertyTypeNew.Controls.Add(new LiteralControl("<h2 class=\"propertypaneTitel\">Add New Property</h2><ul class='genericPropertyList addNewProperty'>"));
                gp = new GenericPropertyWrapper();
                gp.ID = "GenericPropertyNew";
                gp.Tabs = tabs;
                gp.DataTypeDefinitions = dtds;
                PropertyTypeNew.Controls.Add(gp);
                PropertyTypeNew.Controls.Add(new LiteralControl("</ul>"));
            }
            else if (refresh)
            {
                gp = (GenericPropertyWrapper)PropertyTypeNew.Controls[1];
                gp.ID = "GenericPropertyNew";
                gp.Tabs = tabs;
                gp.DataTypeDefinitions = dtds;
                gp.UpdateEditControl();
                gp.GenricPropertyControl.UpdateInterface();
                gp.GenricPropertyControl.Clear();
            }

            _genericProperties.Clear();
            var inTab = new Hashtable();
            int counter = 0;

            foreach (ContentType.TabI tab in tabs)
            {
                bool hasProperties = false;
                string tabCaption = tab.ContentType == _contentType.Id ? tab.GetRawCaption() : tab.GetRawCaption() + " (inherited from " + new ContentType(tab.ContentType).Text + ")";
                PropertyTypes.Controls.Add(new LiteralControl("<div class='genericPropertyListBox'><h2 class=\"propertypaneTitel\">Tab: " + tabCaption + "</h2>"));

                var propertyGroup = propertyTypeGroups.SingleOrDefault(x => x.ParentId == tab.Id);
                var propertyTypes = propertyGroup == null
                                        ? tab.GetPropertyTypes(_contentType.Id, false)
                                        : propertyGroup.GetPropertyTypes();

                var propertyGroupId = tab.Id;

                if (propertyTypes.Any(x => x.ContentTypeId == _contentType.Id))
                {
                    var propSort = new HtmlInputHidden();
                    propSort.ID = "propSort_" + propertyGroupId.ToString() + "_Content";
                    PropertyTypes.Controls.Add(propSort);
                    _sortLists.Add(propSort);

                    PropertyTypes.Controls.Add(new LiteralControl("<ul class='genericPropertyList' id=\"t_" + propertyGroupId.ToString() + "_Contents\">"));

                    foreach (cms.businesslogic.propertytype.PropertyType pt in propertyTypes)
                    {
                        //If the PropertyType doesn't belong on this ContentType skip it and continue to the next one
                        if (pt.ContentTypeId != _contentType.Id) continue;

                        var gpw = new GenericPropertyWrapper();
                        gpw.ID = "gpw_" + pt.Id;
                        gpw.PropertyType = pt;
                        gpw.Tabs = tabs;
                        gpw.TabId = propertyGroupId;
                        gpw.DataTypeDefinitions = dtds;
                        gpw.Delete += new EventHandler(gpw_Delete);
                        gpw.FullId = "t_" + propertyGroupId.ToString() + "_Contents_" + +pt.Id;

                        PropertyTypes.Controls.Add(gpw);
                        _genericProperties.Add(gpw);
                        if (refresh)
                            gpw.GenricPropertyControl.UpdateInterface();

                        inTab.Add(pt.Id.ToString(), "");
                        counter++;
                        hasProperties = true;
                    }

                    PropertyTypes.Controls.Add(new LiteralControl("</ul>"));

                    var jsSortable = @"                            
                                (function($) {
                                    var propSortId = ""#" + propSort.ClientID + @""";
                                    $(document).ready(function() {
                                        $(propSortId).next("".genericPropertyList"").sortable({containment: 'parent', tolerance: 'pointer',
                                            update: function(event, ui) { 
                                                $(propSortId).val($(this).sortable('serialize'));
                                            }});
                                    });
                                })(jQuery);";

                    Page.ClientScript.RegisterStartupScript(this.GetType(), propSort.ClientID, jsSortable, true);

                    if (!hasProperties)
                    {
                        AddNoPropertiesDefinedMessage();
                    }

                    PropertyTypes.Controls.Add(new LiteralControl("</div>"));
                }
                else
                {
                    AddNoPropertiesDefinedMessage();
                    PropertyTypes.Controls.Add(new LiteralControl("</div>"));
                }
            }

            // Generic properties tab
            counter = 0;
            bool propertyTabHasProperties = false;
            var propertiesPH = new PlaceHolder();
            propertiesPH.ID = "propertiesPH";
            PropertyTypes.Controls.Add(new LiteralControl("<h2 class=\"propertypaneTitel\">Tab: Generic Properties</h2>"));
            PropertyTypes.Controls.Add(propertiesPH);

            var propSort_gp = new HtmlInputHidden();
            propSort_gp.ID = "propSort_general_Content";
            propertiesPH.Controls.Add(propSort_gp);
            _sortLists.Add(propSort_gp);


            propertiesPH.Controls.Add(new LiteralControl("<ul class='genericPropertyList' id=\"t_general_Contents\">"));
            foreach (cms.businesslogic.propertytype.PropertyType pt in _contentType.PropertyTypes)
            {
                //This use to be:
                if (pt.ContentTypeId == _contentType.Id && inTab.ContainsKey(pt.Id.ToString()) == false)
                //But seriously, if it's not on a tab the tabId is 0, it's a lot easier to read IMO
                //if (pt.ContentTypeId == _contentType.Id && pt.TabId == 0)
                {
                    var gpw = new GenericPropertyWrapper();

                    // Changed by duckie, was:
                    // gpw.ID = "gpw_" + editPropertyType.Alias;
                    // Which is NOT unique!
                    gpw.ID = "gpw_" + pt.Id;

                    gpw.PropertyType = pt;
                    gpw.Tabs = tabs;
                    gpw.DataTypeDefinitions = dtds;
                    gpw.Delete += new EventHandler(gpw_Delete);
                    gpw.FullId = "t_general_Contents_" + pt.Id;

                    propertiesPH.Controls.Add(gpw);
                    _genericProperties.Add(gpw);
                    if (refresh)
                        gpw.GenricPropertyControl.UpdateInterface();
                    inTab.Add(pt.Id, "");
                    propertyTabHasProperties = true;
                    counter++;
                }
            }

            propertiesPH.Controls.Add(new LiteralControl("</ul>"));

            var jsSortable_gp = @"                
                    (function($) {
                        var propSortId = ""#" + propSort_gp.ClientID + @""";
                        $(document).ready(function() {
                            $(propSortId).next("".genericPropertyList"").sortable({containment: 'parent', tolerance: 'pointer',
                                update: function(event, ui) { 
                                    $(propSortId).val($(this).sortable('serialize'));
                                }});
                        });
                    })(jQuery);";

            Page.ClientScript.RegisterStartupScript(this.GetType(), "propSort_gp", jsSortable_gp, true);


            if (!propertyTabHasProperties)
            {
                PropertyTypes.Controls.Add(new LiteralControl("<div style=\"margin: 10px; padding: 4px; border: 1px solid #ccc;\">No properties defined on this tab. Click on the \"add a new property\" link at the top to create a new property.</div>"));
                PropertyTypes.Controls.Remove(PropertyTypes.FindControl("propertiesPH"));
            }
            else
                PropertyTypes.Controls.Add(propertiesPH);

        }