Exemple #1
0
        protected void save_click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            // 2011 01 06 - APN - Modified method to update Xml caches if a doctype alias changed,
            // also added calls to update the tree if the name has changed
            // ---

            // Keep a reference of the original doctype alias and name
            var originalDocTypeAlias = cType.Alias;
            var originalDocTypeName  = cType.Text;

            cType.Text        = txtName.Text;
            cType.Alias       = txtAlias.Text;
            cType.IconUrl     = ddlIcons.SelectedValue;
            cType.Description = description.Text;
            cType.Thumbnail   = ddlThumbnails.SelectedValue;
            SaveClickEventArgs ea = new SaveClickEventArgs("Saved");

            ea.IconType = umbraco.BasePages.BasePage.speechBubbleIcon.success;

            saveProperties(ref ea);

            SaveTabs();

            SaveAllowedChildTypes();

            // reload content type (due to caching)
            cType = new ContentType(cType.Id);

            // Check if the doctype alias has changed as a result of either the user input or
            // the alias checking performed upon saving
            var docTypeAliasChanged = (string.Compare(originalDocTypeAlias, cType.Alias, true) != 0);
            var docTypeNameChanged  = (string.Compare(originalDocTypeName, cType.Text, true) != 0);

            // Only if the doctype alias changed, cause a regeneration of the xml cache file since
            // the xml element names will need to be updated to reflect the new alias
            if (docTypeAliasChanged)
            {
                RegenerateXmlCaches();
            }

            bindDataGenericProperties(true);

            // we need to re-bind the alias as the SafeAlias method can have changed it
            txtAlias.Text = cType.Alias;

            RaiseBubbleEvent(new object(), ea);

            if (docTypeNameChanged)
            {
                UpdateTreeNode();
            }
        }
Exemple #2
0
        protected void dgTabs_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.CommandName == "Delete")
            {
                cType.DeleteVirtualTab(int.Parse(e.Item.Cells[0].Text));

                SaveClickEventArgs ea = new SaveClickEventArgs(ui.Text("contentTypeTabDeleted"));
                ea.IconType = umbraco.BasePages.BasePage.speechBubbleIcon.success;

                RaiseBubbleEvent(new object(), ea);
            }


            bindTabs();
            bindDataGenericProperties(true);
        }
Exemple #3
0
        protected void btnNewTab_Click(object sender, System.EventArgs e)
        {
            if (txtNewTab.Text.Trim() != "")
            {
                cType.AddVirtualTab(txtNewTab.Text);
                cType = new ContentType(cType.Id);
                SaveClickEventArgs ea = new SaveClickEventArgs(ui.Text("contentTypeTabCreated"));
                ea.IconType = umbraco.BasePages.BasePage.speechBubbleIcon.success;

                RaiseBubbleEvent(new object(), ea);

                txtNewTab.Text = "";
                bindTabs();
                bindDataGenericProperties(true);
            }

            Page.ClientScript.RegisterStartupScript(this.GetType(), "dropDowns", @"
Umbraco.Controls.TabView.onActiveTabChange(function(tabviewid, tabid, tabs) {
    refreshDropDowns();
});
", true);
        }
        private void SavePropertyTypesLegacy(SaveClickEventArgs e)
        {
            this.CreateChildControls();

            GenericProperty gpData = gp.GenricPropertyControl;
            if (gpData.Name.Trim() != "" && gpData.Alias.Trim() != "")
            {
                if (DoesPropertyTypeAliasExist(gpData))
                {
                    cms.businesslogic.propertytype.PropertyType pt =
                        _contentType.AddPropertyType(
                            cms.businesslogic.datatype.DataTypeDefinition.GetDataTypeDefinition(gpData.Type),
                            Casing.SafeAliasWithForcingCheck(gpData.Alias.Trim()), gpData.Name);
                    pt.Description = gpData.Description;
                    pt.ValidationRegExp = gpData.Validation.Trim();
                    pt.Mandatory = gpData.Mandatory;

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

                    gpData.Clear();

                }
                else
                {
                    e.Message = ui.Text("contentTypeDublicatePropertyType", Security.CurrentUser);
                    e.IconType = BasePage.speechBubbleIcon.warning;
                }
            }

            foreach (GenericPropertyWrapper gpw in _genericProperties)
            {
                cms.businesslogic.propertytype.PropertyType pt = gpw.PropertyType;
                pt.Alias = gpw.GenricPropertyControl.Alias; // FIXME so we blindly trust the UI for safe aliases?!
                pt.Name = gpw.GenricPropertyControl.Name;
                pt.Description = gpw.GenricPropertyControl.Description;
                pt.ValidationRegExp = gpw.GenricPropertyControl.Validation.Trim();
                pt.Mandatory = gpw.GenricPropertyControl.Mandatory;
                pt.DataTypeDefinition = cms.businesslogic.datatype.DataTypeDefinition.GetDataTypeDefinition(gpw.GenricPropertyControl.Type);
                if (gpw.GenricPropertyControl.Tab == 0)
                    _contentType.removePropertyTypeFromTab(pt);
                else
                    _contentType.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;
                    }
                }
            }
        }
        private void SavePropertyType(SaveClickEventArgs e, IContentTypeComposition contentTypeItem)
        {
            this.CreateChildControls();

            //The GenericPropertyWrapper control, which contains the details for the PropertyType being added
            GenericProperty gpData = gp.GenricPropertyControl;
            if (string.IsNullOrEmpty(gpData.Name.Trim()) == false && string.IsNullOrEmpty(gpData.Alias.Trim()) == false)
            {
                var propertyTypeAlias = Casing.SafeAliasWithForcingCheck(gpData.Alias.Trim());
                if (contentTypeItem.PropertyTypeExists(propertyTypeAlias) == false)
                {
                    //Find the DataTypeDefinition that the PropertyType should be based on
                    var dataTypeDefinition = ApplicationContext.Current.Services.DataTypeService.GetDataTypeDefinitionById(gpData.Type);
                    var propertyType = new PropertyType(dataTypeDefinition)
                                           {
                                               Alias = propertyTypeAlias,
                                               Name = gpData.Name.Trim(),
                                               Mandatory = gpData.Mandatory,
                                               ValidationRegExp = gpData.Validation,
                                               Description = gpData.Description
                                           };
                    //gpData.Tab == 0 Generic Properties / No Group
                    if (gpData.Tab == 0)
                    {
                        contentTypeItem.AddPropertyType(propertyType);
                    }
                    else
                    {
                        //Find the PropertyGroup by its Id and then set the PropertyType on that group
                        var exists = contentTypeItem.CompositionPropertyGroups.Any(x => x.Id == gpData.Tab);
                        if (exists)
                        {
                            var propertyGroup = contentTypeItem.CompositionPropertyGroups.First(x => x.Id == gpData.Tab);
                            contentTypeItem.AddPropertyType(propertyType, propertyGroup.Name);
                        }
                        else
                        {
                            var tab = gpData.Tabs.FirstOrDefault(x => x.Id == gpData.Tab);
                            if (tab != null)
                            {
                                var caption = tab.GetRawCaption();
                                contentTypeItem.AddPropertyType(propertyType, caption);
                            }
                        }
                    }
                    gpData.Clear();
                }
                else
                {
                    e.Message = ui.Text("contentTypeDublicatePropertyType");
                    e.IconType = BasePage.speechBubbleIcon.warning;
                }
            }
        }
 public SaveAsyncState(
     Umbraco.Web.UmbracoContext umbracoContext,
     SaveClickEventArgs saveArgs, 
     string originalAlias, 
     string originalName,
     string newAlias,
     string newName,
     string[] originalPropertyAliases)
 {
     UmbracoContext = umbracoContext;
     SaveArgs = saveArgs;
     _originalAlias = originalAlias;
     _originalName = originalName;
     _newAlias = newAlias;
     _originalPropertyAliases = originalPropertyAliases;
     _newName = newName;
 }
        /// <summary>
        /// Removes a Tab from current ContentType when user clicks Delete button
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void dgTabs_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.CommandName == "Delete")
            {
                int propertyGroupId = int.Parse(e.Item.Cells[0].Text);
                if (_contentType.ContentTypeItem is IContentType || _contentType.ContentTypeItem is IMediaType)
                {
                    var propertyGroup = _contentType.ContentTypeItem.PropertyGroups.FirstOrDefault(x => x.Id == propertyGroupId);
                    if (propertyGroup != null && string.IsNullOrEmpty(propertyGroup.Name) == false)
                    {
                        _contentType.ContentTypeItem.PropertyGroups.Remove(propertyGroup.Name);
                        _contentType.Save();
                    }
                }

                _contentType.DeleteVirtualTab(propertyGroupId);

                LoadContentType();

                var ea = new SaveClickEventArgs(ui.Text("contentTypeTabDeleted"));
                ea.IconType = BasePage.speechBubbleIcon.success;

                RaiseBubbleEvent(new object(), ea);

            }

            BindTabs();
            BindDataGenericProperties(true);
        }
        /// <summary>
        /// Adds a new Tab to current ContentType when user clicks 'New Tab'-button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnNewTab_Click(object sender, EventArgs e)
        {
            if (txtNewTab.Text.Trim() != "")
            {
                if (_contentType.ContentTypeItem is IContentType || _contentType.ContentTypeItem is IMediaType)
                {
                    _contentType.ContentTypeItem.AddPropertyGroup(txtNewTab.Text);
                    _contentType.Save();
                }
                else
                {
                    _contentType.AddVirtualTab(txtNewTab.Text);
                }

                LoadContentType();

                var ea = new SaveClickEventArgs(ui.Text("contentTypeTabCreated"));
                ea.IconType = BasePage.speechBubbleIcon.success;

                RaiseBubbleEvent(new object(), ea);

                txtNewTab.Text = "";

                BindTabs();
                BindDataGenericProperties(true);
            }

            Page.ClientScript.RegisterStartupScript(this.GetType(), "dropDowns", @"
Umbraco.Controls.TabView.onActiveTabChange(function(tabviewid, tabid, tabs) {
    refreshDropDowns();
});
", true);
        }
Exemple #9
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;
                    }
                }
            }
        }
        protected void dgTabs_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.CommandName == "Delete")
            {
                cType.DeleteVirtualTab(int.Parse(e.Item.Cells[0].Text));

                SaveClickEventArgs ea = new SaveClickEventArgs(ui.Text("contentTypeTabDeleted"));
                ea.IconType = umbraco.BasePages.BasePage.speechBubbleIcon.success;

                RaiseBubbleEvent(new object(), ea);

            }


            bindTabs();
            bindDataGenericProperties(true);
        }
        protected void btnNewTab_Click(object sender, System.EventArgs e)
        {
            if (txtNewTab.Text.Trim() != "")
            {
                cType.AddVirtualTab(txtNewTab.Text);
                cType = new ContentType(cType.Id);
                SaveClickEventArgs ea = new SaveClickEventArgs(ui.Text("contentTypeTabCreated"));
                ea.IconType = umbraco.BasePages.BasePage.speechBubbleIcon.success;

                RaiseBubbleEvent(new object(), ea);

                txtNewTab.Text = "";
                bindTabs();
                bindDataGenericProperties(true);
            }

            Page.ClientScript.RegisterStartupScript(this.GetType(), "dropDowns", @"
Umbraco.Controls.TabView.onActiveTabChange(function(tabviewid, tabid, tabs) {
    refreshDropDowns();
});
", true);
        }
        protected void save_click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            // 2011 01 06 - APN - Modified method to update Xml caches if a doctype alias changed, 
            // also added calls to update the tree if the name has changed
            // ---

            // Keep a reference of the original doctype alias and name
            var originalDocTypeAlias = cType.Alias;
            var originalDocTypeName = cType.Text;

            cType.Text = txtName.Text;
            cType.Alias = txtAlias.Text;
            cType.IconUrl = ddlIcons.SelectedValue;
            cType.Description = description.Text;
            cType.Thumbnail = ddlThumbnails.SelectedValue;
            SaveClickEventArgs ea = new SaveClickEventArgs("Saved");
            ea.IconType = umbraco.BasePages.BasePage.speechBubbleIcon.success;

            saveProperties(ref ea);

            SaveTabs();

            SaveAllowedChildTypes();

            // reload content type (due to caching)
            cType = new ContentType(cType.Id);

            // Check if the doctype alias has changed as a result of either the user input or
            // the alias checking performed upon saving
            var docTypeAliasChanged = (string.Compare(originalDocTypeAlias, cType.Alias, true) != 0);
            var docTypeNameChanged = (string.Compare(originalDocTypeName, cType.Text, true) != 0);

            // Only if the doctype alias changed, cause a regeneration of the xml cache file since
            // the xml element names will need to be updated to reflect the new alias
            if (docTypeAliasChanged)
                RegenerateXmlCaches();

            bindDataGenericProperties(true);

            // we need to re-bind the alias as the SafeAlias method can have changed it
            txtAlias.Text = cType.Alias;

            RaiseBubbleEvent(new object(), ea);

            if (docTypeNameChanged)
                UpdateTreeNode();
        }
        /// <summary>
        /// Adds a new Tab to current ContentType when user clicks 'New Tab'-button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnNewTab_Click(object sender, EventArgs e)
        {
            if (txtNewTab.Text.Trim() != "")
            {
                if (_contentType.ContentTypeItem is IContentType || _contentType.ContentTypeItem is IMediaType)
                {
                    _contentType.ContentTypeItem.AddPropertyGroup(txtNewTab.Text);
                    _contentType.Save();
                }
                else
                {
                    _contentType.AddVirtualTab(txtNewTab.Text);
                }

                LoadContentType();

                var ea = new SaveClickEventArgs(ui.Text("contentTypeTabCreated"));
                ea.IconType = BasePage.speechBubbleIcon.success;

                RaiseBubbleEvent(new object(), ea);

                txtNewTab.Text = "";

                BindTabs();
                BindDataGenericProperties(true);
            }

        }
 public SaveAsyncState(
     SaveClickEventArgs saveArgs, 
     string originalAlias, 
     string originalName,
     string newAlias,
     string newName)
 {
     SaveArgs = saveArgs;
     OriginalAlias = originalAlias;
     OriginalName = originalName;
     NewAlias = newAlias;
     NewName = newName;
 }