Esempio n. 1
0
        protected void SortUp(Message message)
        {
            Assert.ArgumentNotNull(message, "message");
            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;
            }
            renderings.Remove(renderingDefinition);
            renderings.Insert(this.SelectedIndex - 1, renderingDefinition);
            this.SelectedIndex--;
            DeviceEditorForm.SetDefinition(layoutDefinition);
            this.Refresh();
        }
Esempio n. 2
0
        /// <summary>
        /// Refreshes this instance.
        /// </summary>
        private void Refresh()
        {
            this.Renderings.Controls.Clear();
            this.Placeholders.Controls.Clear();
            this.Controls = new System.Collections.ArrayList();
            LayoutDefinition layoutDefinition = DeviceEditorForm.GetLayoutDefinition();
            DeviceDefinition device           = layoutDefinition.GetDevice(this.DeviceID);

            if (device.Renderings == null)
            {
                SheerResponse.SetOuterHtml("Renderings", this.Renderings);
                SheerResponse.SetOuterHtml("Placeholders", this.Placeholders);
                SheerResponse.Eval("if (!scForm.browser.isIE) { scForm.browser.initializeFixsizeElements(); }");
                return;
            }
            int selectedIndex = this.SelectedIndex;

            this.RenderRenderings(device, selectedIndex, 0);
            this.RenderPlaceholders(device);
            this.UpdateRenderingsCommandsState();
            this.UpdatePlaceholdersCommandsState();
            SheerResponse.SetOuterHtml("Renderings", this.Renderings);
            SheerResponse.SetOuterHtml("Placeholders", this.Placeholders);
            SheerResponse.Eval("if (!scForm.browser.isIE) { scForm.browser.initializeFixsizeElements(); }");
        }
Esempio n. 3
0
        protected void Remove(Message message)
        {
            Assert.ArgumentNotNull(message, "message");
            int selectedIndex = this.SelectedIndex;

            if (selectedIndex < 0)
            {
                return;
            }
            LayoutDefinition layoutDefinition = DeviceEditorForm.GetLayoutDefinition();
            DeviceDefinition device           = layoutDefinition.GetDevice(this.DeviceID);

            System.Collections.ArrayList renderings = device.Renderings;
            if (renderings == null)
            {
                return;
            }
            if (selectedIndex < 0 || selectedIndex >= renderings.Count)
            {
                return;
            }
            renderings.RemoveAt(selectedIndex);
            if (selectedIndex >= 0)
            {
                this.SelectedIndex--;
            }
            DeviceEditorForm.SetDefinition(layoutDefinition);
            this.Refresh();
        }
Esempio n. 4
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, System.EventArgs args)
        {
            Assert.ArgumentNotNull(sender, "sender");
            Assert.ArgumentNotNull(args, "args");
            if (this.Layout.Value.Length > 0)
            {
                Item item = Client.ContentDatabase.GetItem(this.Layout.Value);
                if (item == null)
                {
                    Context.ClientPage.ClientResponse.Alert("Layout not found.");
                    return;
                }
                if (item.TemplateID == TemplateIDs.Folder || item.TemplateID == TemplateIDs.Node)
                {
                    Context.ClientPage.ClientResponse.Alert(Translate.Text("\"{0}\" is not a layout.", new object[]
                    {
                        item.DisplayName
                    }));
                    return;
                }
            }
            LayoutDefinition layoutDefinition = DeviceEditorForm.GetLayoutDefinition();
            DeviceDefinition device           = layoutDefinition.GetDevice(this.DeviceID);

            System.Collections.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.");
                return;
            }
            device.Layout = this.Layout.Value;
            DeviceEditorForm.SetDefinition(layoutDefinition);
            Context.ClientPage.ClientResponse.SetDialogValue("yes");
            base.OnOK(sender, args);
        }
Esempio n. 5
0
        /// <summary>
        /// Updates the state of the commands.
        /// </summary>
        private void UpdateRenderingsCommandsState()
        {
            if (this.SelectedIndex < 0)
            {
                this.ChangeButtonsState(true);
                return;
            }
            LayoutDefinition layoutDefinition = DeviceEditorForm.GetLayoutDefinition();
            DeviceDefinition device           = layoutDefinition.GetDevice(this.DeviceID);

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

            if (renderingDefinition == null)
            {
                this.ChangeButtonsState(true);
                return;
            }
            this.ChangeButtonsState(false);
            this.Personalize.Disabled = !string.IsNullOrEmpty(renderingDefinition.MultiVariateTest);
            this.Test.Disabled        = DeviceEditorForm.HasRenderingRules(renderingDefinition);
        }
Esempio n. 6
0
        protected void Change(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))
            {
                return;
            }
            if (args.IsPostBack)
            {
                if (args.HasResult)
                {
                    string[] array = args.Result.Split(new char[]
                    {
                        ','
                    });
                    renderingDefinition.ItemID = array[0];
                    bool flag = array[2] == "1";
                    DeviceEditorForm.SetDefinition(layoutDefinition);
                    this.Refresh();
                    if (flag)
                    {
                        Context.ClientPage.SendMessage(this, "device:edit");
                        return;
                    }
                }
            }
            else
            {
                SelectRenderingOptions selectRenderingOptions = new SelectRenderingOptions
                {
                    ShowOpenProperties  = true,
                    ShowPlaceholderName = false,
                    PlaceholderName     = string.Empty,
                    SelectedItem        = Client.ContentDatabase.GetItem(renderingDefinition.ItemID)
                };
                string url = selectRenderingOptions.ToUrlString(Client.ContentDatabase).ToString();
                SheerResponse.ShowModalDialog(url, true);
                args.WaitForPostBack();
            }
        }
Esempio n. 7
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)
             {
                 System.Collections.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();
     }
 }
Esempio n. 8
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);
            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
            {
                Command command = CommandManager.GetCommand("device:settestdetails");
                Assert.IsNotNull(command, "deviceTestCommand");
                CommandContext commandContext = new CommandContext();
                commandContext.Parameters["deviceDefinitionId"]          = device.ID;
                commandContext.Parameters["renderingDefinitionUniqueId"] = renderingDefinition.UniqueId;
                command.Execute(commandContext);
                args.WaitForPostBack();
            }
        }
Esempio n. 9
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();
            }
        }
Esempio n. 10
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();
            }
        }
Esempio n. 11
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();
            }
        }
Esempio n. 12
0
 /// <summary>
 /// Raises the load event.
 /// </summary>
 /// <param name="e">
 /// The <see cref="T:System.EventArgs" /> instance containing the event data.
 /// </param>
 /// <remarks>
 /// This method notifies the server control that it should perform actions common to each HTTP
 /// request for the page it is associated with, such as setting up a database query. At this
 /// stage in the page life cycle, server controls in the hierarchy are created and initialized,
 /// view state is restored, and form controls reflect client-side data. Use the IsPostBack
 /// property to determine whether the page is being loaded in response to a client post back,
 /// or if it is being loaded and accessed for the first time.
 /// </remarks>
 protected override void OnLoad(System.EventArgs e)
 {
     Assert.ArgumentNotNull(e, "e");
     base.OnLoad(e);
     if (!Context.ClientPage.IsEvent)
     {
         this.DeviceID = WebUtil.GetQueryString("de");
         LayoutDefinition layoutDefinition = DeviceEditorForm.GetLayoutDefinition();
         DeviceDefinition device           = layoutDefinition.GetDevice(this.DeviceID);
         if (device.Layout != null)
         {
             this.Layout.Value = device.Layout;
         }
         this.Personalize.Visible = Policy.IsAllowed("Page Editor/Extended features/Personalization");
         this.Test.Visible        = (XdbSettings.Enabled && Policy.IsAllowed("Page Editor/Extended features/Testing"));
         this.Refresh();
         this.SelectedIndex = -1;
     }
 }
Esempio n. 13
0
 /// <summary>
 /// Raises the load event.
 /// </summary>
 /// <param name="e">
 /// The <see cref="T:System.EventArgs" /> instance containing the event data.
 /// </param>
 /// <remarks>
 /// This method notifies the server control that it should perform actions common to each HTTP
 /// request for the page it is associated with, such as setting up a database query. At this
 /// stage in the page life cycle, server controls in the hierarchy are created and initialized,
 /// view state is restored, and form controls reflect client-side data. Use the IsPostBack
 /// property to determine whether the page is being loaded in response to a client post back,
 /// or if it is being loaded and accessed for the first time.
 /// </remarks>
 protected override void OnLoad(EventArgs e)
 {
     Assert.ArgumentNotNull(e, "e");
     base.OnLoad(e);
     if (!Context.ClientPage.IsEvent)
     {
         this.DeviceID = WebUtil.GetQueryString("de");
         LayoutDefinition layoutDefinition = DeviceEditorForm.GetLayoutDefinition();
         DeviceDefinition device           = layoutDefinition.GetDevice(this.DeviceID);
         if (device.Layout != null)
         {
             this.Layout.Value = device.Layout;
         }
         this.Personalize.Visible = Policy.IsAllowed("Page Editor/Extended features/Personalization");
         Command command = CommandManager.GetCommand("device:settestdetails");
         this.Test.Visible = (command != null && command.QueryState(CommandContext.Empty) != CommandState.Hidden);
         this.Refresh();
         this.SelectedIndex = -1;
     }
 }
Esempio n. 14
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();
        }
Esempio n. 15
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();
     }
 }