コード例 #1
0
ファイル: CmsSiteMap.cs プロジェクト: beachead/gooey-cms-v2
        public CmsSitePath AddChildDirectory(Data.Guid siteGuid, String parentPath, String newDirectory)
        {
            if (String.IsNullOrEmpty(parentPath))
                parentPath = RootPath;

            CmsSitePath parent = GetPath(siteGuid, parentPath);
            if (parent == null)
                throw new ArgumentException("Could not add child directory because the parent path '" + parentPath + "' does not exist.");

            String slash = (parent.Url.EndsWith("/")) ? "" : "/";
            CmsSitePath path = new CmsSitePath();

            if (newDirectory.StartsWith("/"))
                newDirectory = newDirectory.Substring(1);

            path.SubscriptionGuid = siteGuid.Value;
            path.Parent = parent.Url;
            path.IsDirectory = true;
            path.Depth = parent.Depth + 1;
            path.Url = parent.Url + slash + newDirectory;
            path.UrlHash = TextHash.MD5(path.Url).Value;
            path.Position = GetNextPosition(siteGuid,path.Depth);

            ValidatePath(siteGuid, path.Url);
            CmsSitePathDao dao = new CmsSitePathDao();
            using (Transaction tx = new Transaction())
            {
                dao.Save<CmsSitePath>(path);
                tx.Commit();
            }

            return path;
        }
コード例 #2
0
 public RedirectItem(CmsSitePath path)
 {
     this.RedirectFrom = path.Url;
     this.RedirectTo = path.RedirectTo;
     this.SubscriptionId = path.SubscriptionGuid;
 }
コード例 #3
0
ファイル: CmsSiteMap.cs プロジェクト: beachead/gooey-cms-v2
 public void Save(CmsSitePath path)
 {
     CmsSitePathDao dao = new CmsSitePathDao();
     using (Transaction tx = new Transaction())
     {
         dao.Save<CmsSitePath>(path);
         tx.Commit();
     }
 }
コード例 #4
0
ファイル: CmsSiteMap.cs プロジェクト: beachead/gooey-cms-v2
        /// <summary>
        /// Gets the children for the specified parent
        /// </summary>
        /// <param name="parent"></param>
        /// <returns></returns>
        public IList<CmsSitePath> GetChildren(CmsSitePath parent)
        {
            CmsSitePathDao dao = new CmsSitePathDao();
            IList<CmsSitePath> children = dao.FindChildren(parent.SubscriptionGuid,parent.Url);

            return children;
        }
コード例 #5
0
ファイル: CmsSiteMap.cs プロジェクト: beachead/gooey-cms-v2
        public CmsSitePath AddRootDirectory(Data.Guid siteGuid)
        {
            CmsSitePath path = GetRootPath(siteGuid);
            if (path == null)
            {
                path = new CmsSitePath();
                path.SubscriptionGuid = siteGuid.Value;
                path.Parent = null;
                path.IsDirectory = true;
                path.Depth = 1;
                path.Position = 0;
                path.Url = RootPath;
                path.UrlHash = TextHash.MD5(path.Url).Value;

                ValidatePath(siteGuid, path.Url);
                CmsSitePathDao dao = new CmsSitePathDao();
                using (Transaction tx = new Transaction())
                {
                    dao.Save<CmsSitePath>(path);
                    tx.Commit();
                }
            }
            return path;
        }
コード例 #6
0
ファイル: CmsSiteMap.cs プロジェクト: beachead/gooey-cms-v2
        public CmsSitePath AddRedirect(Data.Guid siteGuid, String redirectFrom, String redirectTo)
        {
            if ((!redirectFrom.StartsWith("http")) && (!redirectFrom.StartsWith("~/")))
            {
                if (redirectFrom.StartsWith("/"))
                    redirectFrom = "~" + redirectFrom;
                else if (!redirectFrom.StartsWith("/"))
                    redirectFrom = "~/" + redirectFrom;
            }

            if ((!redirectTo.StartsWith("http")) && (!redirectTo.StartsWith("~/")))
            {
                if (redirectTo.StartsWith("/"))
                    redirectTo = "~" + redirectTo;
                else if (!redirectTo.StartsWith("/"))
                    redirectTo = "~/" + redirectTo;
            }

            CmsSitePath path = GetPath(siteGuid, redirectFrom);
            if (path == null)
            {
                path = new CmsSitePath();
            }

            path.SubscriptionGuid = siteGuid.Value;
            path.Url = redirectFrom;
            path.UrlHash = TextHash.MD5(path.Url).Value;
            path.RedirectTo = redirectTo;
            path.IsRedirect = true;

            CmsSitePathDao dao = new CmsSitePathDao();
            using (Transaction tx = new Transaction())
            {
                dao.Save<CmsSitePath>(path);
                tx.Commit();
            }

            return path;
        }
コード例 #7
0
ファイル: CmsSiteMap.cs プロジェクト: beachead/gooey-cms-v2
        public CmsSitePath AddNewPage(Data.Guid siteGuid, String parentPath, String newPage)
        {
            CmsSitePath parent = GetPath(siteGuid, parentPath);
            if (parent == null)
                throw new ArgumentException(parentPath + " does not exist and can not be used as a parent for " + newPage);

            String fullurl = PathCombine(parent.Url, newPage);

            //Make sure the url doesn't already exist
            CmsSitePath path = GetPath(siteGuid, fullurl);
            if (path == null)
            {
                int depth = parent.Depth + 1;

                path = new CmsSitePath();
                path.SubscriptionGuid = siteGuid.Value;
                path.Depth = depth;
                path.Position = GetNextPosition(siteGuid, depth);
                path.Parent = parent.Url;
                path.Url = fullurl;
                path.UrlHash = TextHash.MD5(fullurl).Value;
                path.IsPage = true;

                CmsSitePathDao dao = new CmsSitePathDao();
                using (Transaction tx = new Transaction())
                {
                    dao.Save<CmsSitePath>(path);
                    tx.Commit();
                }
            }
            return path;
        }
コード例 #8
0
ファイル: PageManager.cs プロジェクト: beachead/gooey-cms-v2
        public void DeleteFolder(CmsSitePath folder)
        {
            if (!folder.IsDirectory)
                throw new ArgumentException("This method may only be used to delete folders not pages");

            IList<CmsSitePath> pages = CmsSiteMap.Instance.GetChildren(folder);
            foreach (CmsSitePath path in pages)
            {
                CmsUrl url = new CmsUrl(path.Url);
                CmsPage page = this.GetLatestPage(url, false);
                if (page == null)
                {
                    page = new CmsPage();
                    page.Url = path.Url;
                    page.UrlHash = TextHash.MD5(page.Url).Value;
                }
                this.DeleteAll(page);
            }

            //Delete the directory itself from the sitemap
            CmsSiteMap.Instance.Remove(folder);
        }