protected void Page_Load(object sender, EventArgs e) { // Register custom style sheet file CssRegistration.RegisterCssLink(Page, "~/CMSModules/StrandsRecommender/StyleSheets/InsertEmailWidget.css"); List <string> emailTemplates = null; // If Strands is disabled (no API key present in settings), show common warning message if (StrandsSettings.IsStrandsEnabled(SiteContext.CurrentSiteName)) { emailTemplates = LoadEmailTemplateNames(); // If there is no template available, show warning message if ((emailTemplates != null) && !emailTemplates.Any()) { AddWarning(GetString("strands.notemplates")); } } else { AddWarning(GetString("strands.notoken")); } RegisterScripts(emailTemplates); SetLabelMoreInformationText(); }
/// <summary> /// OnPreRender event handler. /// </summary> /// <param name="e">Event argument</param> protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); // Register jQuery and Require.js ScriptHelper.RegisterJQuery(Page); RequestContext.ClientApplication.Add("isAppList", true); // Register CMSAppList module ScriptHelper.RegisterModule(Page, "CMS/AppList", new { applicationListBaseUrl = ApplicationUrlHelper.GetElementUrl(), defaultAppUrl = UrlResolver.ResolveUrl("~/CMSModules/ApplicationDashboard/ApplicationDashboard.aspx"), defaultAppName = GetString("cms.dashboard"), indentLiveSite = plcLiveSite.Visible, launchAppWithQuery = String.IsNullOrEmpty(URLHelper.GetQuery(RequestContext.CurrentURL)) ? "" : URLHelper.UrlEncodeQueryString(URLHelper.GetQuery(RequestContext.CurrentURL)).Substring(1), screenLockInterval = SecurityHelper.GetSecondsToShowScreenLockAction(SiteContext.CurrentSiteName) }); ScriptHelper.RegisterModule(Page, "CMS/GlobalEventsHandler"); // Register CSS for jQuery scroller CssRegistration.RegisterCssLink(Page, "~/CMSScripts/jquery/jquery-jscrollpane.css"); // Register bootstrap tooltip for application list ScriptHelper.RegisterBootstrapTooltip(Page, ".js-filter-item a", "<div class=\"tooltip applist-tooltip\"><div class=\"tooltip-arrow\"></div><div class=\"tooltip-inner\"></div></div>"); }
protected override void OnPreRender(EventArgs e) { if (StopProcessing) { // No actions if processing is stopped } else { ScriptHelper.RegisterJQuery(Page); RequestContext.ClientApplication.Add("isVerticalTabs", true); RequestContext.ClientApplication.Add("isApplication", IsApplication); bool allowScrolling = !PortalContext.ViewMode.IsDesign(true); ScriptHelper.RegisterModule(this, "CMS/VerticalTabs", new { id = layoutElem.ClientID, scrollable = allowScrolling }); if (allowScrolling) { CssRegistration.RegisterCssLink(Page, "~/CMSScripts/jquery/jquery-jscrollpane.css"); } if (RequestHelper.IsPostBack()) { tabControl.DoTabSelection(); } } base.OnPreRender(e); }
protected void Page_PreRender(object sender, EventArgs e) { if (IsLiveSite) { // Register custom CSS CssRegistration.RegisterCssLink(Page, DocumentContext.CurrentDocumentStylesheetName, "Skin.css"); } }
protected void Page_Load(object sender, EventArgs e) { ScriptHelper.RegisterJQuery(Page); ScriptHelper.RegisterModule(Page, "CMS/ScrollPane", new { selector = "#language-menu" }); CssRegistration.RegisterCssLink(Page, "~/CMSScripts/jquery/jquery-jscrollpane.css"); string currentSiteName = (SiteID != 0) ? SiteInfoProvider.GetSiteName(SiteID) : SiteContext.CurrentSiteName; var cultures = CultureSiteInfoProvider.GetSiteCultures(currentSiteName).Items; if (cultures.Count > 1) { string defaultCulture = CultureHelper.GetDefaultCultureCode(currentSiteName); CultureInfo ci = CultureInfo.Provider.Get(SelectedCulture); imgLanguage.ImageUrl = GetFlagIconUrl(SelectedCulture, "16x16"); imgLanguage.AlternateText = imgLanguage.ToolTip = ResHelper.LocalizeString(ci.CultureName); lblLanguageName.Text = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(ci.CultureShortName)); // Generate sub-menu only if more cultures to choose from StringBuilder sb = new StringBuilder(); foreach (var culture in cultures) { string cultureCode = culture.CultureCode; string cultureName = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(culture.CultureName)); if (CMSString.Compare(cultureCode, defaultCulture, true) == 0) { cultureName += " " + GetString("general.defaultchoice"); } string flagUrl = GetFlagIconUrl(cultureCode, "16x16"); var click = String.Format("ChangeLanguage({0}); return false;", ScriptHelper.GetString(cultureCode)); sb.AppendFormat("<li><a href=\"#\" onclick=\"{0}\"><img src=\"{1}\" alt=\"\" class=\"language-flag\"><span class=\"language-name\">{2}</span></a></li>", click, flagUrl, cultureName); } ltlLanguages.Text = sb.ToString(); // Split view button btnCompare.ToolTip = GetString("SplitMode.CompareLangVersions"); btnCompare.Text = GetString("SplitMode.Compare"); if (PortalUIHelper.DisplaySplitMode) { btnCompare.AddCssClass("active"); } else { btnCompare.RemoveCssClass("active"); } } else { // Hide language menu for one assigned culture on site Visible = false; } }
protected void Page_Init(object sender, EventArgs e) { ScriptHelper.RegisterTooltip(this); RegisterAngularModule(); ScriptHelper.RegisterDialogScript(this); CssRegistration.RegisterCssLink(this, "~/CMSScripts/jquery/jqueryui/jquery-ui.css"); }
protected void Page_Load(object sender, EventArgs e) { ScriptHelper.RegisterScriptFile(Page, "~/CMSScripts/Laureus/jquery/jquery-3.3.1.min.js"); ScriptHelper.RegisterScriptFile(Page, "~/CMSScripts/Laureus/chosen/chosen.jquery.js"); ScriptHelper.RegisterScriptFile(Page, "~/CMSScripts/Laureus/chosen/chosen.order.jquery.js"); CssRegistration.RegisterCssLink(Page, "~/CMSScripts/Laureus/chosen/chosen.css"); LoadAndSelectList(DependsOnAnotherField); DataBind(); }
protected void Page_Load(object sender, EventArgs e) { ScriptHelper.RegisterScriptFile(Page, "~/CMSScripts/Laureus/jquery/jquery-3.3.1.min.js"); ScriptHelper.RegisterScriptFile(Page, "~/CMSScripts/Laureus/jsTree/jstree.min.js"); CssRegistration.RegisterCssLink(Page, "~/CMSScripts/Laureus/jsTree/themes/default/style.min.css"); var taxonomyService = new TaxonomyService(new TaxonomyRepository()); TaxonomyTree = JsonConvert.SerializeObject(taxonomyService.GetTaxonomyTree(TargetTaxonomyTypes)); }
/// <summary> /// Registers global device profiles style sheet and style sheet for given profile if exists. /// </summary> /// <param name="profileName">Profile code name used as folder name in ~/App_Themes/Components/DeviceProfile/ folder</param> private void RegisterDeviceProfileCss(string profileName) { // Global device profiles css CssRegistration.RegisterCssLink(Page, "~/App_Themes/Design/DeviceProfile.css"); string styleUrl = string.Format("~/App_Themes/Components/DeviceProfile/{0}/DeviceProfile.css", profileName); if (FileHelper.FileExists(styleUrl)) { CssRegistration.RegisterCssLink(Page, styleUrl); } }
protected override void OnLoad(EventArgs e) { // Register Semantic UI and jQuery on page where this web part is used // You can register scripts also on the Master page for them to be available globally CssRegistration.RegisterCssLink(this.Page, "https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.1.8/semantic.min.css"); CssRegistration.RegisterCssLink(this.Page, "https://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"); ScriptHelper.RegisterScriptFile(this.Page, "https://code.jquery.com/jquery-2.2.0.min.js", false); ScriptHelper.RegisterScriptFile(this.Page, "https://code.jquery.com/ui/1.10.4/jquery-ui.min.js", false); ScriptHelper.RegisterScriptFile(this.Page, "https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.1.8/semantic.min.js", false); base.OnLoad(e); }
protected void Page_Load(object sender, EventArgs e) { // Register JS ScriptHelper.RegisterJQuery(Page); ScriptHelper.RegisterJQueryCookie(Page); ScriptHelper.RegisterScriptFile(Page, "~/CMSScripts/jquery-jscrollpane.js"); CssRegistration.RegisterCssLink(Page, "~/CMSScripts/jquery/jquery-jscrollpane.css"); ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Content/CMSDesk/View/View.js"); // Init preview InitializeDevicePreview(); }
protected void Page_Init(object sender, EventArgs e) { ScriptHelper.RegisterTooltip(this); RegisterAngularModule(); ScriptHelper.RegisterDialogScript(this); CssRegistration.RegisterCssLink(this, "~/CMSScripts/jquery/jqueryui/jquery-ui.css"); if (SiteContext.CurrentSite.SiteIsContentOnly && SitePresentationUri == null) { ShowError(GetString("campaign.incorrectPresentationUrl")); MessagesPlaceHolder.ContainerCssClass = CssHelper.EnsureClass(MessagesPlaceHolder.ContainerCssClass, "cms-campaigns-edit"); } }
private void Page_PreRenderComplete(object sender, EventArgs e) { // Hide control if not enough anchors var anchorCount = UIContext.AnchorLinks.Count; if ((anchorCount < MinimalAnchors) || (anchorCount == 0) || !Visible) { pnlWrapper.Visible = false; return; } CssRegistration.RegisterCssLink(Page, "~/CMSScripts/jquery/jquery-jscrollpane.css"); ScriptHelper.RegisterModule(Page, "AdminControls/AnchorDropup", ScrollOffset); repNavigationItems.DataSource = UIContext.AnchorLinks; repNavigationItems.DataBind(); }
/// <summary> /// Raises the <see cref="E:Init"/> event. /// </summary> protected override void OnInit(EventArgs e) { ucEditableImage.ViewMode = CheckPermissions(); ucEditableImage.DataControl = CurrentWebPartInstance; ucEditableImage.CurrentPageInfo = CurrentPageInfo; ucEditableImage.SetupControl(); // Web part property macros need to be resolved manually in the EditText dialog. // In portal engine, macro resolving is being handled by the CMSAbstractWebpart control which cannot be used in this page. ucEditableImage.OnGetValue += ucEditableText_OnGetValue; string title = GetString("Content.EditImageTitle"); if (!String.IsNullOrEmpty(PageTitleSuffix)) { title += " - " + HTMLHelper.HTMLEncode(PageTitleSuffix); } SetTitle(title); // Check whether control is initialized form ASPX page if (QueryHelper.GetBoolean("aspxc", false)) { // Alternate text ucEditableImage.AlternateText = QueryHelper.GetString("at", ucEditableImage.AlternateText); // Image CSS class ucEditableImage.ImageCssClass = QueryHelper.GetString("icc", ucEditableImage.ImageCssClass); // Width/Height ucEditableImage.ImageHeight = QueryHelper.GetInteger("ih", ucEditableImage.ImageHeight); ucEditableImage.ImageWidth = QueryHelper.GetInteger("iw", ucEditableImage.ImageWidth); // Resizing values ucEditableImage.ResizeToHeight = QueryHelper.GetInteger("rth", ucEditableImage.ResizeToHeight); ucEditableImage.ResizeToWidth = QueryHelper.GetInteger("rtw", ucEditableImage.ResizeToWidth); ucEditableImage.ResizeToMaxSideSize = QueryHelper.GetInteger("rtmss", ucEditableImage.ResizeToMaxSideSize); } base.OnInit(e); CssRegistration.RegisterCssLink(Page, "Design", "OnSiteEdit.css"); ScriptHelper.RegisterJQuery(Page); menuElem.ShowSave = false; menuElem.ShowSaveAndClose = true; }
/// <summary> /// Handles the Load event of the Page control. /// </summary> protected void Page_Load(object sender, EventArgs e) { // Override BasicStyles flag to ensure correct styles in widget properties on the dashboard MessagesPlaceHolder.BasicStyles = false; MessagesPlaceHolder.WrapperControlClientID = formCustom.ClientID; ScriptHelper.RegisterEditScript(Page, false); // Register css file with editor classes CssRegistration.RegisterCssLink(Page, "~/CMSModules/Widgets/CSS/editor.css"); string definition = ValidationHelper.GetString(SessionHelper.GetValue("WidgetDefinition"), string.Empty); if (String.IsNullOrEmpty(definition)) { hdnWidgetDefinition.Value = definition; SessionHelper.Remove("WidgetDefinition"); } DocumentManager.RegisterSaveChangesScript = false; }
/// <summary> /// Load event handler. /// </summary> protected void Page_Load(object sender, EventArgs e) { // Contains definition for position of error label CssRegistration.RegisterCssLink(Page, "~/CMSWebparts/StrandsRecommender/StrandsRecommendations.css"); if (!StrandsSettings.IsStrandsEnabled(SiteContext.CurrentSiteName)) { // If Strands is not currently available, stop processing webpart StopProcessing = true; HandleError(GetString("strands.notoken")); } else if (CookieHelper.CurrentCookieLevel < CookieLevel.Visitor) { // Do nothing, if user has decided to forbid cookie usage to under Visitor level, because Strands library uses Cookies under the hood StopProcessing = true; HandleError(); } else { SetupControl(); } }
private void ReloadMenu() { if (StopProcessing) { return; } // Handle several reloads ClearProperties(); if (!HideStandardButtons) { // If content should be refreshed if (AutomationManager.RefreshActionContent) { // Display action message WorkflowActionInfo action = WorkflowActionInfoProvider.GetWorkflowActionInfo(Step.StepActionID); string name = (action != null) ? action.ActionDisplayName : Step.StepDisplayName; string str = (action != null) ? "workflow.actioninprogress" : "workflow.stepinprogress"; string text = string.Format(ResHelper.GetString(str, ResourceCulture), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(name))); text = ScriptHelper.GetLoaderInlineHtml(Page, text); InformationText = text; EnsureRefreshScript(); } // Object update if (AutomationManager.Mode == FormModeEnum.Update) { if (InfoObject != null) { // Get current process WorkflowInfo process = AutomationManager.Process; string objectName = HTMLHelper.HTMLEncode(InfoObject.TypeInfo.GetNiceObjectTypeName().ToLowerCSafe()); // Next step action if (AutomationManager.IsActionAllowed(ComponentEvents.AUTOMATION_MOVE_NEXT)) { next = new NextStepAction(Page) { Tooltip = string.Format(ResHelper.GetString("EditMenu.NextStep", ResourceCulture), objectName), OnClientClick = RaiseGetClientValidationScript(ComponentEvents.AUTOMATION_MOVE_NEXT, null), }; } // Move to specific step action if (AutomationManager.IsActionAllowed(ComponentEvents.AUTOMATION_MOVE_SPEC)) { var steps = WorkflowStepInfoProvider.GetWorkflowSteps() .Where("StepWorkflowID = " + process.WorkflowID + " AND StepType <> " + (int)WorkflowStepTypeEnum.Start) .OrderBy("StepDisplayName"); specific = new NextStepAction(Page) { Text = GetString("AutoMenu.SpecificStepIcon"), Tooltip = string.Format(ResHelper.GetString("AutoMenu.SpecificStepMultiple", ResourceCulture), objectName), CommandName = ComponentEvents.AUTOMATION_MOVE_SPEC, EventName = ComponentEvents.AUTOMATION_MOVE_SPEC, CssClass = "scrollable-menu", // Make action inactive OnClientClick = null, Inactive = true }; foreach (var s in steps) { string stepName = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(s.StepDisplayName)); NextStepAction spc = new NextStepAction(Page) { Text = string.Format(ResHelper.GetString("AutoMenu.SpecificStepTo", ResourceCulture), stepName), Tooltip = string.Format(ResHelper.GetString("AutoMenu.SpecificStep", ResourceCulture), objectName), CommandName = ComponentEvents.AUTOMATION_MOVE_SPEC, EventName = ComponentEvents.AUTOMATION_MOVE_SPEC, CommandArgument = s.StepID.ToString(), OnClientClick = RaiseGetClientValidationScript(ComponentEvents.AUTOMATION_MOVE_SPEC, "if(!confirm(" + ScriptHelper.GetString(string.Format(ResHelper.GetString("autoMenu.MoveSpecificConfirmation"), objectName, ResHelper.LocalizeString(s.StepDisplayName))) + ")) { return false; }"), }; // Process action appearance ProcessAction(spc, Step, s); // Add step specific.AlternativeActions.Add(spc); } // Add comment AddCommentAction(ComponentEvents.AUTOMATION_MOVE_SPEC, specific, objectName); } // Previous step action if (AutomationManager.IsActionAllowed(ComponentEvents.AUTOMATION_MOVE_PREVIOUS)) { var prevSteps = Manager.GetPreviousSteps(InfoObject, StateObject); int prevStepsCount = prevSteps.Count; if (prevStepsCount > 0) { previous = new PreviousStepAction(Page) { Tooltip = string.Format(ResHelper.GetString("EditMenu.PreviousStep", ResourceCulture), objectName), OnClientClick = RaiseGetClientValidationScript(ComponentEvents.AUTOMATION_MOVE_PREVIOUS, null) }; // For managers allow move to specified step if (WorkflowStepInfoProvider.CanUserManageAutomationProcesses(MembershipContext.AuthenticatedUser, InfoObject.Generalized.ObjectSiteName)) { if (prevStepsCount > 1) { foreach (var s in prevSteps) { previous.AlternativeActions.Add(new PreviousStepAction(Page) { Text = string.Format(ResHelper.GetString("EditMenu.PreviousStepTo", ResourceCulture), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(s.StepDisplayName))), Tooltip = string.Format(ResHelper.GetString("EditMenu.PreviousStep", ResourceCulture), objectName), OnClientClick = RaiseGetClientValidationScript(ComponentEvents.AUTOMATION_MOVE_PREVIOUS, null), CommandArgument = s.RelatedHistoryID.ToString() }); } } } // Add comment AddCommentAction(ComponentEvents.AUTOMATION_MOVE_PREVIOUS, previous, objectName); } } if (AutomationManager.IsActionAllowed(ComponentEvents.AUTOMATION_REMOVE)) { delete = new HeaderAction { CommandName = ComponentEvents.AUTOMATION_REMOVE, EventName = ComponentEvents.AUTOMATION_REMOVE, Text = ResHelper.GetString("autoMenu.RemoveState", ResourceCulture), Tooltip = string.Format(ResHelper.GetString("autoMenu.RemoveStateDesc", ResourceCulture), objectName), OnClientClick = RaiseGetClientValidationScript(ComponentEvents.AUTOMATION_REMOVE, "if(!confirm(" + ScriptHelper.GetString(string.Format(ResHelper.GetString("autoMenu.RemoveStateConfirmation"), objectName)) + ")) { return false; }"), ButtonStyle = ButtonStyle.Default }; } // Handle multiple next steps if (next != null) { // Get next step info List <WorkflowStepInfo> steps = AutomationManager.NextSteps; int stepsCount = steps.Count; if (stepsCount > 0) { var nextS = steps[0]; // Only one next step if (stepsCount == 1) { if (nextS.StepIsFinished) { next.Text = ResHelper.GetString("EditMenu.IconFinish", ResourceCulture); next.Tooltip = string.Format(ResHelper.GetString("EditMenu.Finish", ResourceCulture), objectName); } // Process action appearance ProcessAction(next, Step, nextS); } // Multiple next steps else { // Check if not all steps finish steps if (steps.Exists(s => !s.StepIsFinished)) { next.Tooltip = string.Format(ResHelper.GetString("EditMenu.NextStepMultiple", ResourceCulture), objectName); } else { next.Text = ResHelper.GetString("EditMenu.IconFinish", ResourceCulture); next.Tooltip = string.Format(ResHelper.GetString("EditMenu.NextStepMultiple", ResourceCulture), objectName); } // Make action inactive next.OnClientClick = null; next.Inactive = true; // Process action appearance ProcessAction(next, Step, null); string itemText = "EditMenu.NextStepTo"; string itemDesc = "EditMenu.NextStep"; foreach (var s in steps) { NextStepAction nxt = new NextStepAction(Page) { Text = string.Format(ResHelper.GetString(itemText, ResourceCulture), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(s.StepDisplayName))), Tooltip = string.Format(ResHelper.GetString(itemDesc, ResourceCulture), objectName), OnClientClick = RaiseGetClientValidationScript(ComponentEvents.AUTOMATION_MOVE_NEXT, null), CommandArgument = s.StepID.ToString() }; if (s.StepIsFinished) { nxt.Text = string.Format(ResHelper.GetString("EditMenu.FinishTo", ResourceCulture), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(s.StepDisplayName))); nxt.Tooltip = string.Format(ResHelper.GetString("EditMenu.Finish", ResourceCulture), objectName); } // Process action appearance ProcessAction(nxt, Step, s); // Add step next.AlternativeActions.Add(nxt); } } // Add comment AddCommentAction(ComponentEvents.AUTOMATION_MOVE_NEXT, next, objectName); } else { bool displayAction = false; if (!Step.StepAllowBranch) { // Transition exists, but condition doesn't match var transitions = Manager.GetStepTransitions(Step); if (transitions.Count > 0) { WorkflowStepInfo s = WorkflowStepInfoProvider.GetWorkflowStepInfo(transitions[0].TransitionEndStepID); // Finish text if (s.StepIsFinished) { next.Text = ResHelper.GetString("EditMenu.IconFinish", ResourceCulture); next.Tooltip = string.Format(ResHelper.GetString("EditMenu.Finish", ResourceCulture), objectName); } // Inform user displayAction = true; next.Enabled = false; // Process action appearance ProcessAction(next, Step, null); } } if (!displayAction) { // There is not next step next = null; } } } // Handle start button if (AutomationManager.IsActionAllowed(ComponentEvents.AUTOMATION_START) && (process.WorkflowRecurrenceType != ProcessRecurrenceTypeEnum.NonRecurring)) { start = new HeaderAction { CommandName = ComponentEvents.AUTOMATION_START, EventName = ComponentEvents.AUTOMATION_START, Text = ResHelper.GetString("autoMenu.StartState", ResourceCulture), Tooltip = process.WorkflowEnabled ? ResHelper.GetString("autoMenu.StartStateDesc", ResourceCulture) : ResHelper.GetString("autoMenu.DisabledStateDesc", ResourceCulture), CommandArgument = process.WorkflowID.ToString(), Enabled = process.WorkflowEnabled, OnClientClick = RaiseGetClientValidationScript(ComponentEvents.AUTOMATION_START, "if(!confirm(" + ScriptHelper.GetString(string.Format(ResHelper.GetString("autoMenu.startSameProcessConfirmation", ResourceCulture), objectName)) + ")) { return false; }"), ButtonStyle = ButtonStyle.Default }; } } } } // Add actions in correct order menu.ActionsList.Clear(); AddAction(previous); AddAction(next); AddAction(specific); AddAction(delete); AddAction(start); // Set the information text if (!String.IsNullOrEmpty(InformationText)) { lblInfo.Text = InformationText; lblInfo.CssClass = "LeftAlign EditMenuInfo"; lblInfo.Visible = true; } ScriptHelper.RegisterJQuery(Page); ScriptHelper.RegisterModule(Page, "CMS/ScrollPane", new { selector = ".scrollable-menu ul" }); CssRegistration.RegisterCssLink(Page, "~/CMSScripts/jquery/jquery-jscrollpane.css"); }
/// <summary> /// Prepares the layout of the web part. /// </summary> protected override void PrepareLayout() { StartLayout(); if (IsDesign) { Append("<table class=\"LayoutTable\" cellspacing=\"0\" style=\"width: 100%;\">"); if (ViewModeIsDesign()) { Append("<tr><td class=\"LayoutHeader\">"); // Add header container AddHeaderContainer(); Append("</td></tr>"); } Append("<tr><td>"); } // Content before zones Append(BeforeZones); string separator = Separator; string before = BeforeZone; string after = AfterZone; string zoneclass = ZoneCSSClass; string zonewidth = ZoneWidth; // Render the zones for (int i = 1; i <= Zones; i++) { if (i > 1) { Append(separator); } Append("<div"); // Zone class if (!String.IsNullOrEmpty(zoneclass)) { Append(" class=\"", zoneclass, "\""); } // Zone width if (!String.IsNullOrEmpty(zonewidth)) { Append(" style=\"width: ", zonewidth, "\";"); } Append(">", before); // Add the zone CMSWebPartZone zone = AddZone(ID + "_" + i, "[" + i + "]"); Append(after, "</div>"); } // Content after zones Append(AfterZones); if (IsDesign) { Append("</td></tr>"); // Footer if (AllowDesignMode) { Append("<tr><td class=\"LayoutFooter cms-bootstrap\" colspan=\"2\"><div class=\"LayoutFooterContent\">"); // Zone actions AppendRemoveAction(ResHelper.GetString("Layout.RemoveZone"), "Zones"); Append(" "); AppendAddAction(ResHelper.GetString("Layout.AddZone"), "Zones"); Append("</div></td></tr>"); } Append("</table>"); } // Register scripts string[] scripts = ScriptFiles.Split('\r', '\n'); foreach (string script in scripts) { // Register the script file string sfile = script.Trim(); if (!String.IsNullOrEmpty(sfile)) { ScriptHelper.RegisterScriptFile(Page, sfile); } } // Add init script string resolvedInitScript = MacroResolver.Resolve(InitScript); if (!string.IsNullOrEmpty(resolvedInitScript)) { ScriptHelper.RegisterStartupScript(this, typeof(string), ShortClientID + "_Init", ScriptHelper.GetScript(resolvedInitScript)); } // Register CSS files string[] cssFiles = CSSFiles.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); Array.ForEach(cssFiles, cssFile => CssRegistration.RegisterCssLink(Page, cssFile.Trim())); // Add inline CSS string inlinecss = MacroResolver.Resolve(InlineCSS); if (!string.IsNullOrEmpty(inlinecss)) { // Add css to page header CssRegistration.RegisterCssBlock(Page, "zonesWithEffectInlineCss_" + ClientID, inlinecss); } FinishLayout(); }
protected override void OnInit(EventArgs e) { DocumentManager.OnValidateData += DocumentManager_OnValidateData; DocumentManager.OnAfterAction += DocumentManager_OnAfterAction; // Web part property macros need to be resolved manually in the EditText dialog. // In portal engine, macro resolving is being handled by the CMSAbstractWebpart control which cannot be used in this page. ucEditableText.OnGetValue += ucEditableText_OnGetValue; // Process ASPX template parameters if (QueryHelper.Contains("regiontype")) { ucEditableText.RegionType = CMSEditableRegionTypeEnumFunctions.GetRegionTypeEnum(QueryHelper.GetString("regiontype", string.Empty)); if (ucEditableText.RegionType == CMSEditableRegionTypeEnum.HtmlEditor) { // HtmlEditor needs toolbar location defined (due to toolbar positioning and editing area padding) ucEditableText.HtmlAreaToolbarLocation = "Out:CKToolbar"; } // Min/Max length ucEditableText.MaxLength = QueryHelper.GetInteger("maxl", ucEditableText.MaxLength); ucEditableText.MinLength = QueryHelper.GetInteger("minl", ucEditableText.MinLength); // Word wrap ucEditableText.WordWrap = QueryHelper.GetBoolean("wordwrap", ucEditableText.WordWrap); // Upload image dimensions ucEditableText.ResizeToHeight = QueryHelper.GetInteger("resizetoheight", ucEditableText.ResizeToHeight); ucEditableText.ResizeToWidth = QueryHelper.GetInteger("resizetowidth", ucEditableText.ResizeToHeight); ucEditableText.ResizeToMaxSideSize = QueryHelper.GetInteger("resizetomaxsidesize", ucEditableText.ResizeToHeight); // Toolbar set ucEditableText.HtmlAreaToolbar = QueryHelper.GetString("toolbarset", ucEditableText.HtmlAreaToolbar); } ucEditableText.ViewMode = CheckPermissions(); ucEditableText.DataControl = CurrentWebPartInstance; ucEditableText.CurrentPageInfo = CurrentPageInfo; ucEditableText.SetupControl(); CurrentMaster.FooterContainer.Visible = false; CurrentMaster.PanelContent.RemoveCssClass("dialog-content"); string title = GetString("Content.EditTextTitle"); if (!String.IsNullOrEmpty(PageTitleSuffix)) { title += " - " + HTMLHelper.HTMLEncode(PageTitleSuffix); } SetTitle(title); base.OnInit(e); CssRegistration.RegisterCssLink(Page, "Design", "OnSiteEdit.css"); ScriptHelper.RegisterJQuery(Page); menuElem.ShowSaveAndClose = true; String resize = @"function resizeEditor() {$cmsj('.cke_contents').height($cmsj(window).height()-$cmsj('.DialogsPageHeader').height() - $cmsj('.cke_top').height() - $cmsj('.cke_bottom').height() - 20) } $cmsj(window).resize(function() {resizeEditor()});"; ScriptHelper.RegisterClientScriptBlock(this, typeof(Page), "resizeHeight", ScriptHelper.GetScript(resize)); if (ucEditableText.RegionType == CMSEditableRegionTypeEnum.TextArea) { const string resizeScript = @" var resizeTextAreaTimer; // DOM ready $cmsj(document).ready( function() { ResizeEditableArea(200); }); // Window resize $cmsj(window).resize(function () { ResizeEditableArea(100); }); function ResizeEditableArea(timeout) { clearTimeout(resizeTextAreaTimer); resizeTextAreaTimer = window.setTimeout(function () { var textarea = $cmsj('.EditableTextTextBox'); var editableTextContainer = $cmsj('.EditableTextContainer'); var editableTextEdit = $cmsj('.EditableTextEdit'); var borderMargin1 = textarea.outerHeight(true) - textarea.height(); var borderMargin2 = editableTextEdit.outerHeight(true) - editableTextEdit.height(); var borderMargin3 = editableTextContainer.outerHeight(true) - editableTextContainer.height(); var height = $cmsj('.dialog-content').height() - borderMargin1 - borderMargin2 - borderMargin3; textarea.height(height); }, timeout); }"; ScriptHelper.RegisterClientScriptBlock(this, typeof(Page), "ResizeEditableArea", ScriptHelper.GetScript(resizeScript)); } }
private string BuildStartupScript() { bool enBBCode = IsSupport || (ChatSettingsProvider.EnableBBCodeSetting && EnableBBCode); WebControl input = enBBCode ? ucBBEditor.TextArea : txtMessage; if (enBBCode) { txtMessage.Visible = false; } else { ucBBEditor.Visible = false; } string json = JsonConvert.SerializeObject( new { roomID = RoomID, inputClientID = GetString(input), buttonClientID = GetString(btnSendMessage), groupID = GroupID, chbWhisperClientID = GetString(chbWhisper), drpRecipientClientID = GetString(drpRecipient), pnlRecipientContainerClientID = GetString(pnlRecipientContainer), noneLabel = ResHelper.GetString("chat.everyone"), enableBBCode = enBBCode, bbCodeClientID = GetString(ucBBEditor), btnCannedResponses = GetString(btnCannedResponses), pnlContent = GetString(pnlWebpartContent), envelopeID = "#envelope_" + ClientID, informDialogID = GetString(pnlChatMessageSendInfoDialog), btnInformDialogClose = GetString(btnChatMessageSendInformDialogClose) }, new JsonSerializerSettings { StringEscapeHandling = StringEscapeHandling.EscapeHtml } ); string startupScript = String.Format("InitChatSenderWebpart({0});", json); // If this webpart is for support person -> generate "Canned responses" if ((ChatOnlineUserHelper.GetLoggedInChatUser() != null) && (IsSupport == true)) { // Get canned responses from database IEnumerable <ChatSupportCannedResponseInfo> cannedResponses = ChatSupportCannedResponseInfoProvider.GetCannedResponses(ChatOnlineUserHelper.GetLoggedInChatUser().ChatUserID, SiteContext.CurrentSiteID); if (cannedResponses.Any()) { plcCannedResponses.Visible = true; // Register necessary files ScriptHelper.RegisterScriptFile(Page, "~/CMSWebParts/Chat/ChatMessageSend_files/CannedResponses.js"); CssRegistration.RegisterCssLink(Page, "~/App_Themes/Design/Chat/ChatIntelliSense.css"); // Creates canned responses in format expected in javascript var cannedResponseToSerialize = from cr in cannedResponses let resolvedText = MacroResolver.Resolve(cr.ChatSupportCannedResponseText) select new { label = "#" + HTMLHelper.HTMLEncode(cr.ChatSupportCannedResponseTagName), tooltip = HTMLHelper.HTMLEncode(TextHelper.LimitLength(resolvedText, mTooltipLength)), value = resolvedText }; // Serialize canned responses to JS Array expected by javascript string cannedResponsesJSArray = ""; try { cannedResponsesJSArray = JsonConvert.SerializeObject(cannedResponseToSerialize, new JsonSerializerSettings { StringEscapeHandling = StringEscapeHandling.EscapeHtml }); } catch (Exception ex) { EventLogProvider.LogException("Chat", "JSON serialization of canned responses", ex); } startupScript += string.Format("var CannedResponses = {0};", cannedResponsesJSArray); startupScript += string.Format("InitCannedResponses({0}, {1});", ScriptHelper.GetString("#" + input.ClientID), ScriptHelper.GetString("#" + btnCannedResponses.ClientID)); } } return(startupScript); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> protected void Page_Load(object sender, EventArgs e) { // Do not process control by default StopProcessing = true; // Keep frequent objects CurrentUserInfo cui = MembershipContext.AuthenticatedUser; PageInfo pi = DocumentContext.CurrentPageInfo; if (pi == null) { IsPageNotFound = true; pi = DocumentContext.CurrentCultureInvariantPageInfo ?? new PageInfo(); checkChanges = string.Empty; } ucUIToolbar.StopProcessing = true; // Get main UI element var element = UIElementInfoProvider.GetUIElementInfo(MODULE_NAME, ELEMENT_NAME); if (element == null) { return; } // Check whether user is authorized to edit page if ((pi != null) && AuthenticationHelper.IsAuthenticated() && cui.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Editor, SiteContext.CurrentSiteName) && ((IsPageNotFound && pi.NodeID == 0) || cui.IsAuthorizedPerTreeNode(pi.NodeID, NodePermissionsEnum.Read) == AuthorizationResultEnum.Allowed) && CMSPage.CheckUIElementAccessHierarchical(element, redirectToAccessDenied: false)) { // Enable processing StopProcessing = false; // Check whether the preferred culture is RTL isRTL = CultureHelper.IsUICultureRTL(); // Add link to CSS file CssRegistration.RegisterCssLink(Page, "Design", "OnSiteEdit.css"); CssRegistration.RegisterBootstrap(Page); // Filter UI element buttons ucUIToolbar.OnButtonFiltered += ucUIToolbar_OnButtonFiltered; ucUIToolbar.OnButtonCreated += ucUIToolbar_OnButtonCreated; ucUIToolbar.OnGroupsCreated += ucUIToolbar_OnGroupsCreated; ucUIToolbar.IsRTL = isRTL; // Register edit script file RegisterEditScripts(pi); if (ViewMode.IsEditLive()) { popupHandler.Visible = true; IsLiveSite = false; MessagesPlaceHolder.IsLiveSite = false; MessagesPlaceHolder.Opacity = 100; // Keep content of editable web parts when saving the document changes if (!IsPageNotFound) { PortalManager.PreserveContent = true; } // Display warning in the Safe mode if (PortalHelper.SafeMode) { string safeModeText = GetString("onsiteedit.safemode") + "<br/><a href=\"" + RequestContext.RawURL.Replace("safemode=1", "safemode=0") + "\">" + GetString("general.close") + "</a> " + GetString("contentedit.safemode2"); string safeModeDescription = GetString("onsiteedit.safemode") + "<br/>" + GetString("general.seeeventlog"); // Display the warning message ShowWarning(safeModeText, safeModeDescription, ""); } ucUIToolbar.StopProcessing = false; // Ensure document redirection var redirectUrl = TreePathUtils.GetRedirectionUrl(pi); if (!String.IsNullOrEmpty(redirectUrl)) { redirectUrl = UrlResolver.ResolveUrl(redirectUrl); ShowInformation(GetString("onsiteedit.redirectinfo") + " <a href=\"" + redirectUrl + "\">" + redirectUrl + "</a>"); } pnlUpdateProgress.Visible = true; } // Mode menu on live site else if (ViewMode.IsLiveSite()) { // Hide the edit panel, show only slider button pnlToolbarSpace.Visible = false; pnlToolbar.Visible = false; pnlSlider.Visible = true; icon.CssClass = "cms-icon-80 icon-edit"; icon.ToolTip = GetString("onsitedit.editmode"); lblSliderText.Text = GetString("onsiteedit.editmode"); pnlButton.Attributes.Add("onclick", "OnSiteEdit_ChangeEditMode();"); // Hide the OnSite edit button when displayed in administration pnlSlider.Style.Add("display", "none"); } } // Hide control actions for unauthorized users else { plcEdit.Visible = false; } }