/// <summary> /// Gets the placeholders of the control. /// /// </summary> /// <param name="control">The control.</param><param name="result">The result.</param> private static void GetPlaceholders(Control control, List <Placeholder72> result) { Assert.ArgumentNotNull((object)control, "control"); Assert.ArgumentNotNull((object)result, "result"); if (control is Placeholder) { result.Add(control as Placeholder72); } else if (control is IHasPlaceholders) { List <Placeholder> placeholders = (control as IHasPlaceholders).GetPlaceholders(); if (placeholders == null) { return; } result.AddRange((IEnumerable <Placeholder72>)placeholders); } else { foreach (Control control1 in control.Controls) { Placeholder72.GetPlaceholders(control1, result); } } }
/// <summary> /// Renders the renderings. /// /// </summary> /// <param name="output">The output.</param><param name="list">The list.</param> private void RenderRenderings(HtmlTextWriter output, List <RenderingDefinition> list) { Assert.ArgumentNotNull((object)output, "output"); Assert.ArgumentNotNull((object)list, "list"); for (int index = 0; index < list.Count; ++index) { RenderingDefinition renderingDefinition = list[index]; string itemId = renderingDefinition.ItemID; if (!string.IsNullOrEmpty(itemId)) { Item rendering = Sitecore.Context.Database.GetItem(itemId); if (rendering != null) { if (Placeholder72.IsSublayout(rendering)) { this.RenderSublayout(output, rendering, renderingDefinition, index); } else { this.RenderRendering(output, rendering, renderingDefinition, index); } } } } }
/// <summary> /// Renders the control page design mode. /// /// </summary> /// <param name="output">The output.</param><param name="isDesignAllowed">if set to <c>true</c> [is design allowed].</param><param name="control">The control.</param> private void RenderControlPageDesignMode(HtmlTextWriter output, bool isDesignAllowed, Control control) { Assert.ArgumentNotNull((object)output, "output"); Assert.ArgumentNotNull((object)control, "control"); RenderingReference renderingReference = Client.Page.GetRenderingReference(control); bool flag = false; if (renderingReference != null) { string uniqueId = renderingReference.UniqueId; if (Sitecore.Data.ID.IsID(uniqueId)) { string controlId = ShortID.Encode(uniqueId); Item obj = this.GetItem(); Assert.IsNotNull((object)obj, "item"); ChromeData controlData = Placeholder72.GetControlData(renderingReference, obj); output.Write(Placeholder72.GetControlStartMarker(controlId, controlData, isDesignAllowed)); control.RenderControl(output); output.Write(Placeholder72.GetControlEndMarker(controlData)); flag = true; } } if (flag) { return; } control.RenderControl(output); }
/// <summary> /// Renders the page design mode. /// </summary> /// <param name="output">The output.</param> private void RenderPlaceholderPageDesignMode(HtmlTextWriter output) { Assert.ArgumentNotNull((object)output, "output"); bool flag = true; if (!this.CanDesign(Sitecore.Context.Database) || !Policy.IsAllowed("Page Editor/Can Design")) { flag = false; } Item contextItem = this.GetContextItem(); if (contextItem != null && !WebEditUtil.CanDesignItem(contextItem)) { flag = false; } string qualifiedKey = this.GetQualifiedKey(); Item obj = this.GetItem(); GetChromeDataArgs args = obj != null ? new GetChromeDataArgs("placeholder", obj) : new GetChromeDataArgs("placeholder"); args.CustomData["placeHolderKey"] = (object)qualifiedKey; GetChromeDataPipeline.Run(args); ChromeData chromeData = args.ChromeData; string startMarker = Placeholder72.GetStartMarker(qualifiedKey, chromeData, flag); output.Write(startMarker); for (int index = 0; index < this.Controls.Count; ++index) { Control control = this.Controls[index]; this.RenderControlPageDesignMode(output, flag, control); } string endMarker = Placeholder72.GetEndMarker(chromeData); output.Write(endMarker); }
/// <summary> /// Gets the start marker. /// /// </summary> /// <param name="placeholderKey">The placeholder key.</param><param name="data">The data.</param><param name="selectable">if set to <c>true</c> [selectable].</param> /// <returns> /// The start marker. /// </returns> public static string GetStartMarker(string placeholderKey, ChromeData data, bool selectable) { Assert.ArgumentNotNull((object)placeholderKey, "placeholderKey"); Assert.ArgumentNotNull((object)data, "data"); StringBuilder stringBuilder = new StringBuilder(); string str = Placeholder72.EscapeNonWordCharacters(placeholderKey); stringBuilder.AppendFormat("<code type='text/sitecore' chromeType='placeholder' kind='open' id='{0}' key='{1}' class='scpm' data-selectable='{2}'>", (object)str, (object)placeholderKey, (object)MainUtil.BoolToString(selectable)); stringBuilder.Append(data.ToJson()); stringBuilder.Append("</code>"); return(((object)stringBuilder).ToString()); }
/// <summary> /// Renders the control start marker. /// /// </summary> /// <param name="controlId">The control id.</param><param name="data">The data.</param><param name="selectable">Defines wheter element is selectable in</param> /// <returns> /// HTML that precedes the control in page editing mode. /// /// </returns> public static string GetControlStartMarker(string controlId, ChromeData data, bool selectable) { Assert.ArgumentNotNull((object)controlId, "controlId"); Assert.ArgumentNotNull((object)data, "data"); StringBuilder stringBuilder = new StringBuilder(); string str1 = Placeholder72.SanitizeAttribute(data.DisplayName); string str2 = data.ToJson(); stringBuilder.Append(StringExtensions.FormatWith("<code type='text/sitecore' chromeType='rendering' kind='open' hintName='{0}' id='r_{1}' class='scpm' data-selectable='{2}'>", (object)str1, (object)controlId, (object)MainUtil.BoolToString(selectable))); stringBuilder.Append(str2); stringBuilder.Append("</code>"); return(((object)stringBuilder).ToString()); }
/// <summary> /// Gets the end market. /// /// </summary> /// <param name="data">The data.</param> /// <returns> /// The end marker. /// </returns> public static string GetEndMarker(ChromeData data) { string str = string.Empty; if (data != null) { str = Placeholder72.SanitizeAttribute(data.DisplayName); } return(StringExtensions.FormatWith("<code type='text/sitecore' chromeType='placeholder' kind='close' hintName='{0}' class='scpm'></code>", new object[1] { (object)str })); }
/// <summary> /// Gets the placeholders of a control. /// </summary> /// <param name="control">The control.</param><param name="includeSelf">if set to <c>true</c> [include self].</param> /// <returns/> public static List <Placeholder72> GetPlaceholders(Control control, bool includeSelf) { Assert.ArgumentNotNull((object)control, "control"); List <Placeholder72> result = new List <Placeholder72>(); if (includeSelf) { Placeholder72.GetPlaceholders(control, result); } else { foreach (Control control1 in control.Controls) { Placeholder72.GetPlaceholders(control1, result); } } return(result); }
/// <summary> /// Renders the in page design mode. /// /// </summary> /// <param name="output">The output.</param><param name="pageDesignerHandle">The page designer handle.</param> private bool RenderPageLayoutMode(HtmlTextWriter output, string pageDesignerHandle) { Assert.ArgumentNotNull((object)output, "output"); Assert.ArgumentNotNullOrEmpty(pageDesignerHandle, "pageDesignerHandle"); if (!this.CanDesign(Sitecore.Context.Database)) { return(false); } string sessionString = WebUtil.GetSessionString(pageDesignerHandle); if (string.IsNullOrEmpty(sessionString)) { return(true); } DeviceItem device1 = Sitecore.Context.Device; if (device1 == null) { return(false); } DeviceDefinition device2 = LayoutDefinition.Parse(sessionString).GetDevice(device1.ID.ToString()); string qualifiedKey = this.GetQualifiedKey(); List <RenderingDefinition> list = new List <RenderingDefinition>(); foreach (RenderingDefinition renderingDefinition in device2.Renderings) { if (Placeholder72.IsMatch(qualifiedKey, renderingDefinition.Placeholder)) { list.Add(renderingDefinition); } } this.RenderHeader(output, (ICollection <RenderingDefinition>)list); this.RenderRenderings(output, list); Placeholder72.RenderFooter(output); return(true); }
/// <summary> /// Gets the escaped placeholder key. /// </summary> /// <param name="inputKey">The key.</param> /// <returns> /// The escaped placeholder key. /// </returns> public string GetEscapedKey(string inputKey) { Assert.ArgumentNotNull((object)inputKey, "inputKey"); return(Placeholder72.EscapeNonWordCharacters(inputKey)); }
/// <summary> /// Renders the control start marker. /// /// </summary> /// <param name="controlId">The control id.</param><param name="data">The data.</param> /// <returns> /// The control start marker. /// </returns> public static string GetControlStartMarker(string controlId, ChromeData data) { Assert.ArgumentNotNull((object)controlId, "controlId"); Assert.ArgumentNotNull((object)data, "data"); return(Placeholder72.GetControlStartMarker(controlId, data, true)); }
public static string GetControlHandle(RenderingReference reference, Item item) { Assert.ArgumentNotNull((object)reference, "reference"); Assert.ArgumentNotNull((object)item, "item"); return(Placeholder72.GetControlData(reference, item).ToJsonContainer()); }