Ejemplo n.º 1
0
            private void AddPropertyType(object sender, System.EventArgs e)
            {
                if (NameTxt.Text.Trim() != "" && AliasTxt.Text.Trim() != "")
                {
                    string[] info = { NameTxt.Text, DataTypeDDL.SelectedItem.Value };
                    ctctrl.prnt.speechBubble(BasePages.BasePage.speechBubbleIcon.info, ui.Text("speechBubbles", "contentTypePropertyTypeCreated", null), ui.Text("speechBubbles", "contentTypePropertyTypeCreatedText", info, null));
                    _dt.AddPropertyType(cms.businesslogic.datatype.DataTypeDefinition.GetDataTypeDefinition(int.Parse(DataTypeDDL.SelectedValue)), AliasTxt.Text, NameTxt.Text);

                    if (int.Parse(TabDDL.SelectedValue) != 0)
                    {
                        _dt.SetTabOnPropertyType(_dt.getPropertyType(AliasTxt.Text), int.Parse(TabDDL.SelectedValue));
                    }
                    ctctrl.GenericPropertyTypes.Controls.Clear();
                    ctctrl.loadGenericPropertyTypesOnPane();
                    NameTxt.Text  = "";
                    AliasTxt.Text = "";
                    // fire event to tell that a new propertytype is created!!
                    ctctrl.OnPropertyTypeCreate(this, new System.EventArgs());
                }
                else
                {
                    ctctrl.prnt.speechBubble(BasePages.BasePage.speechBubbleIcon.error, ui.Text("error"), ui.Text("errors", "contentTypeAliasAndNameNotNull", null));
                }
            }
Ejemplo n.º 2
0
        private void saveProperties(ref SaveClickEventArgs e)
        {
            this.CreateChildControls();

            GenericProperties.GenericProperty gpData = gp.GenricPropertyControl;
            if (gpData.Name.Trim() != "" && gpData.Alias.Trim() != "")
            {
                if (doesPropertyTypeAliasExist(gpData))
                {
                    string[] info = { gpData.Name, gpData.Type.ToString() };
                    cms.businesslogic.propertytype.PropertyType pt = cType.AddPropertyType(cms.businesslogic.datatype.DataTypeDefinition.GetDataTypeDefinition(gpData.Type), Casing.SafeAliasWithForcingCheck(gpData.Alias.Trim()), gpData.Name);
                    pt.Mandatory        = gpData.Mandatory;
                    pt.ValidationRegExp = gpData.Validation;
                    pt.Description      = gpData.Description;

                    if (gpData.Tab != 0)
                    {
                        cType.SetTabOnPropertyType(pt, gpData.Tab);
                    }

                    gpData.Clear();
                }
                else
                {
                    e.Message  = ui.Text("contentTypeDublicatePropertyType");
                    e.IconType = umbraco.BasePages.BasePage.speechBubbleIcon.warning;
                }
            }

            foreach (GenericProperties.GenericPropertyWrapper gpw in _genericProperties)
            {
                cms.businesslogic.propertytype.PropertyType pt = gpw.PropertyType;
                pt.Alias              = gpw.GenricPropertyControl.Alias;
                pt.Name               = gpw.GenricPropertyControl.Name;
                pt.Description        = gpw.GenricPropertyControl.Description;
                pt.ValidationRegExp   = gpw.GenricPropertyControl.Validation;
                pt.Mandatory          = gpw.GenricPropertyControl.Mandatory;
                pt.DataTypeDefinition = cms.businesslogic.datatype.DataTypeDefinition.GetDataTypeDefinition(gpw.GenricPropertyControl.Type);
                if (gpw.GenricPropertyControl.Tab == 0)
                {
                    cType.removePropertyTypeFromTab(pt);
                }
                else
                {
                    cType.SetTabOnPropertyType(pt, gpw.GenricPropertyControl.Tab);
                }

                pt.Save();
            }

            // Sort order
            foreach (HtmlInputHidden propSorter in _sortLists)
            {
                if (propSorter.Value.Trim() != "")
                {
                    string tabId = propSorter.ID;
                    // remove leading "propSort_" and trailing "_Content"
                    tabId = tabId.Substring(9, tabId.Length - 9 - 8);
                    // calc the position of the prop SO i.e. after "t_<tabId>Contents[]="
                    int propSOPosition = "t_".Length + tabId.Length + "Contents[]=".Length + 1;

                    string[] tempSO = propSorter.Value.Split("&".ToCharArray());
                    for (int i = 0; i < tempSO.Length; i++)
                    {
                        string propSO           = tempSO[i].Substring(propSOPosition);
                        int    currentSortOrder = int.Parse(propSO);
                        cms.businesslogic.propertytype.PropertyType.GetPropertyType(currentSortOrder).SortOrder = i;
                    }
                }
            }
        }