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; }
public virtual IEnumerable<string> GetUploadFolders(Site site) { foreach (var folder in globalFolders) yield return folder; foreach (var folder in site.UploadFolders) yield return folder; }
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; }
public TranslateSpecification(string editUrl, ILanguage language, ContentItem existingItem, ItemDefinition definition, Site site) { EditUrl = editUrl; Language = language; ExistingItem = existingItem; Definition = definition; Site = site; IsTranslatable = true; }
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; }
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 }; }
/// <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; }
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}; }
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; }
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); }
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; }
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); }
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; }
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); }
public virtual IEnumerable<DirectoryData> GetUploadDirectories(Site site) { foreach (string uploadFolder in site.UploadFolders) { yield return FileSystem.GetDirectory(uploadFolder); } }
/// <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; }
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); } }
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")); }
/// <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); } }
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); }
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); }
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); } }
private void Add(Site site) { if (site == null) return; if(site.Authority != null) sitesByAuthority[site.Authority] = site; sitesById[site.StartPageID] = site; wildcards |= site.Wildcards; }
public Host(IWebContext context, Site defaultSite) { this.context = context; this.sites = new SiteTable(defaultSite, Enumerable.Empty<Site>()); }
public Host(IWebContext context, Site defaultSite) { this.context = context; this.sites = new SiteTable(defaultSite, Enumerable.Empty <Site>()); }