示例#1
0
    private void SaveCategoryCollapsingState(BasicForm basicForm)
    {
        var fi = GetWebPartFormInfo();

        foreach (var fci in fi.GetFields <FormCategoryInfo>())
        {
            var isCollapsible = ValidationHelper.GetBoolean(fci.GetPropertyValue(FormCategoryPropertyEnum.Collapsible, basicForm.ContextResolver), false);
            if (isCollapsible)
            {
                var category           = fci.CategoryName;
                var collapsedByDefault = ValidationHelper.GetBoolean(fci.GetPropertyValue(FormCategoryPropertyEnum.CollapsedByDefault, basicForm.ContextResolver), false);

                var isCollapsed = basicForm.IsCategoryCollapsed(category);
                if (isCollapsed == collapsedByDefault)
                {
                    webPartInstance.SetValue(CAT_OPEN_PREFIX + category, null);
                }
                else
                {
                    webPartInstance.SetValue(CAT_OPEN_PREFIX + category, isCollapsed);
                }

                var formCategory = basicForm.FormInformation.GetFormCategory(category);
                if (formCategory != null)
                {
                    formCategory.SetPropertyValue(FormCategoryPropertyEnum.CollapsedByDefault, isCollapsed.ToString().ToLowerInvariant());
                }
            }
        }
    }
示例#2
0
    /// <summary>
    /// Saves collapsed/un-collapsed states of the categories
    /// </summary>
    /// <param name="basicForm">Form</param>
    private void SaveCategoryState(BasicForm basicForm)
    {
        // Save the collapsed/un-collapsed state of categories
        FormInfo fi = GetWebPartFormInfo();

        var categories = fi.GetCategoryNames();

        foreach (string category in categories)
        {
            FormCategoryInfo fci = fi.GetFormCategory(category);
            if (ValidationHelper.GetBoolean(fci.GetPropertyValue(FormCategoryPropertyEnum.Collapsible, basicForm.ContextResolver), false) &&
                ValidationHelper.GetBoolean(fci.GetPropertyValue(FormCategoryPropertyEnum.CollapsedByDefault, basicForm.ContextResolver), false))
            {
                if (basicForm.IsCategoryCollapsed(category))
                {
                    webPartInstance.SetValue("cat_open_" + category, null);
                }
                else
                {
                    webPartInstance.SetValue("cat_open_" + category, true);
                }
            }
        }
    }
    /// <summary>
    /// Saves collapsed/un-collapsed states of the categories
    /// </summary>
    /// <param name="basicForm">Form</param>
    private void SaveCategoryState(BasicForm basicForm)
    {
        // Save the collapsed/un-collapsed state of categories
        FormInfo fi = GetWebPartFormInfo();

        var categories = fi.GetCategoryNames();
        foreach (string category in categories)
        {
            FormCategoryInfo fci = fi.GetFormCategory(category);
            if (ValidationHelper.GetBoolean(fci.GetPropertyValue(FormCategoryPropertyEnum.Collapsible, basicForm.ContextResolver), false) &&
                ValidationHelper.GetBoolean(fci.GetPropertyValue(FormCategoryPropertyEnum.CollapsedByDefault, basicForm.ContextResolver), false))
            {
                if (basicForm.IsCategoryCollapsed(category))
                {
                    webPartInstance.SetValue("cat_open_" + category, null);
                }
                else
                {
                    webPartInstance.SetValue("cat_open_" + category, true);
                }
            }
        }
    }
示例#4
0
    /// <summary>
    /// Saves the given DataRow data to the web part properties.
    /// </summary>
    /// <param name="form">Form to save</param>
    private void SaveFormToWebPart(BasicForm form)
    {
        if (form.Visible && (webPartInstance != null))
        {
            // Keep the old ID to check the change of the ID
            string oldId = webPartInstance.ControlID.ToLowerCSafe();

            DataRow dr = form.DataRow;
            foreach (DataColumn column in dr.Table.Columns)
            {
                webPartInstance.MacroTable[column.ColumnName.ToLowerCSafe()] = form.MacroTable[column.ColumnName.ToLowerCSafe()];
                webPartInstance.SetValue(column.ColumnName, dr[column]);

                // If name changed, move the content
                if (column.ColumnName.ToLowerCSafe() == "webpartcontrolid")
                {
                    try
                    {
                        string newId = null;
                        if (!IsNewVariant)
                        {
                            newId = ValidationHelper.GetString(dr[column], "").ToLowerCSafe();
                        }

                        // Name changed
                        if ((!string.IsNullOrEmpty(newId)) && (newId != oldId))
                        {
                            if (!IsNewWebPart && !IsNewVariant)
                            {
                                mWebPartIdChanged = true;
                            }
                            WebpartId = newId;

                            // Move the document content if present
                            string currentContent = (string)(pi.EditableWebParts[oldId]);
                            if (currentContent != null)
                            {
                                TreeNode node = DocumentHelper.GetDocument(pi.DocumentID, tree);

                                // Move the content in the page info
                                pi.EditableWebParts[oldId] = null;
                                pi.EditableWebParts[newId] = currentContent;

                                // Update the document
                                node.SetValue("DocumentContent", pi.GetContentXml());
                                DocumentHelper.UpdateDocument(node, tree);
                            }

                            // Change the underlying zone names if layout web part
                            if ((wpi != null) && ((WebPartTypeEnum)wpi.WebPartType == WebPartTypeEnum.Layout))
                            {
                                string prefix = oldId + "_";

                                foreach (WebPartZoneInstance zone in pti.WebPartZones)
                                {
                                    if (zone.ZoneID.StartsWithCSafe(prefix, true))
                                    {
                                        // Change the zone prefix to the new one
                                        zone.ZoneID = newId + "_" + zone.ZoneID.Substring(prefix.Length);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        EventLogProvider ev = new EventLogProvider();
                        ev.LogEvent("Content", "CHANGEWEBPART", ex);
                    }
                }
            }

            // Save the collapsed/un-collapsed state of categories
            FormInfo fi = GetWebPartFormInfo();

            var categories = fi.GetCategoryNames();
            foreach (string category in categories)
            {
                FormCategoryInfo fci = fi.GetFormCategory(category);
                if (fci.CategoryCollapsible && fci.CategoryCollapsedByDefault)
                {
                    if (form.IsCategoryCollapsed(category))
                    {
                        webPartInstance.SetValue("cat_open_" + category, null);
                    }
                    else
                    {
                        webPartInstance.SetValue("cat_open_" + category, true);
                    }
                }
            }
        }
    }
    /// <summary>
    /// Saves the given DataRow data to the web part properties.
    /// </summary>
    /// <param name="form">Form to save</param>
    private void SaveFormToWebPart(BasicForm form)
    {
        if (form.Visible && (webPartInstance != null))
        {
            // Keep the old ID to check the change of the ID
            string oldId = webPartInstance.ControlID.ToLowerCSafe();

            DataRow dr = form.DataRow;
            foreach (DataColumn column in dr.Table.Columns)
            {
                webPartInstance.MacroTable[column.ColumnName.ToLowerCSafe()] = form.MacroTable[column.ColumnName.ToLowerCSafe()];
                webPartInstance.SetValue(column.ColumnName, dr[column]);

                // If name changed, move the content
                if (column.ColumnName.ToLowerCSafe() == "webpartcontrolid")
                {
                    try
                    {
                        string newId = null;
                        if (!IsNewVariant)
                        {
                            newId = ValidationHelper.GetString(dr[column], "").ToLowerCSafe();
                        }

                        // Name changed
                        if ((!string.IsNullOrEmpty(newId)) && (newId != oldId))
                        {
                            if (!IsNewWebPart && !IsNewVariant)
                            {
                                mWebPartIdChanged = true;
                            }
                            WebpartId = newId;

                            // Move the document content if present
                            string currentContent = (string)(pi.EditableWebParts[oldId]);
                            if (currentContent != null)
                            {
                                TreeNode node = DocumentHelper.GetDocument(pi.DocumentID, tree);

                                // Move the content in the page info
                                pi.EditableWebParts[oldId] = null;
                                pi.EditableWebParts[newId] = currentContent;

                                // Update the document
                                node.SetValue("DocumentContent", pi.GetContentXml());
                                DocumentHelper.UpdateDocument(node, tree);
                            }

                            // Change the underlying zone names if layout web part
                            if ((wpi != null) && ((WebPartTypeEnum)wpi.WebPartType == WebPartTypeEnum.Layout))
                            {
                                string prefix = oldId + "_";

                                foreach (WebPartZoneInstance zone in pti.WebPartZones)
                                {
                                    if (zone.ZoneID.StartsWithCSafe(prefix, true))
                                    {
                                        // Change the zone prefix to the new one
                                        zone.ZoneID = newId + "_" + zone.ZoneID.Substring(prefix.Length);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        EventLogProvider ev = new EventLogProvider();
                        ev.LogEvent("Content", "CHANGEWEBPART", ex);
                    }
                }
            }

            // Save the collapsed/un-collapsed state of categories
            FormInfo fi = GetWebPartFormInfo();

            var categories = fi.GetCategoryNames();
            foreach (string category in categories)
            {
                FormCategoryInfo fci = fi.GetFormCategory(category);
                if (fci.CategoryCollapsible && fci.CategoryCollapsedByDefault)
                {
                    if (form.IsCategoryCollapsed(category))
                    {
                        webPartInstance.SetValue("cat_open_" + category, null);
                    }
                    else
                    {
                        webPartInstance.SetValue("cat_open_" + category, true);
                    }
                }
            }
        }
    }