示例#1
0
 /// <summary>
 /// Gets the next available position for the specified depth
 /// </summary>
 /// <param name="depth"></param>
 /// <returns></returns>
 private int GetNextPosition(Data.Guid siteGuid, int depth)
 {
     CmsSitePathDao dao = new CmsSitePathDao();
     return dao.FindNextPosition(siteGuid, depth);
 }
示例#2
0
        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;
        }
示例#3
0
 public IList<CmsSitePath> GetRedirects(Data.Guid siteGuid)
 {
     CmsSitePathDao dao = new CmsSitePathDao();
     return dao.FindRedirectsBySiteGuid(siteGuid);
 }
示例#4
0
 public void Save(CmsSitePath path)
 {
     CmsSitePathDao dao = new CmsSitePathDao();
     using (Transaction tx = new Transaction())
     {
         dao.Save<CmsSitePath>(path);
         tx.Commit();
     }
 }
示例#5
0
 public IList<CmsSitePath> GetParentPaths(Data.Guid siteGuid)
 {
     CmsSitePathDao dao = new CmsSitePathDao();
     return dao.FindParentPathsBySite(siteGuid);
 }
示例#6
0
        public CmsSitePath GetPath(Data.Guid siteGuid, String path)
        {
            if (path == null)
                throw new ArgumentNullException("The path may not be null when attempting to retrieve a sitemap path");

            if (!path.StartsWith("/"))
                path = "/" + path;

            Data.Hash hash = TextHash.MD5(path);

            CmsSitePathDao dao = new CmsSitePathDao();
            return dao.FindBySiteAndHash(siteGuid, hash);
        }
示例#7
0
        /// <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;
        }
示例#8
0
 public IList<CmsSitePath> GetAllPaths(Data.Guid siteGuid)
 {
     CmsSitePathDao dao = new CmsSitePathDao();
     return dao.FindAllBySiteGuid(siteGuid);
 }
示例#9
0
        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;
        }
示例#10
0
        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;
        }
示例#11
0
        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;
        }