コード例 #1
0
		public FileSystemRoot(string path, Site site)
		{
			Path = path;
			Readers = new PermissionMap(Permission.Read, new[] { "Administrators", "Editors", "Writers" }, new[] { "admin" });
			Writers = new PermissionMap(Permission.Write, new[] { "Administrators", "Editors", "Writers" }, new[] { "admin" });
			Site = site;
		}
コード例 #2
0
 public virtual IEnumerable<string> GetUploadFolders(Site site)
 {
     foreach (var folder in globalFolders)
         yield return folder;
     foreach (var folder in site.UploadFolders)
         yield return folder;
 }
コード例 #3
0
 public SiteFilteringLanguageGateway(ILanguageGateway languages, Site site, IPersister persister, StructureBoundDictionaryCache<int, LanguageInfo[]> languagesCache, DescendantItemFinder descendantFinder)
 {
     this.languages = languages;
     this.site = site;
     this.persister = persister;
     this.languagesCache = languagesCache;
     this.descendantFinder = descendantFinder;
 }
コード例 #4
0
		public TranslateSpecification(string editUrl, ILanguage language, ContentItem existingItem, ItemDefinition definition, Site site)
		{
			EditUrl = editUrl;
			Language = language;
			ExistingItem = existingItem;
			Definition = definition;
			Site = site;
			IsTranslatable = true;
		}
コード例 #5
0
		public FileSystemRoot(FolderElement folder, Site site)
		{
			Path = FixPath(folder.Path);
			if (!string.IsNullOrEmpty(folder.Title))
				Title = folder.Title;
			Readers = folder.Readers.ToPermissionMap(Permission.Read, new[] { "Administrators", "Editors", "Writers" }, new[] { "admin" });
			Writers = folder.Writers.ToPermissionMap(Permission.Write, new[] { "Administrators", "Editors" }, new[] { "admin" });
			Site = site;
		}
コード例 #6
0
ファイル: StartPage.cs プロジェクト: JohnsonYuan/n2cms
        public IEnumerable<Site> GetSites()
        {
            if (string.IsNullOrEmpty(HostName))
                return new Site[0];

            Site s = new Site((Parent ?? this).ID, ID, HostName);
            s.Wildcards = true;

            return new Site[] { s };
        }
コード例 #7
0
        /// <summary>Gets the language gateway manaing translations on the given site.</summary>
        /// <param name="managingTranslationsOnSite">the site whose language gateway to get.</param>
        /// <returns>A language gateway filtering languages.</returns>
        public virtual ILanguageGateway GetLanguageGateway(Site managingTranslationsOnSite)
        {
			var gateway = languages;
            if (Enabled && LanguagesPerSite)
                gateway = new SiteFilteringLanguageGateway(languages, managingTranslationsOnSite, persister, languagesCache, descendantFinder);

			return Cache
				? new CachingLanguageGatewayDecorator(gateway, cacheWrapper, persister, LanguagesPerSite ? managingTranslationsOnSite.StartPageID.ToString() : "global")
				: gateway;
        }
コード例 #8
0
ファイル: StartPage.cs プロジェクト: grbbod/drconnect-jungo
		public IEnumerable<Site> GetSites()
		{
			if (string.IsNullOrEmpty(HostName))
				return new Site[0];

			Site s = new Site((Parent ?? this).ID, ID, HostName);
			s.Wildcards = true;
			if (SiteUpload)
				s.UploadFolders.Add(new FileSystemRoot("~/Upload/" + HostName, s) { Title = "Upload (" + HostName + ")" });

			return new Site[] {s};
		}
コード例 #9
0
ファイル: Host.cs プロジェクト: sergheizagaiciuc/n2cms
 public static IList<Site> ExtractSites(HostSection config)
 {
     List<Site> sites = new List<Site>();
     foreach (SiteElement configElement in config.Sites)
     {
         Site s = new Site(configElement.RootID ?? config.RootID, configElement.ID, configElement.Name);
         s.Wildcards = configElement.Wildcards || config.Wildcards;
         foreach (FolderElement folder in configElement.UploadFolders)
             s.UploadFolders.Add(folder.Path);
         foreach (string key in configElement.Settings.AllKeys)
             s.Settings[key] = configElement.Settings[key].Value;
         sites.Add(s);
     }
     return sites;
 }
コード例 #10
0
        public void GetChildren_OfSite_ReturnsSiteUploadFolders()
        {
            fs.CreateDirectory("/siteupload/");
            var start2 = CreateOneItem<RootNode>(2, "start", root);
            var site = new Site(1, 2);
            site.UploadFolders.Add("/siteupload/");
            host.AddSites(new[] { site });
            initializer.Start();

            var defaultresult = vnf.GetChildren("/");
            var siteresult = vnf.GetChildren("/start/");

            Assert.That(defaultresult.Any(c => c.Name == "siteupload"), Is.False);
            Assert.That(siteresult.Any(c => c.Name == "siteupload"), Is.True);
        }
コード例 #11
0
ファイル: Host.cs プロジェクト: GrimaceOfDespair/n2cms
        public static IList<Site> ExtractSites(HostSection config)
        {
            List<Site> sites = new List<Site>();
            foreach (SiteElement configElement in config.Sites)
            {
                Site s = new Site(configElement.RootID ?? config.RootID, configElement.ID, configElement.Name);
                s.Wildcards = configElement.Wildcards || config.Wildcards;

                foreach (FolderElement folder in configElement.UploadFolders.AllElements)
                {
                    if (string.IsNullOrEmpty(folder.Path))
                        throw new ConfigurationErrorsException("Upload path configured for site '" + configElement.Name + "' cannot be empty.");
                    s.UploadFolders.Add(FixPath(folder.Path));
                }
                foreach (string key in configElement.Settings.AllKeys)
                    s.Settings[key] = configElement.Settings[key].Value;
                sites.Add(s);
            }
            return sites;
        }
コード例 #12
0
        private string GetHostedUrl(ContentItem item, string url, Site site)
        {
            if (string.IsNullOrEmpty(site.Authority))
                return item.FindPath(PathData.DefaultAction).GetRewrittenUrl();

            return Url.Parse(url).SetAuthority(site.Authority);
        }
コード例 #13
0
ファイル: UrlParser.cs プロジェクト: grbbod/drconnect-jungo
        private ContentItem LocateStartPage(ContentItem startPageConfigured)
        {
            ContentItem startPage = startPageConfigured;
            lock (_syncLock)
            {               
                if (host.CurrentSite.StartPageID != host.CurrentSite.RootItemID) // only when start <> root
                {
                    if (startPage != null)
                    {
                        if (!(startPage is IStartPage))
                        {
                            logger.WarnFormat("Configured start page is no IStartPage #{0} -> {1}",
                                               host.CurrentSite.StartPageID,
                                               startPage.GetType().FullName);
                            startPage = null;
                        }

                        if (startPage != null && !startPage.IsPublished())
                        {
                            logger.ErrorFormat("Configured start page is not published #{0} -> {1}", startPage.ID,
                                               startPage.GetType().FullName);
                            startPage = null;
                        }
                    }

                    if (startPage == null)
                    {
                        // try to locate start page below root
                        var root = persister.Repository.Get(host.CurrentSite.RootItemID);
                        if (root == null)
                        {
                            // no content?
                            return null;
                        }

                        ItemList children = root.GetChildren(new TypeFilter(typeof (IStartPage)), new PublishedFilter());
                        if (children.Count == 1)
                        {
                            startPage = children[0];
                            logger.InfoFormat("Auto updated start page to #{0} -> {1}", startPage.ID,
                                              startPage.GetType().FullName);
                            var newSite = new Site(root.ID, startPage.ID);
                            host.ReplaceSites(newSite, new List<Site>());
                        }
                    }

                    if (startPage == null)
                        return startPageConfigured; // keep configured
                }
            }
            return startPage;
        }
コード例 #14
0
ファイル: Tree.aspx.cs プロジェクト: sale42/n2cms
        private void AddSiteFilesNodes(HierarchyNode<ContentItem> parent, Site site, List<ContentItem> selectionTrail)
        {
            var startPage = Engine.Persister.Get(site.StartPageID);
            var sizes = Engine.Resolve<ImageSizeCache>();

            HierarchyNode<ContentItem> node = null;
            foreach(var dir in Engine.GetContentAdapter<NodeAdapter>(startPage).GetChildren(startPage, Interfaces.Managing).OfType<Directory>())
            {
                if (node == null)
                    node = new HierarchyNode<ContentItem>(startPage);
                var directoryNode = CreateDirectoryNode(FS, dir, node, selectionTrail);
                node.Children.Add(directoryNode);
            }

            if (node != null)
                parent.Children.Add(node);
        }
コード例 #15
0
ファイル: NodeAdapter.cs プロジェクト: AnonymousRetard/n2cms
 public virtual IEnumerable<DirectoryData> GetUploadDirectories(Site site)
 {
     foreach (string uploadFolder in site.UploadFolders)
     {
         yield return FileSystem.GetDirectory(uploadFolder);
     }
 }
コード例 #16
0
        /// <summary>Gets the language gateway manaing translations on the given site.</summary>
        /// <param name="managingTranslationsOnSite">the site whose language gateway to get.</param>
        /// <returns>A language gateway filtering languages.</returns>
        public ILanguageGateway GetLanguageGateway(Site managingTranslationsOnSite)
        {
            if (Enabled && LanguagesPerSite)
                return new SiteFilteringLanguageGateway(languages, managingTranslationsOnSite, persister, languagesCache, descendantFinder);

            return languages;
        }
コード例 #17
0
        private IEnumerable<FolderPair> UploadFoldersForSite(Site site)
        {
            ContentItem item = persister.Get(site.StartPageID);
            if (item == null)
                yield break;

            string itemPath = item.Path;
            foreach (string path in site.UploadFolders)
            {
                yield return new FolderPair(item.ID, item.Path, itemPath + path.TrimStart('~', '/'), path);
            }
        }
コード例 #18
0
        public void Get_UploadFolder_GivesSiteUploadFolder()
        {
            fs.CreateDirectory("/siteupload/");
            var start2 = CreateOneItem<RootNode>(2, "start", root);
            var site = new Site(1, 2);
            site.UploadFolders.Add("/siteupload/");
            host.AddSites(new[] { site });
            initializer.Start();
            vnf.Register(nodeProvider);

            var defaultresult = vnf.Get("/siteupload/");
            var siteresult = vnf.Get("/start/siteupload/");

            Assert.That(defaultresult, Is.Null);
            Assert.That(siteresult, Is.Not.Null);
            Assert.That(siteresult.Name, Is.EqualTo("siteupload"));
        }
コード例 #19
0
ファイル: Host.cs プロジェクト: grbbod/drconnect-jungo
    	/// <summary>Replaces the site list with new sites.</summary>
		/// <param name="newDefaultSite">The default site to use.</param>
    	/// <param name="newSites">The new site list.</param>
    	public void ReplaceSites(Site newDefaultSite, IEnumerable<Site> newSites)
        {
            if(newSites == null) throw new ArgumentNullException("newSites");

			var previous = sites;
			sites = new SiteTable(newDefaultSite, newSites);

			var args = new SitesChangedEventArgs();
			args.PreviousDefault = previous.DefaultSite;
			args.PreviousSites = previous.Sites;
			args.CurrentDefault = sites.DefaultSite;
			args.CurrentSites = sites.Sites;

			if (SitesChanged != null)
			{
				SitesChanged.Invoke(this, args);
			}
		}
コード例 #20
0
ファイル: Tree.aspx.cs プロジェクト: AnonymousRetard/n2cms
        private void AddSiteFilesNodes(HierarchyNode<ContentItem> parent, Site site, List<ContentItem> selectionTrail)
        {
            var siteNode = Engine.Persister.Get(site.StartPageID);

            HierarchyNode<ContentItem> node = null;
            foreach (DirectoryData dd in Engine.Resolve<IContentAdapterProvider>()
                .ResolveAdapter<NodeAdapter>(siteNode)
                .GetUploadDirectories(site))
            {
                if(node == null)
                    node = new HierarchyNode<ContentItem>(siteNode);
                var dir = new Directory(dd, parent.Current);
                dir.Set(FS);
                var directoryNode = CreateDirectoryNode(FS, dir, node, selectionTrail);
                node.Children.Add(directoryNode);
            }

            if (node != null)
                parent.Children.Add(node);
        }
コード例 #21
0
ファイル: Host.cs プロジェクト: grbbod/drconnect-jungo
			public SiteTable(Site defaultSite, IEnumerable<Site> sites)
			{
				this.defaultSite = defaultSite;
				this.sites = new List<Site>(sites).ToArray();

				Add(defaultSite);
				foreach (var site in sites)
					Add(site);
			}
コード例 #22
0
ファイル: NodeAdapter.cs プロジェクト: EzyWebwerkstaden/n2cms
		public virtual IEnumerable<DirectoryData> GetUploadDirectories(Site site)
		{
			foreach (var uploadFolder in site.UploadFolders.Where(uf => uf.Readers.Authorizes(WebContext.User, null, Permission.Read)))
			{
				yield return FileSystem.GetDirectoryOrVirtual(uploadFolder.Path);
			}
		}
コード例 #23
0
ファイル: Host.cs プロジェクト: grbbod/drconnect-jungo
			private void Add(Site site)
			{
				if (site == null)
					return;

				if(site.Authority != null)
					sitesByAuthority[site.Authority] = site;
				sitesById[site.StartPageID] = site;
				
				wildcards |= site.Wildcards;
			}
コード例 #24
0
ファイル: Host.cs プロジェクト: grbbod/drconnect-jungo
		public Host(IWebContext context, Site defaultSite)
		{
			this.context = context;
			this.sites = new SiteTable(defaultSite, Enumerable.Empty<Site>());
		}
コード例 #25
0
 public Host(IWebContext context, Site defaultSite)
 {
     this.context = context;
     this.sites   = new SiteTable(defaultSite, Enumerable.Empty <Site>());
 }