Example #1
0
 protected void Add(ClientPipelineArgs args)
 {
     Assert.ArgumentNotNull(args, "args");
     if (args.IsPostBack)
     {
         if (args.HasResult)
         {
             string[] array = args.Result.Split(new char[]
             {
                 ','
             });
             string              text                = array[0];
             string              placeholder         = array[1].Replace("-c-", ",");
             bool                flag                = array[2] == "1";
             LayoutDefinition    layoutDefinition    = DeviceEditorForm.GetLayoutDefinition();
             DeviceDefinition    device              = layoutDefinition.GetDevice(this.DeviceID);
             RenderingDefinition renderingDefinition = new RenderingDefinition
             {
                 ItemID      = text,
                 Placeholder = placeholder
             };
             device.AddRendering(renderingDefinition);
             DeviceEditorForm.SetDefinition(layoutDefinition);
             this.Refresh();
             if (flag)
             {
                 ArrayList renderings = device.Renderings;
                 if (renderings != null)
                 {
                     this.SelectedIndex = renderings.Count - 1;
                     Context.ClientPage.SendMessage(this, "device:edit");
                 }
             }
             Registry.SetString("/Current_User/SelectRendering/Selected", text);
             return;
         }
     }
     else
     {
         SelectRenderingOptions selectRenderingOptions = new SelectRenderingOptions
         {
             ShowOpenProperties  = true,
             ShowPlaceholderName = true,
             PlaceholderName     = string.Empty
         };
         string @string = Registry.GetString("/Current_User/SelectRendering/Selected");
         if (!string.IsNullOrEmpty(@string))
         {
             selectRenderingOptions.SelectedItem = Client.ContentDatabase.GetItem(@string);
         }
         string url = selectRenderingOptions.ToUrlString(Client.ContentDatabase).ToString();
         SheerResponse.ShowModalDialog(url, true);
         args.WaitForPostBack();
     }
 }
Example #2
0
        protected void SetTest(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            if (this.SelectedIndex < 0)
            {
                return;
            }
            LayoutDefinition layoutDefinition = DeviceEditorForm.GetLayoutDefinition();
            DeviceDefinition device           = layoutDefinition.GetDevice(this.DeviceID);

            System.Collections.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)
                {
                    if (args.Result == "#reset#")
                    {
                        renderingDefinition.MultiVariateTest = string.Empty;
                        DeviceEditorForm.SetDefinition(layoutDefinition);
                        this.Refresh();
                        return;
                    }
                    ID iD = SetTestDetailsOptions.ParseDialogResult(args.Result);
                    if (ID.IsNullOrEmpty(iD))
                    {
                        SheerResponse.Alert("Item not found.", new string[0]);
                        return;
                    }
                    renderingDefinition.MultiVariateTest = iD.ToString();
                    DeviceEditorForm.SetDefinition(layoutDefinition);
                    this.Refresh();
                    return;
                }
            }
            else
            {
                Item itemFromQueryString = UIUtil.GetItemFromQueryString(Client.ContentDatabase);
                SetTestDetailsOptions setTestDetailsOptions = new SetTestDetailsOptions("SC_DEVICEEDITOR", itemFromQueryString.Uri.ToString(), device.ID, renderingDefinition.UniqueId);
                SheerResponse.ShowModalDialog(setTestDetailsOptions.ToUrlString().ToString(), "520px", "695px", string.Empty, true);
                args.WaitForPostBack();
            }
        }
Example #3
0
        protected void PersonalizeControl(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            if (this.SelectedIndex < 0)
            {
                return;
            }
            LayoutDefinition layoutDefinition = DeviceEditorForm.GetLayoutDefinition();
            DeviceDefinition device           = layoutDefinition.GetDevice(this.DeviceID);

            System.Collections.ArrayList renderings = device.Renderings;
            if (renderings == null)
            {
                return;
            }
            RenderingDefinition renderingDefinition = renderings[this.SelectedIndex] as RenderingDefinition;

            if (renderingDefinition == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(renderingDefinition.ItemID) || string.IsNullOrEmpty(renderingDefinition.UniqueId))
            {
                return;
            }
            if (args.IsPostBack)
            {
                if (args.HasResult)
                {
                    XElement rules = XElement.Parse(args.Result);
                    renderingDefinition.Rules = rules;
                    DeviceEditorForm.SetDefinition(layoutDefinition);
                    this.Refresh();
                    return;
                }
            }
            else
            {
                Item               itemFromQueryString = UIUtil.GetItemFromQueryString(Client.ContentDatabase);
                string             contextItemUri      = (itemFromQueryString != null) ? itemFromQueryString.Uri.ToString() : string.Empty;
                PersonalizeOptions personalizeOptions  = new PersonalizeOptions
                {
                    SessionHandle     = DeviceEditorForm.GetSessionHandle(),
                    DeviceId          = this.DeviceID,
                    RenderingUniqueId = renderingDefinition.UniqueId,
                    ContextItemUri    = contextItemUri
                };
                SheerResponse.ShowModalDialog(personalizeOptions.ToUrlString().ToString(), "980px", "712px", string.Empty, true);
                args.WaitForPostBack();
            }
        }
Example #4
0
        protected void EditPlaceholder(ClientPipelineArgs args)
        {
            if (string.IsNullOrEmpty(this.UniqueId))
            {
                return;
            }
            LayoutDefinition      layoutDefinition = DeviceEditorForm.GetLayoutDefinition();
            DeviceDefinition      device           = layoutDefinition.GetDevice(this.DeviceID);
            PlaceholderDefinition placeholder      = device.GetPlaceholder(this.UniqueId);

            if (placeholder == null)
            {
                return;
            }
            if (args.IsPostBack)
            {
                if (!string.IsNullOrEmpty(args.Result) && args.Result != "undefined")
                {
                    string key;
                    Item   item = SelectPlaceholderSettingsOptions.ParseDialogResult(args.Result, Client.ContentDatabase, out key);
                    if (item == null)
                    {
                        return;
                    }
                    placeholder.MetaDataItemId = item.Paths.FullPath;
                    placeholder.Key            = key;
                    DeviceEditorForm.SetDefinition(layoutDefinition);
                    this.Refresh();
                    return;
                }
            }
            else
            {
                Item item2 = string.IsNullOrEmpty(placeholder.MetaDataItemId) ? null : Client.ContentDatabase.GetItem(placeholder.MetaDataItemId);
                SelectPlaceholderSettingsOptions selectPlaceholderSettingsOptions = new SelectPlaceholderSettingsOptions
                {
                    TemplateForCreating      = null,
                    PlaceholderKey           = placeholder.Key,
                    CurrentSettingsItem      = item2,
                    SelectedItem             = item2,
                    IsPlaceholderKeyEditable = true
                };
                SheerResponse.ShowModalDialog(selectPlaceholderSettingsOptions.ToUrlString().ToString(), "460px", "460px", string.Empty, true);
                args.WaitForPostBack();
            }
        }
Example #5
0
        protected void RemovePlaceholder(Message message)
        {
            Assert.ArgumentNotNull(message, "message");
            if (string.IsNullOrEmpty(this.UniqueId))
            {
                return;
            }
            LayoutDefinition      layoutDefinition = DeviceEditorForm.GetLayoutDefinition();
            DeviceDefinition      device           = layoutDefinition.GetDevice(this.DeviceID);
            PlaceholderDefinition placeholder      = device.GetPlaceholder(this.UniqueId);

            if (placeholder == null)
            {
                return;
            }
            System.Collections.ArrayList placeholders = device.Placeholders;
            if (placeholders != null)
            {
                placeholders.Remove(placeholder);
            }
            DeviceEditorForm.SetDefinition(layoutDefinition);
            this.Refresh();
        }
Example #6
0
 protected void AddPlaceholder(ClientPipelineArgs args)
 {
     if (args.IsPostBack)
     {
         if (!string.IsNullOrEmpty(args.Result) && args.Result != "undefined")
         {
             LayoutDefinition layoutDefinition = DeviceEditorForm.GetLayoutDefinition();
             DeviceDefinition device           = layoutDefinition.GetDevice(this.DeviceID);
             string           text;
             Item             item = SelectPlaceholderSettingsOptions.ParseDialogResult(args.Result, Client.ContentDatabase, out text);
             if (item == null || string.IsNullOrEmpty(text))
             {
                 return;
             }
             PlaceholderDefinition placeholderDefinition = new PlaceholderDefinition
             {
                 UniqueId       = ID.NewID.ToString(),
                 MetaDataItemId = item.Paths.FullPath,
                 Key            = text
             };
             device.AddPlaceholder(placeholderDefinition);
             DeviceEditorForm.SetDefinition(layoutDefinition);
             this.Refresh();
             return;
         }
     }
     else
     {
         SelectPlaceholderSettingsOptions selectPlaceholderSettingsOptions = new SelectPlaceholderSettingsOptions
         {
             IsPlaceholderKeyEditable = true
         };
         SheerResponse.ShowModalDialog(selectPlaceholderSettingsOptions.ToUrlString().ToString(), "460px", "460px", string.Empty, true);
         args.WaitForPostBack();
     }
 }