22using Connect . LanguagePackManager . Core . Data ;
33using Connect . LanguagePackManager . Core . Helpers ;
44using Connect . LanguagePackManager . Core . Repositories ;
5- using Connect . LanguagePackManager . Core . Services . Github ;
65using System ;
76using System . Collections . Generic ;
87using System . IO ;
@@ -17,32 +16,6 @@ public class LanguagePackManifest : XmlDocument
1716 public int ModuleId { get ; set ; }
1817 public int ManifestVersion { get ; set ; } = 0 ;
1918 public List < ComponentPack > Components { get ; set ; } = new List < ComponentPack > ( ) ;
20- private string BasePath { get ; set ; } = "" ;
21-
22- public LanguagePackManifest ( GithubTree tree , GithubFile manifestFile , int moduleId )
23- {
24- var manifest = GithubService . DownloadFile ( manifestFile . Url ) ;
25-
26- this . ModuleId = moduleId ;
27- this . LoadXml ( manifest ) ;
28-
29- var mainNodes = this . SelectNodes ( "dotnetnuke/packages/package" ) ;
30- if ( mainNodes . Count > 0 )
31- {
32- this . BasePath = Path . GetDirectoryName ( manifestFile . Path ) ;
33- this . ManifestVersion = 5 ;
34- this . LoadPackV5FromGithub ( tree ) ;
35- }
36- else
37- {
38- mainNodes = this . SelectNodes ( "dotnetnuke/folders/folder" ) ;
39- if ( mainNodes . Count > 0 )
40- {
41- this . ManifestVersion = 3 ;
42- throw new System . Exception ( "Version 3 manifest not implemented" ) ;
43- }
44- }
45- }
4619
4720 public LanguagePackManifest ( UnzipResult unzipResult , int moduleId )
4821 {
@@ -149,60 +122,5 @@ private void LoadPackV5FromUploadedZipFile(UnzipResult unzipResult)
149122 }
150123 }
151124 }
152-
153- private void LoadPackV5FromGithub ( GithubTree tree )
154- {
155- foreach ( XmlNode p in this . SelectNodes ( "dotnetnuke/packages/package" ) )
156- {
157- try
158- {
159- string packType = p . SelectSingleNode ( "@type" ) . InnerText . ToLowerInvariant ( ) ;
160- var isCorePack = packType == "corelanguagepack" ;
161- var component = isCorePack ? Common . Globals . glbCoreName : p . SelectSingleNode ( "components/component/languageFiles/package" ) . InnerText ;
162-
163- var package = PackageRepository . Instance . FindPackage ( component , this . ModuleId ) ;
164- if ( package != null )
165- {
166- var comp = new ComponentPack ( )
167- {
168- Package = package ,
169- Version = p . SelectSingleNode ( "@version" ) . InnerText . ParseVersion ( ) . ToNormalizedFormat ( ) ,
170- Locale = p . SelectSingleNode ( "components/component/languageFiles/code" ) . InnerText . ToLowerInvariant ( )
171- } ;
172- if ( comp . Version == "00.00.00" )
173- {
174- comp . Version = package . LastVersion ;
175- }
176-
177- string basePath = "" ;
178- if ( p . SelectSingleNode ( "components/component/languageFiles/basePath" ) is object )
179- {
180- basePath = p . SelectSingleNode ( "components/component/languageFiles/basePath" ) . InnerText ;
181- }
182-
183- foreach ( XmlNode xNode in p . SelectNodes ( "components/component/languageFiles/languageFile" ) )
184- {
185- string filePath = xNode . SelectSingleNode ( "path" ) . InnerText ;
186- string fileName = xNode . SelectSingleNode ( "name" ) . InnerText ;
187- string fileKey = Globals . DnnPathCombine ( basePath , filePath , Regex . Replace ( fileName , @"(?i)\.\w{2}(-\w+)?\.resx$(?-i)" , ".resx" ) ) ;
188-
189- var fileInZip = Globals . DnnPathCombine ( this . BasePath , filePath , fileName ) . ToLowerInvariant ( ) ;
190-
191- var fileOnGithub = tree . Files . FirstOrDefault ( f => f . Path . ToLowerInvariant ( ) . CompareTo ( fileInZip ) == 0 ) ;
192- if ( fileOnGithub != null )
193- {
194- var rfile = new ResxFile ( fileKey , GithubService . DownloadFile ( fileOnGithub . Url ) ) ;
195- comp . ResourceFiles . Add ( rfile ) ;
196- }
197- }
198-
199- this . Components . Add ( comp ) ;
200- }
201- }
202- catch ( Exception ex )
203- {
204- }
205- }
206- }
207125 }
208126}
0 commit comments