Exemple #1
0
    /// <summary>
    /// Returns the form definition for the web part zone properties.
    /// </summary>
    private FormInfo BuildFormInfo(WebPartZoneInstance webPartZone)
    {
        FormInfo fi = null;

        string formDefinition = String.Empty;

        // Dashboard zone properties
        if ((pti != null) && (pti.PageTemplateType == PageTemplateTypeEnum.Dashboard))
        {
            formDefinition = PortalFormHelper.LoadProperties("WebPartZone", "Dashboard.xml");
        }
        // UI page template properties
        else if ((pti != null) && (pti.PageTemplateType == PageTemplateTypeEnum.UI))
        {
            formDefinition = PortalFormHelper.LoadProperties("WebPartZone", "UI.xml");
        }
        // Classic web part/widget properties
        else
        {
            formDefinition = PortalFormHelper.LoadProperties("WebPartZone", "Standard.xml");
        }

        if (!String.IsNullOrEmpty(formDefinition))
        {
            // Load properties
            fi = new FormInfo(formDefinition);
            fi.UpdateExistingFields(fi);

            DataRow dr = fi.GetDataRow();
            LoadDataRowFromWebPartZone(dr, webPartZone);
        }

        return(fi);
    }
    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.LoadProperties("Widget", "Before.xml");
        string after  = PortalFormHelper.LoadProperties("Widget", "After.xml");

        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.LoadHiddenFields    = true;
            ucDefaultValueEditor.SourceXMLDefinition = xmlDefault.DocumentElement.OuterXml;
        }
    }
Exemple #3
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);
    }