Ejemplo n.º 1
0
        public void Process(GetPlaceholderRenderingsArgs args)
        {
            Assert.IsNotNull(args, "args");

            string placeholderKey;
            string placeholderIndex;

            if (!DynamicPlaceholderKeyProvider.TryGetValue(args.PlaceholderKey, out placeholderKey, out placeholderIndex))
            {
                return;
            }

            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 flag;
                args.HasPlaceholderSettings = true;
                collection = GetRenderings(placeholderItem, out flag);
                if (flag)
                {
                    args.Options.ShowTree = false;
                }
            }
            if (collection != null)
            {
                if (args.PlaceholderRenderings == null)
                {
                    args.PlaceholderRenderings = new List <Item>();
                }
                args.PlaceholderRenderings.AddRange(collection);
            }
        }
        public override void Process(GetChromeDataArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            Assert.IsNotNull(args.ChromeData, "Chrome Data");

            if (!"placeholder".Equals(args.ChromeType, StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            var argument = args.CustomData["placeHolderKey"] as string;

            string placeholderKey;
            string placeholderIndex;

            if (!DynamicPlaceholderKeyProvider.TryGetValue(argument, out placeholderKey, out placeholderIndex))
            {
                return;
            }

            if (args.Item == null)
            {
                return;
            }

            var layout = ChromeContext.GetLayout(args.Item);
            var item   = Client.Page.GetPlaceholderItem(placeholderKey, args.Item.Database, layout);

            if (item == null)
            {
                return;
            }

            args.ChromeData.DisplayName = item.DisplayName;

            if (!string.IsNullOrEmpty(item.Appearance.ShortDescription))
            {
                args.ChromeData.ExpandedDisplayName = item.Appearance.ShortDescription;
            }
        }