示例#1
0
        protected virtual IConfiguration[] ResolveConfigurations()
        {
            var config = HttpContext.Current.Request.QueryString["configuration"];
            var targetConfigurations = ControlPanelUtility.ResolveConfigurationsFromQueryParameter(config);

            if (targetConfigurations.Length == 0)
            {
                throw new ArgumentException("Configuration(s) requested were not defined.");
            }

            return(targetConfigurations);
        }
示例#2
0
        public void Render(HtmlTextWriter writer)
        {
            writer.Write("<h4>Initial Setup</h4>");

            if (ControlPanelUtility.HasAnySourceItems(_configuration))
            {
                writer.Write("<p>Would you like to perform an initial serialization of all configured items using the options outlined above now? This is required to start using this configuration.</p>");

                writer.Write("<a class=\"button\" href=\"?verb=Reserialize&amp;configuration={0}\">Perform Initial Serialization of <em>{1}</em></a>", HttpUtility.UrlEncode(_configuration.Name), _configuration.Name);
            }
            else
            {
                writer.Write("<p>Cannot perform initial serialization until the predicate configuration includes valid root items.</p>");
            }
        }
示例#3
0
        protected virtual IEnumerable <IControlPanelControl> GetDefaultControls()
        {
            var hasSerializedItems      = Configurations.All(ControlPanelUtility.HasAnySerializedItems);
            var hasValidSerializedItems = Configurations.All(ControlPanelUtility.HasAnySourceItems);

            var isAuthorized = Authorization.IsAllowed;

            yield return(new Html5HeadAndStyles());

            var heading = new Heading();

            heading.HasSerializedItems      = hasSerializedItems;
            heading.HasValidSerializedItems = hasValidSerializedItems;
            heading.IsAuthenticated         = isAuthorized;
            yield return(heading);

            if (isAuthorized)
            {
                if (Configurations.Length > 1 && hasSerializedItems && hasValidSerializedItems)
                {
                    yield return(new Literal("<h2>Global Actions</h2>"));

                    yield return(new ControlOptions());

                    yield return(new Literal("<h2>Configurations</h2>"));
                }

                foreach (var configuration in Configurations)
                {
                    var configurationHasSerializedItems = ControlPanelUtility.HasAnySerializedItems(configuration);
                    var configurationHasValidRootItems  = ControlPanelUtility.HasAnySourceItems(configuration);

                    yield return(new Literal("<div class=\"configuration\"><h3>{0}</h3><section>".FormatWith(configuration.Name)));

                    if (!configurationHasValidRootItems)
                    {
                        yield return(new Literal("<p class=\"warning\">This configuration's predicate cannot resolve any valid root items. This usually means it is configured to look for nonexistant paths or GUIDs. Please review your predicate configuration.</p>"));
                    }
                    else if (!configurationHasSerializedItems)
                    {
                        yield return(new Literal("<p class=\"warning\">This configuration does not currently have any valid serialized items. You cannot sync it until you perform an initial serialization.</p>"));
                    }

                    if (configurationHasSerializedItems)
                    {
                        var controlOptions = configuration.Resolve <ControlOptions>();
                        controlOptions.ConfigurationName = configuration.Name;
                        yield return(controlOptions);
                    }

                    var configDetails = configuration.Resolve <ConfigurationDetails>();
                    configDetails.ConfigurationName = configuration.Name;
                    configDetails.CollapseByDefault = configurationHasSerializedItems;
                    yield return(configDetails);

                    if (!configurationHasSerializedItems)
                    {
                        yield return(new InitialSetup(configuration));
                    }

                    yield return(new Literal("</section></div>"));
                }
            }
            else
            {
                yield return(new AccessDenied());
            }

            yield return(new Html5Footer());
        }