/// <summary>
        /// Binds the workflow type picker.
        /// </summary>
        private void BindPagePickerControls()
        {
            if (_hasLaunched)
            {
                ppCommunicationPage.Visible = false;
                return;
            }

            // If a page parameter is set, then it overrides everything else
            var communicationPageId = PageParameter(PageParameterKey.CommunicationPageId).AsIntegerOrNull();
            var selectedPage        = GetAttributeValue(AttributeKey.CommunicationPage);

            if (communicationPageId.HasValue)
            {
                var communicationPage = PageCache.Get(communicationPageId.Value);

                if (communicationPage != null && communicationPage.IsAuthorized(Authorization.VIEW, CurrentPerson))
                {
                    ppCommunicationPage.Visible = false;
                    return;
                }
            }
            else if (selectedPage.IsNotNullOrWhiteSpace())
            {
                var ppFieldType = new PageReferenceFieldType();
                ppFieldType.SetEditValue(ppCommunicationPage, null, selectedPage);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            _pageId     = PageParameter(PageParameterKey.Page).AsIntegerOrNull();
            _pageSearch = PageParameter(PageParameterKey.PageSearch);

            var detailPageReference = new Rock.Web.PageReference(GetAttributeValue(AttributeKey.DetailPage));

            // NOTE: if the detail page is the current page, use the current route instead of route specified in the DetailPage (to preserve old behavior)
            if (detailPageReference == null || detailPageReference.PageId == this.RockPage.PageId)
            {
                hfPageRouteTemplate.Value = (this.RockPage.RouteData.Route as System.Web.Routing.Route).Url;
                hfDetailPageUrl.Value     = new Rock.Web.PageReference(this.RockPage.PageId).BuildUrl();
            }
            else
            {
                hfPageRouteTemplate.Value = string.Empty;
                var pageCache = PageCache.Get(detailPageReference.PageId);
                if (pageCache != null)
                {
                    var route = pageCache.PageRoutes.FirstOrDefault(a => a.Id == detailPageReference.RouteId);
                    if (route != null)
                    {
                        hfPageRouteTemplate.Value = route.Route;
                    }
                }

                hfDetailPageUrl.Value = detailPageReference.BuildUrl();
            }

            InitializeSettingsNotification(upPanel);
        }
        /// <summary>
        /// Gets the selected page identifier.
        /// </summary>
        /// <returns></returns>
        private PageCache GetSelectedPage()
        {
            var communicationPageId = PageParameter(PageParameterKey.CommunicationPageId).AsIntegerOrNull();

            if (communicationPageId.HasValue)
            {
                return(PageCache.Get(communicationPageId.Value));
            }

            communicationPageId = ppCommunicationPage.SelectedValueAsInt();

            if (communicationPageId.HasValue)
            {
                return(PageCache.Get(communicationPageId ?? 0));
            }

            var selectedPage = GetAttributeValue(AttributeKey.CommunicationPage);

            if (selectedPage.IsNotNullOrWhiteSpace())
            {
                return(PageCache.Get(selectedPage));
            }

            return(PageCache.Get(RockPage.Guid));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Shows the detail for zone.
        /// </summary>
        /// <param name="zoneName">Name of the zone.</param>
        private void ShowDetailForZone(string zoneName)
        {
            int pageId = hfPageId.Value.AsInteger();
            var page   = PageCache.Get(pageId);

            lZoneTitle.Text = string.Format("{0} Zone", zoneName);
            lZoneIcon.Text  = "<i class='fa fa-th-large'></i>";
            if (page != null)
            {
                // Refresh ZoneList's "Count" text
                foreach (var zoneListItem in ddlZones.Items.OfType <ListItem>())
                {
                    var zoneBlockCount = page.Blocks.Where(a => a.Zone.Equals(zoneListItem.Value, StringComparison.OrdinalIgnoreCase)).Count();
                    zoneListItem.Text = string.Format("{0} ({1})", zoneListItem.Value, zoneBlockCount);
                }

                // update SiteBlock, LayoutBlock and PageBlock repeaters
                var zoneBlocks = page.Blocks.Where(a => a.Zone == zoneName).ToList();

                rptSiteBlocks.DataSource = zoneBlocks.Where(a => a.BlockLocation == BlockLocation.Site).ToList();
                rptSiteBlocks.DataBind();

                rptLayoutBlocks.DataSource = zoneBlocks.Where(a => a.BlockLocation == BlockLocation.Layout).ToList();
                rptLayoutBlocks.DataBind();

                rptPageBlocks.DataSource = zoneBlocks.Where(a => a.BlockLocation == BlockLocation.Page).ToList();
                rptPageBlocks.DataBind();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Loads a check-in block to determine if it will require a selection or not. This is used to find the
        /// next page/block that does require a selection so that user can be redirected once to that block,
        /// rather than just continuously redirected to next/prev page blocks and possibly exceeding the maximum
        /// number of redirects.
        /// </summary>
        /// <param name="attributeKey">The attribute key.</param>
        /// <returns></returns>
        protected CheckInBlock GetCheckInBlock(string attributeKey)
        {
            var pageReference = new PageReference(GetAttributeValue(attributeKey));

            if (pageReference.PageId > 0)
            {
                var page = PageCache.Get(pageReference.PageId);
                if (page != null)
                {
                    foreach (var block in page.Blocks.OrderBy(b => b.Order))
                    {
                        var control = TemplateControl.LoadControl(block.BlockType.Path);
                        if (control != null)
                        {
                            var checkinBlock = control as CheckInBlock;
                            if (checkinBlock != null)
                            {
                                checkinBlock.SetBlock(page, block, true, true);
                                checkinBlock.GetState();
                                return(checkinBlock);
                            }
                        }
                    }
                }
            }

            return(null);
        }
        public Dictionary <string, string> PostInteraction()
        {
            HttpContent            requestContent         = Request.Content;
            string                 content                = requestContent.ReadAsStringAsync().Result;
            InteractionInformation interactionInformation = JsonConvert.DeserializeObject <InteractionInformation>(content);

            var homePageId = GlobalAttributesCache.Value("AvalancheHomePage").AsInteger();
            var pageCache  = PageCache.Get(homePageId);
            var siteId     = pageCache.SiteId;
            var person     = GetPerson();

            AppInteractionTransaction transaction = new AppInteractionTransaction()
            {
                ComponentName      = "Mobile App",
                SiteId             = siteId,
                PageId             = interactionInformation.PageId.AsIntegerOrNull(),
                PageTitle          = interactionInformation.PageTitle,
                DateViewed         = Rock.RockDateTime.Now,
                Operation          = interactionInformation.Operation,
                PersonAliasId      = person?.PrimaryAliasId,
                InteractionData    = interactionInformation.InteractionData,
                InteractionSummary = interactionInformation.InteractionSummary,
                IPAddress          = GetClientIp(Request),
                UserAgent          = Request.Headers.UserAgent.ToString()
            };

            RockQueue.TransactionQueue.Enqueue(transaction);
            return(new Dictionary <string, string> {
                { "Status", "Ok" }
            });
        }
        public MobileBlockResponse BlockPostRequest(int id, string arg = "")
        {
            HttpContent requestContent = Request.Content;
            string      content        = requestContent.ReadAsStringAsync().Result;
            var         body           = JsonConvert.DeserializeObject <Dictionary <string, string> >(content);
            var         person         = GetPerson();

            HttpContext.Current.Items.Add("CurrentPerson", person);
            var    blockCache = BlockCache.Get(id);
            var    pageCache  = PageCache.Get(blockCache.PageId ?? 0);
            string theme      = pageCache.Layout.Site.Theme;
            string layout     = pageCache.Layout.FileName;
            string layoutPath = PageCache.FormatPath(theme, layout);

            Rock.Web.UI.RockPage cmsPage = (Rock.Web.UI.RockPage)BuildManager.CreateInstanceFromVirtualPath(layoutPath, typeof(Rock.Web.UI.RockPage));

            if (blockCache.IsAuthorized(Authorization.VIEW, person))
            {
                var control = ( RockBlock )cmsPage.TemplateControl.LoadControl(blockCache.BlockType.Path);

                if (control is RockBlock && control is IMobileResource)
                {
                    control.SetBlock(pageCache, blockCache);
                    var mobileResource      = control as IMobileResource;
                    var mobileBlockResponse = mobileResource.HandleRequest(arg, body);
                    mobileBlockResponse.TTL = 0;
                    return(mobileBlockResponse);
                }
            }
            return(new MobileBlockResponse());
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Returns the field's current value(s)
        /// </summary>
        /// <param name="parentControl">The parent control.</param>
        /// <param name="value">Information about the value</param>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="condensed">Flag indicating if the value should be condensed (i.e. for use in a grid column)</param>
        /// <returns></returns>
        public override string FormatValue(System.Web.UI.Control parentControl, string value, Dictionary <string, ConfigurationValue> configurationValues, bool condensed)
        {
            if (!string.IsNullOrWhiteSpace(value))
            {
                //// Value is in format "Page.Guid,PageRoute.Guid"
                string[] valuePair = value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                if (valuePair.Length > 0)
                {
                    Guid?pageGuid = valuePair[0].AsGuidOrNull();
                    if (pageGuid.HasValue)
                    {
                        var page = PageCache.Get(pageGuid.Value);
                        if (page != null)
                        {
                            if (valuePair.Length > 1)
                            {
                                Guid?routeGuid = valuePair[1].AsGuidOrNull();
                                if (routeGuid.HasValue)
                                {
                                    var route = page.PageRoutes.FirstOrDefault(r => r.Guid.Equals(routeGuid.Value));
                                    if (route != null)
                                    {
                                        return(string.Format("{0} ({1})", page.PageTitle, route.Route));
                                    }
                                }
                            }

                            return(page.PageTitle);
                        }
                    }
                }
            }

            return(value);
        }
        public MobileBlockResponse BlockGetRequest(int id, string request = "")
        {
            var person = GetPerson();

            HttpContext.Current.Items.Add("CurrentPerson", person);
            var blockCache = BlockCache.Get(id);

            if (blockCache == null)
            {
                return(new MobileBlockResponse());
            }
            var    pageCache  = PageCache.Get(blockCache.PageId ?? 0);
            string theme      = pageCache.Layout.Site.Theme;
            string layout     = pageCache.Layout.FileName;
            string layoutPath = PageCache.FormatPath(theme, layout);

            Rock.Web.UI.RockPage cmsPage = (Rock.Web.UI.RockPage)BuildManager.CreateInstanceFromVirtualPath(layoutPath, typeof(Rock.Web.UI.RockPage));

            if (blockCache.IsAuthorized(Authorization.VIEW, person))
            {
                var control = ( RockBlock )cmsPage.TemplateControl.LoadControl(blockCache.BlockType.Path);

                if (control is RockBlock && control is IMobileResource)
                {
                    control.SetBlock(pageCache, blockCache);
                    var mobileResource      = control as IMobileResource;
                    var mobileBlockResponse = mobileResource.HandleRequest(request, new Dictionary <string, string>());
                    HttpContext.Current.Response.Headers.Set("TTL", mobileBlockResponse.TTL.ToString());
                    return(mobileBlockResponse);
                }
            }
            HttpContext.Current.Response.Headers.Set("TTL", "0");
            return(new MobileBlockResponse());
        }
        private System.Web.IHttpHandler GetHandlerFor404(RequestContext requestContext, SiteCache site)
        {
            // If we couldn't match a route because it's the root, use the home page
            if (site != null && requestContext.HttpContext.Request.Path == "/")
            {
                return(GetHandlerForPage(requestContext, site.DefaultPage, site.DefaultPageRouteId ?? 0));
            }

            if (site != null && site.PageNotFoundPageId.HasValue)
            {
                if (Convert.ToBoolean(GlobalAttributesCache.Get().GetValue("Log404AsException")))
                {
                    Rock.Model.ExceptionLogService.LogException(
                        new Exception(string.Format("404 Error: {0}", requestContext.HttpContext.Request.Url.AbsoluteUri)),
                        requestContext.HttpContext.ApplicationInstance.Context);
                }

                var page = PageCache.Get(site.PageNotFoundPageId.Value);
                requestContext.HttpContext.Response.StatusCode             = 404;
                requestContext.HttpContext.Response.TrySkipIisCustomErrors = true;

                return(GetHandlerForPage(requestContext, page));
            }
            else
            {
                // no 404 page found for the site, return the default 404 error page
                return((System.Web.UI.Page)BuildManager.CreateInstanceFromVirtualPath("~/Http404Error.aspx", typeof(System.Web.UI.Page)));
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Updates the a communication record from control values.
        /// </summary>
        /// <param name="communication">The communication.</param>
        public override void UpdateCommunication(CommunicationDetails communication)
        {
            EnsureChildControls();
            communication.PushTitle             = tbTitle.Text;
            communication.PushMessage           = tbMessage.Text;
            communication.PushImageBinaryFileId = iupPushImage.BinaryFileId;
            communication.PushOpenAction        = GetSelectedOpenActionOrDefault();

            var pushData = new PushData();

            if (communication.PushOpenAction == PushOpenAction.ShowDetails)
            {
                communication.PushOpenMessage = htmlAdditionalDetails.Text;
                pushData.MobileApplicationId  = ddlMobileApplications.SelectedValue.AsIntegerOrNull();
            }

            if (communication.PushOpenAction == PushOpenAction.LinkToMobilePage)
            {
                pushData.MobilePageQueryString = kvlQuerystring.Value.AsDictionaryOrNull();
                pushData.MobilePageId          = ppMobilePage.SelectedValue.AsIntegerOrNull();
                pushData.MobileApplicationId   = pushData.MobilePageId.HasValue ? PageCache.Get(pushData.MobilePageId.Value)?.SiteId : null;
            }

            if (communication.PushOpenAction == PushOpenAction.LinkToUrl)
            {
                pushData.Url = urlLink.Text;
            }

            communication.PushData = pushData.ToJson();
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Updates any Cache Objects that are associated with this entity
        /// </summary>
        /// <param name="entityState">State of the entity.</param>
        /// <param name="dbContext">The database context.</param>
        public void UpdateCache(System.Data.Entity.EntityState entityState, Rock.Data.DbContext dbContext)
        {
            BlockCache.UpdateCachedEntity(this.Id, entityState);

            var model = this;

            if (model.SiteId.HasValue && model.SiteId != originalSiteId)
            {
                PageCache.RemoveSiteBlocks(model.SiteId.Value);
            }
            else if (model.LayoutId.HasValue && model.LayoutId != originalLayoutId)
            {
                PageCache.RemoveLayoutBlocks(model.LayoutId.Value);
            }

            if (originalSiteId.HasValue)
            {
                PageCache.RemoveSiteBlocks(originalSiteId.Value);
            }
            else if (originalLayoutId.HasValue)
            {
                PageCache.RemoveLayoutBlocks(originalLayoutId.Value);
            }
            else if (originalPageId.HasValue)
            {
                var page = PageCache.Get(originalPageId.Value);
                page.RemoveBlocks();
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Handles the SaveClick event of the mdBlockMove control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void mdBlockMove_SaveClick(object sender, EventArgs e)
        {
            int blockId      = hfBlockMoveBlockId.Value.AsInteger();
            var rockContext  = new RockContext();
            var blockService = new BlockService(rockContext);
            var block        = blockService.Get(blockId);

            var page = PageCache.Get(hfPageId.Value.AsInteger());

            if (block != null)
            {
                block.Zone = ddlMoveToZoneList.SelectedValue;
                if (cblBlockMovePageOrLayout.SelectedValue == "Page")
                {
                    block.PageId   = page.Id;
                    block.LayoutId = null;
                }
                else
                {
                    block.PageId   = null;
                    block.LayoutId = page.LayoutId;
                }

                rockContext.SaveChanges();

                mdBlockMove.Hide();
                ShowDetailForZone(ddlZones.SelectedValue);
            }
        }
Ejemplo n.º 14
0
        /// <inheritdoc/>
        public override string FormatValue(System.Web.UI.Control parentControl, string value, Dictionary <string, ConfigurationValue> configurationValues, bool condensed)
        {
            var navigationAction = value.FromJsonOrNull <MobileNavigationAction>();

            if (navigationAction == null)
            {
                return(string.Empty);
            }

            var popCount  = navigationAction.PopCount ?? 1;
            var pageCache = navigationAction.PageGuid.HasValue
                ? PageCache.Get(navigationAction.PageGuid.Value)
                : null;

            switch (navigationAction.Type)
            {
            case MobileNavigationActionType.None:
                return("None");

            case MobileNavigationActionType.PopPage:
                return($"Pop {popCount} page{( popCount != 1 ? "s" : string.Empty )}");

            case MobileNavigationActionType.PushPage:
                return($"Push '{pageCache?.InternalName}'");

            case MobileNavigationActionType.ReplacePage:
                return($"Replace page with '{pageCache?.InternalName}'");

            case MobileNavigationActionType.ResetToPage:
                return($"Reset to '{pageCache?.InternalName}'");

            default:
                return(string.Empty);
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Fulls the path.
        /// </summary>
        /// <param name="templatePath">The template path.</param>
        /// <returns></returns>
        /// <exception cref="FileSystemException">LavaFileSystem Illegal Template Name</exception>
        public string FullPath(string templatePath)
        {
            if (templatePath != null && HttpContext.Current != null)
            {
                if (templatePath.StartsWith("~~") &&
                    HttpContext.Current.Items != null &&
                    HttpContext.Current.Items.Contains("Rock:PageId"))
                {
                    var rockPage = PageCache.Get(HttpContext.Current.Items["Rock:PageId"].ToString().AsInteger());
                    if (rockPage != null &&
                        rockPage.Layout != null &&
                        rockPage.Layout.Site != null)
                    {
                        templatePath = "~/Themes/" + rockPage.Layout.Site.Theme + (templatePath.Length > 2 ? templatePath.Substring(2) : string.Empty);
                    }
                }
            }

            if (templatePath == null)
            {
                throw new FileSystemException("LavaFileSystem Illegal Template Name", templatePath);
            }

            return(HttpContext.Current.Server.MapPath(templatePath));
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Returns breadcrumbs specific to the block that should be added to navigation
        /// based on the current page reference.  This function is called during the page's
        /// oninit to load any initial breadcrumbs.
        /// </summary>
        /// <param name="pageReference">The <see cref="Rock.Web.PageReference" />.</param>
        /// <returns>
        /// A <see cref="System.Collections.Generic.List{BreadCrumb}" /> of block related <see cref="Rock.Web.UI.BreadCrumb">BreadCrumbs</see>.
        /// </returns>
        public override List <BreadCrumb> GetBreadCrumbs(PageReference pageReference)
        {
            var breadCrumbs = new List <BreadCrumb>();

            int?pageId = PageParameter(pageReference, PageParameterKey.SitePageId).AsIntegerOrNull();

            if (pageId != null)
            {
                var page = PageCache.Get(pageId.Value);

                if (page != null)
                {
                    breadCrumbs.Add(new BreadCrumb(page.InternalName, pageReference));
                }
                else
                {
                    breadCrumbs.Add(new BreadCrumb("New Page", pageReference));
                }
            }
            else
            {
                // don't show a breadcrumb if we don't have a pageparam to work with
            }

            return(breadCrumbs);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Determines whether the given PageId or Route is exclusive to another site.
        /// </summary>
        /// <param name="requestingSite">The requesting site.</param>
        /// <param name="pageId">The page identifier.</param>
        /// <param name="routeId">The route identifier. Provide this to check the route's IsGlobal property.</param>
        /// <returns>
        ///   <c>true</c> if [is page exclusive to another site] [the specified requesting site]; otherwise, <c>false</c>.
        /// </returns>
        private static bool IsPageExclusiveToAnotherSite(SiteCache requestingSite, int?pageId, int?routeId)
        {
            if (pageId == null || requestingSite == null)
            {
                // The default value is not to be exclusive
                return(false);
            }

            var pageCache = PageCache.Get(pageId.Value);
            var pageSite  = pageCache?.Layout.Site;

            if (pageSite == null)
            {
                return(false);
            }

            bool isGlobalRoute = routeId != null?pageCache.PageRoutes.Where(r => r.Id == routeId).Select(r => r.IsGlobal).FirstOrDefault() : false;

            // If pageRoute.IsGlobal then return false, this page is usable by all sites.
            if (isGlobalRoute)
            {
                return(false);
            }

            // See if the requesting site is exclusive and if the requesting site is different from the page's site
            return(pageSite.EnableExclusiveRoutes && requestingSite.Id != pageSite.Id);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Loads the drop downs.
        /// </summary>
        public void LoadDropDowns()
        {
            int pageId = hfPageId.Value.AsInteger();

            ddlZones.Items.Clear();
            ddlMoveToZoneList.Items.Clear();
            var page = PageCache.Get(pageId);

            if (page != null)
            {
                var zoneNames = FindZoneNames(page);

                foreach (var zoneName in zoneNames)
                {
                    var zoneBlockCount = page.Blocks.Where(a => a.Zone.Equals(zoneName, StringComparison.OrdinalIgnoreCase)).Count();
                    ddlZones.Items.Add(new ListItem(string.Format("{0} ({1})", zoneName, zoneBlockCount), zoneName));
                    ddlMoveToZoneList.Items.Add(new ListItem(zoneName, zoneName));
                }

                // default to Main Zone (if there is one)
                ddlZones.SetValue("Main");
            }

            var rockContext      = new RockContext();
            var commonBlockTypes = new BlockTypeService(rockContext).Queryable().Where(a => a.IsCommon).OrderBy(a => a.Name).AsNoTracking().ToList();

            rptCommonBlockTypes.DataSource = commonBlockTypes;
            rptCommonBlockTypes.DataBind();
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Parses the lava.
        /// </summary>
        /// <param name="lava">The lava.</param>
        /// <param name="normalizeWhiteSpace">if set to <c>true</c> [normalize white space].</param>
        /// <returns></returns>
        private static string ParseLava(string lava, bool normalizeWhiteSpace = true)
        {
            if (string.IsNullOrEmpty(lava))
            {
                return(string.Empty);
            }

            if (normalizeWhiteSpace)
            {
                lava = NormalizeWhiteSpaceText(lava);
            }

            //var currentPerson = HttpContext.Current.Items["CurrentPerson"] as Person;
            //var currentPage = HttpContext.Current.Handler as RockPage;
            RockPage rockPage = null;

            if (HttpContext.Current != null)
            {
                rockPage = HttpContext.Current.Handler as RockPage;
            }

            var mergeFields = Rock.Lava.LavaHelper.GetCommonMergeFields(rockPage);

            mergeFields.Add("CurrentPage", PageCache.Get(rockPage.PageId));

            return(lava.ResolveMergeFields(mergeFields, "All"));
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Sends server control content to a provided <see cref="T:System.Web.UI.HtmlTextWriter" /> object, which writes the content to be rendered on the client.
        /// </summary>
        /// <param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter" /> object that receives the server control content.</param>
        protected override void Render(HtmlTextWriter writer)
        {
            RockPage      rockPage             = this.Page as RockPage;
            PageReference currentPageReference = rockPage?.PageReference;
            Person        currentPerson        = rockPage?.CurrentPerson;

            PageCache rootPage = RootPageId > 0 ? PageCache.Get(RootPageId) : PageCache.Get(rockPage?.PageId ?? 0);

            if (rootPage == null)
            {
                return;
            }

            foreach (PageCache page in GetChildPages(rootPage, currentPerson))
            {
                // href
                var pageReference = new PageReference(page.Id);
                if (IncludeCurrentParameters)
                {
                    pageReference.Parameters = currentPageReference?.Parameters;
                }

                if (IncludeCurrentQueryString)
                {
                    pageReference.QueryString = currentPageReference?.QueryString;
                }

                if (QueryStringParametersToAdd != null)
                {
                    NameValueCollection mergedQueryString = new NameValueCollection(pageReference.QueryString ?? new NameValueCollection());
                    foreach (string key in QueryStringParametersToAdd)
                    {
                        mergedQueryString[key] = QueryStringParametersToAdd[key];
                    }

                    pageReference.QueryString = mergedQueryString;
                }

                writer.AddAttribute(HtmlTextWriterAttribute.Href, pageReference.BuildUrl());

                // class
                string cssClass = CssClass;
                if (rockPage?.PageId == page.Id && CssClassActive.IsNotNullOrWhiteSpace())
                {
                    cssClass = cssClass.IsNotNullOrWhiteSpace()
                        ? string.Join(" ", cssClass, CssClassActive)
                        : CssClassActive;
                }

                if (cssClass.IsNotNullOrWhiteSpace())
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, cssClass);
                }

                // <a>
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                writer.Write(page.PageTitle);
                writer.RenderEndTag();
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Update the custom UI to reflect the current settings found in the entity.
        /// </summary>
        /// <param name="attributeEntity">The attribute entity.</param>
        public void ReadSettingsFromEntity(IHasAttributes attributeEntity)
        {
            SetupFormBindings();

            var fieldSettings = attributeEntity.GetAttributeValue(AttributeKeys.FieldSettings);

            if (fieldSettings.IsNotNullOrWhiteSpace())
            {
                this.FieldSettings = JsonConvert.DeserializeObject <List <ContentChannelItemList.FieldSetting> >(fieldSettings);
            }
            BindFieldGrid();

            ddlContentChannel.SelectedValue = attributeEntity.GetAttributeValue(AttributeKeys.ContentChannel);
            nbPageSize.Text                = attributeEntity.GetAttributeValue(AttributeKeys.PageSize);
            cbIncludeFollowing.Checked     = attributeEntity.GetAttributeValue(AttributeKeys.IncludeFollowing).AsBoolean();
            cbCheckItemSecurity.Checked    = attributeEntity.GetAttributeValue(AttributeKeys.CheckItemSecurity).AsBoolean();
            cbShowChildrenOfParent.Checked = attributeEntity.GetAttributeValue(AttributeKeys.ShowChildrenOfParent).AsBoolean();
            var pageCache = PageCache.Get(attributeEntity.GetAttributeValue(AttributeKeys.DetailPage).AsGuid());

            ppDetailPage.SetValue(pageCache != null ? ( int? )pageCache.Id : null);
            hfDataFilterId.Value          = attributeEntity.GetAttributeValue(AttributeKeys.FilterId);
            cbQueryParamFiltering.Checked = attributeEntity.GetAttributeValue(AttributeKeys.QueryParameterFiltering).AsBoolean();
            kvlOrder.Value = attributeEntity.GetAttributeValue(AttributeKeys.Order);

            LoadAttributeListForContentChannel();

            ConfigureChannelSpecificSettings();
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            int pageId = PageParameter("EditPage").AsInteger();

            _Page     = PageCache.Get(pageId);
            _ZoneName = this.PageParameter("ZoneName");

            if (_Page != null)
            {
                lAllPagesOnSite.Text = string.Format("Site");


                gSiteBlocks.DataKeyNames              = new string[] { "Id" };
                gSiteBlocks.Actions.ShowAdd           = true;
                gSiteBlocks.Actions.ShowExcelExport   = false;
                gSiteBlocks.Actions.ShowMergeTemplate = false;
                gSiteBlocks.Actions.AddClick         += SiteBlocks_Add;
                gSiteBlocks.GridReorder += gSiteBlocks_GridReorder;
                gSiteBlocks.GridRebind  += gSiteBlocks_GridRebind;

                lAllPagesForLayout.Text = string.Format("Layout ({0})", _Page.Layout.Name);

                gLayoutBlocks.DataKeyNames              = new string[] { "Id" };
                gLayoutBlocks.Actions.ShowAdd           = true;
                gLayoutBlocks.Actions.ShowExcelExport   = false;
                gLayoutBlocks.Actions.ShowMergeTemplate = false;
                gLayoutBlocks.Actions.AddClick         += LayoutBlocks_Add;
                gLayoutBlocks.GridReorder += gLayoutBlocks_GridReorder;
                gLayoutBlocks.GridRebind  += gLayoutBlocks_GridRebind;

                gPageBlocks.DataKeyNames              = new string[] { "Id" };
                gPageBlocks.Actions.ShowAdd           = true;
                gPageBlocks.Actions.ShowExcelExport   = false;
                gPageBlocks.Actions.ShowMergeTemplate = false;
                gPageBlocks.Actions.AddClick         += gPageBlocks_GridAdd;
                gPageBlocks.GridReorder += gPageBlocks_GridReorder;
                gPageBlocks.GridRebind  += gPageBlocks_GridRebind;

                LoadBlockTypes(!Page.IsPostBack);

                string script = string.Format(
                    @"Sys.Application.add_load(function () {{
                    $('div.modal-header h3').html('{0} Zone');
                    $('#{1} a').click(function() {{ $('#{4}').val('Page'); }});
                    $('#{2} a').click(function() {{ $('#{4}').val('Layout'); }});
                    $('#{3} a').click(function() {{ $('#{4}').val('Site'); }});
                }});",
                    _ZoneName,
                    liPage.ClientID,
                    liLayout.ClientID,
                    liSite.ClientID,
                    hfOption.ClientID);

                this.Page.ClientScript.RegisterStartupScript(this.GetType(), string.Format("zone-add-load-{0}", this.ClientID), script, true);
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Shows the detail for zone.
        /// </summary>
        /// <param name="zoneName">Name of the zone.</param>
        private void ShowDetailForZone(string zoneName)
        {
            int pageId = hfPageId.Value.AsInteger();
            var page   = PageCache.Get(pageId);

            hlInvalidZoneWarning.Visible = _invalidPageZones != null && _invalidPageZones.Contains(zoneName);

            lZoneTitle.Text = string.Format("{0} Zone", zoneName);
            lZoneIcon.Text  = "<i class='fa fa-th-large'></i>";
            if (page != null)
            {
                // Refresh ZoneList's "Count" text
                foreach (var zoneListItem in ddlZones.Items.OfType <ListItem>())
                {
                    var zoneBlockCount = page.Blocks.Where(a => a.Zone.Equals(zoneListItem.Value, StringComparison.OrdinalIgnoreCase)).Count();
                    zoneListItem.Text = string.Format("{0} ({1})", zoneListItem.Value, zoneBlockCount);
                }

                // update SiteBlock, LayoutBlock and PageBlock repeaters
                var zoneBlocks = page.Blocks.Where(a => a.Zone == zoneName).ToList();

                var blockTypes = zoneBlocks.Select(a => a.BlockType).Distinct().ToList();

                // if the blockType has changed since it IsInstancePropertiesVerified, check for updated attributes
                foreach (var blockType in blockTypes)
                {
                    if (blockType != null && !blockType.IsInstancePropertiesVerified)
                    {
                        try
                        {
                            int blockTypeId = blockType.Id;
                            using (var rockContext = new RockContext())
                            {
                                var  blockCompiledType = blockType.GetCompiledType();
                                int? blockEntityTypeId = EntityTypeCache.Get(typeof(Block)).Id;
                                bool attributesUpdated = Rock.Attribute.Helper.UpdateAttributes(blockCompiledType, blockEntityTypeId, "BlockTypeId", blockTypeId.ToString(), rockContext);
                                BlockTypeCache.Get(blockTypeId).MarkInstancePropertiesVerified(true);
                            }
                        }
                        catch
                        {
                            // ignore if it can't be compiled
                        }
                    }
                }

                rptSiteBlocks.DataSource = zoneBlocks.Where(a => a.BlockLocation == BlockLocation.Site).ToList();
                rptSiteBlocks.DataBind();

                rptLayoutBlocks.DataSource = zoneBlocks.Where(a => a.BlockLocation == BlockLocation.Layout).ToList();
                rptLayoutBlocks.DataBind();

                rptPageBlocks.DataSource = zoneBlocks.Where(a => a.BlockLocation == BlockLocation.Page).ToList();
                rptPageBlocks.DataBind();
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Handles the Click event of the lbCalendarsDetail control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void lbCalendarsDetail_Click(object sender, EventArgs e)
        {
            var qryParams = new Dictionary <string, string>();
            var pageCache = PageCache.Get(RockPage.PageId);

            if (pageCache != null && pageCache.ParentPage != null && pageCache.ParentPage.ParentPage != null)
            {
                NavigateToPage(pageCache.ParentPage.ParentPage.Guid, qryParams);
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="pageId">The page identifier.</param>
        public void ShowDetail(int pageId)
        {
            hfPageId.Value = pageId.ToString();
            var page = PageCache.Get(pageId);

            this.Visible = page != null;
            LoadDropDowns();

            ShowDetailForZone(ddlZones.SelectedValue);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Gets the page cache.
        /// </summary>
        /// <returns></returns>
        private PageCache GetPageCache()
        {
            if (_pageCache == null)
            {
                var pageId = PageParameter(PageParamKey.Page).AsInteger();
                _pageCache = PageCache.Get(pageId);
            }

            return(_pageCache);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Determines whether the given PageId or Route is exclusive to another site.
        /// </summary>
        /// <param name="requestingSite">The requesting site.</param>
        /// <param name="pageId">The page identifier.</param>
        /// <returns>
        ///   <c>true</c> if [is page exclusive to another site] [the specified requesting site]; otherwise, <c>false</c>.
        /// </returns>
        private static bool IsPageExclusiveToAnotherSite(SiteCache requestingSite, int?pageId)
        {
            if (pageId != null)
            {
                var pageSite = PageCache.Get(pageId.Value)?.Layout.Site;
                return(pageSite == null ? false : pageSite.EnableExclusiveRoutes && requestingSite.Id != pageSite.Id);
            }

            return(false);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Builds the control.
        /// </summary>
        /// <param name="group">The group.</param>
        /// <param name="resourceTypes">The resource types.</param>
        /// <param name="resources">The resources.</param>
        public void BuildControl(Group group, List <GroupTypeCache> resourceTypes, Dictionary <string, AttributeValueCache> resources)
        {
            if (_group == null)
            {
                _group = group;
            }

            if (_resourceTypes == null)
            {
                _resourceTypes = resourceTypes;
            }

            if (_resources == null)
            {
                _resources = resources;
            }

            // Set up group panel
            SetGroupHeader(group);

            pnlGroupMembers.DataKeyNames             = new string[] { "Id" };
            pnlGroupMembers.PersonIdField            = "PersonId";
            pnlGroupMembers.RowSelected             += pnlGroupMembers_EditClick;
            pnlGroupMembers.RowDataBound            += pnlGroupMembers_RowDataBound;
            pnlGroupMembers.GridRebind              += pnlGroupMembers_GridRebind;
            pnlGroupMembers.Actions.AddClick        += pnlGroupMembers_AddClick;
            pnlGroupMembers.GetRecipientMergeFields += pnlGroupMembers_GetRecipientMergeFields;
            pnlGroupMembers.RowItemText              = _group.GroupType.GroupTerm + " " + _group.GroupType.GroupMemberTerm;
            pnlGroupMembers.ExportFilename           = _group.Name;
            pnlGroupMembers.ExportSource             = ExcelExportSource.ColumnOutput;
            pnlGroupMembers.AllowPaging              = false;

            // custom javascript (see GroupMemberList.ascx ) handles deletes instead
            pnlGroupMembers.ShowConfirmDeleteDialog = false;
            pnlGroupMembers.Actions.ShowMergePerson = false;

            pnlGroupMembers.Actions.ShowAdd = true;
            pnlGroupMembers.IsDeleteEnabled = true;

            // if group is being sync'ed remove ability to add/delete members
            if (_group != null && _group.GroupSyncs != null && _group.GroupSyncs.Count() > 0)
            {
                pnlGroupMembers.IsDeleteEnabled = false;
                pnlGroupMembers.Actions.ShowAdd = false;
                hlSyncStatus.Visible            = true;

                // link to the DataView
                var pageId     = PageCache.Get(Rock.SystemGuid.Page.DATA_VIEWS.AsGuid()).Id;
                var dataViewId = _group.GroupSyncs.FirstOrDefault().SyncDataViewId;
                hlSyncSource.NavigateUrl = System.Web.VirtualPathUtility.ToAbsolute(string.Format("~/page/{0}?DataViewId={1}", pageId, dataViewId));
            }

            AddDynamicControls();
            BindGroupMembersGrid();
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            _accountId = PageParameter("AccountId");

            var detailPageReference = new Rock.Web.PageReference(GetAttributeValue("DetailPage"));

            // NOTE: if the detail page is the current page, use the current route instead of route specified in the DetailPage (to preserve old behavior)
            if (detailPageReference == null || detailPageReference.PageId == this.RockPage.PageId)
            {
                hfPageRouteTemplate.Value = (this.RockPage.RouteData.Route as System.Web.Routing.Route).Url;
                hfDetailPageUrl.Value     = new Rock.Web.PageReference(this.RockPage.PageId).BuildUrl();
            }
            else
            {
                hfPageRouteTemplate.Value = string.Empty;
                var pageCache = PageCache.Get(detailPageReference.PageId);
                if (pageCache != null)
                {
                    var route = pageCache.PageRoutes.FirstOrDefault(a => a.Id == detailPageReference.RouteId);
                    if (route != null)
                    {
                        hfPageRouteTemplate.Value = route.Route;
                    }
                }

                hfDetailPageUrl.Value = detailPageReference.BuildUrl();
            }

            // this event gets fired after block settings are updated. it's nice to repaint the screen if these settings would alter it
            this.BlockUpdated += Block_BlockUpdated;
            this.AddConfigurationUpdateTrigger(upAccountType);

            pnlConfigPanel.Visible    = this.GetAttributeValue("ShowFilterOption").AsBooleanOrNull() ?? false;
            pnlRolloverConfig.Visible = this.GetAttributeValue("ShowFilterOption").AsBooleanOrNull() ?? false;
            hfUsePublicName.Value     = this.GetAttributeValue("UsePublicName").AsBoolean(false).ToTrueFalse();

            if (pnlConfigPanel.Visible)
            {
                var hideInactiveAccounts = this.GetUserPreference("HideInactiveAccounts").AsBooleanOrNull();
                if (!hideInactiveAccounts.HasValue)
                {
                    hideInactiveAccounts = this.GetAttributeValue("InitialActiveSetting") == "1";
                }

                tglHideInactiveAccounts.Checked = hideInactiveAccounts ?? true;
            }
            else
            {
                // if the filter is hidden, don't show inactive accounts
                tglHideInactiveAccounts.Checked = true;
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Gets the Guid for the Page that has the specified Id
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns></returns>
        public override Guid?GetGuid(int id)
        {
            var cacheItem = PageCache.Get(id);

            if (cacheItem != null)
            {
                return(cacheItem.Guid);
            }

            return(null);
        }