Пример #1
0
        /// <summary>
        /// Reads new values entered by the user for the field.  Returns with Page.Guid,PageRoute.Guid or just Page.Guid
        /// </summary>
        /// <param name="control">Parent control that controls were added to in the CreateEditControl() method</param>
        /// <param name="configurationValues">The configuration values.</param>
        /// <returns></returns>
        public override string GetEditValue(System.Web.UI.Control control, Dictionary <string, ConfigurationValue> configurationValues)
        {
            PagePicker ppPage = control as PagePicker;
            string     result = null;

            if (ppPage != null)
            {
                //// Value is in format "Page.Guid,PageRoute.Guid"
                //// If only a Page is specified, this is just a reference to a page without a special route

                if (ppPage.IsPageRoute)
                {
                    int?pageRouteId = ppPage.PageRouteId;
                    var pageRoute   = new PageRouteService(new RockContext()).Get(pageRouteId ?? 0);
                    if (pageRoute != null)
                    {
                        result = string.Format("{0},{1}", pageRoute.Page.Guid, pageRoute.Guid);
                    }
                }
                else
                {
                    var page = new PageService(new RockContext()).Get(ppPage.PageId ?? 0);
                    if (page != null)
                    {
                        result = page.Guid.ToString();
                    }
                }
            }

            return(result);
        }
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            Controls.Clear();
            RockControlHelper.CreateChildControls(this, Controls);
            EnsureChildControls();

            ddlActionList              = new RockDropDownList();
            ddlActionList.Label        = "Action";
            ddlActionList.AutoPostBack = true;
            ddlActionList.Items.Add(new ListItem("Do Nothing", "0"));
            ddlActionList.Items.Add(new ListItem("Push New Page", "1"));
            ddlActionList.Items.Add(new ListItem("Replace Current Page", "2"));
            ddlActionList.Items.Add(new ListItem("Pop Curent Page", "3"));
            ddlActionList.Items.Add(new ListItem("Open Browser", "4"));
            ddlActionList.SelectedIndexChanged += DdlActionList_SelectedIndexChanged;
            ddlActionList.CssClass              = "col-md-12";
            ddlActionList.ID = "ddlActionList_" + this.ID;

            ppPage = new PagePicker()
            {
                Label = "Page",
                ID    = "ppPage_" + this.ID
            };

            tbTarget = new RockTextBox()
            {
                Label = "Target",
                ID    = "tbTarget_" + this.ID
            };

            tbParameter = new RockTextBox()
            {
                Label = "Parameter",
                ID    = "tbParameter_" + this.ID
            };

            ddlRckipid       = new RockDropDownList();
            ddlRckipid.ID    = "ddlRckipid_" + this.ID;
            ddlRckipid.Label = "Send Impersonation Id";
            ddlRckipid.Items.Add(new ListItem("No", "0"));
            ddlRckipid.Items.Add(new ListItem("Yes", "1"));

            Controls.Add(ddlActionList);
            Controls.Add(ppPage);
            Controls.Add(tbTarget);
            Controls.Add(tbParameter);
            Controls.Add(ddlRckipid);
            EnsureChildControls();
        }
Пример #3
0
        /// <summary>
        /// Sets the value ( as either Page.Guid,PageRoute.Guid or just Page.Guid if not specific to a route )
        /// </summary>
        /// <param name="control">The control.</param>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="value">The value.</param>
        public override void SetEditValue(System.Web.UI.Control control, Dictionary <string, ConfigurationValue> configurationValues, string value)
        {
            if (value != null)
            {
                PagePicker ppPage = control as PagePicker;
                if (ppPage != null)
                {
                    string[] valuePair = value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                    Page      page      = null;
                    PageRoute pageRoute = null;

                    //// Value is in format "Page.Guid,PageRoute.Guid"
                    //// If only the Page.Guid is specified this is just a reference to a page without a special route
                    //// In case the PageRoute record can't be found from PageRoute.Guid (maybe the pageroute was deleted), fall back to the Page without a PageRoute

                    var rockContext = new RockContext();

                    if (valuePair.Length == 2)
                    {
                        Guid pageRouteGuid;
                        Guid.TryParse(valuePair[1], out pageRouteGuid);
                        pageRoute = new PageRouteService(rockContext).Get(pageRouteGuid);
                    }

                    if (pageRoute != null)
                    {
                        ppPage.SetValue(pageRoute);
                    }
                    else
                    {
                        if (valuePair.Length > 0)
                        {
                            Guid pageGuid;
                            Guid.TryParse(valuePair[0], out pageGuid);
                            page = new PageService(rockContext).Get(pageGuid);
                        }

                        ppPage.SetValue(page);
                    }
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            Controls.Clear();

            tbTitle = new RockTextBox
            {
                ID        = string.Format("tbTextTitle_{0}", this.ID),
                TextMode  = TextBoxMode.SingleLine,
                Required  = false,
                Label     = "Title",
                MaxLength = 100
            };
            Controls.Add(tbTitle);

            rcwMessage = new RockControlWrapper
            {
                ID    = string.Format("rcwMessage_{0}", this.ID),
                Label = "Message",
                Help  = "<span class='tip tip-lava'></span>"
            };
            Controls.Add(rcwMessage);

            mfpMessage = new MergeFieldPicker
            {
                ID = string.Format("mfpMergeFields_{0}", this.ID)
            };
            mfpMessage.MergeFields.Clear();
            mfpMessage.MergeFields.Add("GlobalAttribute");
            mfpMessage.MergeFields.Add("Rock.Model.Person");
            mfpMessage.CssClass   += " pull-right margin-b-sm";
            mfpMessage.SelectItem += mfpMergeFields_SelectItem;
            rcwMessage.Controls.Add(mfpMessage);

            lblCount = new Label
            {
                CssClass = "badge margin-all-sm pull-right",
                ID       = $"{nameof( lblCount )}_{ID}"
            };
            rcwMessage.Controls.Add(lblCount);

            tbMessage = new RockTextBox
            {
                ID       = string.Format("tbTextMessage_{0}", this.ID),
                TextMode = TextBoxMode.MultiLine,
                Rows     = 3
            };
            rcwMessage.Controls.Add(tbMessage);

            iupPushImage = new ImageUploader
            {
                ID      = $"{nameof( iupPushImage )}_{ID}",
                Label   = "Image",
                Help    = "We recommend an image size of 1038x520.",
                Visible = false // Images aren't used during push yet, so don't show.
            };

            rcwMessage.Controls.Add(iupPushImage);

            rbOpenAction = CreateOpenActionRadioList();
            rcwMessage.Controls.Add(rbOpenAction);

            ddlMobileApplications = CreateMobileApplicationDropDownList();
            rcwMessage.Controls.Add(ddlMobileApplications);

            htmlAdditionalDetails = new HtmlEditor
            {
                ID     = $"{nameof( htmlAdditionalDetails )}_{ID}",
                Label  = "Additional Details",
                Height = 300
            };

            rcwMessage.Controls.Add(htmlAdditionalDetails);

            ppMobilePage = new PagePicker
            {
                ID    = $"{nameof( ppMobilePage )}_{ID}",
                Label = "Mobile Page"
            };

            rcwMessage.Controls.Add(ppMobilePage);

            kvlQuerystring = new KeyValueList
            {
                ID          = $"{nameof( kvlQuerystring )}_{ID}",
                Label       = "Mobile Page Query String",
                KeyPrompt   = "Key",
                ValuePrompt = "Value"
            };

            rcwMessage.Controls.Add(kvlQuerystring);

            urlLink = new UrlLinkBox
            {
                ID    = $"{nameof( urlLink )}_{ID}",
                Label = "URL"
            };

            rcwMessage.Controls.Add(urlLink);
        }