/// <summary> /// Handles a click on the OK button. /// </summary> /// <remarks>When the user clicks OK, the dialog is closed by calling /// the <see cref="M:Sitecore.Web.UI.Sheer.ClientResponse.CloseWindow">CloseWindow</see> method.</remarks> protected override void OK_Click() { foreach (var field in this.Info) { if (!field.Disabled && field.Required && ((field.IsRestricted && string.IsNullOrEmpty(field.CrmValue)) || field.UseValueType == 0 && string.IsNullOrEmpty(field.FormValueFrom))) { AjaxScriptManager.Alert(ResourceManager.Localize("SELECT_VALUE_FOR_REQUIRED")); return; } } this.SaveInfo(this.ActiveField.Value); this.Info.Remove(f => f.Disabled); if (this.EntityList != null) { this.SetValue(FormConstants.ActionSubTitle, this.EntityList.SelectedItem.Text); } this.SetLongValue("CrmEntityInfo", this.Info.ToString()); base.OK_Click(); }
/// <summary> /// Called when the entity type has changed. /// </summary> protected void OnEntityTypeChanged() { this.ClearMetadata(); this.FillAudit(this.AuditField, this.AuditField.SelectedValue); AjaxScriptManager.SetInnerHtml(this.AuditSettings.ID, this.AuditGrid); this.RefreshMainContent(); }
protected virtual void Render(HtmlTextWriter output, IDataView dataView, string filter, Item root, Item folder) { Assert.ArgumentNotNull(output, "output"); Assert.ArgumentNotNull(dataView, "dataView"); Assert.ArgumentNotNull(filter, "filter"); Assert.ArgumentNotNull(root, "root"); Assert.ArgumentNotNull(folder, "folder"); output.Write(string.Format("<div id=\"{0}\"", this.ID)); //double click custom event output.Write(string.Format(" onclick=\"javascript:return Sitecore.Treeview.onTreeClick(this,event);\" ondblclick=\"FieldSuite.Fields.Treelist.AddItem('{0}',event);", this.ParentId)); output.Write("\""); if (!string.IsNullOrEmpty(this.ContextMenu)) { output.Write(" oncontextmenu=\""); output.Write(AjaxScriptManager.GetEventReference(this.ContextMenu)); output.Write("\""); } if (this.AllowDragging) { output.Write( " onmousedown=\"javascript:return Sitecore.Treeview.onTreeDrag(this,event)\" onmousemove=\"javascript:return Sitecore.Treeview.onTreeDrag(this,event)\" ondragstart=\"javascript:return Sitecore.Treeview.onTreeDrag(this,event)\" ondragover=\"javascript:return Sitecore.Treeview.onTreeDrop(this,event)\" ondrop=\"javascript:return Sitecore.Treeview.onTreeDrop(this,event)\""); } output.Write(">"); output.Write("<input id=\""); output.Write(this.ID); output.Write("_Selected\" type=\"hidden\" value=\"" + folder.ID.ToShortID() + "\"/>"); output.Write("<input id=\""); output.Write(this.ID); output.Write("_Database\" type=\"hidden\" value=\"" + folder.Database.Name + "\"/>"); output.Write("<input id=\""); output.Write(this.ID); output.Write("_Parameters\" type=\"hidden\" value=\"" + this.GetParameters() + "\"/>"); output.Write("<input id=\""); output.Write(this.ID); output.Write("_ExcludedTemplatesForSelection\" type=\"hidden\" value=\"" + this.GetExcludedTemplates() + "\"/>"); output.Write("<input id=\""); output.Write(this.ID); output.Write("_IncludedTemplatesForSelection\" type=\"hidden\" value=\"" + this.GetIncludedTemplates() + "\"/>"); if (this.ShowRoot) { this.RenderNode(output, dataView, filter, root, root, folder); } else { ItemCollection children = dataView.GetChildren(root, string.Empty, true, 0, 0, this.GetFilter()); foreach (Item item in children) { this.RenderNode(output, dataView, filter, root, item, folder); } } output.Write("</div>"); }
protected override void OK_Click() { var result = new UrlString(); result.Add("DefaultProjectPath", tbProjectRootPath.Text); result.Add("DefaultFileName", tbDefaultFileName.Text); result.Add("DefaultNamespace", tbDefaultNamespace.Text); result.Add("UsingStatement", tbUsingStatements.Text); result.Add("ClassType", lstbxClassType.SelectedValue); AjaxScriptManager.SetDialogValue(result.ToString()); base.OK_Click(); }
protected static void Run(ClientPipelineArgs args) { Assert.ArgumentNotNull(args, "args"); if (args.IsPostBack) { if (!args.HasResult) { return; } string results = args.Result; AjaxScriptManager ajaxScriptManager = Client.AjaxScriptManager; if (string.IsNullOrEmpty(results)) { ajaxScriptManager.Alert("Enter an old URL and a new URL for the new redirect."); return; } string[] values = results.Split('|'); var oldValue = values[1]; var newValue = values[2]; var siteName = values[3]; if (Regex.IsMatch(oldValue, Data.Constants.HostNameRegex)) { SheerResponse.Alert(Translate.Text("Only partial URLs are allowed in the Old URL field.")); ShowModal(args); } var repository = new Repository("sitecore_master_index"); if (!repository.RedirectExists(oldValue, siteName)) // check if the old redirect exists here { try { //values[1] = values[1].Replace("%20", " "); repository.Insert(siteName, oldValue, newValue, MainUtil.GetBool(Convert.ToInt32(values[0]), false)); ajaxScriptManager.Dispatch("redirectmanager:refresh"); return; } catch (Exception exception) { ajaxScriptManager.Alert(Translate.Text("An error occured while creating the redirect for\"\":\n\n{1}", new object[] { values[1], exception.Message })); ShowModal(args); } } SheerResponse.Alert(Translate.Text("A redirect with the old URL \"{0}\" already exists.", new object[] { values[1] }), new string[0]); } ShowModal(args); }
/// <summary> /// Updates the ribbon. /// </summary> public virtual void UpdateRibbon() { if (this.RibbonSourceUri == null) { return; } var ribbon = new Ribbon(); IHasCommandContext context = this; ribbon.CommandContext = context.GetCommandContext(); ribbon.ID = "Ribbon"; HtmlTextWriter writer = new HtmlTextWriter(new StringWriter()); ribbon.RenderControl(writer); AjaxScriptManager.SetOuterHtml("Ribbon", writer.InnerWriter.ToString()); AjaxScriptManager.Eval("scCatalog.showRibbon()"); }
/// <summary> /// Updates the settings. /// </summary> /// <param name="name">The name.</param> /// <param name="updateUI">if set to <c>true</c> [update UI].</param> protected void UpdateSettings(string name, bool updateUI) { var field = this.Info[name]; if (field != null) { this.SetAllowedUseValueTypesForField(field); this.FillCurrentSettingsValues(field); this.SetAllowedEditMode(field); this.ShowSettings(field); this.UpdateDescription(field); } if (updateUI) { AjaxScriptManager.SetInnerHtml(this.SettingsBorder.ID, this.SettingsHolder); AjaxScriptManager.Current.Eval("$('{0}_Input').readOnly = true".FormatWith(this.ModeCombobox.ClientID)); } }
/// <summary> /// Handles the recording of the new record into the Sitecore database. /// </summary> /// <param name="args">The pipeline args</param> protected static void Run(ClientPipelineArgs args) { Assert.ArgumentNotNull(args, "args"); if (!args.IsPostBack) { ShowModal(args); return; } if (!args.HasResult) { return; } string results = args.Result; AjaxScriptManager ajaxScriptManager = Client.AjaxScriptManager; if (string.IsNullOrEmpty(results)) { ajaxScriptManager.Alert("Enter an old URL and a new URL for the new redirect."); return; } string[] values = results.Split('|'); var candidate = new MarketingRedirect { IsPermanent = MainUtil.GetBool(Convert.ToInt32(values[0]), false), OldUrl = values[1].ToLower().Trim(), NewUrl = values[2].ToLower().Trim(), SiteName = values[3] }; var repository = new Repository(Sitecore.Context.ContentDatabase, "sitecore_master_index"); if (repository.CandidateOldUrlContainsHostname(candidate)) { SheerResponse.Alert(Translate.Text("Only partial URLs are allowed in the Old URL field.")); ShowModal(args); return; } if (!repository.CandidateIsUnique(candidate)) { SheerResponse.Alert( Translate.Text("A redirect with the old URL \"{0}\" already exists.", new object[] { candidate.OldUrl }), new string[0]); ShowModal(args); return; } if (repository.CandidateTargetIsRedirect(candidate)) { SheerResponse.Alert("This redirect is invalid because the new URL provided would also be redirected due to another rule in this system. The New URL must resolve to a published page."); ShowModal(args); return; } if (!repository.CandidateTargetReturnsHttpSuccessResponse(candidate, out var status)) { SheerResponse.Alert(status.Message); ShowModal(args); return; } try { repository.Insert(candidate.SiteName, candidate.OldUrl, candidate.NewUrl, candidate.IsPermanent); Thread.Sleep(250); // If we don't do this, the refresh call won't work. ajaxScriptManager.Dispatch("redirectmanager:refresh"); } catch (Exception exception) { ajaxScriptManager.Alert(Translate.Text("An error occurred while creating the redirect for\"\":\n\n{1}", new object[] { values[1], exception.Message })); ShowModal(args); } }
/// <summary> /// Refreshes the grid. /// </summary> public virtual void RefreshGrid() { AjaxScriptManager.Eval("scCatalog.refreshGrid()"); }
private void Render(HtmlTextWriter output, IDataView dataView, string filter, Item root, Item folder) { Assert.ArgumentNotNull(output, "output"); Assert.ArgumentNotNull(dataView, "dataView"); Assert.ArgumentNotNull(filter, "filter"); Assert.ArgumentNotNull(root, "root"); Assert.ArgumentNotNull(folder, "folder"); output.Write("<div id=\""); output.Write(this.ID); output.Write("\" onclick=\"javascript:return Sitecore.Treeview.onTreeClick(this,event"); if (!string.IsNullOrEmpty(this.Click)) { output.Write(",'"); output.Write(StringUtil.EscapeQuote(this.Click)); output.Write("'"); } output.Write(")\""); if (!string.IsNullOrEmpty(this.DblClick)) { output.Write(" ondblclick=\""); output.Write(AjaxScriptManager.GetEventReference(this.DblClick)); output.Write("\""); } if (!string.IsNullOrEmpty(this.ContextMenu)) { output.Write(" oncontextmenu=\""); output.Write(AjaxScriptManager.GetEventReference(this.ContextMenu)); output.Write("\""); } if (this.AllowDragging) { output.Write(" onmousedown=\"javascript:return Sitecore.Treeview.onTreeDrag(this,event)\" onmousemove=\"javascript:return Sitecore.Treeview.onTreeDrag(this,event)\" ondragstart=\"javascript:return Sitecore.Treeview.onTreeDrag(this,event)\" ondragover=\"javascript:return Sitecore.Treeview.onTreeDrop(this,event)\" ondrop=\"javascript:return Sitecore.Treeview.onTreeDrop(this,event)\""); } output.Write(">"); output.Write("<input id=\""); output.Write(this.ID); string selectedVal = (this.SelectedIDs.Count > 0) ? StringUtil.Join(this.SelectedIDs, ",") : folder.ID.ToShortID().ToString(); output.Write("_Selected\" type=\"hidden\" value=\"" + selectedVal + "\" />"); output.Write("<input id=\""); output.Write(this.ID); output.Write("_Database\" type=\"hidden\" value=\"" + folder.Database.Name + "\" />"); output.Write("<input id=\""); output.Write(this.ID); output.Write("_Parameters\" type=\"hidden\" value=\"" + this.GetParameters() + "\" />"); if (!Sitecore.Data.ID.IsNullOrEmpty(this.EnabledItemsTemplateId)) { output.Write("<input id=\""); output.Write(this.ID); output.Write("_templateID\" type=\"hidden\" value=\"" + this.EnabledItemsTemplateId + "\"/>"); } if (this.ShowRoot) { this.RenderNode(output, dataView, filter, root, root, folder); } else { foreach (Item item in dataView.GetChildren(root, string.Empty, true, 0, 0, this.GetFilter())) { this.RenderNode(output, dataView, filter, root, item, folder); } } output.Write("</div>"); }
/// <summary> /// Handles the process of committing record changes to the Sitecore database. /// </summary> /// <param name="args">the pipeline args.</param> protected void Run(ClientPipelineArgs args) { Assert.ArgumentNotNull(args, "args"); AjaxScriptManager ajaxScriptManager = Client.AjaxScriptManager; if (args.IsPostBack) { if (!args.HasResult) { return; } string results = args.Result; if (string.IsNullOrEmpty(results)) { ajaxScriptManager.Alert("Enter an old URL and a new URL for the new redirect."); return; } string[] values = results.Split('|'); var changes = new MarketingRedirect(); changes.ItemId = new ID(args.Parameters["ID"]); changes.IsPermanent = MainUtil.GetBool(Convert.ToInt32(values[0]), false); changes.OldUrl = values[1].ToLower().Trim(); changes.NewUrl = values[2].ToLower().Trim(); changes.SiteName = values[3]; if (Repository.CandidateOldUrlContainsHostname(changes)) { SheerResponse.Alert(Translate.Text("Only partial URLs are allowed in the Old URL field.")); return; } if (!Repository.CandidateIsUnique(changes)) { SheerResponse.Alert( Translate.Text("A redirect with the old URL \"{0}\" already exists.", new object[] { values[1] }), new string[0]); return; } if (Repository.CandidateTargetIsRedirect(changes)) { SheerResponse.Alert("The destination URL of this redirect is also a redirect. New URL must point to a page."); return; } if (!Repository.CandidateTargetReturnsHttpSuccessResponse(changes, out var status)) { SheerResponse.Alert(status.Message); return; } try { Repository.Update(changes); Thread.Sleep(250); // If we don't do this, the refresh call might not work. ajaxScriptManager.Dispatch("redirectmanager:refresh"); } catch (Exception exception) { ajaxScriptManager.Alert( Translate.Text("An error occured while creating the redirect for\"\":\n\n{1}", new object[] { values[1], exception.Message })); } } else { ajaxScriptManager.Alert("Are you sure you want to Edit this redirect?"); UrlString editRedirectUrl = new UrlString("/sitecore/shell/~/xaml/Sitecore.SitecoreModule.Shell.Redirect.EditRedirect.aspx"); editRedirectUrl.Parameters["ID"] = args.Parameters["ID"]; SheerResponse.ShowModalDialog(editRedirectUrl.ToString(), "780", "350", string.Empty, true); args.WaitForPostBack(); } }
protected void Run(ClientPipelineArgs args) { Assert.ArgumentNotNull(args, "args"); AjaxScriptManager ajaxScriptManager = Client.AjaxScriptManager; if (args.IsPostBack) { ID id = new ID(args.Parameters["ID"]); //int id = Convert.ToInt32(strid); if (!args.HasResult) { return; } string results = args.Result; if (string.IsNullOrEmpty(results)) { ajaxScriptManager.Alert("Enter an old URL and a new URL for the new redirect."); return; } //results = HttpUtility.HtmlEncode(results); string[] values = results.Split('|'); var oldValue = values[1]; var newValue = values[2]; var siteName = values[3]; if (Regex.IsMatch(oldValue, Data.Constants.HostNameRegex)) { SheerResponse.Alert(Translate.Text("Only partial URLs are allowed in the Old URL field.")); return; } if (!Repository.CheckUrlExists(id, oldValue, siteName)) // check if the old redirect exists here { try { //values[1] = values[1].Replace("%20", " "); Repository.Update(id, siteName, oldValue, newValue, MainUtil.GetBool(Convert.ToInt32(values[0]), false)); ajaxScriptManager.Dispatch("redirectmanager:refresh"); return; } catch (Exception exception) { ajaxScriptManager.Alert( Translate.Text("An error occured while creating the redirect for\"\":\n\n{1}", new object[] { values[1], exception.Message })); } } SheerResponse.Alert( Translate.Text("A redirect with the old URL \"{0}\" already exists.", new object[] { values[1] }), new string[0]); } else { ajaxScriptManager.Alert("Are you sure you want to Edit this redirect?"); UrlString editRedirectUrl = new UrlString("/sitecore/shell/~/xaml/Sitecore.SitecoreModule.Shell.Redirect.EditRedirect.aspx"); editRedirectUrl.Parameters["ID"] = args.Parameters["ID"]; SheerResponse.ShowModalDialog(editRedirectUrl.ToString(), "780", "350", string.Empty, true); args.WaitForPostBack(); } }