示例#1
0
    protected void GridViewCountries_DataBound(object sender, EventArgs e)
    {
        foreach (GridViewRow row in GridViewCountries.Rows)
        {
            // Copy id from 5th column to invisible label in last column
            Label id = new Label();
            id.Visible = false;
            id.Text    = row.Cells[3].Text;
            row.Cells[3].Controls.Add(id);

            TextBox txtValue = ControlsHelper.GetChildControl(row, typeof(TextBox), "txtTaxValue") as TextBox;
            if (txtValue != null)
            {
                txtValue.ID = "txtTaxValue" + id.Text;
            }

            CMSCheckBox chkIsFlat = ControlsHelper.GetChildControl(row, typeof(CMSCheckBox), "chkIsFlatValue") as CMSCheckBox;
            if (chkIsFlat != null)
            {
                chkIsFlat.ID = "chkIsFlatValue" + id.Text;

                // Bind script for changing absolute/relative marks
                Label lblCurrency = ControlsHelper.GetChildControl(row, typeof(Label), "lblCurrency") as Label;
                if (lblCurrency != null)
                {
                    chkIsFlat.InputAttributes["onclick"]  = "switchCurrency(this.checked, '" + lblCurrency.ClientID + "')";
                    chkIsFlat.InputAttributes["onchange"] = "switchCurrency(this.checked, '" + lblCurrency.ClientID + "')";
                }
            }
        }
    }
    /// <summary>
    /// AfterDataLoad event handler of UIForm.
    /// </summary>
    /// <param name="sender">Sender object</param>
    /// <param name="e">Event argument</param>
    private void Control_OnAfterDataLoad(object sender, EventArgs e)
    {
        // Store edited site object in local variable
        siteInfo = Control.EditedObject as SiteInfo;

        // Set SiteID of SiteCultureSelector in order to offer only cultures assigned to the edited site.
        FormEngineUserControl visitorCultureControl = Control.FieldControls["SiteDefaultVisitorCulture"];

        if (visitorCultureControl != null)
        {
            visitorCultureControl.SetValue("SiteID", siteInfo.SiteID);
        }

        // Set "(none)" special item value for Site default stylesheet field
        EditingFormControl efc = Control.FieldEditingControls["SiteDefaultStylesheetID"];

        if (efc != null)
        {
            UniSelector uniSelector = ControlsHelper.GetChildControl(efc, typeof(UniSelector)) as UniSelector;
            if (uniSelector != null)
            {
                uniSelector.NoneRecordValue = "-1";
            }
        }
    }
示例#3
0
    protected void gvStates_DataBound(object sender, EventArgs e)
    {
        for (int i = 0; i < gvStates.Rows.Count; i++)
        {
            // Copy id from 5th column to invisible label in last column
            Label id = new Label();
            id.Visible = false;
            id.Text    = gvStates.Rows[i].Cells[4].Text;
            gvStates.Rows[i].Cells[4].Controls.Add(id);

            GridViewRow row = gvStates.Rows[i];

            // Set unique text box ID
            TextBox txtValue = ControlsHelper.GetChildControl(row, typeof(TextBox), "txtTaxValue") as TextBox;
            txtValue.ID = "txtTaxValue" + id.Text;

            // Set unique check box ID
            CheckBox chkIsFlat = ControlsHelper.GetChildControl(row, typeof(CheckBox), "chkIsFlatValue") as CheckBox;
            chkIsFlat.ID = "chkIsFlatValue" + id.Text;

            Label lblCurrency = ControlsHelper.GetChildControl(row, typeof(Label), "lblCurrency") as Label;
            if (lblCurrency != null)
            {
                chkIsFlat.InputAttributes["onclick"]  = "switchCurrency(this.checked, '" + lblCurrency.ClientID + "')";
                chkIsFlat.InputAttributes["onchange"] = "switchCurrency(this.checked, '" + lblCurrency.ClientID + "')";
            }
        }
    }
示例#4
0
    protected void InitActions()
    {
        HeaderActions actions = (HeaderActions)ControlsHelper.GetChildControl(layoutElem, typeof(HeaderActions));

        if (actions != null)
        {
            actions.AddAction(new SaveAction(Page));
        }
    }
示例#5
0
    protected void Page_PreRender(object sender, EventArgs e)
    {
        plcPageSize.Visible = (DisplayPager && ShowPageSize && (drpPageSize.Items.Count > 1));

        // Handle pager only if visible
        if (pagerElem.Visible)
        {
            if (UniPager.PageCount > UniPager.GroupSize)
            {
                LocalizedLabel lblPage = ControlsHelper.GetChildControl(UniPager, typeof(LocalizedLabel), "lblPage") as LocalizedLabel;
                using (Control drpPage = ControlsHelper.GetChildControl(UniPager, typeof(DropDownList), "drpPage"))
                {
                    using (Control txtPage = ControlsHelper.GetChildControl(UniPager, typeof(TextBox), "txtPage"))
                    {
                        if ((lblPage != null) && (drpPage != null) && (txtPage != null))
                        {
                            if (UniPager.PageCount > 20)
                            {
                                drpPage.Visible = false;
                                // Set labels associated control for US Section 508 validation
                                lblPage.AssociatedControlClientID = txtPage.ClientID;
                            }
                            else
                            {
                                txtPage.Visible = false;
                                // Set labels associated control for US Section 508 validation
                                lblPage.AssociatedControlClientID = drpPage.ClientID;
                            }
                        }
                    }
                }
            }
            else
            {
                // Remove direct page control if only one group of pages is  shown
                using (Control plcDirectPage = ControlsHelper.GetChildControl(UniPager, typeof(PlaceHolder), "plcDirectPage"))
                {
                    if (plcDirectPage != null)
                    {
                        plcDirectPage.Controls.Clear();
                    }
                }
            }
        }

        plcSpace.Visible = !pagerElem.Visible;

        // Hide entire control if pager and page size drodown is hidden
        if (!plcPageSize.Visible && !pagerElem.Visible)
        {
            Visible          = false;
            UniPager.Enabled = false;
        }

        PagerLoaded = true;
    }
    /// <summary>
    /// Updates information on index of currently processed file.
    /// </summary>
    private void UpdateImportIndex()
    {
        Literal ltlImportFilesNo = ControlsHelper.GetChildControl(this.importFilesTitleElem.RightPlaceHolder, typeof(Literal)) as Literal;

        if (ltlImportFilesNo == null)
        {
            ltlImportFilesNo = new Literal();
            this.importFilesTitleElem.RightPlaceHolder.Controls.Add(ltlImportFilesNo);
        }
        ltlImportFilesNo.Text = "<div style=\"white-space:nowrap;\">" + string.Format(FILES_NUMBERS_TEXT, this.ImportCurrFileIndex, this.ImportFilesNumber) + "</div>";
    }
    protected override void OnPreRender(EventArgs e)
    {
        if (Visible)
        {
            if (pnlEdit.Visible)
            {
                // Register other scripts which are necessary in edit mode
                if (UseProgressScript)
                {
                    ScriptHelper.RegisterLoader(Page);
                }

                // Register script
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("function Delete_" + menuElem.ClientID + "(NodeID) { " + Page.ClientScript.GetPostBackEventReference(btnDelete, null) + "; } \n");
                sb.AppendLine("function " + formElem.ClientID + "_RefreshForm(){" + Page.ClientScript.GetPostBackEventReference(btnRefresh, "") + " }");

                // Register the scripts
                AddScript(sb.ToString());

                ScriptHelper.RegisterBootstrapScripts(Page);

                if (formElem.FieldControls != null)
                {
                    // Disable maximize plugin on HTML editors
                    var htmlControls = formElem.FormInformation.GetFields(FormFieldControlTypeEnum.HtmlAreaControl);

                    foreach (FormFieldInfo field in htmlControls)
                    {
                        Control       control    = formElem.FieldControls[field.Name];
                        CMSHtmlEditor htmlEditor = ControlsHelper.GetChildControl(control, typeof(CMSHtmlEditor)) as CMSHtmlEditor;
                        if (htmlEditor != null)
                        {
                            var parameters = new LiveSiteWidgetsParameters(CurrentDocument.NodeAliasPath, PortalContext.ViewMode)
                            {
                                IsInlineWidget = true
                            };
                            htmlEditor.Node = CurrentDocument;
                            htmlEditor.RemovePlugins.Add("maximize");
                            htmlEditor.Config["CurrentHash"]     = parameters.GetHashString();
                            htmlEditor.Config["CurrentViewMode"] = PortalContext.ViewMode.ToStringRepresentation();
                        }
                    }
                }

                if (!NewDocument && !NewCulture)
                {
                    formElem.Enabled = AllowSave;
                }
            }
        }

        base.OnPreRender(e);
    }
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        Button btnRefresh = ControlsHelper.GetChildControl(elemActivate, typeof(Button), "ButtonRefresh") as Button;

        if (btnRefresh != null)
        {
            btnRefresh.CssClass = "LongButton";
            btnRefresh.Text     = "ContentButton";
        }
    }
示例#9
0
    protected void InitActions()
    {
        EmailTemplateInfo emailTemplate = (EmailTemplateInfo)EditedObject;

        if ((emailTemplate != null) && (emailTemplate.TemplateID > 0))
        {
            ObjectEditMenu menu = (ObjectEditMenu)ControlsHelper.GetChildControl(Page, typeof(ObjectEditMenu));
            if (menu != null)
            {
                EmailTemplateEditExtender.RegisterEditPageHeaderActions(Page, menu, emailTemplate);
            }
        }
    }
示例#10
0
    private void InitHeaderActions()
    {
        EmailTemplateInfo emailTemplate = Control.EditedObject as EmailTemplateInfo;

        if ((emailTemplate != null) && (emailTemplate.TemplateID > 0))
        {
            Page page = Control.Page;

            ObjectEditMenu menu = (ObjectEditMenu)ControlsHelper.GetChildControl(page, typeof(ObjectEditMenu));
            if (menu != null)
            {
                RegisterEditPageHeaderActions(page, menu, emailTemplate);
            }
        }
    }
    protected override void OnPreRender(EventArgs e)
    {
        if (Visible)
        {
            if (pnlEdit.Visible)
            {
                // Register other scripts which are necessary in edit mode
                if (UseProgressScript)
                {
                    ScriptHelper.RegisterLoader(Page);
                }

                // Register script
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("function Delete_" + menuElem.ClientID + "(NodeID) { " + Page.ClientScript.GetPostBackEventReference(btnDelete, null) + "; } \n");
                sb.AppendLine("function " + formElem.ClientID + "_RefreshForm(){" + Page.ClientScript.GetPostBackEventReference(btnRefresh, "") + " }");

                // Register the scripts
                AddScript(sb.ToString());

                ScriptHelper.RegisterBootstrapScripts(Page);

                if (formElem.FieldControls != null)
                {
                    // Disable maximize plugin on HTML editors
                    var htmlControls = formElem.FormInformation.GetFieldsWithControl(FormFieldControlName.HTMLAREA);

                    foreach (FormFieldInfo field in htmlControls)
                    {
                        Control       control    = formElem.FieldControls[field.Name];
                        CMSHtmlEditor htmlEditor = ControlsHelper.GetChildControl(control, typeof(CMSHtmlEditor)) as CMSHtmlEditor;
                        if (htmlEditor != null)
                        {
                            htmlEditor.Node = DocumentContext.CurrentDocument;
                            htmlEditor.RemovePlugins.Add("maximize");
                        }
                    }
                }

                if (!NewDocument && !NewCulture)
                {
                    formElem.Enabled = AllowSave;
                }
            }
        }

        base.OnPreRender(e);
    }
    /// <summary>
    /// Handles OnLoad event of the UI form.
    /// </summary>
    /// <param name="sender">Sender object</param>
    /// <param name="e">Event argument</param>
    private void Control_Load(object sender, EventArgs e)
    {
        // Store edited site object in local variable
        siteInfo = Control.EditedObject as SiteInfo;

        // Set "(none)" special item value for Site default stylesheet field
        EditingFormControl efc = Control.FieldEditingControls["SiteDefaultStylesheetID"];

        if (efc != null)
        {
            UniSelector uniSelector = ControlsHelper.GetChildControl(efc, typeof(UniSelector)) as UniSelector;
            if (uniSelector != null)
            {
                uniSelector.NoneRecordValue = "-1";
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (userId > 0)
        {
            // Check that only global administrator can edit global administrator's accouns
            UserInfo ui = UserInfoProvider.GetUserInfo(userId);
            CheckUserAvaibleOnSite(ui);
            EditedObject = ui;
        }

        Panel pnlContent = ControlsHelper.GetChildControl(Page, typeof(Panel), "pnlContent") as Panel;

        if (pnlContent != null)
        {
            pnlContent.CssClass = "";
        }
    }
示例#14
0
    protected void GridViewCountries_DataBound(object sender, EventArgs e)
    {
        foreach (GridViewRow row in GridViewCountries.Rows)
        {
            // Copy id from CountryID column to invisible label in last column
            Label id = new Label();
            id.Visible = false;
            id.Text    = row.Cells[2].Text;
            row.Cells[2].Controls.Add(id);

            TextBox txtValue = ControlsHelper.GetChildControl(row, typeof(TextBox), "txtTaxValue") as TextBox;
            if (txtValue != null)
            {
                txtValue.ID = "txtTaxValue" + id.Text;
            }
        }
    }
示例#15
0
    /// <summary>
    /// Initializes header actions.
    /// </summary>
    /// <param name="templateId">Email template ID</param>
    /// <param name="siteId">Site ID</param>
    protected void InitHeaderActions(int templateId, int siteId)
    {
        if (templateId > 0)
        {
            // Get number of attachments
            InfoDataSet <MetaFileInfo> ds = MetaFileInfoProvider.GetMetaFiles(templateId, PredefinedObjectType.EMAILTEMPLATE, MetaFileInfoProvider.OBJECT_CATEGORY_TEMPLATE,
                                                                              siteId > 0 ? "MetaFileSiteID=" + siteId : "MetaFileSiteID IS NULL", null, "MetafileID", -1);
            int attachCount = ds.Items.Count;

            string script = @"
function UpdateAttachmentCount(count) {
    var counter = document.getElementById('attachmentCount');
    if (counter != null) {
        if (count > 0) { counter.innerHTML = ' (' + count + ')'; }
        else { counter.innerHTML = ''; }
    }
}";
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "UpdateAttachmentScript_" + this.ClientID, script, true);

            // Register dialog scripts
            ScriptHelper.RegisterDialogScript(Page);

            // Prepare metafile dialog URL
            string metaFileDialogUrl = ResolveUrl(@"~/CMSModules/AdminControls/Controls/MetaFiles/MetaFileDialog.aspx");
            string query             = string.Format("?objectid={0}&objecttype={1}&siteid={2}", templateId, PredefinedObjectType.EMAILTEMPLATE, siteId);
            metaFileDialogUrl += string.Format("{0}&category={1}&hash={2}", query, MetaFileInfoProvider.OBJECT_CATEGORY_TEMPLATE, QueryHelper.GetHash(query));

            // Init attachment button
            ObjectEditMenu menu = ControlsHelper.GetChildControl(Page, typeof(ObjectEditMenu)) as ObjectEditMenu;
            if (menu != null)
            {
                attachmentsAction = new HeaderAction()
                {
                    ControlType   = HeaderActionTypeEnum.LinkButton,
                    Text          = GetString("general.attachments") + string.Format("<span id='attachmentCount'>{0}</span>", (attachCount > 0) ? " (" + attachCount.ToString() + ")" : string.Empty),
                    Tooltip       = GetString("general.attachments"),
                    OnClientClick = string.Format(@"if (modalDialog) {{modalDialog('{0}', 'Attachments', '700', '500');}}", metaFileDialogUrl) + " return false;",
                    ImageUrl      = GetImageUrl("Objects/CMS_MetaFile/attachment.png"),
                    Visible       = !pnlObjectLocking.IsObjectLocked()
                };

                menu.AddExtraAction(attachmentsAction);
            }
        }
    }
    protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        switch (sourceName.ToLowerCSafe())
        {
        case "remove":
            bool rejected = ValidationHelper.GetString(((DataRowView)((GridViewRow)parameter).DataItem).Row["FriendStatus"], string.Empty) == "1";
            // Disable checkbox
            GridViewRow row = (GridViewRow)parameter;

            Control control = ControlsHelper.GetChildControl(row, typeof(CheckBox));
            if (control != null)
            {
                CheckBox checkBox = (CheckBox)control;
                checkBox.Enabled = !rejected;
            }
            // Disable button
            if (rejected)
            {
                ImageButton button = ((ImageButton)sender);
                button.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/deletedisabled.png");
                button.Enabled  = false;
            }
            break;

        case "status":
            // Set status (rejected/waiting)
            FriendshipStatusEnum status =
                (FriendshipStatusEnum)Enum.Parse(typeof(FriendshipStatusEnum), parameter.ToString());
            switch (status)
            {
            case FriendshipStatusEnum.Waiting:
                parameter = "<span class=\"Waiting\">" + GetString("friends.waiting") + "</span>";
                break;

            case FriendshipStatusEnum.Rejected:
                parameter = "<span class=\"Rejected\">" + GetString("general.rejected") + "</span>";
                break;
            }
            break;

        case "formattedusername":
            return(HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(Convert.ToString(parameter), IsLiveSite)));
        }
        return(parameter);
    }
示例#17
0
    /// <summary>
    /// Setup control.
    /// </summary>
    public void SetupControl()
    {
        ObjectEditMenu menu = ControlsHelper.GetChildControl(Page, typeof(ObjectEditMenu)) as ObjectEditMenu;

        if (menu != null)
        {
            menu.ShowSave = false;
        }

        var abstractMenu = ControlsHelper.GetChildControl(Page, typeof(IObjectEditMenu)) as IObjectEditMenu;

        if (abstractMenu != null)
        {
            abstractMenu.AbstractObjectManager.OnAfterAction += (sender, args) =>
            {
                if (DialogMode)
                {
                    ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "parentWOpenerRefresh", ScriptHelper.GetScript("if (parent && parent.wopener && parent.wopener.refresh) { parent.wopener.refresh(); }"));
                }
            };
        }

        gridHistory.ZeroRowsText = GetString("objectversioning.objecthasnohistory");
        if (Object != null)
        {
            // Set buttons confirmation
            btnDestroy.OnClientClick   = "return confirm(" + ScriptHelper.GetString(ResHelper.GetString("VersionProperties.ConfirmDestroy")) + ");";
            btnMakeMajor.OnClientClick = "return confirm(" + ScriptHelper.GetString(ResHelper.GetString("VersionProperties.ConfirmMakeMajor")) + ");";

            gridHistory.OnExternalDataBound += gridHistory_OnExternalDataBound;
            gridHistory.OnAction            += gridHistory_OnAction;
            gridHistory.WhereCondition       = "VersionObjectType = '" + SqlHelper.GetSafeQueryString(Object.TypeInfo.ObjectType, false) + "' AND VersionObjectID = " + Object.Generalized.ObjectID;
            gridHistory.Columns              = "VersionID, UserName, FullName, VersionModifiedWhen, VersionNumber";
        }
        else
        {
            gridHistory.StopProcessing = true;
            headTitle.Visible          = false;
            btnDestroy.Visible         = false;

            ShowError(GetString("objectversioning.uknownobject"));
        }
    }
    private void ReloadAttachmentData(int PostId)
    {
        string where = "(AttachmentPostID = " + PostId + ")";

        // Load unigrid
        UniGrid.IsLiveSite           = IsLiveSite;
        UniGrid.ObjectType           = "Forums.ForumAttachment";
        UniGrid.Columns              = "AttachmentID,AttachmentFileName,AttachmentFileSize,AttachmentGUID";
        UniGrid.WhereCondition       = where;
        UniGrid.OnAction            += UniGrid_OnAction;
        UniGrid.OnExternalDataBound += UniGrid_OnExternalDataBound;

        UniGrid.Visible = true;
        Panel pnlUniGrid = ControlsHelper.GetChildControl(UniGrid, typeof(Panel), "pnlContent") as Panel;

        if (pnlUniGrid != null)
        {
            pnlUniGrid.Style.Add("margin-bottom", "15px");
        }
    }
    /// <summary>
    /// PreRender event handler.
    /// </summary>
    protected void Page_PreRender(object sender, EventArgs e)
    {
        if ((Node == null) || (TagGroupSelector == null))
        {
            return;
        }

        bool noneSelected = ValidationHelper.GetInteger(TagGroupSelector.Value, 0) == 0;

        object val;

        inheritedValues.TryGetValue("DocumentTagGroupID", out val);
        int parentValue = ValidationHelper.GetInteger(val, 0);

        // Allow empty value in selector if node has no tag group selected and parent tag group also isn't set
        TagGroupSelector.SetValue("AllowEmpty", noneSelected || ((Node.DocumentTagGroupID == 0) && (parentValue == 0)));

        // Get all groups from original page site ID
        TagGroupSelector.SetValue("WhereCondition", "[TagGroupSiteID] = " + Node.OriginalNodeSiteID);

        if (!TagGroupSelector.HasData)
        {
            // Hide tag module controls and show information if no tag group exists
            Control.MessagesPlaceHolder.ShowInformation(ResHelper.GetString("PageProperties.TagsInfo"));
            Control.FieldsToHide.Add("DocumentTagGroupID");
            Control.FieldsToHide.Add("DocumentTagGroupIDInherit");
            Control.FieldsToHide.Add("DocumentTags");

            var lblNoTags = ControlsHelper.GetChildControl(Control, typeof(LocalizedLabel), "lblNoTags") as LocalizedLabel;
            lblNoTags.Visible = true;
        }
        else
        {
            Control.FieldControls["DocumentTags"].Enabled = !noneSelected;
            if (noneSelected)
            {
                // Clear tags if no tag group selected
                Control.FieldControls["DocumentTags"].Text = String.Empty;
            }
        }
    }
示例#20
0
    private void RepeaterElement_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (!CanManageTemplates)
        {
            return;
        }

        var item = e.Item;

        if (item.ItemType != ListItemType.Item && item.ItemType != ListItemType.AlternatingItem)
        {
            return;
        }

        var templateId = ((AutomationTemplateViewModel)item.DataItem).Id;

        if (templateId == CREATE_FROM_SCRATCH_ID)
        {
            return;
        }

        var tileOptions = ControlsHelper.GetChildControl <CMSMoreOptionsButton>(item);

        tileOptions.Visible = true;
        tileOptions.ToolTip = GetString("EditMenu.MoreActions");
        tileOptions.Actions = new List <CMSButtonAction>()
        {
            new CMSButtonAction
            {
                Text          = GetString("general.edit"),
                ToolTip       = GetString("general.edit"),
                OnClientClick = $"editTemplate({templateId}); return false;"
            },
            new CMSButtonAction
            {
                Text          = GetString("general.delete"),
                ToolTip       = GetString("general.delete"),
                OnClientClick = $"deleteTemplate({templateId}); return false;"
            }
        };
    }
    /// <summary>
    /// Appends draggable startup script of each automation step to the <see cref="mStartupScriptBuilder"/>.
    /// </summary>
    protected void stepRepeater_OnItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        var stepItem = e.Item.DataItem as Item;

        var stepControl = ControlsHelper.GetChildControl <CMSModules_ContactManagement_Controls_UI_Automation_AutomationDesignerToolbarStep>(e.Item);

        if (stepItem == null || stepControl == null)
        {
            return;
        }

        var stepPanel = ControlsHelper.GetChildControl <Panel>(stepControl);

        if (stepPanel == null)
        {
            return;
        }

        var stepDraggableScript = $"$cmsj( '#{stepPanel.ClientID}' ).draggable({{ helper:{GetDraggableHandler(stepItem.DraggableTemplateHandler)}, scope:'{stepItem.DraggableScope}', containment:'body' }});";

        mStartupScriptBuilder.AppendLine(stepDraggableScript);
    }
示例#22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (userId > 0)
        {
            // Check that only global administrator can edit global administrator's accouns
            UserInfo ui = UserInfoProvider.GetUserInfo(userId);
            CheckUserAvaibleOnSite(ui);
            EditedObject = ui;
        }

        Panel pnlContent = ControlsHelper.GetChildControl(Page, typeof(Panel), "pnlContent") as Panel;

        if (pnlContent != null)
        {
            pnlContent.CssClass = "";
        }

        ScriptHelper.HideVerticalTabs(this);

        // Ensure correct object type in breadcrumbs
        UIHelper.SetBreadcrumbsSuffix("");
    }
示例#23
0
    protected void InitAttachmentAction()
    {
        EmailTemplateInfo emailTemplate = Control.EditedObject as EmailTemplateInfo;

        if ((emailTemplate != null) && (emailTemplate.TemplateID > 0))
        {
            int  siteId = emailTemplate.TemplateSiteID;
            Page page   = Control.Page;

            // Get number of attachments
            InfoDataSet <MetaFileInfo> ds = MetaFileInfoProvider.GetMetaFiles(emailTemplate.TemplateID, EmailTemplateInfo.OBJECT_TYPE, ObjectAttachmentsCategories.TEMPLATE,
                                                                              siteId > 0 ? "MetaFileSiteID=" + siteId : "MetaFileSiteID IS NULL", null, "MetafileID", -1);
            int attachCount = ds.Items.Count;

            // Register attachments count update module
            ScriptHelper.RegisterModule(page, "CMS/AttachmentsCountUpdater", new { Selector = "." + mAttachmentsActionClass, Text = ResHelper.GetString("general.attachments") });

            // Register dialog scripts
            ScriptHelper.RegisterDialogScript(page);

            // Prepare metafile dialog URL
            string metaFileDialogUrl = URLHelper.ResolveUrl(@"~/CMSModules/AdminControls/Controls/MetaFiles/MetaFileDialog.aspx");
            string query             = String.Format("?objectid={0}&objecttype={1}&siteid={2}", emailTemplate.TemplateID, EmailTemplateInfo.OBJECT_TYPE, siteId);
            metaFileDialogUrl += String.Format("{0}&category={1}&hash={2}", query, ObjectAttachmentsCategories.TEMPLATE, QueryHelper.GetHash(query));

            ObjectEditMenu menu = (ObjectEditMenu)ControlsHelper.GetChildControl(page, typeof(ObjectEditMenu));
            if (menu != null)
            {
                menu.AddExtraAction(new HeaderAction()
                {
                    Text          = ResHelper.GetString("general.attachments") + ((attachCount > 0) ? " (" + attachCount.ToString() + ")" : String.Empty),
                    OnClientClick = String.Format(@"if (modalDialog) {{modalDialog('{0}', 'Attachments', '700', '500');}}", metaFileDialogUrl) + " return false;",
                    Enabled       = !SynchronizationHelper.UseCheckinCheckout || emailTemplate.Generalized.IsCheckedOutByUser(MembershipContext.AuthenticatedUser),
                    CssClass      = mAttachmentsActionClass
                });
            }
        }
    }
    /// <summary>
    /// Gets CheckBox control for given field name
    /// </summary>
    /// <param name="fieldName">Name of field which can have inherited value</param>
    private CMSCheckBox GetCheckBox(string fieldName)
    {
        if (checkboxes.ContainsKey(fieldName))
        {
            // Return from dictionary
            return(checkboxes[fieldName]);
        }

        FormEngineUserControl control = Control.FieldControls[fieldName + SUFFIX_INHERIT];

        if (control != null)
        {
            // Get checkbox from form control
            CMSCheckBox checkbox = ControlsHelper.GetChildControl <CMSCheckBox>(control);
            if (checkbox != null)
            {
                checkboxes[fieldName] = checkbox;
                return(checkbox);
            }
        }

        return(null);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (AlternativeFormInfo == null || BizFormInfo == null)
        {
            RedirectToAccessDenied(GetString("general.invalidparameters"));
        }

        CurrentMaster.BodyClass += " FieldEditorBody";

        altFormFieldEditor.AlternativeFormID = AlternativeFormInfo.FormID;
        altFormFieldEditor.Mode = FieldEditorModeEnum.AlternativeBizFormDefinition;
        altFormFieldEditor.DisplayedControls = FieldEditorControlsEnum.Bizforms;
        altFormFieldEditor.OnBeforeSave     += altFormFieldEditor_OnBeforeSave;

        ObjectEditMenu menu = (ObjectEditMenu)ControlsHelper.GetChildControl(Page, typeof(ObjectEditMenu));

        if (menu != null)
        {
            menu.AllowSave = MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.form", "EditForm", SiteInfoProvider.GetSiteName(BizFormInfo.FormSiteID));
        }

        ScriptHelper.HideVerticalTabs(this);
    }
示例#26
0
    /// <summary>
    /// OnPreRender event of the control.
    /// </summary>
    /// <param name="e">Event argument</param>
    protected override void OnPreRender(EventArgs e)
    {
        FormEngineUserControl plainCssPreviewControl = EditForm.FieldControls["StylesheetCodePreview"];
        CMSRadioButtonList    radios = ControlsHelper.GetChildControl <CMSRadioButtonList>(plainCssPreviewControl);

        // Bind click event handler to radio buttons in order to compile CSS client-side after Plain CSS preview button is clicked
        if (radios != null)
        {
            string radioScript = @"
function CompileCssForPreview(obj) {
    if (obj.value == 'preview') {
        CompileCss();
    }
}
";

            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "CompileCssForPreview", radioScript, true);
            foreach (ListItem li in radios.Items)
            {
                li.Attributes.Add("onclick", "CompileCssForPreview(this)");
            }
        }

        // Register script for client-side compilation
        RegisterClientSideCompilationScript();

        startWithFullScreen = ((previewState != 0) && editMenuElem.ObjectManager.IsObjectChecked());
        RegisterInitScripts(pnlContainer.ClientID, editMenuElem.MenuPanel.ClientID, startWithFullScreen);

        if (Editor != null)
        {
            Editor.ShowBookmarks        = true;
            Editor.RegularExpression    = @"\s*/\*\s*#\s*([a-zA-Z_0-9-/\+\*.=~\!@\$%\^&\(\[\]\);:<>\?\s]*)\s*#\s*\*/";
            Editor.EnablePositionMember = true;
            Editor.EnableSections       = true;
            Editor.AutoSize             = true;
            Editor.ParentElementID      = ParentClientID;

            // Initialize selected line
            string script = @"
$j(document).ready(function () {
    setTimeout(function() {
        var cmCSS = document.getElementById('" + Editor.EditorID + @"');
        if(cmCSS != null) {
            cmCSS.setCursor(" + (QueryHelper.GetInteger("line", 0) - 1) + @");
        }
    }, 50);
});";
            // Register client script
            ScriptHelper.RegisterStartupScript(EditForm, typeof(string), "JumpToLine", script, true);
        }

        // Correct offset for displaying preview
        if ((previewState != 0) && (CssStylesheetCode != null))
        {
            CssStylesheetCode.SetValue("TopOffset", 40);
        }

        // Register loader script
        ScriptHelper.RegisterLoader(Page);

        base.OnPreRender(e);
    }