/// <summary> /// Get the absolute path by virtual path /// </summary> /// <param name="virtualPath">Virtual path</param> /// <returns>Path</returns> protected virtual string GetFullPath(string virtualPath) { virtualPath ??= string.Empty; if (!virtualPath.StartsWith("/")) { virtualPath = "/" + virtualPath; } virtualPath = virtualPath.TrimEnd('/'); return(_fileProvider.Combine(_webHostEnvironment.WebRootPath, virtualPath)); }
static ApplicationPartManagerExtensions() { //we use the default file provider, since the DI isn't initialized yet _fileProvider = CommonHelper.DefaultFileProvider; _baseAppLibraries = new List <string>(); //get all libraries from /bin/{version}/ directory _baseAppLibraries.AddRange(_fileProvider.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "*.dll") .Select(fileName => _fileProvider.GetFileName(fileName))); //get all libraries from base site directory if (!AppDomain.CurrentDomain.BaseDirectory.Equals(Environment.CurrentDirectory, StringComparison.InvariantCultureIgnoreCase)) { _baseAppLibraries.AddRange(_fileProvider.GetFiles(Environment.CurrentDirectory, "*.dll") .Select(fileName => _fileProvider.GetFileName(fileName))); } //get all libraries from refs directory var refsPathName = _fileProvider.Combine(Environment.CurrentDirectory, SmiPluginDefaults.RefsPathName); if (_fileProvider.DirectoryExists(refsPathName)) { _baseAppLibraries.AddRange(_fileProvider.GetFiles(refsPathName, "*.dll") .Select(fileName => _fileProvider.GetFileName(fileName))); } }
/// <summary> /// Get picture (thumb) local path /// </summary> /// <param name="thumbFileName">Filename</param> /// <returns>Local picture thumb path</returns> protected virtual string GetThumbLocalPath(string thumbFileName) { var thumbsDirectoryPath = _fileProvider.GetAbsolutePath(SmiMediaDefaults.ImageThumbsPath); if (_mediaSettings.MultipleThumbDirectories) { //get the first two letters of the file name var fileNameWithoutExtension = _fileProvider.GetFileNameWithoutExtension(thumbFileName); if (fileNameWithoutExtension != null && fileNameWithoutExtension.Length > SmiMediaDefaults.MultipleThumbDirectoriesLength) { var subDirectoryName = fileNameWithoutExtension.Substring(0, SmiMediaDefaults.MultipleThumbDirectoriesLength); thumbsDirectoryPath = _fileProvider.GetAbsolutePath(SmiMediaDefaults.ImageThumbsPath, subDirectoryName); _fileProvider.CreateDirectory(thumbsDirectoryPath); } } var thumbFilePath = _fileProvider.Combine(thumbsDirectoryPath, thumbFileName); return(thumbFilePath); }
/// <summary> /// Returns the path to the backup file /// </summary> /// <param name="backupFileName">The name of the backup file</param> /// <returns>The path to the backup file</returns> public virtual string GetBackupPath(string backupFileName) { return(_fileProvider.Combine(GetBackupDirectoryPath(), backupFileName)); }
/// <summary> /// Install plugin /// </summary> public override void Install() { //pictures var sampleImagesPath = _fileProvider.MapPath("~/Plugins/Widgets.NivoSlider/Content/nivoslider/sample-images/"); //settings var settings = new NivoSliderSettings { Picture1Id = _pictureService.InsertPicture(_fileProvider.ReadAllBytes(_fileProvider.Combine(sampleImagesPath, "banner1.jpg")), MimeTypes.ImagePJpeg, "banner_1").Id, Text1 = "", Link1 = _webHelper.GetStoreLocation(false), Picture2Id = _pictureService.InsertPicture(_fileProvider.ReadAllBytes(_fileProvider.Combine(sampleImagesPath, "banner2.jpg")), MimeTypes.ImagePJpeg, "banner_2").Id, Text2 = "", Link2 = _webHelper.GetStoreLocation(false) //Picture3Id = _pictureService.InsertPicture(File.ReadAllBytes(_fileProvider.Combine(sampleImagesPath,"banner3.jpg")), MimeTypes.ImagePJpeg, "banner_3").Id, //Text3 = "", //Link3 = _webHelper.GetStoreLocation(false), }; _settingService.SaveSetting(settings); _localizationService.AddPluginLocaleResource(new Dictionary <string, string> { ["Plugins.Widgets.NivoSlider.Picture1"] = "Picture 1", ["Plugins.Widgets.NivoSlider.Picture2"] = "Picture 2", ["Plugins.Widgets.NivoSlider.Picture3"] = "Picture 3", ["Plugins.Widgets.NivoSlider.Picture4"] = "Picture 4", ["Plugins.Widgets.NivoSlider.Picture5"] = "Picture 5", ["Plugins.Widgets.NivoSlider.Picture"] = "Picture", ["Plugins.Widgets.NivoSlider.Picture.Hint"] = "Upload picture.", ["Plugins.Widgets.NivoSlider.Text"] = "Comment", ["Plugins.Widgets.NivoSlider.Text.Hint"] = "Enter comment for picture. Leave empty if you don't want to display any text.", ["Plugins.Widgets.NivoSlider.Link"] = "URL", ["Plugins.Widgets.NivoSlider.Link.Hint"] = "Enter URL. Leave empty if you don't want this picture to be clickable.", ["Plugins.Widgets.NivoSlider.AltText"] = "Image alternate text", ["Plugins.Widgets.NivoSlider.AltText.Hint"] = "Enter alternate text that will be added to image." }); base.Install(); }