Ejemplo n.º 1
0
        public FixedPropertyEditors(IUmbracoApplicationContext fakeUmbracoApplicationContext)
        {
            var fakeBackOfficeContext = new FakeBackOfficeRequestContext(fakeUmbracoApplicationContext);

            _propertyEditors = new PropertyEditor[]
                {
                    new NonMandatoryPropertyEditor(Guid.Parse("D3DC1AC8-F83D-4D73-A13B-024E3100A600"), "rte", ""),
                    new NonMandatoryPropertyEditor(Guid.Parse("781FA5A4-C26D-4BBB-9F58-6CBBE0A9D14A"), "cust", ""),
                    new NonMandatoryPropertyEditor(Guid.Parse("3F5ED845-7018-4BDE-AB4E-C7106EE0992D"), "text", ""),
                    new NonMandatoryPropertyEditor(Guid.Parse("9CCB7060-3550-11E0-8A80-074CDFD72085"), "swatch", ""),
                    new NonMandatoryPropertyEditor(Guid.Parse("2B4DF3F1-C84E-4611-87EE-1D90ED437337"), "tags", ""),
                    new NonMandatoryPropertyEditor(),
                    new MandatoryPropertyEditor(),
                    new RegexPropertyEditor(),
                    new PreValueRegexPropertyEditor(),
                    //ensure node name is there
                    new NodeNameEditor(fakeBackOfficeContext.Application),
                    new SelectedTemplateEditor(fakeBackOfficeContext),
                    new UploadEditor(fakeBackOfficeContext),
                    new LabelEditor(),
                    new TrueFalseEditor(),
                    new DateTimePickerEditor(),
                    new NumericEditor(),
                    new TreeNodePicker(Enumerable.Empty<Lazy<TreeController, TreeMetadata>>()),
                    new ListPickerEditor(),
                    new TestContentAwarePropertyEditor()
                };
        }
Ejemplo n.º 2
0
 public RenderRouteHandler(IControllerFactory controllerFactory, 
     IUmbracoApplicationContext applicationContext, 
     IRenderModelFactory modelFactory)
 {
     _modelFactory = modelFactory;
     _applicationContext = applicationContext;
     _controllerFactory = controllerFactory;
 }
Ejemplo n.º 3
0
 public IgnorePluginRoute(string url, string areaName, IUmbracoApplicationContext appContext, IEnumerable<ControllerPluginMetadata> toIgnore)
     : base(url, new StopRoutingHandler())
 {
     _areaName = areaName;
     _appContext = appContext;
     _toIgnore = toIgnore;
     Constraints = new RouteValueDictionary { { "ignore-existing", new IgnoreExistingControllersConstraint(appContext, _areaName, _toIgnore) } };
 }
Ejemplo n.º 4
0
 public RenderBootstrapper(
     IUmbracoApplicationContext applicationContext, 
     IRouteHandler routeHandler, 
     IRenderModelFactory renderModelFactory)
 {
     _routeHandler = routeHandler;
     _renderModelFactory = renderModelFactory;
     _applicationContext = applicationContext;
 }
        /// <summary>
        /// Creates a custom individual route for the specified controller plugin. Individual routes
        /// are required by controller plugins to map to a unique URL based on ID.
        /// </summary>
        /// <typeparam name="T">An PluginAttribute</typeparam>
        /// <param name="controllerName"></param>
        /// <param name="controllerType"></param>
        /// <param name="routes">An existing route collection</param>
        /// <param name="routeIdParameterName">the data token name for the controller plugin</param>
        /// <param name="controllerSuffixName">
        /// The suffix name that the controller name must end in before the "Controller" string for example:
        /// ContentTreeController has a controllerSuffixName of "Tree"
        /// </param>
        /// <param name="baseUrlPath">
        /// The base name of the URL to create for example: Umbraco/[PackageName]/Trees/ContentTree/1 has a baseUrlPath of "Trees"
        /// </param>
        /// <param name="defaultAction"></param>
        /// <param name="defaultId"></param>
        /// <param name="isDefaultUmbracoPlugin">If it's a default (built in) Umbraco plugin, then make the route with the GUID</param>
        /// <param name="area"></param>
        /// <param name="controllerId"></param>
        /// <param name="appContext"></param>
        /// <param name="umbracoTokenValue">The DataToken value to set for the 'umbraco' key, this defaults to 'backoffice' </param>
        internal static void RouteControllerPlugin(this AreaRegistration area, Guid controllerId, string controllerName, Type controllerType, RouteCollection routes,
                                                   string routeIdParameterName, string controllerSuffixName, string baseUrlPath, string defaultAction, object defaultId,
                                                   bool isDefaultUmbracoPlugin, IUmbracoApplicationContext appContext, string umbracoTokenValue = "backoffice")
        {
            Mandate.ParameterNotNullOrEmpty(controllerName, "controllerName");
            Mandate.ParameterNotNullOrEmpty(routeIdParameterName, "routeIdParameterName");
            Mandate.ParameterNotNullOrEmpty(controllerSuffixName, "controllerSuffixName");
            Mandate.ParameterNotNullOrEmpty(defaultAction, "defaultAction");
            Mandate.ParameterNotNull(controllerType, "controllerType");
            Mandate.ParameterNotNull(routes, "routes");
            Mandate.ParameterNotNull(defaultId, "defaultId");

            //the url structure will change whether or not it is a built in Umbraco plugin.
            //url to match - if it's a non-Umbraco plugin use the GUID to route the request.
            //routes are explicitly name with controller names.
            //if its a plugin controller, then the route will always start with /Umbraco/ (BackOfficePath)
            var url = isDefaultUmbracoPlugin
                          ? area.AreaName + "/" + baseUrlPath + "/" + controllerName + "/{action}/{id}"
                          : baseUrlPath.IsNullOrWhiteSpace()
                                ? appContext.Settings.UmbracoPaths.BackOfficePath + "/" + area.AreaName + "/" + controllerName + "/{action}/{id}"
                                : appContext.Settings.UmbracoPaths.BackOfficePath + "/" + area.AreaName + "/" + baseUrlPath + "/" + controllerName + "/{action}/{id}";

            //create a new route with custom name, specified url, and the namespace of the controller plugin
            var controllerPluginRoute = routes.MapRoute(
                //name
                string.Format("umbraco-{0}-{1}", controllerName, controllerId),
                //url format
                url,
                //set the namespace of the controller to match
                new[] { controllerType.Namespace });

            //set defaults
            controllerPluginRoute.Defaults = new RouteValueDictionary(
                new Dictionary<string, object>
                    {
                        { "controller", controllerName },
                        { routeIdParameterName, controllerId.ToString("N") },
                        { "action", defaultAction },
                        { "id", defaultId }    
                    });

            //constraints: only match controllers ending with 'controllerSuffixName' and only match this controller's ID for this route            
            controllerPluginRoute.Constraints = new RouteValueDictionary(
                new Dictionary<string, object>
                    {
                        { "controller", @"(\w+)" + controllerSuffixName },
                        { routeIdParameterName, Regex.Escape(controllerId.ToString("N")) }
                    });
            //now add our custom back office route constraint
            controllerPluginRoute.Constraints.Add("backOffice", new BackOfficeRouteConstraint(appContext));

            //match this area
            controllerPluginRoute.DataTokens.Add("area", area.AreaName);
            controllerPluginRoute.DataTokens.Add("umbraco", umbracoTokenValue); //ensure the umbraco token is set

        }
        public RoutableRequestContext(IUmbracoApplicationContext applicationContext, ComponentRegistrations components, IRoutingEngine routingEngine)
        {
            Mandate.ParameterNotNull(applicationContext, "applicationContext");
            Mandate.ParameterNotNull(components, "components");
            Mandate.ParameterNotNull(routingEngine, "routingEngine");

            Application = applicationContext;
            RegisteredComponents = components;
            RoutingEngine = routingEngine;
        }
        /// <summary>
        /// Creates the Umbraco authentication ticket, this will look up the associated User
        /// for the supplied username in Hive
        /// </summary>
        /// <param name="http">The HTTP.</param>
        /// <param name="username">The username.</param>
        /// <param name="appContext">The app context.</param>
        public static void CreateUmbracoAuthTicket(this HttpContextBase http, string username, IUmbracoApplicationContext appContext)
        {
            using (var uow = appContext.Hive.OpenWriter<ISecurityStore>(new Uri("security://users")))
            {
                var user = BackOfficeMembershipProvider.GetUmbracoUser(appContext, uow, username, false);
                if (user == null)
                    throw new NullReferenceException("No User found with username " + username);

                http.CreateUmbracoAuthTicket(user);
            }         
        }
 /// <summary>
 /// Constructor using a specific UmbracoSettings object
 /// </summary>
 /// <param name="applicationContext"></param>
 /// <param name="componentRegistrar"></param>
 public UmbracoAreaRegistration(
     IUmbracoApplicationContext applicationContext,
     ComponentRegistrations componentRegistrar)
 {
     _applicationContext = applicationContext;
     _umbracoSettings = _applicationContext.Settings;
     _componentRegistrar = componentRegistrar;
     _treeControllers = _componentRegistrar.TreeControllers;
     _editorControllers = _componentRegistrar.EditorControllers;
     _surfaceControllers = _componentRegistrar.SurfaceControllers;
 }
        public PackageAreaRegistration(DirectoryInfo packageFolder,
            IUmbracoApplicationContext applicationContext,
            ComponentRegistrations componentRegistrar)
        {
            //TODO: do we need to validate the package name??

            _packageName = packageFolder.Name;

            _packageFolder = packageFolder;
            _applicationContext = applicationContext;
            _componentRegistrar = componentRegistrar;
            _treeControllers = _componentRegistrar.TreeControllers;
            _editorControllers = _componentRegistrar.EditorControllers;
            _surfaceControllers = componentRegistrar.SurfaceControllers;
        }
        public DefaultBackOfficeRequestContext(IUmbracoApplicationContext applicationContext,
            HttpContextBase httpContext,
            ComponentRegistrations components,
            IPackageContext packageContext,
            IRoutingEngine routingEngine)
            : base(applicationContext, components, routingEngine)
        {

            //create the IO resolvers
            var urlHelper = new UrlHelper(httpContext.Request.RequestContext);
            DocumentTypeIconResolver = new DocumentTypeIconFileResolver(httpContext.Server, applicationContext.Settings, urlHelper);
            DocumentTypeThumbnailResolver = new DocumentTypeThumbnailFileResolver(httpContext.Server, applicationContext.Settings, urlHelper);
            ApplicationIconResolver = new ApplicationIconFileResolver(httpContext.Server, applicationContext.Settings, urlHelper);

            PackageContext = packageContext;
        }
 public FakeBackOfficeRequestContext(IUmbracoApplicationContext application, IRoutingEngine engine)
     : base(application, engine)
 {
     
 }
Ejemplo n.º 12
0
 public UmbracoRenderModel(IUmbracoApplicationContext baseContext, Content renderItem)
 {
     _baseContext = baseContext;
     _renderItem = renderItem;
 }
 /// <summary>
 ///   Initializes a new instance of the <see cref = "T:System.Web.Security.MembershipProvider" /> class.
 /// </summary>
 public BackOfficeMembershipProvider()
 {
     _appContext = DependencyResolver.Current.GetService <IUmbracoApplicationContext>();
     _hive       = _appContext.Hive.GetWriter <ISecurityStore>(new Uri("security://users"));
 }
        /// <summary>
        /// Creates the Umbraco authentication ticket, this will look up the associated User
        /// for the supplied username in Hive
        /// </summary>
        /// <param name="http">The HTTP.</param>
        /// <param name="username">The username.</param>
        /// <param name="appContext">The app context.</param>
        public static void CreateUmbracoAuthTicket(this HttpContextBase http, string username, IUmbracoApplicationContext appContext)
        {
            using (var uow = appContext.Hive.OpenWriter <ISecurityStore>(new Uri("security://users")))
            {
                var user = BackOfficeMembershipProvider.GetUmbracoUser(appContext, uow, username, false);
                if (user == null)
                {
                    throw new NullReferenceException("No User found with username " + username);
                }

                http.CreateUmbracoAuthTicket(user);
            }
        }
Ejemplo n.º 15
0
 public MacroRenderer(ComponentRegistrations componentRegistrations, IRoutableRequestContext routableRequestContext)
 {
     _componentRegistrations = componentRegistrations;
     _routableRequestContext = routableRequestContext;
     _applicationContext     = routableRequestContext.Application;
 }
Ejemplo n.º 16
0
 public BackOfficeRouteConstraint(IUmbracoApplicationContext applicationContext)
 {
     _applicationContext = applicationContext;
 }
Ejemplo n.º 17
0
 public RichTextBoxEditor(IUmbracoApplicationContext appContext)
 {
     _appContext = appContext;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object"/> class.
 /// </summary>
 public RenderControllerFactory(IUmbracoApplicationContext applicationContext)
 {
     Mandate.ParameterNotNull(applicationContext, "applicationContext");
     ApplicationContext = applicationContext;
 }
Ejemplo n.º 19
0
 public UmbracoRenderModel(IUmbracoApplicationContext baseContext, Content renderItem)
 {
     _baseContext = baseContext;
     _renderItem  = renderItem;
 }
Ejemplo n.º 20
0
 public UmbracoRenderModel(IUmbracoApplicationContext baseContext, Func <Content> renderItemDeferred)
 {
     _baseContext        = baseContext;
     _renderItemDeferred = renderItemDeferred;
 }
 public ConfigurationTaskContext(IUmbracoApplicationContext applicationContext, IEnumerable <ITaskParameter> parameters, ITask task)
 {
     Parameters         = parameters.ToDictionary(x => x.Name, x => x.Value);
     Task               = task;
     ApplicationContext = applicationContext;
 }
 public RichTextBoxPreValueModel(IUmbracoApplicationContext appContext)
 {
     _appContext = appContext;
 }
Ejemplo n.º 23
0
 public FakeBackOfficeRequestContext(IUmbracoApplicationContext application)
     : base(application)
 {
 }
Ejemplo n.º 24
0
        public virtual IUmbracoApplicationContext Start()
        {
            LogHelper.TraceIfEnabled<UmbracoWebApplication>("Start called. Product info: {0} build {1}", () => UmbracoWebApplication.ProductVersionInfo, () => UmbracoWebApplication.ProductVersion);
            using (var bootManager = CreateBootManager())
            {
                bootManager
                    .AddAppErrorHandler(OnApplicationError)
                    .InitializeContainer(() => _containerBuilder)
                    .AddContainerBuildingHandler(OnContainerBuilding)
                    .AddContainerBuildingCompleteHandler(OnContainerBuildingComplete)
                    .SetMvcResolverFactory(_mvcResolverFactory)
                    .MvcAreaRegistration(_registerAreas)
                    .MvcCustomRouteRegistration(_registerCustomRoutes)
                    .MvcDefaultRouteRegistration(_registerDefaultRoutes)
                    .MvcGlobalFilterRegistration(_registerFilters);

                _appContext = Boot(bootManager);
                _isStarted = true;
            }
            return AppContext;
        }
Ejemplo n.º 25
0
 public static DevDataset GetDemoData(IUmbracoApplicationContext appContext, IAttributeTypeRegistry attributeTypeRegistry)
 {
     return(new DevDataset(new MockedPropertyEditorFactory(appContext), appContext.FrameworkContext, attributeTypeRegistry));
 }
Ejemplo n.º 26
0
 public FakeBackOfficeRequestContext(IUmbracoApplicationContext application, IRoutingEngine engine)
     : base(application, engine)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultRoutingEngine"/> class.
 /// </summary>
 /// <param name="appContext">The routable request context.</param>
 /// <param name="httpContext"></param>
 public DefaultRoutingEngine(IUmbracoApplicationContext appContext, HttpContextBase httpContext)
 {
     _applicationContext = appContext;
     _httpContext        = httpContext;
 }
 public static bool AnyProvidersHaveStatus(this IUmbracoApplicationContext appContext, InstallStatusType status)
 {
     return(appContext.GetInstallStatus().Any(s => s.StatusType == status));
 }
 public UserGroupUsersEditorModel(string userGroupName, IUmbracoApplicationContext appContext)
 {
     _userGroupName = userGroupName;
     _appContext    = appContext;
 }
Ejemplo n.º 30
0
 public IgnoreExistingControllersConstraint(IUmbracoApplicationContext appContext, string areaName, IEnumerable<ControllerPluginMetadata> toIgnore)
 {
     _appContext = appContext;
     _areaName = areaName;
     _toIgnore = toIgnore.Select(x => x.ControllerName).ToArray();
 }
 public RenderRouteConstraint(IUmbracoApplicationContext applicationContext, IRenderModelFactory modelFactory)
     : base(applicationContext.Settings.RouteMatches)
 {
     _applicationContext = applicationContext;
     _modelFactory = modelFactory;
 }
 public MockedPropertyEditorFactory(IUmbracoApplicationContext appContext)
 {
     _propEditors = new FixedPropertyEditors(appContext).GetPropertyEditorDefinitions();
 }
 public ConfigurationTaskContext(IUmbracoApplicationContext applicationContext, IEnumerable<ITaskParameter> parameters, ITask task)
 {
     Parameters = parameters.ToDictionary(x => x.Name, x => x.Value);
     Task = task;
     ApplicationContext = applicationContext;
 }
 public MockedPropertyEditorFactory(IUmbracoApplicationContext appContext)
 {
     _propEditors = new FixedPropertyEditors(appContext).GetPropertyEditorDefinitions();
 }
Ejemplo n.º 35
0
 public static DevDataset GetDemoData(IUmbracoApplicationContext appContext, IAttributeTypeRegistry attributeTypeRegistry)
 {
     return new DevDataset(new MockedPropertyEditorFactory(appContext), appContext.FrameworkContext, attributeTypeRegistry);
 }
Ejemplo n.º 36
0
 public FakeRenderModelFactory(IUmbracoApplicationContext application)
 {
     _application = application;
 }
 public UserGroupUsersEditorModel(string userGroupName, IUmbracoApplicationContext appContext)
 {
     _userGroupName = userGroupName;
     _appContext = appContext;
 }
 public FakeBackOfficeRequestContext(IUmbracoApplicationContext application)
     : base(application)
 {
 }
Ejemplo n.º 39
0
 public DocumentTypePropertyModelBinder(IUmbracoApplicationContext applicationContext)
 {
     _applicationContext = applicationContext;
 }
Ejemplo n.º 40
0
 public UmbracoRenderModel(IUmbracoApplicationContext baseContext, Func<Content> renderItemDeferred)
 {
     _baseContext = baseContext;
     _renderItemDeferred = renderItemDeferred;
 }
 public MembersMembershipProvider(IHiveManager hiveManager, IUmbracoApplicationContext appContext)
 {
     base.HiveManager = hiveManager;
     this.AppContext = appContext;
 }
Ejemplo n.º 42
0
 public IgnoreExistingControllersConstraint(IUmbracoApplicationContext appContext, string areaName, IEnumerable <ControllerPluginMetadata> toIgnore)
 {
     _appContext = appContext;
     _areaName   = areaName;
     _toIgnore   = toIgnore.Select(x => x.ControllerName).ToArray();
 }
Ejemplo n.º 43
0
 public DictionaryHelper(IUmbracoApplicationContext appContext)
     : this(appContext.Hive, appContext.Settings.Languages)
 {
 }
 public DefaultRenderModelFactory(IUmbracoApplicationContext applicationContext)
 {
     _applicationContext = applicationContext;
 }
 public FakeControllerContext(IUmbracoApplicationContext context, Content page)
 {
     this.context = context;
     this.page = page;
 }
Ejemplo n.º 46
0
 public EnsureUniqueNameTask(IUmbracoApplicationContext applicationContext) 
     : base(applicationContext)
 { }
 /// <summary>
 ///   Initializes a new instance of the <see cref = "T:System.Web.Security.MembershipProvider" /> class.
 /// </summary>
 public BackOfficeMembershipProvider()
 {
     _appContext = DependencyResolver.Current.GetService<IUmbracoApplicationContext>();
     _hive = _appContext.Hive.GetWriter<ISecurityStore>(new Uri("security://users"));
 }
Ejemplo n.º 48
0
 protected AbstractWebTask(IUmbracoApplicationContext applicationContext) : base(applicationContext.FrameworkContext)
 {
     ApplicationContext = applicationContext;
 }
        internal static User GetUmbracoUser(IUmbracoApplicationContext appContext, IGroupUnit<ISecurityStore> uow, string username, bool userIsOnline)
        {
            // TODO: Enable type of extension method GetEntityByRelationType to be passed all the way to the provider
            // so that it can use the typemappers collection to map back to a User

            // APN: I changed SingleOrDefault to FirstOrDefault to guard against YSODs if somehow a duplicate user gets into the store [31/Jan]
            var userEntity = uow.Repositories
                .GetEntityByRelationType<TypedEntity>(
                    FixedRelationTypes.DefaultRelationType, FixedHiveIds.UserVirtualRoot)
                .FirstOrDefault(x => x.Attribute<string>(UserSchema.UsernameAlias) == username);


            if (userEntity == null) return null;

            var user = new User();
            user.SetupFromEntity(userEntity);

            if (userIsOnline)
            {
                user.LastActivityDate = DateTime.UtcNow;

                uow.Repositories.AddOrUpdate(user);
                uow.Complete();
            }

            return user;
        }
 public DocumentTypePropertyModelBinder(IUmbracoApplicationContext applicationContext)
 {
     _applicationContext = applicationContext;
 }
Ejemplo n.º 51
0
 protected AbstractWebTask(IUmbracoApplicationContext applicationContext) : base(applicationContext.FrameworkContext)
 {
     ApplicationContext = applicationContext;
 }