Example #1
0
        public SchemaPath(Schema schema)
        {
            if (schema == null)
            {
                return;
            }

            string schemaName = schema.Name;

            RepositoryPath repositoryPath = new RepositoryPath(schema.Repository);
            var            schemaPath     = Path.Combine(repositoryPath.PhysicalPath, "Schemas", schema.Name);

            //Schema is link
            //
            if (!Directory.Exists(schemaPath) && File.Exists(schemaPath + ".lnk"))
            {
                PhysicalPath = LinkHelper.ResolveShortcut(schemaPath + ".lnk");
                SettingFile  = Path.Combine(PhysicalPath, PathHelper.SettingFileName);
                VirtualPath  = UrlUtility.GetVirtualPath(PhysicalPath);
            }
            else
            {
                var basePhysicalPath = GetBaseDir(schema.Repository);
                this.PhysicalPath = Path.Combine(basePhysicalPath, schemaName);
                this.SettingFile  = Path.Combine(PhysicalPath, PathHelper.SettingFileName);

                VirtualPath = UrlUtility.RawCombine(repositoryPath.VirtualPath, PATH_NAME, schemaName);
            }
        }
Example #2
0
        public DirectoryEntry(DirectoryResource rootDir, string relativePath)
            : base("")
        {
            this.physicalPath     = Path.Combine(rootDir.PhysicalPath, relativePath);
            this.virtualPath      = UrlUtility.GetVirtualPath(physicalPath);
            this.basePhysicalPath = Path.GetDirectoryName(this.physicalPath);
            var paths = this.virtualPath.Split("/".ToArray(), StringSplitOptions.RemoveEmptyEntries);

            this.baseVirtualPath = UrlUtility.Combine(paths.Take(paths.Count() - 1).ToArray());

            this.RootDir = rootDir;
        }
Example #3
0
        public FolderPath(Folder folder)
        {
            var repositoryPath = new RepositoryPath(folder.Repository);

            if (folder.Parent != null)
            {
                var parentPath = new FolderPath(folder.Parent);
                this.PhysicalPath = Path.Combine(parentPath.PhysicalPath, folder.Name);
                VirtualPath       = UrlUtility.Combine(parentPath.VirtualPath, folder.Name);
            }
            else
            {
                if (folder.GetType() == typeof(TextFolder))
                {
                    var dirName = Path.Combine(repositoryPath.PhysicalPath, GetRootPath(folder.GetType()), folder.Name);

                    //Folder is link
                    //
                    if (!Directory.Exists(dirName) && File.Exists(dirName + ".lnk"))
                    {
                        var baseDir = Kooboo.CMS.Common.Runtime.EngineContext.Current.Resolve <IBaseDir>();
                        PhysicalPath = Path.Combine(baseDir.Cms_DataPhysicalPath, "Contents", folder.Repository.Name, GetRootPath(folder.GetType()), folder.Name);
                        VirtualPath  = UrlUtility.GetVirtualPath(PhysicalPath);
                    }
                    else
                    {
                        PhysicalPath = Path.Combine(repositoryPath.PhysicalPath, GetRootPath(folder.GetType()), folder.Name);
                        VirtualPath  = UrlUtility.Combine(repositoryPath.VirtualPath, GetRootPath(folder.GetType()), folder.Name);
                    }
                }
                else
                {
                    var environment = PathUtils.GetDeployEnvironment(HttpContext.Current);
                    if (environment != null && !string.IsNullOrWhiteSpace(environment.ContentPath) && !string.IsNullOrWhiteSpace(environment.ContentVirtualPath))
                    {
                        PhysicalPath = Path.Combine(environment.ContentPath, GetRootPath(folder.GetType()), folder.Name);
                        VirtualPath  = UrlUtility.Combine(environment.ContentVirtualPath, GetRootPath(folder.GetType()), folder.Name);
                    }
                    else
                    {
                        this.PhysicalPath = Path.Combine(repositoryPath.PhysicalPath, GetRootPath(folder.GetType()), folder.Name);
                        VirtualPath       = UrlUtility.Combine(repositoryPath.VirtualPath, GetRootPath(folder.GetType()), folder.Name);
                    }
                }
            }
            this.SettingFile = Path.Combine(PhysicalPath, PathHelper.SettingFileName);
        }
Example #4
0
        public virtual ItemTemplate GetItemTemplate(string templateName)
        {
            var physicalPath = TemplatePath;

            if (Directory.Exists(physicalPath))
            {
                ItemTemplate itemTemplate = new ItemTemplate()
                {
                    TemplateName = templateName
                };
                itemTemplate.TemplateFile = Path.Combine(physicalPath, templateName + FileExtension);
                var thumbnail = Path.Combine(physicalPath, templateName + ".png");
                itemTemplate.Thumbnail = UrlUtility.GetVirtualPath(thumbnail);
                return(itemTemplate);
            }
            return(null);
        }
Example #5
0
        public virtual ItemTemplate GetItemTemplate(string category, string templateName)
        {
            var physicalPath = GetCategoryPhysicalPath(category);
            var itemFile     = Path.Combine(physicalPath, templateName + FileExtension);

            if (File.Exists(itemFile))
            {
                ItemTemplate itemTemplate = new ItemTemplate()
                {
                    TemplateName = templateName, Category = category
                };
                itemTemplate.TemplateFile = itemFile;
                var thumbnail = Path.Combine(physicalPath, templateName + ".png");
                if (File.Exists(thumbnail))
                {
                    itemTemplate.Thumbnail = UrlUtility.GetVirtualPath(thumbnail);
                }
                return(itemTemplate);
            }
            return(null);
        }
Example #6
0
        public FileEntry(DirectoryResource rootDir, string relativePath)
            : base("")
        {
            this.physicalPath = Path.Combine(rootDir.PhysicalPath, relativePath);
            this.virtualPath  = UrlUtility.GetVirtualPath(physicalPath);

            this.basePhysicalPath = Path.GetDirectoryName(this.physicalPath);
            var paths = this.virtualPath.Split("/".ToArray(), StringSplitOptions.RemoveEmptyEntries);

            this.baseVirtualPath = UrlUtility.Combine(paths.Take(paths.Count() - 1).ToArray());
            this.FileName        = paths.Last();
            if (this.FileName.Contains('.'))
            {
                this.Name          = FileName.Substring(0, FileName.IndexOf("."));
                this.FileExtension = FileExtension.Substring(FileExtension.IndexOf(".") + 1);
            }
            else
            {
                this.Name = FileName;
            }

            this.RootDir = rootDir;
            //this.RelativePath = relativeVirtualPath;
        }