protected override void OnLoad(EventArgs e)
        {
            Title = "Administrate Form Fields";

            if (
                CurrentList.ParentWeb.Properties.ContainsKey(String.Format("DisplaySetting{0}",
                                                                           CurrentList.ID)))
            {
                _fieldProperties =
                    SPSWebPropertiesHelper.Decode(
                        CurrentList.ParentWeb.Properties[String.Format("DisplaySetting{0}", CurrentList.ID)]);
            }

            // récupération de la liste des champs affichables et des settings dejà défini
            foreach (SPField field in CurrentList.Fields)
            {
                if ((field.Reorderable))
                {
                    _displayableFields.Add(field);
                }
            }

            // Récupération des groups
            foreach (SPGroup group in CurrentList.ParentWeb.Groups)
            {
                _groups.Add(group);
            }

            _pageRender = PrepareRenderPage();
            RegisterScript();

            Cancel.PostBackUrl = string.Format("~/_layouts/listedit.aspx?List={0}", CurrentList.ID);
        }
示例#2
0
        protected override bool IsFieldExcluded(SPField field)
        {
            if (CheckIfFeatureIsEnabled())
            {
                string key = String.Format("DisplaySetting{0}", SPContext.Current.List.ID);

                if (SPContext.Current.List.ParentWeb.Properties.ContainsKey(key))
                {
                    var fieldProperties = SPSWebPropertiesHelper.Decode(
                        SPContext.Current.List.ParentWeb.Properties[key]);

                    string displaySettings;

                    if (!fieldProperties.ContainsKey(field.InternalName))
                    {
                        return(base.IsFieldExcluded(field));
                    }

                    switch (SPContext.Current.FormContext.FormMode)
                    {
                    case SPControlMode.Display:
                    {
                        displaySettings = fieldProperties[field.InternalName]["Display"];

                        GetAttributes(displaySettings);

                        return(NecesaryRender(field));
                    }

                    case SPControlMode.Edit:
                    {
                        displaySettings = fieldProperties[field.InternalName]["Edit"];

                        GetAttributes(displaySettings);

                        return(NecesaryRender(field));
                    }

                    case SPControlMode.New:
                    {
                        if (!fieldProperties[field.InternalName].ContainsKey("New"))
                        {
                            return(base.IsFieldExcluded(field));
                        }

                        displaySettings = fieldProperties[field.InternalName]["New"];
                        GetAttributes(displaySettings);

                        return(NecesaryRender(field));
                    }

                    default:
                        return(base.IsFieldExcluded(field));
                    }
                }
                return(base.IsFieldExcluded(field));
            }
            return(base.IsFieldExcluded(field));
        }