public static Guid GetPageIDByFolderUrl(string relativePath, string siteid) { if (relativePath == null) { relativePath = ""; } if (relativePath.StartsWith("/")) { relativePath = relativePath.Substring(1); } if (relativePath.EndsWith("/")) { relativePath = relativePath.Substring(0, relativePath.Length - 1); } Guid returnValue = Guid.Empty; string where = String.Format("FK_Site='{0}' AND RelativePath = '{1}'", siteid, relativePath); CmsPageFolder folder = BaseObject.GetFirst <CmsPageFolder>(where); if (folder != null) { //where = "FK_Folder = '" + folder.ID.ToString() + "' AND IsHomePage='1'"; //CmsPage page = BaseObject.GetFirst<CmsPage>(where); CmsPage page = folder.GetHomePage(); if (page != null) { returnValue = page.ID; } } return(returnValue); }
public override void Save() { if (IsNew && WebSessionHelper.CurrentLicense != null && WebSessionHelper.CurrentLicense.HasMaxNumberExceeded("PageFolder")) { throw new Exception("Kan niet opslaan: licentie heeft maximale aantal folders (" + WebSessionHelper.CurrentLicense.MaxNumberOfPageFolders + ") overschreden."); } Validate(); RelativePath = GetCompletePath(); //unique check //workaraound voor mysql: uniek is combi van naam, site en folder //als folder leeg is (NULL), gaat uniqueconstraint niet af in mySql //hierom in c# checken if (this.ParentFolder == null && ID != Guid.Empty) { string sql = String.Format("FK_Site='{0}' AND FK_Parent_Folder IS NULL AND name = '{1}' AND ID != '{2}'", Site.ID, this.Name, this.ID); CmsPageFolder checkFolder = BaseObject.GetFirst <CmsPageFolder>(sql); if (checkFolder != null) { throw new Exception("Naam is niet uniek."); } } CmsPageFolder currentFolder = BaseObject.GetById <CmsPageFolder>(this.ID); if (currentFolder != null) { currentFolder.DeleteCurrentFolderLocation(); } base.Save(); //bij naamswijziging, moeten alle paden in subfolders en pagina's worden geupdate UpdateRelativePathAndUnpublishedItemsInSubFoldersAndPages(); UnpublishedItem.Set(this, "Folder"); }
private void Validate() { bool valid = true; //controleer of parent path niet naar zichzelf verwijst CmsPageFolder parent = ParentFolder; while (valid && parent != null) { if (parent.Equals(this)) { valid = false; } parent = parent.ParentFolder; } if (!valid) { throw new Exception("Folder mag niet onder zichzelf vallen."); } }
public CmsPageFolder Copy(string newName, Guid?parentFolderID) { CmsPageFolder newFolder = this.CreateCopy <CmsPageFolder>(false); if (newName != "") { newFolder.Name = newName; } newFolder.LastPublishedDate = null; if (parentFolderID.HasValue) { newFolder.ParentFolder = new CmsPageFolder(); newFolder.ParentFolder.ID = parentFolderID.Value; } if (this.HasAutorisation) { foreach (Autorisation.SiteUserGroup userGroup in this.AutorizedSiteUserGroups) { newFolder.AutorizedSiteUserGroups.Add(userGroup); } foreach (Autorisation.SiteUser user in this.AutorizedSiteUsers) { newFolder.AutorizedSiteUsers.Add(user); } } newFolder.Save(); foreach (CmsPageFolder subFolder in this.GetSubFolders()) { CmsPageFolder newSubFolder = subFolder.Copy(subFolder.Name, newFolder.ID); } foreach (CmsPage page in this.GetPages()) { CmsPage newPage = page.Copy(page.Name, newFolder.ID); } return(newFolder); }
public string GetCompletePath() { //hack om er zeker van te zijn dat parentfolder laatste uit database is. //Dat kan niet, omdat je anders de parentFolder nooit kan wijzigen;) /* if (!IsNew) * { * CmsPageFolder dummy = BaseObject.GetById<CmsPageFolder>(this.ID); * * this.ParentFolder = dummy.ParentFolder; * //this.Load(); * } */ //einde hack string path = this.Name; CmsPageFolder parentFolder = this.ParentFolder; while (parentFolder != null) { path = parentFolder.Name + "/" + path; parentFolder = parentFolder.ParentFolder; } return(path); }