Esempio n. 1
0
        /// <summary>
        /// Creates the HTML controls required to configure this type of field
        /// </summary>
        /// <returns></returns>
        public override List <Control> ConfigurationControls()
        {
            var controls = base.ConfigurationControls();

            // build a drop down list of defined types (the one that gets selected is
            // used to build a list of defined values)
            var ddl = new RockDropDownList();

            controls.Add(ddl);
            ddl.AutoPostBack          = true;
            ddl.EnhanceForLongLists   = true;
            ddl.SelectedIndexChanged += OnQualifierUpdated;
            ddl.Label = "Content Channel";
            ddl.Help  = "Content Channel to select items from, if left blank any content channel's item can be selected.";

            ddl.Items.Add(new ListItem());

            var contentChannels = ContentChannelCache.All().OrderBy(a => a.Name).ToList();

            contentChannels.ForEach(g =>
                                    ddl.Items.Add(new ListItem(g.Name, g.Id.ToString().ToUpper()))
                                    );

            return(controls);
        }
 /// <summary>
 /// Bind content channel dropdown
 /// </summary>
 private void BindContentChannelDropdown()
 {
     ddlContentChannel.Items.Clear();
     ddlContentChannel.Items.Add(new ListItem());
     foreach (var contentChannel in ContentChannelCache.All().OrderBy(a => a.Name))
     {
         ddlContentChannel.Items.Add(new ListItem(contentChannel.Name, contentChannel.Guid.ToString()));
     }
 }
        /// <summary>
        /// Loads the content channels.
        /// </summary>
        private void LoadContentChannels()
        {
            _ddlContentChannel.Items.Clear();
            _ddlContentChannel.Items.Add(new ListItem());

            var contentChannels = ContentChannelCache.All().OrderBy(a => a.Name).ToList();

            foreach (var contentChannel in contentChannels)
            {
                _ddlContentChannel.Items.Add(new ListItem(contentChannel.Name, contentChannel.Id.ToString().ToUpper()));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Shows the settings.
        /// </summary>
        protected override void ShowSettings()
        {
            pnlSettings.Visible = true;
            ddlContentChannel.Items.Clear();
            ddlContentChannel.Items.Add(new ListItem());
            foreach (var contentChannel in ContentChannelCache.All().OrderBy(a => a.Name))
            {
                ddlContentChannel.Items.Add(new ListItem(contentChannel.Name, contentChannel.Guid.ToString()));
            }

            ddlLaunchWorkflowCondition.Items.Clear();
            foreach (LaunchWorkflowCondition launchWorkflowCondition in Enum.GetValues(typeof(LaunchWorkflowCondition)))
            {
                ddlLaunchWorkflowCondition.Items.Add(new ListItem(launchWorkflowCondition.ConvertToString(true), launchWorkflowCondition.ConvertToInt().ToString()));
            }

            var channelGuid = this.GetAttributeValue("ContentChannel").AsGuidOrNull();

            ddlContentChannel.SetValue(channelGuid);
            UpdateSocialMediaDropdowns(channelGuid);

            cblStatus.BindToEnum <ContentChannelItemStatus>();
            foreach (string status in GetAttributeValue("Status").SplitDelimitedValues())
            {
                var li = cblStatus.Items.FindByValue(status);
                if (li != null)
                {
                    li.Selected = true;
                }
            }

            var ppFieldType = new PageReferenceFieldType();

            ppFieldType.SetEditValue(ppDetailPage, null, GetAttributeValue("DetailPage"));
            tbContentChannelQueryParameter.Text = this.GetAttributeValue("ContentChannelQueryParameter");
            ceLavaTemplate.Text        = this.GetAttributeValue("LavaTemplate");
            nbOutputCacheDuration.Text = this.GetAttributeValue("OutputCacheDuration");
            nbItemCacheDuration.Text   = this.GetAttributeValue("ItemCacheDuration");

            DefinedValueService definedValueService = new DefinedValueService(new RockContext());

            cblCacheTags.DataSource = definedValueService.GetByDefinedTypeGuid(Rock.SystemGuid.DefinedType.CACHE_TAGS.AsGuid()).Select(v => v.Value).ToList();
            cblCacheTags.DataBind();
            string[] selectedCacheTags = this.GetAttributeValue("CacheTags").SplitDelimitedValues();
            foreach (ListItem cacheTag in cblCacheTags.Items)
            {
                cacheTag.Selected = selectedCacheTags.Contains(cacheTag.Value);
            }

            cbSetPageTitle.Checked = this.GetAttributeValue("SetPageTitle").AsBoolean();
            cbMergeContent.Checked = GetAttributeValue("MergeContent").AsBoolean();

            if (this.GetAttributeValue("LogInteractions").AsBoolean())
            {
                cbLogInteractions.Checked = true;
                cbWriteInteractionOnlyIfIndividualLoggedIn.Visible = true;
                cbWriteInteractionOnlyIfIndividualLoggedIn.Checked = this.GetAttributeValue("WriteInteractionOnlyIfIndividualLoggedIn").AsBoolean();
            }
            else
            {
                cbLogInteractions.Checked = false;
                cbWriteInteractionOnlyIfIndividualLoggedIn.Visible = false;
                cbWriteInteractionOnlyIfIndividualLoggedIn.Checked = false;
            }

            var rockContext = new RockContext();

            // Workflow
            Guid?workflowTypeGuid = this.GetAttributeValue("WorkflowType").AsGuidOrNull();

            if (workflowTypeGuid.HasValue)
            {
                wtpWorkflowType.SetValue(new WorkflowTypeService(rockContext).GetNoTracking(workflowTypeGuid.Value));
            }
            else
            {
                wtpWorkflowType.SetValue(null);
            }

            ShowHideControls();

            cbLaunchWorkflowOnlyIfIndividualLoggedIn.Checked = this.GetAttributeValue("LaunchWorkflowOnlyIfIndividualLoggedIn").AsBoolean();
            ddlLaunchWorkflowCondition.SetValue(this.GetAttributeValue("LaunchWorkflowCondition"));

            // Social Media
            ddlMetaDescriptionAttribute.SetValue(this.GetAttributeValue("MetaDescriptionAttribute"));
            ddlOpenGraphType.SetValue(this.GetAttributeValue("OpenGraphType"));
            ddlOpenGraphTitleAttribute.SetValue(this.GetAttributeValue("OpenGraphTitleAttribute"));
            ddlOpenGraphDescriptionAttribute.SetValue(this.GetAttributeValue("OpenGraphDescriptionAttribute"));
            ddlOpenGraphImageAttribute.SetValue(this.GetAttributeValue("OpenGraphImageAttribute"));

            ddlTwitterTitleAttribute.SetValue(this.GetAttributeValue("TwitterTitleAttribute"));
            ddlTwitterDescriptionAttribute.SetValue(this.GetAttributeValue("TwitterDescriptionAttribute"));
            ddlTwitterImageAttribute.SetValue(this.GetAttributeValue("TwitterImageAttribute"));
            ddlTwitterCard.SetValue(this.GetAttributeValue("TwitterCard"));

            mdSettings.Show();
        }
        /// <summary>
        /// Gets the list source.
        /// </summary>
        /// <value>
        /// The list source.
        /// </value>
        internal override Dictionary <string, string> GetListSource(Dictionary <string, ConfigurationValue> configurationValues)
        {
            var allChannels = ContentChannelCache.All();

            return(allChannels.ToDictionary(c => c.Guid.ToString(), c => c.Name));
        }