/// <summary>
    /// XML created, save it.
    /// </summary>
    protected void defaultValueEditor_XMLCreated(object sender, EventArgs e)
    {
        if (!String.IsNullOrEmpty(defaultValueEditor.ErrorMessage))
        {
            ShowError(defaultValueEditor.ErrorMessage);
            return;
        }

        if (wi != null)
        {
            // Load xml definition
            if (wi.WebPartParentID > 0)
            {
                // Load the form definition
                string before = PortalFormHelper.GetWebPartProperties(WebPartTypeEnum.Standard, PropertiesPosition.Before);
                string after  = PortalFormHelper.GetWebPartProperties(WebPartTypeEnum.Standard, PropertiesPosition.Before);

                string formDef = FormHelper.CombineFormDefinitions(before, after);

                // Web part default values contains either properties or changed "system" values
                // First Remove records with same name as "system properties" => only actual webpart's properties remains
                string filteredDef = defaultValueEditor.FitlerDefaultValuesDefinition(wi.WebPartDefaultValues, formDef, false);

                WebPartInfo wpi = WebPartInfoProvider.GetWebPartInfo(wi.WebPartParentID);

                // Remove records with same name as parent's property - its already stored in webpart's properties
                if (wpi != null)
                {
                    filteredDef = defaultValueEditor.FitlerDefaultValuesDefinition(filteredDef, wpi.WebPartProperties, true);
                }
                // If inherited web part merge webpart's properties hier with default system values
                wi.WebPartDefaultValues = FormHelper.CombineFormDefinitions(filteredDef, defaultValueEditor.DefaultValueXMLDefinition);
            }
            else
            {
                wi.WebPartProperties = defaultValueEditor.DefaultValueXMLDefinition;
            }

            // Sav web part info
            WebPartInfoProvider.SetWebPartInfo(wi);

            // Redirect with saved assign
            string url = URLHelper.RemoveParameterFromUrl(URLRewriter.CurrentURL, "saved");
            url = URLHelper.AddParameterToUrl(url, "saved", "1");
            URLHelper.Redirect(url);
        }
    }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int widgetID = QueryHelper.GetInteger("widgetID", 0);

        // Default values XML load
        XmlDocument xmlBefore = new XmlDocument();
        XmlDocument xmlAfter  = new XmlDocument();

        ucDefaultValueEditor.XMLCreated += new EventHandler(ucDefaultValueEditor_XMLCreated);

        // If saved is found in query string
        if (!RequestHelper.IsPostBack() && (QueryHelper.GetInteger("saved", 0) == 1))
        {
            ShowChangesSaved();
        }

        // Load the form definition
        string before = PortalFormHelper.GetWebPartProperties(WebPartTypeEnum.Standard, PropertiesPosition.Before);
        string after  = PortalFormHelper.GetWebPartProperties(WebPartTypeEnum.Standard, PropertiesPosition.After);

        string formDef = FormHelper.CombineFormDefinitions(before, after);

        // Get the widget info
        WidgetInfo wi = WidgetInfoProvider.GetWidgetInfo(widgetID);

        if (wi != null)
        {
            // Load default values for current web part
            XmlDocument xmlDefault = LoadDefaultValuesXML(wi, formDef);

            // Set field editor
            if (wi.WidgetDefaultValues == String.Empty)
            {
                ucDefaultValueEditor.DefaultValueXMLDefinition = "<form></form>";
            }
            else
            {
                // WebPartDefaultValues contains changed fields versus default XML settings (stored in files)
                ucDefaultValueEditor.DefaultValueXMLDefinition = wi.WidgetDefaultValues;
            }

            ucDefaultValueEditor.SourceXMLDefinition = xmlDefault.DocumentElement.OuterXml;
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Returns form info with webpart properties.
    /// </summary>
    /// <param name="wpi">Web part info</param>
    protected FormInfo GetWebPartProperties(WebPartInfo wpi)
    {
        if (wpi != null)
        {
            // Before form
            string   before = PortalFormHelper.GetWebPartProperties((WebPartTypeEnum)wpi.WebPartType, PropertiesPosition.Before);
            FormInfo bfi    = new FormInfo(before);
            // After form
            string   after = PortalFormHelper.GetWebPartProperties((WebPartTypeEnum)wpi.WebPartType, PropertiesPosition.After);
            FormInfo afi   = new FormInfo(after);

            // Add general category to first items in webpart without category
            string properties = FormHelper.EnsureDefaultCategory(wpi.WebPartProperties, GetString("general.general"));

            return(PortalFormHelper.GetWebPartFormInfo(wpi.WebPartName, properties, bfi, afi, true));
        }

        return(null);
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Returns form info with webpart properties.
    /// </summary>
    /// <param name="wpi">Web part info</param>
    protected FormInfo GetWebPartProperties(WebPartInfo wpi)
    {
        if (wpi != null)
        {
            // Before form
            string   before = PortalFormHelper.GetWebPartProperties((WebPartTypeEnum)wpi.WebPartType, PropertiesPosition.Before);
            FormInfo bfi    = new FormInfo(before);
            // After form
            string   after = PortalFormHelper.GetWebPartProperties((WebPartTypeEnum)wpi.WebPartType, PropertiesPosition.After);
            FormInfo afi   = new FormInfo(after);

            // Add general category to first items in webpart without category
            string properties = wpi.WebPartProperties;
            if (!string.IsNullOrEmpty(properties) && (!properties.StartsWithCSafe("<form><category", true)))
            {
                properties = properties.Insert(6, "<category name=\"" + GetString("general.general") + "\" />");
            }

            return(PortalFormHelper.GetWebPartFormInfo(wpi.WebPartName, properties, bfi, afi, true));
        }

        return(null);
    }
Ejemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        eObject = UIContext.EditedObject as BaseInfo;

        // If saved is found in query string
        if (!RequestHelper.IsPostBack() && (QueryHelper.GetInteger("saved", 0) == 1))
        {
            ShowChangesSaved();
        }

        string before = String.Empty;
        string after  = String.Empty;

        String objectType = UIContextHelper.GetObjectType(UIContext);

        switch (objectType.ToLowerCSafe())
        {
        case "cms.webpart":
            defaultValueColumName = "WebPartDefaultValues";

            before = PortalFormHelper.GetWebPartProperties(WebPartTypeEnum.Standard, PropertiesPosition.Before);
            after  = PortalFormHelper.GetWebPartProperties(WebPartTypeEnum.Standard, PropertiesPosition.After);

            defaultSet = FormHelper.CombineFormDefinitions(before, after);

            WebPartInfo wi = eObject as WebPartInfo;

            // If inherited web part load parent properties
            if (wi.WebPartParentID > 0)
            {
                WebPartInfo parentInfo = WebPartInfoProvider.GetWebPartInfo(wi.WebPartParentID);
                if (parentInfo != null)
                {
                    properties = FormHelper.MergeFormDefinitions(parentInfo.WebPartProperties, wi.WebPartProperties);
                }
            }
            else
            {
                properties = wi.WebPartProperties;
            }

            break;

        case "cms.widget":
            before = PortalFormHelper.LoadProperties("Widget", "Before.xml");
            after  = PortalFormHelper.LoadProperties("Widget", "After.xml");

            defaultSet = FormHelper.CombineFormDefinitions(before, after);

            defaultValueColumName = "WidgetDefaultValues";
            WidgetInfo wii = eObject as WidgetInfo;
            if (wii != null)
            {
                WebPartInfo wiiWp = WebPartInfoProvider.GetWebPartInfo(wii.WidgetWebPartID);
                if (wiiWp != null)
                {
                    properties = FormHelper.MergeFormDefinitions(wiiWp.WebPartProperties, wii.WidgetProperties);
                }
            }

            break;
        }

        // Get the web part info
        if (eObject != null)
        {
            String defVal = ValidationHelper.GetString(eObject.GetValue(defaultValueColumName), string.Empty);
            defaultSet = LoadDefaultValuesXML(defaultSet);

            fieldEditor.Mode                     = FieldEditorModeEnum.SystemWebPartProperties;
            fieldEditor.FormDefinition           = FormHelper.MergeFormDefinitions(defaultSet, defVal);
            fieldEditor.OnAfterDefinitionUpdate += fieldEditor_OnAfterDefinitionUpdate;
            fieldEditor.OriginalFormDefinition   = defaultSet;
            fieldEditor.WebPartId                = eObject.Generalized.ObjectID;
        }

        ScriptHelper.HideVerticalTabs(Page);
    }
Ejemplo n.º 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string aliasPath   = QueryHelper.GetString("aliaspath", "");
        string webpartId   = QueryHelper.GetString("webpartid", "");
        string zoneId      = QueryHelper.GetString("zoneid", "");
        Guid   webpartGuid = QueryHelper.GetGuid("webpartguid", Guid.Empty);
        int    templateId  = QueryHelper.GetInteger("templateId", 0);

        PageTemplateInfo pti = null;

        if (templateId > 0)
        {
            pti = PageTemplateInfoProvider.GetPageTemplateInfo(templateId);
        }

        if (pti == null)
        {
            var      siteName = SiteContext.CurrentSiteName;
            PageInfo pi       = PageInfoProvider.GetPageInfo(siteName, aliasPath, LocalizationContext.PreferredCultureCode, null, SiteInfoProvider.CombineWithDefaultCulture(siteName));
            if (pi != null)
            {
                pti = pi.UsedPageTemplateInfo;
            }
        }

        if (pti != null)
        {
            // Get web part
            WebPartInstance webPart = pti.TemplateInstance.GetWebPart(webpartGuid, webpartId);
            if (webPart != null)
            {
                StringBuilder sb         = new StringBuilder();
                Hashtable     properties = webPart.Properties;

                // Get the webpart object
                WebPartInfo wi = WebPartInfoProvider.GetWebPartInfo(webPart.WebPartType);
                if (wi != null)
                {
                    // Add the header
                    sb.Append("Webpart properties (" + wi.WebPartDisplayName + ")" + Environment.NewLine + Environment.NewLine);
                    sb.Append("Alias path: " + aliasPath + Environment.NewLine);
                    sb.Append("Zone ID: " + zoneId + Environment.NewLine + Environment.NewLine);


                    string wpProperties = "<default></default>";
                    // Get the form info object and load it with the data

                    if (wi.WebPartParentID > 0)
                    {
                        // Load parent properties
                        WebPartInfo wpi = WebPartInfoProvider.GetWebPartInfo(wi.WebPartParentID);
                        if (wpi != null)
                        {
                            wpProperties = FormHelper.MergeFormDefinitions(wpi.WebPartProperties, wi.WebPartProperties);
                        }
                    }
                    else
                    {
                        wpProperties = wi.WebPartProperties;
                    }

                    FormInfo fi = new FormInfo(wpProperties);

                    // General properties of webparts
                    string beforeFormDefinition = PortalFormHelper.GetWebPartProperties((WebPartTypeEnum)wi.WebPartType, PropertiesPosition.Before);
                    string afterFormDefinition  = PortalFormHelper.GetWebPartProperties((WebPartTypeEnum)wi.WebPartType, PropertiesPosition.After);

                    // General properties before custom
                    if (!String.IsNullOrEmpty(beforeFormDefinition))
                    {
                        // Load before definition
                        fi = new FormInfo(FormHelper.MergeFormDefinitions(beforeFormDefinition, wpProperties, true));

                        // Add Default category for first before items
                        sb.Append(Environment.NewLine + "Default" + Environment.NewLine + Environment.NewLine + Environment.NewLine);
                    }


                    // General properties after custom
                    if (!String.IsNullOrEmpty(afterFormDefinition))
                    {
                        // Load after definition
                        fi = new FormInfo(FormHelper.MergeFormDefinitions(fi.GetXmlDefinition(), afterFormDefinition, true));
                    }

                    // Generate all properties
                    sb.Append(GetProperties(fi.GetFormElements(true, false), webPart));

                    // Send the text file to the user to download
                    UTF8Encoding enc  = new UTF8Encoding();
                    byte[]       file = enc.GetBytes(sb.ToString());

                    Response.AddHeader("Content-disposition", "attachment; filename=webpartproperties_" + HTTPHelper.GetDispositionFilename(webPart.ControlID) + ".txt");
                    Response.ContentType = "text/plain";
                    Response.BinaryWrite(file);

                    RequestHelper.EndResponse();
                }
            }
        }
    }