Beispiel #1
0
        protected void SortUp(Message message)
        {
            Assert.ArgumentNotNull((object)message, "message");
            if (this.SelectedIndex <= 0)
            {
                return;
            }
            LayoutDefinition layoutDefinition = CustomDeviceEditor.GetLayoutDefinition();
            ArrayList        renderings       = layoutDefinition.GetDevice(this.DeviceID).Renderings;

            if (renderings == null)
            {
                return;
            }
            RenderingDefinition renderingDefinition = renderings[this.SelectedIndex] as RenderingDefinition;

            if (renderingDefinition == null)
            {
                return;
            }
            renderings.Remove((object)renderingDefinition);
            renderings.Insert(this.SelectedIndex - 1, (object)renderingDefinition);
            --this.SelectedIndex;
            CustomDeviceEditor.SetDefinition(layoutDefinition);
            this.Refresh();
        }
Beispiel #2
0
        /// <summary>Handles a click on the OK button.</summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The arguments.</param>
        /// <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 OnOK(object sender, EventArgs args)
        {
            Assert.ArgumentNotNull(sender, "sender");
            Assert.ArgumentNotNull((object)args, "args");
            if (this.Layout.Value.Length > 0)
            {
                Item obj = Client.ContentDatabase.GetItem(this.Layout.Value);
                if (obj == null)
                {
                    Context.ClientPage.ClientResponse.Alert("Layout not found.");
                    return;
                }
                if (obj.TemplateID == TemplateIDs.Folder || obj.TemplateID == TemplateIDs.Node)
                {
                    Context.ClientPage.ClientResponse.Alert(Translate.Text("\"{0}\" is not a layout.", (object)obj.DisplayName));
                    return;
                }
            }
            LayoutDefinition layoutDefinition = CustomDeviceEditor.GetLayoutDefinition();
            DeviceDefinition device           = layoutDefinition.GetDevice(this.DeviceID);
            ArrayList        renderings       = device.Renderings;

            if (renderings != null && renderings.Count > 0 && this.Layout.Value.Length == 0)
            {
                Context.ClientPage.ClientResponse.Alert("You must specify a layout when you specify renderings.");
            }
            else
            {
                device.Layout = this.Layout.Value;
                CustomDeviceEditor.SetDefinition(layoutDefinition);
                Context.ClientPage.ClientResponse.SetDialogValue("yes");
                base.OnOK(sender, args);
            }
        }
Beispiel #3
0
 protected void AddPlaceholder(ClientPipelineArgs args)
 {
     if (args.IsPostBack)
     {
         if (string.IsNullOrEmpty(args.Result) || !(args.Result != "undefined"))
         {
             return;
         }
         LayoutDefinition layoutDefinition = CustomDeviceEditor.GetLayoutDefinition();
         DeviceDefinition device           = layoutDefinition.GetDevice(this.DeviceID);
         string           placeholderKey;
         Item             dialogResult = SelectPlaceholderSettingsOptions.ParseDialogResult(args.Result, Client.ContentDatabase, out placeholderKey);
         if (dialogResult == null || string.IsNullOrEmpty(placeholderKey))
         {
             return;
         }
         PlaceholderDefinition placeholderDefinition = new PlaceholderDefinition()
         {
             UniqueId       = ID.NewID.ToString(),
             MetaDataItemId = dialogResult.Paths.FullPath,
             Key            = placeholderKey
         };
         device.AddPlaceholder(placeholderDefinition);
         CustomDeviceEditor.SetDefinition(layoutDefinition);
         this.Refresh();
     }
     else
     {
         SheerResponse.ShowModalDialog(new SelectPlaceholderSettingsOptions()
         {
             IsPlaceholderKeyEditable = true
         }.ToUrlString().ToString(), "460px", "460px", string.Empty, true);
         args.WaitForPostBack();
     }
 }
Beispiel #4
0
        protected void Add(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull((object)args, "args");
            if (args.IsPostBack)
            {
                if (!args.HasResult)
                {
                    return;
                }
                string[]            strArray            = args.Result.Split(',');
                string              str1                = strArray[0];
                string              str2                = strArray[1].Replace("-c-", ",");
                bool                flag                = strArray[2] == "1";
                LayoutDefinition    layoutDefinition    = CustomDeviceEditor.GetLayoutDefinition();
                DeviceDefinition    device              = layoutDefinition.GetDevice(this.DeviceID);
                RenderingDefinition renderingDefinition = new RenderingDefinition()
                {
                    ItemID      = str1,
                    Placeholder = str2
                };
                device.AddRendering(renderingDefinition);
                CustomDeviceEditor.SetDefinition(layoutDefinition);
                this.Refresh();
                if (flag)
                {
                    ArrayList renderings = device.Renderings;
                    if (renderings != null)
                    {
                        this.SelectedIndex = renderings.Count - 1;
                        Context.ClientPage.SendMessage((object)this, "device:edit");
                    }
                }
                Registry.SetString("/Current_User/SelectRendering/Selected", str1);
            }
            else
            {
                Item itm = UIUtil.GetItemFromQueryString(Sitecore.Client.ContentDatabase);
                SelectRenderingOptions renderingOptions = new SelectRenderingOptions()
                {
                    ShowOpenProperties  = true,
                    ShowPlaceholderName = true,
                    PlaceholderName     = string.Empty
                };
                string @string = Registry.GetString("/Current_User/SelectRendering/Selected");
                if (!string.IsNullOrEmpty(@string))
                {
                    renderingOptions.SelectedItem = Client.ContentDatabase.GetItem(@string);
                }

                //Modify the following line to include id and deviceid parameters
                SheerResponse.ShowModalDialog(renderingOptions.ToUrlString(Sitecore.Client.ContentDatabase).ToString() + "&ciId=" +
                                              System.Web.HttpUtility.UrlEncode(itm.ID.ToString()) + "&deviceid=" +
                                              System.Web.HttpUtility.UrlEncode(this.DeviceID), true);

                //SheerResponse.ShowModalDialog(renderingOptions.ToUrlString(Client.ContentDatabase).ToString(), true);

                args.WaitForPostBack();
            }
        }
Beispiel #5
0
        protected void SetTest(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull((object)args, "args");
            if (this.SelectedIndex < 0)
            {
                return;
            }
            LayoutDefinition layoutDefinition = CustomDeviceEditor.GetLayoutDefinition();
            DeviceDefinition device           = layoutDefinition.GetDevice(this.DeviceID);
            ArrayList        renderings       = device.Renderings;

            if (renderings == null)
            {
                return;
            }
            RenderingDefinition renderingDefinition = renderings[this.SelectedIndex] as RenderingDefinition;

            if (renderingDefinition == null)
            {
                return;
            }
            if (args.IsPostBack)
            {
                if (!args.HasResult)
                {
                    return;
                }
                if (args.Result == "#reset#")
                {
                    renderingDefinition.MultiVariateTest = string.Empty;
                    CustomDeviceEditor.SetDefinition(layoutDefinition);
                    this.Refresh();
                }
                else
                {
                    ID dialogResult = SetTestDetailsOptions.ParseDialogResult(args.Result);
                    if (ID.IsNullOrEmpty(dialogResult))
                    {
                        SheerResponse.Alert("Item not found.");
                    }
                    else
                    {
                        renderingDefinition.MultiVariateTest = dialogResult.ToString();
                        CustomDeviceEditor.SetDefinition(layoutDefinition);
                        this.Refresh();
                    }
                }
            }
            else
            {
                SheerResponse.ShowModalDialog(new SetTestDetailsOptions("SC_DEVICEEDITOR", UIUtil.GetItemFromQueryString(Client.ContentDatabase).Uri.ToString(), device.ID, renderingDefinition.UniqueId).ToUrlString().ToString(), "520px", "695px", string.Empty, true);
                args.WaitForPostBack();
            }
        }
Beispiel #6
0
        protected void Change(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull((object)args, "args");
            if (this.SelectedIndex < 0)
            {
                return;
            }
            LayoutDefinition layoutDefinition = CustomDeviceEditor.GetLayoutDefinition();
            ArrayList        renderings       = layoutDefinition.GetDevice(this.DeviceID).Renderings;

            if (renderings == null)
            {
                return;
            }
            RenderingDefinition renderingDefinition = renderings[this.SelectedIndex] as RenderingDefinition;

            if (renderingDefinition == null || string.IsNullOrEmpty(renderingDefinition.ItemID))
            {
                return;
            }
            if (args.IsPostBack)
            {
                if (!args.HasResult)
                {
                    return;
                }
                string[] strArray = args.Result.Split(',');
                renderingDefinition.ItemID = strArray[0];
                bool flag = strArray[2] == "1";
                CustomDeviceEditor.SetDefinition(layoutDefinition);
                this.Refresh();
                if (!flag)
                {
                    return;
                }
                Context.ClientPage.SendMessage((object)this, "device:edit");
            }
            else
            {
                SelectRenderingOptions renderingOptions = new SelectRenderingOptions();
                renderingOptions.ShowOpenProperties  = true;
                renderingOptions.ShowPlaceholderName = false;
                renderingOptions.PlaceholderName     = string.Empty;
                renderingOptions.SelectedItem        = Client.ContentDatabase.GetItem(renderingDefinition.ItemID);
                SheerResponse.ShowModalDialog(renderingOptions.ToUrlString(Client.ContentDatabase).ToString(), true);
                args.WaitForPostBack();
            }
        }
Beispiel #7
0
        protected void PersonalizeControl(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull((object)args, "args");
            if (this.SelectedIndex < 0)
            {
                return;
            }
            LayoutDefinition layoutDefinition = CustomDeviceEditor.GetLayoutDefinition();
            ArrayList        renderings       = layoutDefinition.GetDevice(this.DeviceID).Renderings;

            if (renderings == null)
            {
                return;
            }
            RenderingDefinition renderingDefinition = renderings[this.SelectedIndex] as RenderingDefinition;

            if (renderingDefinition == null || string.IsNullOrEmpty(renderingDefinition.ItemID) || string.IsNullOrEmpty(renderingDefinition.UniqueId))
            {
                return;
            }
            if (args.IsPostBack)
            {
                if (!args.HasResult)
                {
                    return;
                }
                XElement xelement = XElement.Parse(args.Result);
                renderingDefinition.Rules = xelement;
                CustomDeviceEditor.SetDefinition(layoutDefinition);
                this.Refresh();
            }
            else
            {
                Item   itemFromQueryString = UIUtil.GetItemFromQueryString(Client.ContentDatabase);
                string str = itemFromQueryString != null?itemFromQueryString.Uri.ToString() : string.Empty;

                SheerResponse.ShowModalDialog(new PersonalizeOptions()
                {
                    SessionHandle     = CustomDeviceEditor.GetSessionHandle(),
                    DeviceId          = this.DeviceID,
                    RenderingUniqueId = renderingDefinition.UniqueId,
                    ContextItemUri    = str
                }.ToUrlString().ToString(), "980px", "712px", string.Empty, true);
                args.WaitForPostBack();
            }
        }
Beispiel #8
0
        protected void EditPlaceholder(ClientPipelineArgs args)
        {
            if (string.IsNullOrEmpty(this.UniqueId))
            {
                return;
            }
            LayoutDefinition      layoutDefinition = CustomDeviceEditor.GetLayoutDefinition();
            PlaceholderDefinition placeholder      = layoutDefinition.GetDevice(this.DeviceID).GetPlaceholder(this.UniqueId);

            if (placeholder == null)
            {
                return;
            }
            if (args.IsPostBack)
            {
                if (string.IsNullOrEmpty(args.Result) || !(args.Result != "undefined"))
                {
                    return;
                }
                string placeholderKey;
                Item   dialogResult = SelectPlaceholderSettingsOptions.ParseDialogResult(args.Result, Client.ContentDatabase, out placeholderKey);
                if (dialogResult == null)
                {
                    return;
                }
                placeholder.MetaDataItemId = dialogResult.Paths.FullPath;
                placeholder.Key            = placeholderKey;
                CustomDeviceEditor.SetDefinition(layoutDefinition);
                this.Refresh();
            }
            else
            {
                Item obj = string.IsNullOrEmpty(placeholder.MetaDataItemId) ? (Item)null : Client.ContentDatabase.GetItem(placeholder.MetaDataItemId);
                SelectPlaceholderSettingsOptions placeholderSettingsOptions = new SelectPlaceholderSettingsOptions();
                placeholderSettingsOptions.TemplateForCreating      = (Template)null;
                placeholderSettingsOptions.PlaceholderKey           = placeholder.Key;
                placeholderSettingsOptions.CurrentSettingsItem      = obj;
                placeholderSettingsOptions.SelectedItem             = obj;
                placeholderSettingsOptions.IsPlaceholderKeyEditable = true;
                SheerResponse.ShowModalDialog(placeholderSettingsOptions.ToUrlString().ToString(), "460px", "460px", string.Empty, true);
                args.WaitForPostBack();
            }
        }
Beispiel #9
0
        protected void RemovePlaceholder(Message message)
        {
            Assert.ArgumentNotNull((object)message, "message");
            if (string.IsNullOrEmpty(this.UniqueId))
            {
                return;
            }
            LayoutDefinition      layoutDefinition = CustomDeviceEditor.GetLayoutDefinition();
            DeviceDefinition      device           = layoutDefinition.GetDevice(this.DeviceID);
            PlaceholderDefinition placeholder      = device.GetPlaceholder(this.UniqueId);

            if (placeholder == null)
            {
                return;
            }
            ArrayList placeholders = device.Placeholders;

            if (placeholders != null)
            {
                placeholders.Remove((object)placeholder);
            }
            CustomDeviceEditor.SetDefinition(layoutDefinition);
            this.Refresh();
        }
Beispiel #10
0
        protected void Remove(Message message)
        {
            Assert.ArgumentNotNull((object)message, "message");
            int selectedIndex = this.SelectedIndex;

            if (selectedIndex < 0)
            {
                return;
            }
            LayoutDefinition layoutDefinition = CustomDeviceEditor.GetLayoutDefinition();
            ArrayList        renderings       = layoutDefinition.GetDevice(this.DeviceID).Renderings;

            if (renderings == null || selectedIndex < 0 || selectedIndex >= renderings.Count)
            {
                return;
            }
            renderings.RemoveAt(selectedIndex);
            if (selectedIndex >= 0)
            {
                --this.SelectedIndex;
            }
            CustomDeviceEditor.SetDefinition(layoutDefinition);
            this.Refresh();
        }