Exemplo n.º 1
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;
        }
Exemplo n.º 2
0
 public void Save(CmsSitePath path)
 {
     CmsSitePathDao dao = new CmsSitePathDao();
     using (Transaction tx = new Transaction())
     {
         dao.Save<CmsSitePath>(path);
         tx.Commit();
     }
 }
Exemplo n.º 3
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;
        }
Exemplo n.º 4
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;
        }
Exemplo n.º 5
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;
        }