public new void Process(GetPlaceholderRenderingsArgs args) { string placeholderKey = args.PlaceholderKey; Regex regex = new Regex(DYNAMIC_KEY_REGEX); Match match = regex.Match(placeholderKey); if (match.Success && match.Groups.Count > 0) { placeholderKey = match.Groups[1].Value; } else { return; } List<Item> renderings = null; var placeholderItem = Sitecore.Client.Page.GetPlaceholderItem(placeholderKey, args.ContentDatabase, args.LayoutDefinition); if (placeholderItem != null) { bool allowedControlsSpecified; args.HasPlaceholderSettings = true; renderings = this.GetRenderings(placeholderItem, out allowedControlsSpecified); if (allowedControlsSpecified) { args.CustomData["allowedControlsSpecified"] = true; } } if (renderings != null) { if (args.PlaceholderRenderings == null) { args.PlaceholderRenderings = new List<Item>(); } args.PlaceholderRenderings.AddRange(renderings); } }
public void Process(GetPlaceholderRenderingsArgs args) { Assert.IsNotNull(args, "args"); try { _contextItem = _getContextItem(); Assert.IsNotNull(_contextItem, "_contextItem"); Item placeholderItem = null; if (args.DeviceId.IsNull) { placeholderItem = Client.Page.GetPlaceholderItem(args.PlaceholderKey, args.ContentDatabase, args.LayoutDefinition); } else { using (new DeviceSwitcher(args.DeviceId, args.ContentDatabase)) { placeholderItem = Client.Page.GetPlaceholderItem(args.PlaceholderKey, args.ContentDatabase, args.LayoutDefinition); } } if (placeholderItem != null) { args.HasPlaceholderSettings = true; this.ProcessPlaceholder(placeholderItem, args); } } catch (Exception ex) { Log.Error("Error in GetActiveModules", ex, this); } }
public void AddsSelectedRenderings() { ID[] ids; var layoutDefinition = new LayoutDefinition() { Devices = new ArrayList() { new DeviceDefinition() } }; using (var db = GetDatabase(out ids)) { var item = db.GetItem("/sitecore/home/page"); var args = new GetPlaceholderRenderingsArgs("placeholder", layoutDefinition.ToXml(), db.Database) { PlaceholderRenderings = new List <Item>() }; var ctx = new PlaceholderSettingsRuleContext(args, item); var action = new AddRenderingAction <PlaceholderSettingsRuleContext>() { RenderingItemIds = string.Join("|", ids.Select(x => x.ToString())) }; action.Apply(ctx); args.PlaceholderRenderings.Should().HaveSameCount(ids); } }
public new void Process(GetPlaceholderRenderingsArgs args) { Assert.IsNotNull(args, "args"); var placeholderKey = args.PlaceholderKey; var regex = new Regex(DynamicKeyRegex); var match = regex.Match(placeholderKey); if (!match.Success || match.Groups.Count <= 0) { return; } placeholderKey = match.Groups[1].Value; var placeholderItem = GetPlaceholderItem(args, placeholderKey); var renderings = GetRenderings(args, placeholderItem); if (renderings == null) { return; } if (args.PlaceholderRenderings == null) { args.PlaceholderRenderings = new List <Item>(); } args.PlaceholderRenderings.AddRange(renderings); }
public ResponsePlaceholder(Item contextItem, LayoutDefinition layoutDefinition, string name, string parentUniqueId, bool exists = true, bool dynamic = true) { Name = name; ParentUniqueId = parentUniqueId; Exists = exists; Icon = "<img src=\"/temp/IconCache/Business/16x16/table_selection_block.png\" alt=\"\" />"; Dynamic = dynamic; //DynamicPlaceholderName = name + "-" + ParentUniqueId + ""; ValidRenderings = new List <ResponsePlaceholderRendering>(); // TODO: find all the valid renderings! GetPlaceholderRenderingsArgs args = new GetPlaceholderRenderingsArgs(Name, layoutDefinition.ToXml(), contextItem.Database); //args.ContextItemPath = contextItem.Paths.FullPath; //args.ShowDialogIfDatasourceSetOnRenderingItem = true; CorePipeline.Run("getPlaceholderRenderings", args); if (args.PlaceholderRenderings != null) { foreach (var placeholderRendering in args.PlaceholderRenderings) { ValidRenderings.Add(new ResponsePlaceholderRendering(placeholderRendering, layoutDefinition, contextItem)); } } }
private string GetSiteName(GetPlaceholderRenderingsArgs args) { //get the id from the querystring var queryString = HttpContext.Current.Request.QueryString; var itemId = queryString["sc_itemId"] ?? queryString["id"]; var siteName = Context.GetSiteName(); if (!string.IsNullOrEmpty(itemId)) { //get the sitecore item, which is the context item of the page in the xEditor var pageItem = args.ContentDatabase.GetItem(itemId); if (pageItem != null) { //match it with a content site foreach ( var info in SiteContextFactory.Sites.Where( info => !string.IsNullOrEmpty(info.RootPath) && (info.RootPath != "/sitecore/content" || info.Name.Equals("website")))) { if (pageItem.Paths.FullPath.StartsWith(info.RootPath, StringComparison.OrdinalIgnoreCase)) { siteName = info.Name; break; } } } } return siteName.ToLowerInvariant(); }
public new void Process(GetPlaceholderRenderingsArgs args) { Assert.IsNotNull((object)args, "args"); try { this.Setup(args); this.GetPlaceholderItems(args); if (_placeholderItems != null && _placeholderItems.Length > 0) { args.HasPlaceholderSettings = true; foreach (Item placeholderItem in _placeholderItems) { ProcessIndividualPlaceholder(placeholderItem, args); } RemoveDisallowedRenderings(args); } } catch (Exception ex) { Log.Error("Smart Placeholder Settings: GetAllowedRenderings - Process", ex, this); } }
public void Process(GetPlaceholderRenderingsArgs args) { Assert.IsNotNull(args, "args"); // If the placeholder key contains the dynamic suffix... if (args.PlaceholderKey.ToLower().Contains(Constants.DynamicPlaceholderSuffix.ToLower())) { // Strip off the suffix to get the actual placeholder key. var actualKey = args.PlaceholderKey.ToLower().Substring(0, args.PlaceholderKey.ToLower().LastIndexOf(Constants.DynamicPlaceholderSuffix.ToLower())); // Re-build the arguments using the actual placeholder key. var newArgs = args.DeviceId.IsNull ? new GetPlaceholderRenderingsArgs(actualKey, args.LayoutDefinition, args.ContentDatabase) : new GetPlaceholderRenderingsArgs(actualKey, args.LayoutDefinition, args.ContentDatabase, args.DeviceId); // Call Sitecore's processor using our new arguments. GetRenderingsProcessor.Process(newArgs); // Bring Sitecore's processor's results into our args variable. args.Options.ShowTree = newArgs.Options.ShowTree; args.Options.ShowRoot = newArgs.Options.ShowRoot; args.Options.SetRootAsSearchRoot = newArgs.Options.SetRootAsSearchRoot; args.HasPlaceholderSettings = newArgs.HasPlaceholderSettings; args.OmitNonEditableRenderings = newArgs.OmitNonEditableRenderings; args.PlaceholderRenderings = newArgs.PlaceholderRenderings; } else { // Otherwise, just fall back on Sitecore's implementations for non-dynamic placeholders. GetRenderingsProcessor.Process(args); } }
private void ProcessIndividualPlaceholder(Item placeholderItem, GetPlaceholderRenderingsArgs args) { PlaceholderSettingsRuleContext context = this.EvaluatePlaceholderRules(placeholderItem, args.PlaceholderKey); List <Item> smallList = new List <Item>(); if (context.AllowSelectedControls) { // Add any additional renderings to the args.PlaceholderRenderings list smallList = this.GetRenderings(placeholderItem, out allowedControlsSpecified); if (smallList.Count > 0) { string infoMessage = "\n\tContextItem: " + GetContextItem(args.PlaceholderKey).Paths.Path + "\n\tSmart Placeholder Item: " + placeholderItem.Paths.Path + "\n\tKey: " + args.PlaceholderKey + "\n\tRenderings: " + smallList.Select(i => i.Paths.Path).Aggregate((i, j) => i + "; " + j); Log.Info("Smart Placeholder Settings: Renderings Added" + infoMessage, this); args.PlaceholderRenderings.AddRange((IEnumerable <Item>)smallList); if (allowedControlsSpecified) { args.Options.ShowTree = false; } } } else if (context.DisallowSelectedControls) { // Create list of disallowed renderings to remove at the end. smallList = this.GetRenderings(placeholderItem, out allowedControlsSpecified); if (smallList.Count > 0) { disAllowList.AddRange((IEnumerable <Item>)smallList); } } }
public new void Process(GetPlaceholderRenderingsArgs args) { Assert.IsNotNull((object)args, "args"); try { this.Setup(args); this.GetPlaceholderItems(args); if (_placeholderItems != null && _placeholderItems.Length > 0) { args.HasPlaceholderSettings = true; foreach (Item placeholderItem in _placeholderItems) { ProcessIndividualPlaceholder(placeholderItem, args); } RemoveDisallowedRenderings(args); } } catch(Exception ex) { Log.Error("Smart Placeholder Settings: GetAllowedRenderings - Process", ex, this); } }
public void Process(GetPlaceholderRenderingsArgs args) { Assert.IsNotNull((object)args, "args"); string initialKey = args.PlaceholderKey; if (initialKey.Contains("/")) { initialKey = initialKey.Substring(args.PlaceholderKey.LastIndexOf('/')).Replace("/", string.Empty); } if (!string.IsNullOrEmpty(initialKey) && initialKey.Contains("|")) { string[] arrKey = initialKey.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); if (arrKey != null && arrKey.Length > 1) { string finalKey = arrKey[0]; GetPlaceholderRenderingsArgs basePlaceholderArgs = args.DeviceId.IsNull ? new GetPlaceholderRenderingsArgs(finalKey, args.LayoutDefinition, args.ContentDatabase) : new GetPlaceholderRenderingsArgs(finalKey, args.LayoutDefinition, args.ContentDatabase, args.DeviceId); this.getRenderings.Process(basePlaceholderArgs); this.AssimilateArgumentResults(ref args, basePlaceholderArgs); return; } } this.getRenderings.Process(args); }
public new void Process(GetPlaceholderRenderingsArgs args) { Assert.IsNotNull(args, "args"); // get the placeholder key string placeholderKey = args.PlaceholderKey; var regex = new Regex(DynamicKeyRegex); Match match = regex.Match(placeholderKey); // if the placeholder key text followed by a Guid if (match.Success && match.Groups.Count > 0) { // Is a dynamic placeholder placeholderKey = match.Groups[1].Value; } else { return; } // Same as Sitecore.Pipelines.GetPlaceholderRenderings.GetAllowedRenderings from here but with fake placeholderKey // i.e. the placeholder without the Guid Item placeholderItem = null; if (ID.IsNullOrEmpty(args.DeviceId)) { placeholderItem = Client.Page.GetPlaceholderItem(placeholderKey, args.ContentDatabase, args.LayoutDefinition); } else { using (new DeviceSwitcher(args.DeviceId, args.ContentDatabase)) { placeholderItem = Client.Page.GetPlaceholderItem(placeholderKey, args.ContentDatabase, args.LayoutDefinition); } } List <Item> collection = null; if (placeholderItem != null) { bool allowedControlsSpecified; args.HasPlaceholderSettings = true; collection = this.GetRenderings(placeholderItem, out allowedControlsSpecified); if (allowedControlsSpecified) { // Hide the Layout/Rendering tree to show the Allowed Renderings args.Options.ShowTree = false; } } if (collection != null) { if (args.PlaceholderRenderings == null) { args.PlaceholderRenderings = new List <Item>(); } args.PlaceholderRenderings.AddRange(collection); } }
public void ClearsAllRenderings() { ID[] ids; var layoutDefinition = new LayoutDefinition() { Devices = new ArrayList() { new DeviceDefinition() } }; using (var db = GetDatabase(out ids)) { var item = db.GetItem("/sitecore/home/page"); var args = new GetPlaceholderRenderingsArgs("placeholder", layoutDefinition.ToXml(), db.Database) { PlaceholderRenderings = db.Database.SelectItems("//Layouts/*").ToList() }; args.PlaceholderRenderings.Should().NotBeEmpty(); var ctx = new PlaceholderSettingsRuleContext(args, item); var action = new ClearRenderingsAction <PlaceholderSettingsRuleContext>(); action.Apply(ctx); args.PlaceholderRenderings.Should().BeEmpty(); } }
/// <summary> /// Add All Prefabs as options to all placeholders. /// </summary> /// <param name="args">The arguments.</param> public void Process(GetPlaceholderRenderingsArgs args) { if (Config.Sxa.IsEnabled) // Don't need to do this for SXA, because SXA has it's own method of rendering registration { return; } Assert.ArgumentNotNull(args, "args"); var root = Config.Paths.Renderings.TrimEnd('/'); var query = $"{root}//*[@@templatename='Method Rendering' and @__Icon='Office/32x32/pci_card.png']"; // Set root using (new SecurityDisabler()) { var prefabs = args.ContentDatabase.SelectItems(query); if (prefabs == null || !prefabs.Any()) { return; } if (args.PlaceholderRenderings == null) { args.PlaceholderRenderings = prefabs.ToList(); } else { args.PlaceholderRenderings.AddRange(prefabs); } } }
public void AddsAllRenderingsFromFolder() { ID[] renderingIds; ID[] folderIds; var layoutDefinition = new LayoutDefinition() { Devices = new ArrayList() { new DeviceDefinition() } }; using (var db = GetDatabase(out renderingIds, out folderIds)) { var item = db.GetItem("/sitecore/home/page"); var args = new GetPlaceholderRenderingsArgs("placeholder", layoutDefinition.ToXml(), db.Database) { PlaceholderRenderings = new List <Item>() }; var ctx = new PlaceholderSettingsRuleContext(args, item); var action = new AddRenderingFolderAction <PlaceholderSettingsRuleContext>() { RenderingFolderItemId = folderIds[0].ToString() }; action.Apply(ctx); args.PlaceholderRenderings.Select(x => x.ID) .Should().HaveCount(2) .And.Contain(renderingIds.Take(2)); } }
public override void Process(GetChromeDataArgs args) { Assert.ArgumentNotNull(args, nameof(args)); Assert.IsNotNull(args.ChromeData, "Chrome Data"); if (!"placeholder".Equals(args.ChromeType, StringComparison.OrdinalIgnoreCase)) { return; } var placeholderKey = args.CustomData["placeHolderKey"] as string; Assert.IsNotNull(placeholderKey, "CustomData[\"{0}\"]", "placeHolderKey"); var lastPart = StringUtil.GetLastPart(placeholderKey, '/', placeholderKey); args.ChromeData.DisplayName = lastPart; AddButtonsToChromeData(GetButtons("/sitecore/content/Applications/WebEdit/Default Placeholder Buttons"), args); var placeholderItem = (Item)null; var hasPlaceholderSettings = false; if (args.Item != null) { var layout = ChromeContext.GetLayout(args.Item); var placeholderRenderingsArgs = new GetPlaceholderRenderingsArgs(placeholderKey, layout, args.Item.Database) { OmitNonEditableRenderings = true }; //add full dynamic placeholder key to reference in applicable rules placeholderRenderingsArgs.CustomData.Add("fullPlaceholderKey", placeholderKey); CorePipeline.Run("getPlaceholderRenderings", placeholderRenderingsArgs); hasPlaceholderSettings = placeholderRenderingsArgs.HasPlaceholderSettings; var getRenderingList = placeholderRenderingsArgs.PlaceholderRenderings != null ? placeholderRenderingsArgs.PlaceholderRenderings.Select(i => i.ID.ToShortID().ToString()).ToList() : new List <string>(); args.ChromeData.Custom.Add("allowedRenderings", getRenderingList); placeholderItem = Client.Page.GetPlaceholderItem(placeholderRenderingsArgs.PlaceholderKey, args.Item.Database, layout); args.ChromeData.DisplayName = placeholderItem == null?StringUtil.GetLastPart(placeholderRenderingsArgs.PlaceholderKey, '/', placeholderRenderingsArgs.PlaceholderKey) : HttpUtility.HtmlEncode(placeholderItem.DisplayName); if (placeholderItem != null && !string.IsNullOrEmpty(placeholderItem.Appearance.ShortDescription)) { args.ChromeData.ExpandedDisplayName = HttpUtility.HtmlEncode(placeholderItem.Appearance.ShortDescription); } } else { args.ChromeData.Custom.Add("allowedRenderings", new List <string>()); } var isEditable = (placeholderItem == null || placeholderItem["Editable"] == "1") && Settings.WebEdit.PlaceholdersEditableWithoutSettings | hasPlaceholderSettings; args.ChromeData.Custom.Add("editable", isEditable.ToString().ToLowerInvariant()); }
public override void Process(GetPlaceholderRenderingsArgs args, PlaceholderRuleContext ruleContext) { if (!ruleContext.IsEditable) { args.HasPlaceholderSettings = false; args.PlaceholderRenderings = null; } }
public void Process(GetPlaceholderRenderingsArgs args) { var ruleContext = GetRuleContext(args); if (ruleContext != null) { Process(args, ruleContext); } }
private void GetItem(GetPlaceholderRenderingsArgs args) { Item = Context.Item; if (Item == null) { var id = HttpContext.Current.Request.QueryString["id"]; Item = args.ContentDatabase.GetItem(id); } }
///The process. ///The pipeline args. public override void Process(GetChromeDataArgs args) { Assert.ArgumentNotNull(args, "args"); Assert.IsNotNull(args.ChromeData, "Chrome Data"); if (!ChromeType.Equals(args.ChromeType, StringComparison.OrdinalIgnoreCase)) { return; } var placeholderPath = args.CustomData[PlaceholderKey] as string; Assert.ArgumentNotNull(placeholderPath, string.Format("CustomData[\"{0}\"]", PlaceholderKey)); var placeholderKey = StringUtil.GetLastPart(placeholderPath, '/', placeholderPath); args.ChromeData.DisplayName = placeholderKey; AddButtonsToChromeData(GetButtons(DefaultButtonsRoot), args); Item placeholderItem = null; var hasPlaceholderSettings = false; if (args.Item != null) { //this is the part modified from base implementation var layout = GetCachedLayout(args.Item); var placeholderRenderingsArgs = new GetPlaceholderRenderingsArgs(placeholderPath, layout, args.Item.Database) { OmitNonEditableRenderings = true }; CorePipeline.Run("getPlaceholderRenderings", placeholderRenderingsArgs); hasPlaceholderSettings = placeholderRenderingsArgs.HasPlaceholderSettings; var stringList = new List <string>(); if (placeholderRenderingsArgs.PlaceholderRenderings != null) { stringList = placeholderRenderingsArgs.PlaceholderRenderings.Select(i => i.ID.ToShortID().ToString()).ToList() ?? new List <string>(); } args.ChromeData.Custom.Add("allowedRenderings", stringList); placeholderItem = Client.Page.GetPlaceholderItem(placeholderPath, args.Item.Database, layout); if (placeholderItem != null) { args.ChromeData.DisplayName = HttpUtility.HtmlEncode(placeholderItem.DisplayName); } if (placeholderItem != null && !string.IsNullOrEmpty(placeholderItem.Appearance.ShortDescription)) { args.ChromeData.ExpandedDisplayName = HttpUtility.HtmlEncode(placeholderItem.Appearance.ShortDescription); } } else { args.ChromeData.Custom.Add("allowedRenderings", new List <string>()); } var isEditable = (placeholderItem == null || placeholderItem["Editable"] == "1") && (Settings.WebEdit.PlaceholdersEditableWithoutSettings || hasPlaceholderSettings); args.ChromeData.Custom.Add("editable", isEditable.ToString().ToLowerInvariant()); }
private void GetDevice(GetPlaceholderRenderingsArgs args) { Device = Context.Device; if (Device == null || Device.Database.Name != ContentDatabase.Name) { var id = HttpContext.Current.Request.QueryString["dev"]; Device = args.ContentDatabase.GetItem(id); } }
protected void SetComponent(ClientPipelineArgs args) { string str = args.Parameters["variationid"]; if (string.IsNullOrEmpty(str)) { SheerResponse.Alert("Item not found.", new string[0]); } else if ((Rendering == null) || (Layout == null)) { SheerResponse.Alert("An error ocurred.", new string[0]); } else if (!args.IsPostBack) { string placeholder = Rendering.Placeholder; Assert.IsNotNull(placeholder, "placeholder"); string str3 = Layout.ToXml(); var args2 = new GetPlaceholderRenderingsArgs(placeholder, str3, Client.ContentDatabase, ID.Parse(DeviceId)); args2.OmitNonEditableRenderings = true; args2.CustomData["showOpenProperties"] = false; CorePipeline.Run("getPlaceholderRenderings", args2); string dialogURL = args2.DialogURL; if (string.IsNullOrEmpty(dialogURL)) { SheerResponse.Alert("An error ocurred.", new string[0]); } else { SheerResponse.ShowModalDialog(dialogURL, "720px", "470px", string.Empty, true); args.WaitForPostBack(); } } else if (args.HasResult) { ID id = ShortID.DecodeID(str); List <VariableValueItemStub> variableValues = VariableValues; VariableValueItemStub stub = variableValues.Find(v => v.Id == id); if (stub != null) { string result; if (args.Result.IndexOf(',') >= 0) { result = args.Result.Split(new[] { ',' })[0]; } else { result = args.Result; } stub.ReplacementComponent = result; var output = new HtmlTextWriter(new StringWriter()); RenderComponentControls(output, stub); SheerResponse.SetOuterHtml(str + "_component", output.InnerWriter.ToString()); VariableValues = variableValues; } } }
public new void Process(GetPlaceholderRenderingsArgs args) { if (!args.CustomData.ContainsKey("DynamicPlaceholderKey")) return; var placeholderKey = args.CustomData["DynamicPlaceholderKey"] as string; var placeholderKeyField = args.GetType().GetField("placeholderKey", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); placeholderKeyField?.SetValue(args, placeholderKey); }
private void Setup(GetPlaceholderRenderingsArgs args) { if (args.PlaceholderRenderings == null) { args.PlaceholderRenderings = new List <Item>(); } _placeholderItems = null; disAllowList = new List <Item>(); }
public new void Process(GetPlaceholderRenderingsArgs args) { Assert.IsNotNull(args, "args"); var placeholderKey = args.PlaceholderKey; var regex = new Regex(DynamicKeyRegex); Match match = regex.Match(placeholderKey); if (match.Success && match.Groups.Count > 0) { placeholderKey = match.Groups[1].Value; } else { return; } // Same as Sitecore.Pipelines.GetPlaceholderRenderings.GetAllowedRenderings but with fake placeholderKey Item placeholderItem; if (ID.IsNullOrEmpty(args.DeviceId)) { placeholderItem = Client.Page.GetPlaceholderItem(placeholderKey, args.ContentDatabase, args.LayoutDefinition); } else { using (new DeviceSwitcher(args.DeviceId, args.ContentDatabase)) { placeholderItem = Client.Page.GetPlaceholderItem(placeholderKey, args.ContentDatabase, args.LayoutDefinition); } } List <Item> collection = null; if (placeholderItem != null) { bool flag; args.HasPlaceholderSettings = true; collection = this.GetRenderings(placeholderItem, out flag); if (flag) { args.CustomData["allowedControlsSpecified"] = true; args.Options.ShowTree = false; } } if (collection == null) { return; } if (args.PlaceholderRenderings == null) { args.PlaceholderRenderings = new List <Item>(); } args.PlaceholderRenderings.AddRange(collection); }
public new void Process(GetPlaceholderRenderingsArgs args) { Assert.IsNotNull(args, "args"); string placeholderKey = args.PlaceholderKey; Regex regex = new Regex(DYNAMIC_KEY_REGEX); Match match = regex.Match(placeholderKey); if (match.Success && match.Groups.Count > 0) { // Set with normalPlaceholderKey void of index on end placeholderKey = match.Groups[1].Value; } else { return; } // Same code as Sitecore.Pipelines.GetPlaceholderRenderings.GetAllowedRenderings but with fake placeholderKey Item placeholderItem = null; if (ID.IsNullOrEmpty(args.DeviceId)) { placeholderItem = Client.Page.GetPlaceholderItem(placeholderKey, args.ContentDatabase, args.LayoutDefinition); } else { using (new DeviceSwitcher(args.DeviceId, args.ContentDatabase)) { placeholderItem = Client.Page.GetPlaceholderItem(placeholderKey, args.ContentDatabase, args.LayoutDefinition); } } List <Item> renderings = null; if (placeholderItem != null) { bool allowedControlsSpecified; args.HasPlaceholderSettings = true; renderings = this.GetRenderings(placeholderItem, out allowedControlsSpecified); if (allowedControlsSpecified) { args.CustomData["allowedControlsSpecified"] = true; args.Options.ShowTree = false; } } if (renderings != null) { if (args.PlaceholderRenderings == null) { args.PlaceholderRenderings = new List <Item>(); } args.PlaceholderRenderings.AddRange(renderings); } }
protected RuleList <PlaceholderRuleContext> CreateRuleList(GetPlaceholderRenderingsArgs args) { var ruleFolder = args.ContentDatabase.GetItem(FolderId); if (ruleFolder == null) { throw new InvalidOperationException("Placeholder settings rule folder could not be found."); } return(RuleFactory.GetRules <PlaceholderRuleContext>(ruleFolder, "Rule")); }
public override void Process(GetPlaceholderRenderingsArgs args, PlaceholderRuleContext ruleContext) { if (args.PlaceholderRenderings == null || ruleContext.BlockedRenderings.Count == 0 || !ruleContext.IsEditable) { return; } var comparer = new ItemIdComparer(); args.PlaceholderRenderings.RemoveAll(i => ruleContext.BlockedRenderings.Contains(i, comparer)); }
private void GetPlaceholderItems(GetPlaceholderRenderingsArgs args) { if (ID.IsNullOrEmpty(args.DeviceId)) { _placeholderItems = Client.Page.GetPlacehoderItemsSearch(args.PlaceholderKey, args.ContentDatabase, args.LayoutDefinition); } else { using (new DeviceSwitcher(args.DeviceId, args.ContentDatabase)) _placeholderItems = Client.Page.GetPlacehoderItemsSearch(args.PlaceholderKey, args.ContentDatabase, args.LayoutDefinition); } }
private static Item GetPlaceholderItem(GetPlaceholderRenderingsArgs args, string placeholderKey) { if (ID.IsNullOrEmpty(args.DeviceId)) { return(Client.Page.GetPlaceholderItem(placeholderKey, args.ContentDatabase, args.LayoutDefinition)); } using (new DeviceSwitcher(args.DeviceId, args.ContentDatabase)) { return(Client.Page.GetPlaceholderItem(placeholderKey, args.ContentDatabase, args.LayoutDefinition)); } }
private void AssimilateArgumentResults(ref GetPlaceholderRenderingsArgs args, GetPlaceholderRenderingsArgs basePlaceholderArgs) { args.Options.ShowTree = basePlaceholderArgs.Options.ShowTree; ((SelectItemOptions)args.Options).ShowRoot = (((SelectItemOptions)basePlaceholderArgs.Options).ShowRoot); ((SelectItemOptions)args.Options).SetRootAsSearchRoot = (((SelectItemOptions)basePlaceholderArgs.Options).SetRootAsSearchRoot); args.HasPlaceholderSettings = (basePlaceholderArgs.HasPlaceholderSettings); args.OmitNonEditableRenderings = (basePlaceholderArgs.OmitNonEditableRenderings); args.PlaceholderRenderings = (basePlaceholderArgs.PlaceholderRenderings); }
public new void Process(GetPlaceholderRenderingsArgs args) { Assert.IsNotNull(args, "args"); var index = args.PlaceholderKey.LastIndexOf("/", System.StringComparison.Ordinal); var currentPlaceholderKey = index > 0 ? args.PlaceholderKey.Substring(index) : args.PlaceholderKey; var temporaryPlaceholderKey = string.Empty; var regex = new Regex(DynamicPlaceholders.PlaceholderKeyRegex.DynamicKeyRegex); var match = regex.Match(currentPlaceholderKey); if (match.Success && match.Groups.Count > 0) { temporaryPlaceholderKey = match.Groups[1].Value; } else { return; } Item placeholderItem = null; if (ID.IsNullOrEmpty(args.DeviceId)) { placeholderItem = Client.Page.GetPlaceholderItem(temporaryPlaceholderKey, args.ContentDatabase, args.LayoutDefinition); } else { using (new DeviceSwitcher(args.DeviceId, args.ContentDatabase)) { placeholderItem = Client.Page.GetPlaceholderItem(temporaryPlaceholderKey, args.ContentDatabase, args.LayoutDefinition); } } List <Item> renderings = null; if (placeholderItem != null) { bool flag; args.HasPlaceholderSettings = true; renderings = this.GetRenderings(placeholderItem, out flag); if (flag) { args.Options.ShowTree = false; } } if (renderings != null) { if (args.PlaceholderRenderings == null) { args.PlaceholderRenderings = new List <Item>(); } args.PlaceholderRenderings.AddRange(renderings); } }
private void AssimilateArgumentResults(ref GetPlaceholderRenderingsArgs args, GetPlaceholderRenderingsArgs basePlaceholderArgs) { args.Options.ShowTree = basePlaceholderArgs.Options.ShowTree; ((SelectItemOptions)args.Options).ShowRoot = (((SelectItemOptions)basePlaceholderArgs.Options).ShowRoot); ((SelectItemOptions)args.Options).SetRootAsSearchRoot = (((SelectItemOptions)basePlaceholderArgs.Options).SetRootAsSearchRoot); args.HasPlaceholderSettings = (basePlaceholderArgs.HasPlaceholderSettings); args.OmitNonEditableRenderings = (basePlaceholderArgs.OmitNonEditableRenderings); args.PlaceholderRenderings = (basePlaceholderArgs.PlaceholderRenderings); }
public override void Process(GetPlaceholderRenderingsArgs args, PlaceholderRuleContext ruleContext) { var rules = CreateRuleList(args); using (new DeviceSwitcher(ruleContext.Device)) using (new ContextItemSwitcher(ruleContext.Item)) { rules.Run(ruleContext); } SetRuleContext(args, ruleContext); }
public new void Process(GetPlaceholderRenderingsArgs args) { Assert.IsNotNull(args, "args"); var placeholderKey = args.PlaceholderKey; if (PlaceholderKeyHelper.IsDynamicPlaceholder(placeholderKey)) { placeholderKey = PlaceholderKeyHelper.ExtractPlaceholderKey(placeholderKey); } else { return; } // Same as Sitecore.Pipelines.GetPlaceholderRenderings.GetAllowedRenderings but with fake placeholderKey Item placeholderItem; if (ID.IsNullOrEmpty(args.DeviceId)) { placeholderItem = Client.Page.GetPlaceholderItem(placeholderKey, args.ContentDatabase, args.LayoutDefinition); } else { using (new DeviceSwitcher(args.DeviceId, args.ContentDatabase)) { placeholderItem = Client.Page.GetPlaceholderItem(placeholderKey, args.ContentDatabase, args.LayoutDefinition); } } List <Item> collection = null; if (placeholderItem != null) { bool flag; args.HasPlaceholderSettings = true; collection = GetRenderings(placeholderItem, out flag); if (flag) { args.CustomData["allowedControlsSpecified"] = true; args.Options.ShowTree = false; } } if (collection != null) { if (args.PlaceholderRenderings == null) { args.PlaceholderRenderings = new List <Item>(); } args.PlaceholderRenderings.AddRange(collection); } }
/// <summary> /// Stores arguments for later use. /// </summary> public new void Process(GetPlaceholderRenderingsArgs args) { Assert.IsNotNull(args, "args"); // Store these args for later. DeviceId = args.DeviceId; PlaceholderKey = args.PlaceholderKey; ContentDatabase = args.ContentDatabase; LayoutDefinition = args.LayoutDefinition; // Call the base class implementation. base.Process(args); }
public new void Process(GetPlaceholderRenderingsArgs args) { Assert.IsNotNull(args, "args"); string placeholderKey = args.PlaceholderKey; Regex regex = new Regex(DYNAMIC_KEY_REGEX); Match match = regex.Match(placeholderKey); if (match.Success && match.Groups.Count > 0) { placeholderKey = match.Groups[1].Value; } else { return; } // Same code as Sitecore.Pipelines.GetPlaceholderRenderings.GetAllowedRenderings but with fake placeholderKey Item placeholderItem = null; if (ID.IsNullOrEmpty(args.DeviceId)) { placeholderItem = Client.Page.GetPlaceholderItem(placeholderKey, args.ContentDatabase, args.LayoutDefinition); } else { using (new DeviceSwitcher(args.DeviceId, args.ContentDatabase)) { placeholderItem = Client.Page.GetPlaceholderItem(placeholderKey, args.ContentDatabase, args.LayoutDefinition); } } List<Item> renderings = null; if (placeholderItem != null) { bool allowedControlsSpecified; args.HasPlaceholderSettings = true; renderings = this.GetRenderings(placeholderItem, out allowedControlsSpecified); if (allowedControlsSpecified) { args.CustomData["allowedControlsSpecified"] = true; args.Options.ShowTree = false; } } if (renderings != null) { if (args.PlaceholderRenderings == null) { args.PlaceholderRenderings = new List<Item>(); } args.PlaceholderRenderings.AddRange(renderings); } }
public new void Process(GetPlaceholderRenderingsArgs args) { Assert.IsNotNull(args, "args"); var currentPlaceholderKey = args.PlaceholderKey; var temporaryPlaceholderKey = string.Empty; var regex = new Regex(DynamicPlaceholders.PlaceholderKeyRegex.DynamicKeyRegex); var match = regex.Match(currentPlaceholderKey); if (match.Success && match.Groups.Count > 0) { temporaryPlaceholderKey = match.Groups[1].Value; } else { return; } Item placeholderItem = null; if (ID.IsNullOrEmpty(args.DeviceId)) { placeholderItem = Client.Page.GetPlaceholderItem(temporaryPlaceholderKey, args.ContentDatabase, args.LayoutDefinition); } else { using (new DeviceSwitcher(args.DeviceId, args.ContentDatabase)) { placeholderItem = Client.Page.GetPlaceholderItem(temporaryPlaceholderKey, args.ContentDatabase, args.LayoutDefinition); } } List<Item> renderings = null; if (placeholderItem != null) { bool flag; args.HasPlaceholderSettings = true; renderings = this.GetRenderings(placeholderItem, out flag); if (flag) { args.Options.ShowTree = false; } } if (renderings != null) { if (args.PlaceholderRenderings == null) { args.PlaceholderRenderings = new List<Item>(); } args.PlaceholderRenderings.AddRange(renderings); } }
public new void Process(GetPlaceholderRenderingsArgs args) { Assert.IsNotNull(args, "args"); var placeholderKey = args.PlaceholderKey; if (PlaceholderKeyHelper.IsDynamicPlaceholder(placeholderKey)) { placeholderKey = PlaceholderKeyHelper.ExtractPlaceholderKey(placeholderKey); } else { return; } // Same as Sitecore.Pipelines.GetPlaceholderRenderings.GetAllowedRenderings but with fake placeholderKey Item placeholderItem; if (ID.IsNullOrEmpty(args.DeviceId)) { placeholderItem = Client.Page.GetPlaceholderItem(placeholderKey, args.ContentDatabase, args.LayoutDefinition); } else { using (new DeviceSwitcher(args.DeviceId, args.ContentDatabase)) { placeholderItem = Client.Page.GetPlaceholderItem(placeholderKey, args.ContentDatabase, args.LayoutDefinition); } } List<Item> collection = null; if (placeholderItem != null) { bool flag; args.HasPlaceholderSettings = true; collection = GetRenderings(placeholderItem, out flag); if (flag) { args.CustomData["allowedControlsSpecified"] = true; args.Options.ShowTree = false; } } if (collection != null) { if (args.PlaceholderRenderings == null) { args.PlaceholderRenderings = new List<Item>(); } args.PlaceholderRenderings.AddRange(collection); } }
public void Process(GetPlaceholderRenderingsArgs args) { Assert.IsNotNull(args, "args"); var placeholderKey = args.PlaceholderKey ?? string.Empty; //filter out the guid if its a dynamically generated placeholder var match = _regex.Match(placeholderKey); var isDynamicPlaceholder = match.Success && match.Groups.Count > 0; if (isDynamicPlaceholder) placeholderKey = match.Groups[1].Value; //get current item's sitename and compile a site specific placeholderKey var siteName = GetSiteName(args); if (string.IsNullOrEmpty(siteName)) return; var placeholderKeySegments = placeholderKey.Split('/'); placeholderKeySegments[placeholderKeySegments.Count() - 1] = string.Format("{0}-{1}", siteName, placeholderKeySegments[placeholderKeySegments.Count() - 1]); var siteSpecificPlaceholderKey = string.Join("/", placeholderKeySegments); //try to resolve the specific placeholderKey var page = Client.Page; Assert.IsNotNull(page, "page"); Item placeholderItem; if (ID.IsNullOrEmpty(args.DeviceId)) { placeholderItem = page.GetPlaceholderItem(siteSpecificPlaceholderKey, args.ContentDatabase, args.LayoutDefinition); } else { using (new DeviceSwitcher(args.DeviceId, args.ContentDatabase)) placeholderItem = page.GetPlaceholderItem(siteSpecificPlaceholderKey, args.ContentDatabase, args.LayoutDefinition); } //adjust the placeholderKey if we were able to resolve it //unfortunately the args.PlaceholderKey has no setter so for now this is fixed with some casual Reflection hacking if (placeholderItem != null) { //re-add the dynamic part because it ensures business as usual (ie. the support package expects it) if (isDynamicPlaceholder) siteSpecificPlaceholderKey = string.Format("{0}{1}", siteSpecificPlaceholderKey, match.Groups[2].Value); var placeholderKeyField = typeof (GetPlaceholderRenderingsArgs).GetField("placeholderKey", BindingFlags.Instance | BindingFlags.NonPublic); if (placeholderKeyField != null) placeholderKeyField.SetValue(args, siteSpecificPlaceholderKey); //args.PlaceholderKey = siteSpecificPlaceholderKey; } }
public void Process(GetPlaceholderRenderingsArgs args) { Assert.IsNotNull((object)args, "args"); string initialKey = args.PlaceholderKey; if (initialKey.Contains("/")) initialKey = initialKey.Substring(args.PlaceholderKey.LastIndexOf('/')).Replace("/", string.Empty); if (!string.IsNullOrEmpty(initialKey) && initialKey.Contains("|")) { string[] arrKey = initialKey.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); if (arrKey != null && arrKey.Length > 1) { string finalKey = arrKey[0]; GetPlaceholderRenderingsArgs basePlaceholderArgs = args.DeviceId.IsNull ? new GetPlaceholderRenderingsArgs(finalKey, args.LayoutDefinition, args.ContentDatabase) : new GetPlaceholderRenderingsArgs(finalKey, args.LayoutDefinition, args.ContentDatabase, args.DeviceId); this.getRenderings.Process(basePlaceholderArgs); this.AssimilateArgumentResults(ref args, basePlaceholderArgs); return; } } this.getRenderings.Process(args); }
public new void Process(GetPlaceholderRenderingsArgs args) { KernelContainer.Inject(this); this.DoGetAllowedRenderingsa(args); }
protected void SetComponent(ClientPipelineArgs args) { string str = args.Parameters["variationid"]; if (string.IsNullOrEmpty(str)) { SheerResponse.Alert("Item not found.", new string[0]); } else if ((Rendering == null) || (Layout == null)) { SheerResponse.Alert("An error ocurred.", new string[0]); } else if (!args.IsPostBack) { string placeholder = Rendering.Placeholder; Assert.IsNotNull(placeholder, "placeholder"); string str3 = Layout.ToXml(); var args2 = new GetPlaceholderRenderingsArgs(placeholder, str3, Client.ContentDatabase, ID.Parse(DeviceId)); args2.OmitNonEditableRenderings = true; args2.CustomData["showOpenProperties"] = false; CorePipeline.Run("getPlaceholderRenderings", args2); string dialogURL = args2.DialogURL; if (string.IsNullOrEmpty(dialogURL)) { SheerResponse.Alert("An error ocurred.", new string[0]); } else { SheerResponse.ShowModalDialog(dialogURL, "720px", "470px", string.Empty, true); args.WaitForPostBack(); } } else if (args.HasResult) { ID id = ShortID.DecodeID(str); List<VariableValueItemStub> variableValues = VariableValues; VariableValueItemStub stub = variableValues.Find(v => v.Id == id); if (stub != null) { string result; if (args.Result.IndexOf(',') >= 0) { result = args.Result.Split(new[] {','})[0]; } else { result = args.Result; } stub.ReplacementComponent = result; var output = new HtmlTextWriter(new StringWriter()); RenderComponentControls(output, stub); SheerResponse.SetOuterHtml(str + "_component", output.InnerWriter.ToString()); VariableValues = variableValues; } } }
private void GetPlaceholderItems(GetPlaceholderRenderingsArgs args) { if (ID.IsNullOrEmpty(args.DeviceId)) { _placeholderItems = Client.Page.GetPlacehoderItemsSearch(args.PlaceholderKey, args.ContentDatabase, args.LayoutDefinition); } else { using (new DeviceSwitcher(args.DeviceId, args.ContentDatabase)) _placeholderItems = Client.Page.GetPlacehoderItemsSearch(args.PlaceholderKey, args.ContentDatabase, args.LayoutDefinition); } }
private void ProcessIndividualPlaceholder(Item placeholderItem, GetPlaceholderRenderingsArgs args) { PlaceholderSettingsRuleContext context = this.EvaluatePlaceholderRules(placeholderItem, args.PlaceholderKey); List<Item> smallList = new List<Item>(); if (context.AllowSelectedControls) { // Add any additional renderings to the args.PlaceholderRenderings list smallList = this.GetRenderings(placeholderItem, out allowedControlsSpecified); if (smallList.Count > 0) { string infoMessage = "\n\tContextItem: " + GetContextItem(args.PlaceholderKey).Paths.Path + "\n\tSmart Placeholder Item: " + placeholderItem.Paths.Path + "\n\tKey: " + args.PlaceholderKey + "\n\tRenderings: " + smallList.Select(i => i.Paths.Path).Aggregate((i, j) => i + "; " + j); Log.Info("Smart Placeholder Settings: Renderings Added" + infoMessage, this); args.PlaceholderRenderings.AddRange((IEnumerable<Item>)smallList); if (allowedControlsSpecified) args.Options.ShowTree = false; } } else if (context.DisallowSelectedControls) { // Create list of disallowed renderings to remove at the end. smallList = this.GetRenderings(placeholderItem, out allowedControlsSpecified); if (smallList.Count > 0) { disAllowList.AddRange((IEnumerable<Item>)smallList); } } }
private void RemoveDisallowedRenderings(GetPlaceholderRenderingsArgs args) { // Loop through and remove disallowed renderings if (disAllowList.Count > 0) { foreach (Item rendering in disAllowList) { args.PlaceholderRenderings.RemoveAll(r => r.ID == rendering.ID); } string infoMessage = "\n\tContextItem: " + GetContextItem(args.PlaceholderKey).Paths.Path + "\n\tKey: " + args.PlaceholderKey + "\n\tRenderings: " + disAllowList.Select(i => i.Paths.Path).Aggregate((i, j) => i + "; " + j); Log.Info("Smart Placeholder Settings: Renderings Removed" + infoMessage, this); } }
private void Setup(GetPlaceholderRenderingsArgs args) { if (args.PlaceholderRenderings == null) args.PlaceholderRenderings = new List<Item>(); _placeholderItems = null; disAllowList = new List<Item>(); }
protected abstract void DoGetAllowedRenderingsa(GetPlaceholderRenderingsArgs args);