예제 #1
0
 public ContentSectionTable(HostSection web, EngineSection engine, DatabaseSection database, EditSection management)
 {
     Web        = web;
     Engine     = engine;
     Database   = database;
     Management = management;
 }
예제 #2
0
 public UploadedFilesResizer(IFileSystem files, ImageResizer resizer, EditSection config)
 {
     this.files = files;
     this.resizer = resizer;
     this.images = config.Images;
     sizeNames = config.Images.Sizes.AllElements.Select(s => s.Name).ToArray();
 }
		public DefaultDirectorySelector(IHost host, EditSection config)
		{
			this.host = host;
			mode = config.DefaultDirectory.Mode;
			defaultFolderPath = config.DefaultDirectory.RootPath;
			uploadFolders = new List<string>(config.UploadFolders.Folders);
		}
예제 #4
0
        public override void SetUp()
        {
            base.SetUp();

            root = CreateOneItem<RootNode>(1, "root", null);
            start = CreateOneItem<RootNode>(2, "start", root);
            host = new Host(new ThreadContext(), root.ID, start.ID);

            fs = new FakeMappedFileSystem();
            fs.BasePath = AppDomain.CurrentDomain.BaseDirectory + @"\FileSystem\";

            vnf = new VirtualNodeFactory();
            config = new EditSection();

            injector = new FakeDependencyInjector();
            injector.injectors.Add(new EntityDependencySetter<IFileSystem>(fs));
            injector.injectors.Add(new EntityDependencySetter<IDependencyInjector>(injector));
            var sizeCache = new ImageSizeCache(new ConfigurationManagerWrapper { Sections = new ConfigurationManagerWrapper.ContentSectionTable(null, null, null, config) });
            injector.injectors.Add(new EntityDependencySetter<ImageSizeCache>(sizeCache));
            //nodeProvider = new FolderNodeProvider(fs, persister, injector);
            //initializer = new VirtualFolderInitializer(host, persister, fs, vnf, new Plugin.ConnectionMonitor().SetConnected(SystemStatusLevel.UpAndRunning), config, new ImageSizeCache(new ConfigurationManagerWrapper { Sections = new ConfigurationManagerWrapper.ContentSectionTable(null, null, null, config) }), nodeProvider);
            //nodeProvider = new FolderNodeProvider(fs, persister, injector);
            //nodeProvider = new FolderNodeProvider(fs, persister, injector);
            nodeProvider = new FolderNodeProvider(fs, persister.Repository, injector);
            initializer = new VirtualFolderInitializer(host, persister, fs, vnf, monitor = new Plugin.ConnectionMonitor().SetConnected(SystemStatusLevel.UpAndRunning), new UploadFolderSource(host, config), nodeProvider);
        }
예제 #5
0
        public override void SetUp()
        {
            base.SetUp();

			var edit = new EditSection();// { Editors = new PermissionElement(), Administrators  };
			finder = new PluginFinder(typeFinder, new SecurityManager(new ThreadContext(), edit), TestSupport.SetupEngineSection());
        }
 public ExternalContentRepository(ContainerRepository<ExternalItem> containerRepository, IPersister persister, ContentActivator activator, EditSection config)
 {
     this.containerRepository = containerRepository;
     this.persister = persister;
     this.activator = activator;
     externalItemType = Type.GetType(config.Externals.ExternalItemType) ?? typeof(ExternalItem);
 }
예제 #7
0
		public VersionManager(ContentVersionRepository versionRepository, IContentItemRepository itemRepository, StateChanger stateChanger, EditSection config)
		{
			this.Repository = versionRepository;
			this.itemRepository = itemRepository;
			this.stateChanger = stateChanger;
			maximumVersionsPerItem = config.Versions.MaximumPerItem;
		}
예제 #8
0
 public VersionManager(IRepository<int, ContentItem> itemRepository, IItemFinder finder, StateChanger stateChanger, EditSection config)
 {
     this.itemRepository = itemRepository;
     this.finder = finder;
     this.stateChanger = stateChanger;
     maximumVersionsPerItem = config.Versions.MaximumPerItem;
 }
예제 #9
0
 public UpdateFilePrefixMigration(EditSection config, IContentItemRepository repository, Tracker tracker)
 {
     this.config = config;
     this.repository = repository;
     this.tracker = tracker;
     Title = "Updates links to files with prefix";
     Description = "Updates links to files within an upload folder prepending the configured prefix (if any)";
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="VirtualFolderInitializer"/> class.
 /// </summary>
 /// <param name="host">The host.</param>
 /// <param name="persister">The persister.</param>
 /// <param name="fs">The fs.</param>
 /// <param name="virtualNodes">The virtual nodes.</param>
 /// <param name="editConfig">The edit config.</param>
 public VirtualFolderInitializer(IHost host, IPersister persister, IFileSystem fs, VirtualNodeFactory virtualNodes, ConnectionMonitor monitor, EditSection editConfig, ImageSizeCache imageSizes, FolderNodeProvider nodeProvider)
 {
     this.host = host;
     this.persister = persister;
     this.virtualNodes = virtualNodes;
     this.monitor = monitor;
     this.folders = editConfig.UploadFolders;
     this.nodeProvider = nodeProvider;
 }
예제 #11
0
 public EditUrlManager(EditSection config)
 {
     ManagementInterfaceUrl = config.ManagementInterfaceUrl.TrimEnd('/');
     EditTreeUrl = config.EditTreeUrl;
     EditItemUrl = config.EditItemUrl;
     EditInterfaceUrl = config.EditInterfaceUrl;
     NewItemUrl = config.NewItemUrl;
     DeleteItemUrl = config.DeleteItemUrl;
 }
		public RebuildImageSizesMigration(IPersister persister, N2.Edit.UploadFolderSource uploads, EditSection config)
		{
			this.persister = persister;
			this.uploads = uploads;
			configuredSizes = config.Images.Sizes;

			Title = "Rebuild Image Sizes";
			Description = "Redirects to a page where images can re-generated using currently configured settings";
		}
예제 #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="VirtualFolderInitializer"/> class.
        /// </summary>
        /// <param name="host">The host.</param>
        /// <param name="persister">The persister.</param>
        /// <param name="fs">The fs.</param>
        /// <param name="virtualNodes">The virtual nodes.</param>
        /// <param name="editConfig">The edit config.</param>
        public VirtualFolderInitializer(IHost host, IPersister persister, IFileSystem fs, VirtualNodeFactory virtualNodes, DatabaseStatusCache dbStatus, EditSection editConfig, ImageSizeCache imageSizes)
        {
            this.host = host;
            this.persister = persister;
            this.fs = fs;
            this.virtualNodes = virtualNodes;
            this.dbStatus = dbStatus;
            this.folders = editConfig.UploadFolders;

            nodeProvider = new FolderNodeProvider(fs, persister, imageSizes);
        }
예제 #14
0
파일: SlugTests.cs 프로젝트: Biswo/n2cms
        private Slug CreateDefaultSlug()
        {
            NameEditorElement nameEditorElement = new NameEditorElement();
            EditSection editSection = new EditSection { NameEditor = nameEditorElement };

            ConfigurationManagerWrapper cmw = new ConfigurationManagerWrapper
            {
                Sections = new ConfigurationManagerWrapper.ContentSectionTable(null, null, null, editSection)
            };

            return new Slug(cmw);
        }
예제 #15
0
 public ErrorHandler(IWebContext context, ISecurityManager security, InstallationManager installer,
     EngineSection config, EditSection editConfig)
     : this(context, security, installer)
 {
     this.editConfig = editConfig;
     action = config.Errors.Action;
     mailTo = config.Errors.MailTo;
     mailFrom = config.Errors.MailFrom;
     maxErrorReportsPerHour = config.Errors.MaxErrorReportsPerHour;
     handleWrongClassException = config.Errors.HandleWrongClassException;
     mailSender = new SmtpMailSender();
 }
예제 #16
0
		public EditUrlManager(IUrlParser parser, EditSection config)
		{
            this.parser = parser;

			ManagementInterfaceUrl = config.Paths.ManagementInterfaceUrl.TrimEnd('/');
			EditTreeUrl = config.Paths.EditTreeUrl;
			EditItemUrl = config.Paths.EditItemUrl;
			EditInterfaceUrl = config.Paths.EditInterfaceUrl;
			NewItemUrl = config.Paths.NewItemUrl;
			DeleteItemUrl = config.Paths.DeleteItemUrl;
			defaultViewPreference = config.Versions.DefaultViewMode;
		}
예제 #17
0
        public override void SetUp()
        {
            base.SetUp();

            CreatePersister();
            parser = mocks.StrictMock<N2.Web.IUrlParser>();
            context = CreateWebContext(false);

            EditSection editSection = new EditSection();
            security = new SecurityManager(context, editSection);
            enforcer = new SecurityEnforcer(persister, security, new ContentActivator(null, null, null), parser, context, new HostSection());
            enforcer.Start();
        }
예제 #18
0
        public override void SetUp()
        {
            base.SetUp();

            host = new Host(new Fakes.FakeWebContextWrapper(), 1, 1);
            config = new EditSection();
            config.DefaultDirectory = new DefaultDirectoryElement();
            config.UploadFolders = new FileSystemFolderCollection();

            root = CreateOneItem<Items.NormalPage>(1, "root", null);
            item1 = CreateOneItem<Items.NormalPage>(2, "item1", root);
            item2 = CreateOneItem<Items.NormalPage>(3, "item2", item1);
        }
예제 #19
0
        public static string CopyToDb()
        {
            if (fs.GetType() != typeof(DatabaseFileSystem))
                throw new Exception("Database filesystem not configured");

            var uploadFolders = new EditSection().UploadFolders;
            foreach (var uploadFolder in uploadFolders)
            {
                CopyFilesInDirectoryRecursively(HttpContext.Current.Server.MapPath(uploadFolder.Path));
            }

            return returnValue;
        }
예제 #20
0
        public ItemBridge(ContentActivator activator, IPersister persister, ISecurityManager security, IHost host, EditSection config)
        {
            this.security = security;
            this.activator = activator;
            this.persister = persister;
            this.host = host;
            this.editorUsernames = ToArray(config.Editors.Users);
            this.administratorUsernames = ToArray(config.Administrators.Users);

            Type configuredUserType = Type.GetType(config.Membership.UserType);
            if (configuredUserType == null) throw new ArgumentException("Couldn't create configured membership user type: " + config.Membership.UserType);
            SetUserType(configuredUserType);
        }
예제 #21
0
        internal static void HttpApplication_PreRequestHandlerExecute(object sender, EventArgs e)
        {
            var app = sender as HttpApplication;
            if (app == null) return;

            var uploadFolders = new EditSection().UploadFolders;
            if (!uploadFolders.Folders.Any(x => app.Request.Path.StartsWith(x.TrimStart('~'), StringComparison.OrdinalIgnoreCase)))
                return;

            if (!(Context.Current.Resolve<IFileSystem>()).FileExists(app.Request.Path))
                return;

            app.Context.Handler = new UploadFileHttpHandler(Context.Current.Resolve<IFileSystem>());
        }
예제 #22
0
        public ItemBridge(ContentActivator activator, IPersister persister, ISecurityManager security, IHost host, EditSection config)
        {
            this.security = security;
            this.activator = activator;
            this.persister = persister;
            this.host = host;
            this.editorUsernames = ToArray(config.Editors.Users);
            this.administratorUsernames = ToArray(config.Administrators.Users);

            Type configuredUserType = Type.GetType(config.Membership.UserType);
            if (configuredUserType == null) throw new ArgumentException("Couldn't create configured membership user type: " + config.Membership.UserType);
            if (!typeof(User).IsAssignableFrom(configuredUserType)) throw new ArgumentException("Configured membership user type '" + config.Membership.UserType + "' doesn't derive from '" + typeof(User).AssemblyQualifiedName + "'");
            this.userType = configuredUserType;
        }
예제 #23
0
 /// <summary>Creates a new instance of the RequestLifeCycleHandler class.</summary>
 /// <param name="webContext">The web context wrapper.</param>
 /// <param name="broker"></param>
 /// <param name="installer"></param>
 /// <param name="dispatcher"></param>
 /// <param name="adapters"></param>
 /// <param name="errors"></param>
 /// <param name="editConfig"></param>
 /// <param name="hostConfig"></param>
 /// <param name="managementUrls"></param>
 public RequestLifeCycleHandler(IWebContext webContext, EventBroker broker, InstallationManager installer,
     RequestPathProvider dispatcher, IContentAdapterProvider adapters, IErrorHandler errors,
     IEditUrlManager editUrlManager, EditSection editConfig, HostSection hostConfig)
 {
     checkInstallation = editConfig.Installer.CheckInstallationStatus;
     welcomeUrl = editConfig.Installer.WelcomeUrl;
     managementUrl = editConfig.ManagementInterfaceUrl;
     rewriteMethod = hostConfig.Web.Rewrite;
     this.webContext = webContext;
     this.broker = broker;
     this.adapters = adapters;
     this.errors = errors;
     this.editUrlManager = editUrlManager;
     this.installer = installer;
     this.dispatcher = dispatcher;
 }
예제 #24
0
        public EditUrlManager(IUrlParser parser, EditSection config)
        {
            this.parser = parser;

            ManagementInterfaceUrl = config.Paths.ManagementInterfaceUrl.TrimEnd('/');
            EditTreeUrl = config.Paths.EditTreeUrl;
            EditItemUrl = config.Paths.EditItemUrl;
            EditInterfaceUrl = config.Paths.EditInterfaceUrl;
            if (config.Legacy)
                EditInterfaceUrl += "Content/";
            NewItemUrl = config.Paths.NewItemUrl;
            DeleteItemUrl = config.Paths.DeleteItemUrl;
            defaultViewPreference = config.Versions.DefaultViewMode;
            MediaBrowserUrl = config.Paths.MediaBrowserUrl;
            ensureLocalhostPreviewUrls = config.Paths.EnsureLocalhostPreviewUrls;
        }
예제 #25
0
		public EditUrlManager(IUrlParser parser, EditSection config)
		{
			this.parser = parser;

			ManagementInterfaceUrl = config.Paths.ManagementInterfaceUrl.TrimEnd('/');
			EditTreeUrl = config.Paths.EditTreeUrl;
			EditItemUrl = config.Paths.EditItemUrl;
			ImportLanguageItemUrl = config.Paths.ImportLanguageItemUrl;
			UpdateLanguageItemUrl = config.Paths.UpdateLanguageItemUrl;
			ExportLanguageItemUrl = config.Paths.ExportLanguageItemUrl;
			EditInterfaceUrl = config.Paths.EditInterfaceUrl;
			if (config.Legacy)
				EditInterfaceUrl += "Content/";
			NewItemUrl = config.Paths.NewItemUrl;
			DeleteItemUrl = config.Paths.DeleteItemUrl;
			defaultViewPreference = config.Versions.DefaultViewMode;
		}
예제 #26
0
파일: SlugTests.cs 프로젝트: Biswo/n2cms
        private Slug CreateLowercaseSlug()
        {
            NameEditorElement nameEditorElement = new NameEditorElement
            {
                WhitespaceReplacement = '-',
                Replacements = new PatternValueCollection(),
                ToLower = true
            };

            EditSection editSection = new EditSection { NameEditor = nameEditorElement };

            ConfigurationManagerWrapper cmw = new ConfigurationManagerWrapper
            {
                Sections = new ConfigurationManagerWrapper.ContentSectionTable(null, null, null, editSection)
            };

            return new Slug(cmw);
        }
예제 #27
0
파일: SlugTests.cs 프로젝트: Biswo/n2cms
        private Slug CreateCustomReplacementSlug()
        {
            PatternValueCollection patterns = new PatternValueCollection();
            patterns.Clear(); // to remove all those added by constructor
            patterns.Add(new PatternValueElement("c1", "[@]", "at", true));

            NameEditorElement nameEditorElement = new NameEditorElement
            {
                // WhitespaceReplacement = '-',
                Replacements = patterns //,
                // ToLower = true
            };

            EditSection editSection = new EditSection { NameEditor = nameEditorElement };

            ConfigurationManagerWrapper cmw = new ConfigurationManagerWrapper
            {
                Sections = new ConfigurationManagerWrapper.ContentSectionTable(null, null, null, editSection)
            };

            return new Slug(cmw);
        }
예제 #28
0
파일: Tree.aspx.cs 프로젝트: sale42/n2cms
        protected override void OnInit(EventArgs e)
        {
            FS = Engine.Resolve<IFileSystem>();
            Config = Engine.Resolve<ConfigurationManagerWrapper>().Sections.Management;
            Register.JQueryUi(Page);
            var selected = Selection.SelectedItem;
            if (IsPostBack && !string.IsNullOrEmpty(inputFile.PostedFile.FileName))
            {
                string uploadFolder = Request["inputLocation"];
                if(!IsAvailable(uploadFolder))
                    throw new N2Exception("Cannot upload to " + Server.HtmlEncode(uploadFolder));

                string fileName = System.IO.Path.GetFileName(inputFile.PostedFile.FileName);
                string filePath = Url.Combine(uploadFolder, fileName);
                FS.WriteFile(filePath, inputFile.PostedFile.InputStream);

                ClientScript.RegisterStartupScript(typeof(Tree), "select", "updateOpenerWithUrlAndClose('" + ResolveUrl(filePath) + "');", true);
            }
            else if (Request["location"] == "files" || Request["location"] == "filesselection")
            {
                IHost host = Engine.Resolve<IHost>();
                HierarchyNode<ContentItem> root = new HierarchyNode<ContentItem>(Engine.Persister.Get(host.DefaultSite.RootItemID));

                var selectionTrail = new List<ContentItem>();
                if (selected is AbstractNode)
                {
                    selectionTrail = new List<ContentItem>(Find.EnumerateParents(selected, null, true));
                }
                else
                {
                    TrySelectingPrevious(ref selected, ref selectionTrail);
                }

                foreach (string uploadFolder in Engine.EditManager.UploadFolders)
                {
                    var dd = FS.GetDirectory(uploadFolder);

                    var dir = Directory.New(dd, root.Current, FS, Engine.Resolve<ImageSizeCache>());
                    var node = CreateDirectoryNode(FS, dir, root, selectionTrail);
                    root.Children.Add(node);
                }

                AddSiteFilesNodes(root, host.DefaultSite, selectionTrail);
                foreach (var site in host.Sites)
                {
                    if (site.StartPageID == host.DefaultSite.StartPageID)
                        continue;

                    AddSiteFilesNodes(root, site, selectionTrail);
                }

                siteTreeView.Nodes = root;
                siteTreeView.SelectedItem = selected;
            }
            else
            {
                var filter = Engine.EditManager.GetEditorFilter(Page.User);
                siteTreeView.Filter = filter;
                siteTreeView.RootNode = Engine.Resolve<Navigator>().Navigate(Request["root"] ?? "/");
                siteTreeView.SelectedItem = selected;
            }

            siteTreeView.SelectableTypes = Request["selectableTypes"];
            siteTreeView.SelectableExtensions = Request["selectableExtensions"];
            siteTreeView.DataBind();

            base.OnInit(e);
        }
예제 #29
0
 public UploadedFilesResizer(IFileSystem files, ImageResizer resizer, EditSection config)
 {
     this.files = files;
     this.resizer = resizer;
     this.images = config.Images;
 }
예제 #30
0
		public UploadFolderSource(IHost host, EditSection config)
		{
			this.host = host;
			this.globalFolders = config.UploadFolders
				.AllElements.Select(u => new FileSystemRoot(u, host.DefaultSite) { IsGlobal = true }).ToArray();
		}
예제 #31
0
 public ErrorHandler(IWebContext context, ISecurityManager security, InstallationManager installer,
     IMailSender mailSender, EngineSection config, EditSection editConfig)
     : this(context, security, installer, config, editConfig)
 {
     this.mailSender = mailSender;
 }