/// <summary>
    /// Loads the data row data from given web part instance.
    /// </summary>
    /// <param name="dr">DataRow to fill</param>
    /// <param name="webPart">Source web part</param>
    private static void LoadDataRowFromWebPart(DataRow dr, WebPartInstance webPart)
    {
        foreach (DataColumn column in dr.Table.Columns)
        {
            try
            {
                object value = webPart.GetValue(column.ColumnName);

                // Convert value into default format
                if (value != null)
                {
                    if (column.DataType == typeof(decimal))
                    {
                        value = ValidationHelper.GetDouble(value, 0, "en-us");
                    }

                    if (column.DataType == typeof(DateTime))
                    {
                        value = ValidationHelper.GetDateTime(value, DateTime.MinValue, "en-us");
                    }
                }

                DataHelper.SetDataRowValue(dr, column.ColumnName, value);
            }
            catch
            {
            }
        }
    }
Beispiel #2
0
    private void ApplySavedCategoryCollapsingState(BasicForm basicForm)
    {
        if (webPartInstance == null)
        {
            return;
        }

        var fi = basicForm.FormInformation;

        foreach (var fci in fi.GetFields <FormCategoryInfo>())
        {
            var isCollapsible = ValidationHelper.GetBoolean(fci.GetPropertyValue(FormCategoryPropertyEnum.Collapsible, basicForm.ContextResolver), false);
            if (isCollapsible)
            {
                var isCollapsedValue = ValidationHelper.GetString(webPartInstance.GetValue(CAT_OPEN_PREFIX + fci.CategoryName), "");
                if (!String.IsNullOrEmpty(isCollapsedValue))
                {
                    var collapsedByDefault = ValidationHelper.GetBoolean(fci.GetPropertyValue(FormCategoryPropertyEnum.CollapsedByDefault, basicForm.ContextResolver), false);

                    var isCollapsed = ValidationHelper.GetBoolean(isCollapsedValue, false);
                    if (isCollapsed != collapsedByDefault)
                    {
                        fci.SetPropertyValue(FormCategoryPropertyEnum.CollapsedByDefault, isCollapsedValue.ToLowerInvariant());
                    }
                }
            }
        }
    }
Beispiel #3
0
    /// <summary>
    /// Exports properties given in the array list.
    /// </summary>
    /// <param name="elem">List of properties to export</param>
    /// <param name="webPart">WebPart instance with data</param>
    private string GetProperties(IEnumerable <IDataDefinitionItem> elem, WebPartInstance webPart)
    {
        StringBuilder sb = new StringBuilder();

        // Iterate through all fields
        foreach (object o in elem)
        {
            FormCategoryInfo fci = o as FormCategoryInfo;
            if (fci != null)
            {
                // We have category now
                sb.Append(Environment.NewLine + fci.GetPropertyValue(FormCategoryPropertyEnum.Caption, MacroContext.CurrentResolver) + Environment.NewLine + Environment.NewLine + Environment.NewLine);
            }
            else
            {
                // Form element
                FormFieldInfo ffi = o as FormFieldInfo;
                if (ffi != null)
                {
                    object value = webPart.GetValue(ffi.Name);
                    sb.Append(ffi.GetPropertyValue(FormFieldPropertyEnum.FieldCaption, MacroContext.CurrentResolver) + ": " + (value == null ? "" : value.ToString()) + Environment.NewLine + Environment.NewLine);
                }
            }
        }

        return(sb.ToString());
    }
Beispiel #4
0
    /// <summary>
    /// Exports properties given in the array list.
    /// </summary>
    /// <param name="elem">List of properties to export</param>
    /// <param name="webPart">WebPart instance with data</param>
    private string GetProperties(ArrayList elem, WebPartInstance webPart)
    {
        StringBuilder sb = new StringBuilder();

        // Iterate through all fields
        foreach (object o in elem)
        {
            FormCategoryInfo fci = o as FormCategoryInfo;
            if (fci != null)
            {
                // We have category now
                sb.Append(Environment.NewLine + fci.CategoryCaption + Environment.NewLine + Environment.NewLine + Environment.NewLine);
            }
            else
            {
                // Form element
                FormFieldInfo ffi = o as FormFieldInfo;
                if (ffi != null)
                {
                    object value = webPart.GetValue(ffi.Name);
                    sb.Append(ffi.Caption + ": " + (value == null ? "" : value.ToString()) + Environment.NewLine + Environment.NewLine);
                }
            }
        }

        return(sb.ToString());
    }
Beispiel #5
0
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        // Check permissions for web part properties UI
        CurrentUserInfo currentUser = CMSContext.CurrentUser;

        if (!currentUser.IsAuthorizedPerUIElement("CMS.Content", "WebPartProperties.Code"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Content", "WebPartProperties.Code");
        }

        if (webpartId != "")
        {
            // Get page info
            pi = GetPageInfo(aliasPath, templateId);
            if (pi == null)
            {
                this.Visible = false;
                return;
            }

            pti = pi.PageTemplateInfo;
            if ((pti != null) && ((pti.TemplateInstance != null)))
            {
                // Get web part instance
                webPart = pti.TemplateInstance.GetWebPart(instanceGuid, zoneVariantId, variantId) ?? pti.GetWebPart(webpartId);

                if (webPart != null)
                {
                    txtCode.Text = ValidationHelper.GetString(webPart.GetValue("WebPartCode"), "");
                }
            }
        }
    }
Beispiel #6
0
    /// <summary>
    /// Loads the data row data from given web part instance.
    /// </summary>
    /// <param name="dr">DataRow to fill</param>
    private void LoadDataRowFromWidget(DataRow dr, FormInfo fi)
    {
        if (mWidgetInstance != null)
        {
            foreach (DataColumn column in dr.Table.Columns)
            {
                try
                {
                    bool load = true;
                    // switch by xml version
                    switch (mXmlVersion)
                    {
                    case 1:
                        load = mWidgetInstance.Properties.Contains(column.ColumnName.ToLowerCSafe()) || column.ColumnName.EqualsCSafe("webpartcontrolid", true);
                        break;

                    // Version 0
                    default:
                        // Load default value for Boolean type in old XML version
                        if ((column.DataType == typeof(bool)) && !mWidgetInstance.Properties.Contains(column.ColumnName.ToLowerCSafe()))
                        {
                            FormFieldInfo ffi = fi.GetFormField(column.ColumnName);
                            if (ffi != null)
                            {
                                mWidgetInstance.SetValue(column.ColumnName, ffi.GetPropertyValue(FormFieldPropertyEnum.DefaultValue));
                            }
                        }
                        break;
                    }

                    if (load)
                    {
                        object value = mWidgetInstance.GetValue(column.ColumnName);

                        // Convert value into default format
                        if ((value != null) && (value.ToString() != ""))
                        {
                            if (column.DataType == typeof(decimal))
                            {
                                value = ValidationHelper.GetDouble(value, 0, "en-us");
                            }

                            if (column.DataType == typeof(DateTime))
                            {
                                value = ValidationHelper.GetDateTime(value, DateTime.Now, "en-us");
                            }
                        }

                        if (!DataHelper.IsEmpty(value))
                        {
                            DataHelper.SetDataRowValue(dr, column.ColumnName, value);
                        }
                    }
                }
                catch
                {
                }
            }
        }
    }
    /// <summary>
    /// Initializes menu.
    /// </summary>
    protected void InitalizeMenu()
    {
        if (webpartId != "")
        {
            // get pageinfo
            PageInfo pi = GetPageInfo(aliasPath, templateId);
            if (pi == null)
            {
                this.Visible = false;
                return;
            }

            PageTemplateInfo pti = pi.PageTemplateInfo;
            if (pti != null)
            {
                WebPartInfo wi = null;

                // Get web part
                WebPartInstance webPart = pti.GetWebPart(instanceGuid, webpartId);
                if (webPart != null)
                {
                    wi = WebPartInfoProvider.GetWebPartInfo(webPart.WebPartType);
                    if (ValidationHelper.GetString(webPart.GetValue("WebPartCode"), "").Trim() != "")
                    {
                        showCodeTab = true;
                    }
                    if (webPart.Bindings.Count > 0)
                    {
                        showBindingTab = true;
                    }
                }
                else
                {
                    wi = WebPartInfoProvider.GetWebPartInfo(ValidationHelper.GetInteger(webpartId, 0));
                }

                if (wi != null)
                {
                    // Generate documentation link
                    Literal ltr = new Literal();
                    PageTitle.RightPlaceHolder.Controls.Add(ltr);

                    string docScript = "NewWindow('" + ResolveUrl("~/CMSModules/PortalEngine/UI/WebParts/WebPartDocumentationPage.aspx") + "?webpartid=" + ScriptHelper.GetString(wi.WebPartName, false) + "', 'WebPartPropertiesDocumentation', 800, 800); return false;";

                    ltr.Text  = "<table cellpadding=\"0\" cellspacing=\"0\"><tr><td>";
                    ltr.Text += "<a onclick=\"" + docScript + "\" href=\"#\"><img src=\"" + ResolveUrl(GetImageUrl("CMSModules/CMS_PortalEngine/Documentation.png")) + "\" style=\"border-width: 0px;\"></a>";
                    ltr.Text += "</td>";
                    ltr.Text += "<td>";
                    ltr.Text += "<a onclick=\"" + docScript + "\" href=\"#\">" + GetString("WebPartPropertie.DocumentationLink") + "</a>";
                    ltr.Text += "</td></tr></table>";

                    PageTitle.TitleText = GetString("WebpartProperties.Title") + " (" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(wi.WebPartDisplayName)) + ")";
                }
            }
        }

        CurrentUserInfo currentUser = CMSContext.CurrentUser;

        tabsElem.UrlTarget = "webpartpropertiescontent";
    }
Beispiel #8
0
    /// <summary>
    /// Loads the data row data from given web part instance.
    /// </summary>
    /// <param name="dr">DataRow to fill</param>
    /// <param name="webPart">Source web part</param>
    /// <param name="formInfo">Web part form info</param>
    private void LoadDataRowFromWebPart(DataRow dr, WebPartInstance webPart, FormInfo formInfo)
    {
        if (webPart != null)
        {
            foreach (DataColumn column in dr.Table.Columns)
            {
                try
                {
                    var  safeColumnName = column.ColumnName.ToLowerInvariant();
                    bool load           = true;
                    // switch by xml version
                    switch (xmlVersion)
                    {
                    case 1:
                        load = webPart.Properties.Contains(safeColumnName) || string.Equals("webpartcontrolid", safeColumnName, StringComparison.OrdinalIgnoreCase);
                        break;

                    // Version 0
                    default:
                        // Load default value for Boolean type in old XML version
                        if ((column.DataType == typeof(bool)) && !webPart.Properties.Contains(safeColumnName))
                        {
                            FormFieldInfo ffi = formInfo.GetFormField(column.ColumnName);
                            if (ffi != null)
                            {
                                webPart.SetValue(column.ColumnName, ffi.GetPropertyValue(FormFieldPropertyEnum.DefaultValue));
                            }
                        }
                        break;
                    }

                    if (load)
                    {
                        var value = webPart.GetValue(column.ColumnName);

                        // Convert value into default format
                        if ((value != null) && (ValidationHelper.GetString(value, String.Empty) != String.Empty))
                        {
                            if (column.DataType == typeof(decimal))
                            {
                                value = ValidationHelper.GetDouble(value, 0, "en-us");
                            }

                            if (column.DataType == typeof(DateTime))
                            {
                                value = ValidationHelper.GetDateTime(value, DateTime.MinValue, "en-us");
                            }
                        }

                        DataHelper.SetDataRowValue(dr, column.ColumnName, value);
                    }
                }
                catch (Exception ex)
                {
                    EventLogProvider.LogException("WebPartProperties", "LOADDATAROW", ex);
                }
            }
        }
    }
    protected override void OnPreInit(EventArgs e)
    {
        WebPartInstance webPart = null;

        // Check permissions for web part properties UI
        if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.Design", "WebPartProperties.Layout"))
        {
            RedirectToUIElementAccessDenied("CMS.Design", "WebPartProperties.Layout");
        }

        if (webpartId != "")
        {
            // Get pageinfo
            PageInfo pi = GetPageInfo(aliasPath, templateId, cultureCode);
            if (pi == null)
            {
                return;
            }

            // Get page template
            PageTemplateInfo pti = pi.UsedPageTemplateInfo;
            if ((pti != null) && ((pti.TemplateInstance != null)))
            {
                webPart = pti.TemplateInstance.GetWebPart(instanceGuid, zoneVariantId, variantId) ?? pti.TemplateInstance.GetWebPart(webpartId);
            }
        }

        if (webPart != null)
        {
            WebPartInfo wpi = WebPartInfoProvider.GetWebPartInfo(webPart.WebPartType);
            layoutCodeName = QueryHelper.GetString("layoutcodename", String.Empty);

            if (String.IsNullOrEmpty(layoutCodeName))
            {
                // Get the current layout name
                layoutCodeName = ValidationHelper.GetString(webPart.GetValue("WebPartLayout"), "");
            }

            if (wpi != null)
            {
                wpli = WebPartLayoutInfoProvider.GetWebPartLayoutInfo(wpi.WebPartName, layoutCodeName);
                if (wpli != null)
                {
                    if ((layoutCodeName != "|default|") && (layoutCodeName != "|new|") && !QueryHelper.GetBoolean("tabmode", false))
                    {
                        string url = UIContextHelper.GetElementUrl("CMS.Design", "Design.WebPartProperties.LayoutEdit", false, wpli.WebPartLayoutID);
                        url = URLHelper.AppendQuery(url, RequestContext.CurrentQueryString);
                        url = URLHelper.AddParameterToUrl(url, "tabmode", "1");
                        URLHelper.Redirect(url);
                    }
                }
            }
        }
        base.OnPreInit(e);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check permissions for web part properties UI
        var currentUser = MembershipContext.AuthenticatedUser;

        if (!currentUser.IsAuthorizedPerUIElement("CMS.Design", "WebPartProperties.Layout"))
        {
            RedirectToUIElementAccessDenied("CMS.Design", "WebPartProperties.Layout");
        }

        WebPartInstance webPart = null;

        if (webpartId != "")
        {
            // Get pageinfo
            PageInfo pi = GetPageInfo(aliasPath, templateId, cultureCode);
            if (pi != null)
            {
                // Get page template
                PageTemplateInfo pti = pi.UsedPageTemplateInfo;

                // Get web part
                if ((pti != null) && ((pti.TemplateInstance != null)))
                {
                    webPart = pti.TemplateInstance.GetWebPart(instanceGuid, zoneVariantId, variantId) ?? pti.TemplateInstance.GetWebPart(webpartId);
                }
            }
        }

        // If the web part is not found, do not continue
        if (webPart != null)
        {
            WebPartInfo wpi = WebPartInfoProvider.GetWebPartInfo(webPart.WebPartType);
            if (wpi != null)
            {
                // Get the current layout name
                if (String.IsNullOrEmpty(LayoutCodeName))
                {
                    // Get the current layout name
                    LayoutCodeName = ValidationHelper.GetString(webPart.GetValue("WebPartLayout"), "");
                }

                // Load the web part information
                if (LayoutCodeName != "")
                {
                    WebPartLayoutInfo wpli = WebPartLayoutInfoProvider.GetWebPartLayoutInfo(wpi.WebPartName, LayoutCodeName);
                    SetEditedObject(wpli, null);
                }
            }
        }

        // Set page tabs
        InitTabs("webpartlayoutcontent");
        SetTab(0, GetString("general.general"), "webpartproperties_layout.aspx" + RequestContext.CurrentQueryString, null);
    }
Beispiel #11
0
    /// <summary>
    /// Loads the data row data from given web part instance.
    /// </summary>
    /// <param name="dr">DataRow to fill</param>
    /// <param name="webPart">Source web part</param>
    private void LoadDataRowFromWebPart(DataRow dr, WebPartInstance webPart, FormInfo fi)
    {
        foreach (DataColumn column in dr.Table.Columns)
        {
            try
            {
                bool load = true;
                // switch by xml version
                switch (xmlVersion)
                {
                case 1:
                    load = webPart.Properties.Contains(column.ColumnName.ToLowerCSafe()) || column.ColumnName.EqualsCSafe("webpartcontrolid", true);
                    break;

                // Version 0
                default:
                    // Load default value for Boolean type in old XML version
                    if ((column.DataType == typeof(bool)) && !webPart.Properties.Contains(column.ColumnName.ToLowerCSafe()))
                    {
                        FormFieldInfo ffi = fi.GetFormField(column.ColumnName);
                        if (ffi != null)
                        {
                            webPart.SetValue(column.ColumnName, ffi.DefaultValue);
                        }
                    }
                    break;
                }

                if (load)
                {
                    object value = webPart.GetValue(column.ColumnName);

                    // Convert value into default format
                    if ((value != null) && (ValidationHelper.GetString(value, String.Empty) != String.Empty))
                    {
                        if (column.DataType == typeof(decimal))
                        {
                            value = ValidationHelper.GetDouble(value, 0, "en-us");
                        }

                        if (column.DataType == typeof(DateTime))
                        {
                            value = ValidationHelper.GetDateTime(value, DateTime.MinValue, "en-us");
                        }
                    }

                    DataHelper.SetDataRowValue(dr, column.ColumnName, value);
                }
            }
            catch
            {
            }
        }
    }
    protected override void OnPreInit(EventArgs e)
    {
        WebPartInstance webPart = null;

        // Check permissions for web part properties UI
        if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Content", "WebPartProperties.Layout"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Content", "WebPartProperties.Layout");
        }

        if (webpartId != "")
        {
            // Get pageinfo
            PageInfo pi = GetPageInfo(aliasPath, templateId, cultureCode);
            if (pi == null)
            {
                return;
            }

            // Get page template
            PageTemplateInfo pti = pi.UsedPageTemplateInfo;
            if ((pti != null) && ((pti.TemplateInstance != null)))
            {
                webPart = pti.TemplateInstance.GetWebPart(instanceGuid, zoneVariantId, variantId) ?? pti.GetWebPart(webpartId);
            }
        }

        if (webPart != null)
        {
            WebPartInfo wpi = WebPartInfoProvider.GetWebPartInfo(webPart.WebPartType);
            layoutCodeName = QueryHelper.GetString("layoutcodename", String.Empty);

            if (String.IsNullOrEmpty(layoutCodeName))
            {
                // Get the current layout name
                layoutCodeName = ValidationHelper.GetString(webPart.GetValue("WebPartLayout"), "");
            }

            if (wpi != null)
            {
                wpli = WebPartLayoutInfoProvider.GetWebPartLayoutInfo(wpi.WebPartName, layoutCodeName);
                if (wpli != null)
                {
                    if ((layoutCodeName != "|default|") && (layoutCodeName != "|new|"))
                    {
                        SetEditedObject(wpli, "WebPartProperties_layout_frameset_frameset.aspx");
                    }
                }
            }
        }

        base.OnPreInit(e);
    }
    /// <summary>
    /// OnInit
    /// </summary>
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        // Check permissions for web part properties UI
        CurrentUserInfo currentUser = CMSContext.CurrentUser;

        if (!currentUser.IsAuthorizedPerUIElement("CMS.Content", "WebPartProperties.Code"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Content", "WebPartProperties.Code");
        }

        if (webpartId != "")
        {
            // Get page info
            pi = GetPageInfo(aliasPath, templateId, cultureCode);
            if (pi == null)
            {
                Visible = false;
                return;
            }

            pti = pi.UsedPageTemplateInfo;
            if ((pti != null) && ((pti.TemplateInstance != null)))
            {
                // Get web part instance
                webPart = pti.TemplateInstance.GetWebPart(instanceGuid, zoneVariantId, variantId) ?? pti.GetWebPart(webpartId);

                if (webPart != null)
                {
                    txtCode.Text = ValidationHelper.GetString(webPart.GetValue("WebPartCode"), "");
                }
                EditedObject = webPart;
            }
        }
    }
Beispiel #14
0
    /// <summary>
    /// Handles form's after data load event.
    /// </summary>
    protected void EditForm_OnAfterDataLoad(object sender, EventArgs e)
    {
        etaCode.Language = LanguageEnum.HTML;

        cssLayoutEditor.Editor.Language      = LanguageEnum.CSS;
        cssLayoutEditor.Editor.ShowBookmarks = true;

        // Do not check changes
        DocumentManager.RegisterSaveChangesScript = false;

        EditForm.OnBeforeSave += EditForm_OnBeforeSave;

        etaCode.Language = LanguageEnum.HTML;

        wpli = UIContext.EditedObject as WebPartLayoutInfo;

        layoutID = QueryHelper.GetInteger("layoutid", 0);

        isSiteManager = ((MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin) && layoutID != 0) || QueryHelper.GetBoolean("sitemanager", false));
        isNew         = (LayoutCodeName == "|new|");
        isDefault     = (LayoutCodeName == "|default|") || (!isSiteManager && string.IsNullOrEmpty(LayoutCodeName));

        if ((wpli == null) || (wpli.WebPartLayoutID <= 0))
        {
            isNew |= isSiteManager;
            editMenuElem.ObjectManager.ObjectType = WebPartLayoutInfo.OBJECT_TYPE;
        }

        ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "PreviewHierarchyPerformAction", ScriptHelper.GetScript("function actionPerformed(action) { if (action == 'saveandclose') { document.getElementById('" + hdnClose.ClientID + "').value = '1'; } " + editMenuElem.ObjectManager.GetJSFunction(ComponentEvents.SAVE, null, null) + "; }"));

        currentUser = MembershipContext.AuthenticatedUser;

        // Get web part instance (if edited in administration)
        if ((webpartId != "") && !isSiteManager)
        {
            // Get page info
            pi = CMSWebPartPropertiesPage.GetPageInfo(aliasPath, templateId, culture);
            if (pi == null)
            {
                ShowInformation(GetString("WebPartProperties.WebPartNotFound"), persistent: false);
            }
            else
            {
                // Get page template
                pti = pi.UsedPageTemplateInfo;
                if ((pti != null) && ((pti.TemplateInstance != null)))
                {
                    webPart = pti.TemplateInstance.GetWebPart(instanceGuid, zoneVariantId, variantId) ?? pti.TemplateInstance.GetWebPart(webpartId);
                }
            }
        }

        // If the web part is not found, try web part ID
        if (webPart == null)
        {
            wpi = WebPartInfoProvider.GetWebPartInfo(ValidationHelper.GetInteger(webpartId, 0));
            if (wpi == null)
            {
                ShowError(GetString("WebPartProperties.WebPartNotFound"));
                return;
            }
        }
        else
        {
            // CMS desk
            wpi = WebPartInfoProvider.GetWebPartInfo(webPart.WebPartType);
            if (string.IsNullOrEmpty(LayoutCodeName))
            {
                // Get the current layout name
                LayoutCodeName = ValidationHelper.GetString(webPart.GetValue("WebPartLayout"), "");
            }
        }

        if (wpi != null)
        {
            // Load the web part information
            webPartInfo = wpi;
            bool loaded = false;

            if (!RequestHelper.IsPostBack())
            {
                if (wpli != null)
                {
                    editMenuElem.MenuPanel.Visible = true;

                    // Read-only code text area
                    etaCode.Editor.ReadOnly = false;
                    loaded = true;
                }

                if (!loaded)
                {
                    string fileName = WebPartInfoProvider.GetFullPhysicalPath(webPartInfo);

                    // Check if filename exist
                    if (!FileHelper.FileExists(fileName))
                    {
                        ShowError(GetString("WebPartProperties.FileNotExist"));
                        pnlContent.Visible = false;
                        editMenuElem.ObjectEditMenu.Visible = false;
                    }
                    else
                    {
                        // Load default web part layout code
                        etaCode.Text = File.ReadAllText(Server.MapPath(fileName));

                        // Load default web part CSS
                        cssLayoutEditor.Text = wpi.WebPartCSS;
                    }
                }
            }
        }

        if (((wpli == null) || (wpli.WebPartLayoutID <= 0)) && isSiteManager)
        {
            editMenuElem.Title.Breadcrumbs.AddBreadcrumb(new BreadcrumbItem
            {
                Text        = GetString("WebParts.Layout"),
                RedirectUrl = String.Format("{0}&parentobjectid={1}&displaytitle={2}", UIContextHelper.GetElementUrl("CMS.Design", "WebPart.Layout"), QueryHelper.GetInteger("webpartid", 0), false)
            });

            editMenuElem.Title.Breadcrumbs.AddBreadcrumb(new BreadcrumbItem
            {
                Text = GetString("webparts_layout_newlayout"),
            });
        }

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ApplyButton", ScriptHelper.GetScript(
                                                   "function SetRefresh(refreshpage) { document.getElementById('" + hidRefresh.ClientID + @"').value = refreshpage; }
             function OnApplyButton(refreshpage) { SetRefresh(refreshpage); actionPerformed('save');refreshPreview(); }  
             function OnOKButton(refreshpage) { SetRefresh(refreshpage); actionPerformed('saveandclose'); } "));

        InitLayoutForm();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        this.CurrentMaster.DisplaySiteSelectorPanel = true;

        if (webpartId != "")
        {
            // Get pageinfo
            pi = GetPageInfo(aliasPath, templateId);
            if (pi == null)
            {
                RedirectToInformation(GetString("WebPartProperties.WebPartNotFound"));
                return;
            }

            // Get page template
            pti = pi.PageTemplateInfo;
            if ((pti != null) && ((pti.TemplateInstance != null)))
            {
                webPart = pti.TemplateInstance.GetWebPart(instanceGuid, zoneVariantId, variantId) ?? pti.GetWebPart(webpartId);
            }
        }

        // If the web part is not found, do not continue
        if (webPart == null)
        {
            RedirectToInformation(GetString("WebPartProperties.WebPartNotFound"));
            return;
        }
        else
        {
            // Get the current layout name
            if (String.IsNullOrEmpty(LayoutCodeName))
            {
                mLayoutCodeName = ValidationHelper.GetString(webPart.GetValue("WebPartLayout"), "");
            }
        }

        // Strings
        lblLayouts.Text = GetString("WebPartPropertise.LayoutList");

        if (!RequestHelper.IsPostBack())
        {
            LoadLayouts();
        }

        // Add default drop down items
        selectLayout.ShowDefaultItem = true;

        // Add new item
        if (SettingsKeyProvider.UsingVirtualPathProvider && CurrentUser.IsAuthorizedPerResource("CMS.Design", "EditCode"))
        {
            selectLayout.ShowNewItem = true;
        }

        webPartInfo = WebPartInfoProvider.GetWebPartInfo(webPart.WebPartType);

        // Where condition
        selectLayout.WhereCondition = "WebPartLayoutWebPartID =" + webPartInfo.WebPartID;

        if (QueryHelper.GetBoolean("reload", false))
        {
            SetContentPage();
        }
    }
    /// <summary>
    /// Loads the data row data from given web part instance.
    /// </summary>
    /// <param name="dr">DataRow to fill</param>
    /// <param name="webPart">Source web part</param>
    /// <param name="formInfo">Web part form info</param>
    private void LoadDataRowFromWebPart(DataRow dr, WebPartInstance webPart, FormInfo formInfo)
    {
        if (webPart != null)
        {
            foreach (DataColumn column in dr.Table.Columns)
            {
                try
                {
                    bool load = true;
                    // switch by xml version
                    switch (xmlVersion)
                    {
                        case 1:
                            load = webPart.Properties.Contains(column.ColumnName.ToLowerCSafe()) || column.ColumnName.EqualsCSafe("webpartcontrolid", true);
                            break;
                        // Version 0
                        default:
                            // Load default value for Boolean type in old XML version
                            if ((column.DataType == typeof(bool)) && !webPart.Properties.Contains(column.ColumnName.ToLowerCSafe()))
                            {
                                FormFieldInfo ffi = formInfo.GetFormField(column.ColumnName);
                                if (ffi != null)
                                {
                                    webPart.SetValue(column.ColumnName, ffi.GetPropertyValue(FormFieldPropertyEnum.DefaultValue));
                                }
                            }
                            break;
                    }

                    if (load)
                    {
                        var value = webPart.GetValue(column.ColumnName);

                        // Convert value into default format
                        if ((value != null) && (ValidationHelper.GetString(value, String.Empty) != String.Empty))
                        {
                            if (column.DataType == typeof(decimal))
                            {
                                value = ValidationHelper.GetDouble(value, 0, "en-us");
                            }

                            if (column.DataType == typeof(DateTime))
                            {
                                value = ValidationHelper.GetDateTime(value, DateTime.MinValue, "en-us");
                            }
                        }

                        DataHelper.SetDataRowValue(dr, column.ColumnName, value);
                    }
                }
                catch (Exception ex)
                {
                    EventLogProvider.LogException("WebPartProperties", "LOADDATAROW", ex);
                }
            }
        }
    }
Beispiel #17
0
    /// <summary>
    /// Initializes the form.
    /// </summary>
    /// <param name="basicForm">Form</param>
    /// <param name="dr">Data row with the data</param>
    /// <param name="fi">Form info</param>
    private void InitForm(BasicForm basicForm, DataRow dr, FormInfo fi)
    {
        if (basicForm != null)
        {
            basicForm.DataRow = dr;
            if (webPartInstance != null)
            {
                basicForm.MacroTable = webPartInstance.MacroTable;
            }
            else
            {
                basicForm.MacroTable = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
            }

            if (!RequestHelper.IsPostBack() && (webPartInstance != null))
            {
                fi = new FormInfo(fi.GetXmlDefinition());

                // Load the collapsed/un-collapsed state of categories
                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) && ValidationHelper.GetBoolean(webPartInstance.GetValue("cat_open_" + category), false))
                    {
                        fci.SetPropertyValue(FormCategoryPropertyEnum.CollapsedByDefault, "false");
                    }
                }
            }

            basicForm.SubmitButton.Visible = false;
            basicForm.SiteName             = SiteContext.CurrentSiteName;
            basicForm.FormInformation      = fi;
            basicForm.ShowPrivateFields    = true;
            basicForm.OnItemValidation    += formElem_OnItemValidation;
            basicForm.ReloadData();
        }
    }
    /// <summary>
    /// Exports properties given in the array list.
    /// </summary>
    /// <param name="elem">List of properties to export</param>
    /// <param name="webPart">WebPart instance with data</param>
    private string GetProperties(IEnumerable<IField> elem, WebPartInstance webPart)
    {
        StringBuilder sb = new StringBuilder();

        // Iterate through all fields
        foreach (object o in elem)
        {
            FormCategoryInfo fci = o as FormCategoryInfo;
            if (fci != null)
            {
                // We have category now
                sb.Append(Environment.NewLine + fci.GetPropertyValue(FormCategoryPropertyEnum.Caption, MacroContext.CurrentResolver) + Environment.NewLine + Environment.NewLine + Environment.NewLine);
            }
            else
            {
                // Form element
                FormFieldInfo ffi = o as FormFieldInfo;
                if (ffi != null)
                {
                    object value = webPart.GetValue(ffi.Name);
                    sb.Append(ffi.GetPropertyValue(FormFieldPropertyEnum.FieldCaption, MacroContext.CurrentResolver) + ": " + (value == null ? "" : value.ToString()) + Environment.NewLine + Environment.NewLine);
                }
            }
        }

        return sb.ToString();
    }
    /// <summary>
    /// Exports properties given in the array list.
    /// </summary>
    /// <param name="elem">List of properties to export</param>
    /// <param name="webPart">WebPart instance with data</param>
    private string GetProperties(ArrayList elem, WebPartInstance webPart)
    {
        StringBuilder sb = new StringBuilder();

        // Iterate through all fields
        foreach (object o in elem)
        {
            FormCategoryInfo fci = o as FormCategoryInfo;
            if (fci != null)
            {
                // We have category now
                sb.Append(Environment.NewLine + fci.CategoryCaption + Environment.NewLine + Environment.NewLine + Environment.NewLine);
            }
            else
            {
                // Form element
                FormFieldInfo ffi = o as FormFieldInfo;
                if (ffi != null)
                {
                    object value = webPart.GetValue(ffi.Name);
                    sb.Append(ffi.Caption + ": " + (value == null ? "" : value.ToString()) + Environment.NewLine + Environment.NewLine);
                }
            }
        }

        return sb.ToString();
    }
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        CurrentMaster.DisplaySiteSelectorPanel = true;

        if (webpartId != "")
        {
            // Get pageinfo
            pi = GetPageInfo(aliasPath, templateId, cultureCode);
            if (pi == null)
            {
                RedirectToInformation(GetString("WebPartProperties.WebPartNotFound"));
                return;
            }

            // Get page template
            pti = pi.UsedPageTemplateInfo;
            if ((pti != null) && ((pti.TemplateInstance != null)))
            {
                webPart = pti.TemplateInstance.GetWebPart(instanceGuid, zoneVariantId, variantId) ?? pti.TemplateInstance.GetWebPart(webpartId);
            }
        }

        bool hide = false;

        // If the web part is not found, do not continue
        // Redirect to information is in main window, just hide selector
        if (webPart == null)
        {
            hide = true;
        }
        else
        {
            webPartInfo = WebPartInfoProvider.GetWebPartInfo(webPart.WebPartType);
            if (webPartInfo == null)
            {
                hide = true;
            }

            // Get the current layout name
            if (String.IsNullOrEmpty(LayoutCodeName))
            {
                mLayoutCodeName = ValidationHelper.GetString(webPart.GetValue("WebPartLayout"), "");
            }
        }

        if (hide)
        {
            pnlContent.Visible = false;
            return;
        }

        // Strings
        lblLayouts.Text = GetString("WebPartPropertise.LayoutList");

        // Add default drop down items
        selectLayout.ShowDefaultItem = true;

        // Add new item
        if (CurrentUser.IsAuthorizedPerResource("CMS.Design", "EditCode"))
        {
            selectLayout.ShowNewItem = true;
        }

        // Set where condition
        selectLayout.WhereCondition = "WebPartLayoutWebPartID =" + webPartInfo.WebPartID;

        // Hide loader, it appears on wrong position because of small frame
        selectLayout.UniSelector.OnBeforeClientChanged = "if (window.Loader) { window.Loader.hide(); }";

        // Load layouts
        if (!RequestHelper.IsPostBack() && (LayoutCodeName != ""))
        {
            selectLayout.Value = LayoutCodeName;
        }

        // Reload the content page if required
        if (!RequestHelper.IsPostBack() || QueryHelper.GetBoolean("reload", false))
        {
            LoadContentPage();
        }
    }
Beispiel #21
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check permissions for web part properties UI
        CurrentUserInfo currentUser = CMSContext.CurrentUser;

        if (!currentUser.IsAuthorizedPerUIElement("CMS.Content", "WebPartProperties.Layout"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Content", "WebPartProperties.Layout");
        }

        // Check saved
        bool saved = false;

        if (QueryHelper.GetBoolean("saved", false))
        {
            saved           = true;
            lblInfo.Visible = true;
            lblInfo.Text    = GetString("General.ChangesSaved");
        }

        // Init GUI
        mCheckOut     = GetString("WebPartLayout.CheckOut");
        mCheckIn      = GetString("WebPartLayout.CheckIn");
        mUndoCheckOut = GetString("WebPartLayout.DiscardCheckOut");
        mSave         = GetString("General.Save");

        this.imgSave.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/Save.png");

        this.imgCheckIn.ImageUrl  = GetImageUrl("CMSModules/CMS_Content/EditMenu/checkin.png");
        this.imgCheckOut.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/checkout.png");

        this.imgUndoCheckOut.ImageUrl      = GetImageUrl("CMSModules/CMS_Content/EditMenu/undocheckout.png");
        this.btnUndoCheckOut.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("General.ConfirmUndoCheckOut")) + ");";

        if (webpartId != "")
        {
            // Get pageinfo
            pi = GetPageInfo(aliasPath, templateId);
            if (pi == null)
            {
                this.lblInfo.Text        = GetString("WebPartProperties.WebPartNotFound");
                this.pnlFormArea.Visible = false;
                return;
            }

            // Get page template
            pti = pi.PageTemplateInfo;
            if ((pti != null) && ((pti.TemplateInstance != null)))
            {
                webPart = pti.TemplateInstance.GetWebPart(instanceGuid, zoneVariantId, variantId) ?? pti.GetWebPart(webpartId);
            }
        }

        // If the web part is not found, do not continue
        if (webPart == null)
        {
            this.lblInfo.Text        = GetString("WebPartProperties.WebPartNotFound");
            this.pnlFormArea.Visible = false;

            return;
        }
        else
        {
            if (String.IsNullOrEmpty(LayoutCodeName))
            {
                // Get the current layout name
                LayoutCodeName = ValidationHelper.GetString(webPart.GetValue("WebPartLayout"), "");
            }
        }

        WebPartInfo wpi = WebPartInfoProvider.GetWebPartInfo(webPart.WebPartType);

        if (wpi != null)
        {
            // Load the web part information
            webPartInfo = wpi;
            bool loaded = false;

            if (!RequestHelper.IsPostBack())
            {
                pnlMenu.Visible         = false;
                pnlCheckOutInfo.Visible = false;

                if (LayoutCodeName != "")
                {
                    WebPartLayoutInfo wpli = WebPartLayoutInfoProvider.GetWebPartLayoutInfo(wpi.WebPartName, LayoutCodeName);
                    if (wpli != null)
                    {
                        if ((LayoutCodeName != "|default|") && (LayoutCodeName != "|new|"))
                        {
                            SetEditedObject(wpli, "WebPartProperties_layout_frameset_frameset.aspx");
                        }

                        pnlMenu.Visible         = true;
                        pnlCheckOutInfo.Visible = true;

                        // Read-only code text area
                        etaCode.ReadOnly = false;
                        etaCSS.ReadOnly  = false;

                        // Set checkout panel
                        SetCheckPanel(wpli);

                        etaCode.Text = wpli.WebPartLayoutCode;
                        etaCSS.Text  = wpli.WebPartLayoutCSS;
                        loaded       = true;
                    }
                }

                if (!loaded)
                {
                    string fileName = webPartInfo.WebPartFileName;

                    if (webPartInfo.WebPartParentID > 0)
                    {
                        WebPartInfo pwpi = WebPartInfoProvider.GetWebPartInfo(webPartInfo.WebPartParentID);
                        if (pwpi != null)
                        {
                            fileName = pwpi.WebPartFileName;
                        }
                    }

                    if (!fileName.StartsWith("~"))
                    {
                        fileName = "~/CMSWebparts/" + fileName;
                    }

                    // Check if filename exist
                    if (!FileHelper.FileExists(fileName))
                    {
                        lblError.Text      = GetString("WebPartProperties.FileNotExist");
                        lblError.Visible   = true;
                        plcContent.Visible = false;
                    }
                    else
                    {
                        // Load default web part layout code
                        etaCode.Text = File.ReadAllText(Server.MapPath(fileName));

                        // Load default web part CSS
                        etaCSS.Text = wpi.WebPartCSS;
                    }
                }
            }
        }

        btnOnOK.Click += new EventHandler(btnOnOK_Click);

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ApplyButton", ScriptHelper.GetScript(
                                                   "function SetRefresh(refreshpage) { document.getElementById('" + this.hidRefresh.ClientID + "').value = refreshpage; } \n" +
                                                   "function OnApplyButton(refreshpage) { SetRefresh(refreshpage); " + Page.ClientScript.GetPostBackEventReference(lnkSave, "") + "} \n" +
                                                   "function OnOKButton(refreshpage) { SetRefresh(refreshpage); " + Page.ClientScript.GetPostBackEventReference(btnOnOK, "") + "} \n"
                                                   ));

        if (saved && (LayoutCodeName == "|new|"))
        {
            // Refresh menu
            string query = URLHelper.Url.Query;
            query = URLHelper.AddParameterToUrl(query, "layoutcodename", webPart.GetValue("WebPartLayout").ToString());
            query = URLHelper.AddParameterToUrl(query, "reload", "true");

            string scriptText = ScriptHelper.GetScript(@"parent.frames['webpartpropertiesmenu'].location = 'webpartproperties_layout_menu.aspx" + query + "';");
            ScriptHelper.RegisterStartupScript(this, typeof(string), "ReloadAfterNewLayout", scriptText);
        }

        if (!RequestHelper.IsPostBack())
        {
            InitLayoutForm();
        }

        this.plcCssLink.Visible = String.IsNullOrEmpty(etaCSS.Text.Trim());
        this.lnkStyles.Visible  = !String.IsNullOrEmpty(LayoutCodeName) && (LayoutCodeName != "|default|");
    }
    /// <summary>
    /// Loads the data row data from given web part instance.
    /// </summary>
    /// <param name="dr">DataRow to fill</param>
    /// <param name="webPart">Source web part</param>
    private static void LoadDataRowFromWebPart(DataRow dr, WebPartInstance webPart)
    {
        foreach (DataColumn column in dr.Table.Columns)
        {
            try
            {
                object value = webPart.GetValue(column.ColumnName);

                // Convert value into default format
                if (value != null)
                {
                    if (column.DataType == typeof(decimal))
                    {
                        value = ValidationHelper.GetDouble(value, 0, "en-us");
                    }

                    if (column.DataType == typeof(DateTime))
                    {
                        value = ValidationHelper.GetDateTime(value, DateTime.MinValue, "en-us");
                    }
                }

                DataHelper.SetDataRowValue(dr, column.ColumnName, value);
            }
            catch
            {
            }
        }
    }
Beispiel #23
0
    /// <summary>
    /// Initializes the form.
    /// </summary>
    /// <param name="form">Form</param>
    /// <param name="dr">Data row with the data</param>
    /// <param name="fi">Form info</param>
    private void InitForm(BasicForm form, DataRow dr, FormInfo fi)
    {
        if (form != null)
        {
            form.DataRow = dr;
            if (webPartInstance != null)
            {
                form.MacroTable = webPartInstance.MacroTable;
            }
            else
            {
                form.MacroTable = new Hashtable();
            }

            if (!RequestHelper.IsPostBack() && (webPartInstance != null))
            {
                fi = new FormInfo(fi.GetXmlDefinition());

                // Load the collapsed/un-collapsed state of categories
                var categories = fi.GetCategoryNames();
                foreach (string category in categories)
                {
                    FormCategoryInfo fci = fi.GetFormCategory(category);
                    if (fci.CategoryCollapsible && fci.CategoryCollapsedByDefault && ValidationHelper.GetBoolean(webPartInstance.GetValue("cat_open_" + category), false))
                    {
                        fci.CategoryCollapsedByDefault = false;
                    }
                }
            }

            form.SubmitButton.Visible = false;
            form.SiteName             = CMSContext.CurrentSiteName;
            form.FormInformation      = fi;
            form.ShowPrivateFields    = true;
            form.OnItemValidation    += formElem_OnItemValidation;
            form.ReloadData();
        }
    }
Beispiel #24
0
    /// <summary>
    /// Init event handler.
    /// </summary>
    protected override void OnInit(EventArgs e)
    {
        // Do not check changes
        DocumentManager.RegisterSaveChangesScript = false;

        EditForm.OnBeforeSave += EditForm_OnBeforeSave;

        etaCode.Editor.Language = LanguageEnum.HTML;
        etaCSS.Editor.Language  = LanguageEnum.CSS;

        wpli = CMSContext.EditedObject as WebPartLayoutInfo;

        layoutID = QueryHelper.GetInteger("layoutid", 0);

        isSiteManager = ((CMSContext.CurrentUser.IsGlobalAdministrator && layoutID != 0) || QueryHelper.GetBoolean("sitemanager", false));
        isNew         = (LayoutCodeName == "|new|");
        isDefault     = (LayoutCodeName == "|default|") || (!isSiteManager && string.IsNullOrEmpty(LayoutCodeName));

        if ((wpli == null) && isSiteManager)
        {
            isNew = true;
        }

        if (wpli == null)
        {
            editMenuElem.ObjectManager.ObjectType = PredefinedObjectType.WEBPARTLAYOUT;
        }

        ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "PreviewHierarchyPerformAction", ScriptHelper.GetScript("function actionPerformed(action) { if (action == 'saveandclose') { document.getElementById('" + hdnClose.ClientID + "').value = '1'; } " + editMenuElem.ObjectManager.GetJSFunction(ComponentEvents.SAVE, null, null) + "; }"));

        RegisterResizeHeaders();

        currentUser = CMSContext.CurrentUser;

        // Get webpart instance (if edited in CMSDesk)
        if ((webpartId != "") && !isSiteManager)
        {
            // Get pageinfo
            pi = CMSWebPartPropertiesPage.GetPageInfo(aliasPath, templateId, culture);
            if (pi == null)
            {
                ShowInformation(GetString("WebPartProperties.WebPartNotFound"), null, false);
            }

            // Get page template
            pti = pi.UsedPageTemplateInfo;
            if ((pti != null) && ((pti.TemplateInstance != null)))
            {
                webPart = pti.TemplateInstance.GetWebPart(instanceGuid, zoneVariantId, variantId) ?? pti.GetWebPart(webpartId);
            }
        }

        // If the web part is not found, try webpart ID
        if (webPart == null)
        {
            // Site manager
            wpi = WebPartInfoProvider.GetWebPartInfo(ValidationHelper.GetInteger(webpartId, 0));
            if (wpi == null)
            {
                ShowError(GetString("WebPartProperties.WebPartNotFound"), null, null);
                startWithFullScreen = false;
                return;
            }
        }
        else
        {
            // CMS desk
            wpi = WebPartInfoProvider.GetWebPartInfo(webPart.WebPartType);
            if (string.IsNullOrEmpty(LayoutCodeName))
            {
                // Get the current layout name
                LayoutCodeName = ValidationHelper.GetString(webPart.GetValue("WebPartLayout"), "");
            }
        }

        if (wpi != null)
        {
            if (CMSObjectHelper.UseCheckinCheckout && (!isNew || isSiteManager))
            {
                pnlFormArea.CssClass = "PreviewDefaultContentLarge";
            }
            else
            {
                pnlFormArea.CssClass = "PreviewDefaultContent";
            }

            // Load the web part information
            webPartInfo = wpi;
            bool loaded = false;

            if (!RequestHelper.IsPostBack())
            {
                if (wpli != null)
                {
                    editMenuElem.MenuPanel.Visible = true;

                    // Read-only code text area
                    etaCode.Editor.ReadOnly = false;
                    loaded = true;
                }

                if (!loaded)
                {
                    string fileName = webPartInfo.WebPartFileName;

                    if (webPartInfo.WebPartParentID > 0)
                    {
                        WebPartInfo pwpi = WebPartInfoProvider.GetWebPartInfo(webPartInfo.WebPartParentID);
                        if (pwpi != null)
                        {
                            fileName = pwpi.WebPartFileName;
                        }
                    }

                    if (!fileName.StartsWithCSafe("~"))
                    {
                        fileName = "~/CMSWebparts/" + fileName;
                    }

                    // Check if filename exist
                    if (!FileHelper.FileExists(fileName))
                    {
                        ShowError(GetString("WebPartProperties.FileNotExist"), null, null);
                        plcContent.Visible = false;
                    }
                    else
                    {
                        // Load default web part layout code
                        etaCode.Text = File.ReadAllText(Server.MapPath(fileName));

                        // Load default web part CSS
                        etaCSS.Text         = wpi.WebPartCSS;
                        startWithFullScreen = false;
                    }
                }
            }
        }

        if ((wpli == null) && isSiteManager)
        {
            pnlFormArea.CssClass += " NewPreviewContent";

            var breadcrumbs = new string[2, 3];
            breadcrumbs[0, 0] = GetString("WebParts.Layout");
            breadcrumbs[0, 1] = ResolveUrl("~/CMSModules/PortalEngine/UI/WebParts/Development/WebPart_Edit_Layout.aspx?webpartid=" + QueryHelper.GetInteger("webpartid", 0));
            breadcrumbs[1, 0] = GetString("webparts_layout_newlayout");
            editMenuElem.PageTitleBreadcrumbs = breadcrumbs;
        }

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ApplyButton", ScriptHelper.GetScript(
                                                   "function SetRefresh(refreshpage) { document.getElementById('" + hidRefresh.ClientID + @"').value = refreshpage; }
             function OnApplyButton(refreshpage) { SetRefresh(refreshpage); actionPerformed('save');refreshPreview(); }  
             function OnOKButton(refreshpage) { SetRefresh(refreshpage); actionPerformed('saveandclose'); } "));

        InitLayoutForm();

        plcCssLink.Visible = string.IsNullOrEmpty(etaCSS.Text.Trim());

        base.OnInit(e);
    }