Exemple #1
0
    /// <summary>
    /// Gets the form info for the given web part
    /// </summary>
    private FormInfo GetWebPartFormInfo()
    {
        // Load parent
        EnsureParentWebPartInfo();

        if (wpi == null)
        {
            return(null);
        }

        string wpProperties = wpi.WebPartProperties;

        // Use parent web part if is defined
        if (parentWpi != null)
        {
            wpProperties = parentWpi.WebPartProperties;
        }

        // Get before FormInfo
        FormInfo beforeFI = null;

        if (BeforeFormDefinition == null)
        {
            beforeFI = PortalFormHelper.GetPositionFormInfo((WebPartTypeEnum)wpi.WebPartType, PropertiesPosition.Before);
        }
        else
        {
            beforeFI = new FormInfo(BeforeFormDefinition);
        }

        // Get after FormInfo
        FormInfo afterFI = null;

        if (AfterFormDefinition == null)
        {
            afterFI = PortalFormHelper.GetPositionFormInfo((WebPartTypeEnum)wpi.WebPartType, PropertiesPosition.After);
        }
        else
        {
            afterFI = new FormInfo(AfterFormDefinition);
        }

        // Add 'General' category at the beginning if no one is specified
        if (!string.IsNullOrEmpty(wpProperties) && (!wpProperties.StartsWithCSafe("<form><category", true)))
        {
            wpProperties = wpProperties.Insert(6, "<category name=\"" + GetString("general.general") + "\" />");
        }

        // Get merged web part FormInfo
        FormInfo fi = PortalFormHelper.GetWebPartFormInfo(wpi.WebPartName, wpProperties, beforeFI, afterFI, true);

        return(fi);
    }
 /// <summary>
 /// Generate form info for webpart.
 /// </summary>
 /// <param name="wpi">Web part info</param>
 private FormInfo CreateFormInfo(WebPartInfo wpi)
 {
     if (wpi != null)
     {
         // Get parent webpart if webpart is inherited
         if (wpi.WebPartParentID != 0)
         {
             WebPartInfo pwpi = WebPartInfoProvider.GetWebPartInfo(wpi.WebPartParentID);
             if (pwpi != null)
             {
                 wpi = pwpi;
             }
         }
     }
     return(PortalFormHelper.GetWebPartFormInfo(wpi.WebPartName + FormHelper.CORE, wpi.WebPartProperties, null, null, false));
 }
Exemple #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);
    }
Exemple #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);
    }
    public void BindData()
    {
        if (WebpartId != "")
        {
            // Get page info
            pi = CMSWebPartPropertiesPage.GetPageInfo(AliasPath, PageTemplateId, CultureCode);
            if (pi == null)
            {
                Visible = false;
                return;
            }

            // Get page template info
            pti = pi.UsedPageTemplateInfo;
            if (pti != null)
            {
                // Get web part instance
                webPart = pti.GetWebPart(InstanceGUID, WebpartId);
                if (webPart == null)
                {
                    CMSPage.EditedObject = null;
                    return;
                }

                // Get the web part info
                WebPartInfo wpi = WebPartInfoProvider.GetBaseWebPart(webPart.WebPartType);
                if (wpi == null)
                {
                    return;
                }

                // Get webpart properties (XML)
                string   wpProperties = wpi.WebPartProperties;
                FormInfo fi           = PortalFormHelper.GetWebPartFormInfo(wpi.WebPartName + FormHelper.CORE, wpi.WebPartProperties, null, null, false);

                // Get datarow with required columns
                DataRow dr = fi.GetDataRow();

                // Bind drop down list
                if (!RequestHelper.IsPostBack())
                {
                    DataTable dropTable = new DataTable();
                    dropTable.Columns.Add("name");

                    foreach (DataColumn column in dr.Table.Columns)
                    {
                        dropTable.Rows.Add(column.ColumnName);
                    }

                    dropTable.DefaultView.Sort = "name";
                    drpProperty.DataTextField  = "name";
                    drpProperty.DataValueField = "name";
                    drpProperty.DataSource     = dropTable.DefaultView;
                    drpProperty.DataBind();
                }

                // Bind grid view
                DataTable table = new DataTable();
                table.Columns.Add("LocalProperty");
                table.Columns.Add("SourceProperty");
                bindings = webPart.Bindings;

                foreach (DataColumn column in dr.Table.Columns)
                {
                    string propertyName = column.ColumnName.ToLowerCSafe();
                    if (bindings.ContainsKey(propertyName))
                    {
                        WebPartBindingInfo bi = (WebPartBindingInfo)bindings[propertyName];
                        table.Rows.Add(column.ColumnName, bi.SourceWebPart + "." + bi.SourceProperty);
                    }
                }

                gvBinding.DataSource = table;
                gvBinding.DataBind();
            }
        }
    }
Exemple #6
0
    /// <summary>
    /// Generate editor table.
    /// </summary>
    public void GenerateEditor()
    {
        FormInfo fi = null;

        // Call handlers
        if (OnEditorLoaded != null)
        {
            fi = OnEditorLoaded();
        }
        else
        {
            // Get parent web part info
            WebPartInfo wpi = WebPartInfoProvider.GetWebPartInfo(ParentWebPartID);

            if (wpi != null)
            {
                // Create form info and load xml definition
                fi = PortalFormHelper.GetWebPartFormInfo(wpi.WebPartName + FormHelper.CORE, wpi.WebPartProperties, null, null, false);
            }
            else
            {
                fi = new FormInfo(SourceXMLDefinition);
            }
        }

        if (fi != null)
        {
            dr = fi.GetDataRow(false);

            // Get definition elements
            var infos = fi.GetFormElements(true, false);

            // create table part
            Literal table1 = new Literal();
            pnlEditor.Controls.Add(table1);
            table1.Text = "<table cellpadding=\"3\">";

            // Hashtable counter
            int  i = 0;
            bool categoryExists = false;

            // Check all items in object array
            foreach (object contrl in infos)
            {
                // Generate row for form category
                if (contrl is FormCategoryInfo)
                {
                    // Load category info
                    FormCategoryInfo fci = contrl as FormCategoryInfo;
                    if (fci != null)
                    {
                        CreateCategory(fci.CategoryCaption);
                        categoryExists = true;
                    }
                }
                else
                {
                    // Ensure the default category
                    if (!categoryExists)
                    {
                        CreateCategory(GetString("General.General"));
                        categoryExists = true;
                    }

                    // Get form field info
                    FormFieldInfo ffi = contrl as FormFieldInfo;
                    if (ffi != null)
                    {
                        CreateField(ffi, ref i);
                    }
                }
            }

            // End table part
            Literal table6 = new Literal();
            pnlEditor.Controls.Add(table6);
            table6.Text = "</table>";
        }
    }