Skip to content

Commit

Permalink
Update to version 1.0.9
Browse files Browse the repository at this point in the history
 - Fixed multilanguage resources removing process. Now all localized resources removing before picture;
 - New version of JSSOR slider added. Now clients can configure slide transitions of PublicInfo view;
 - Admin permissions controll was added to plugin configuration controller;
 - Fixed 'plugin descriptor not found' exception for Linux servers;
  • Loading branch information
iAlexeyProkhorov committed May 16, 2020
1 parent e22e2e4 commit 9bd5577
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 7,099 deletions.
104 changes: 10 additions & 94 deletions BaseBaroquePlugin.cs
Original file line number Diff line number Diff line change
@@ -1,93 +1,39 @@
using Newtonsoft.Json;
using Nop.Core;
using Nop.Core.Infrastructure;
using Nop.Core.Infrastructure;
using Nop.Services.Localization;
using Nop.Services.Plugins;
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Xml;

namespace Nop.Plugin.Widgets.qBoSlider
{
/// <summary>
/// Base Baroque plugin
/// </summary>
public abstract class BaseBaroquePlugin : BasePlugin
{
#region Fields

private readonly ILanguageService _languageService;
private readonly ILocalizationService _localizationService;

#endregion

#region Additional fields

public static FileInfo _originalAssemblyFile { get; private set; }

public static PluginDescriptor BaroquePluginDescriptor { get; private set; }
private readonly FileInfo _originalAssemblyFile;

#endregion

#region Constructor

public BaseBaroquePlugin()
{
//get plugin descriptor
var pluginsInfo = Singleton<IPluginsInfo>.Instance;
var descriptor = pluginsInfo.PluginDescriptors.FirstOrDefault(x => x.PluginType == this.GetType());
//intialize varialbes
this._localizationService = EngineContext.Current.Resolve<ILocalizationService>();
this._languageService = EngineContext.Current.Resolve<ILanguageService>();

//get current plugin location in file system
string pluginLibraryLocationPath = Assembly.GetExecutingAssembly().Location;

//get plugin library name
string pluginLibraryName = Path.GetFileName(pluginLibraryLocationPath);
}

static BaseBaroquePlugin()
{
//get current plugin location in file system
string pluginLibraryLocationPath = Assembly.GetExecutingAssembly().Location;

//get plugin library name
string pluginLibraryName = Path.GetFileName(pluginLibraryLocationPath);

//get plugin library folder
string pluginLibraryFolder = Path.GetDirectoryName(pluginLibraryLocationPath);
var parentFolder = Directory.GetParent(pluginLibraryFolder);

//search for this file in nop plugins folder
var foundedFiles = Directory.GetFiles(parentFolder.FullName, pluginLibraryName, SearchOption.AllDirectories);

//create default plugin descriptor
BaroquePluginDescriptor = new PluginDescriptor(Assembly.GetExecutingAssembly());

//get plugin descriptor from plugin description file
if (foundedFiles.Any())
{
string nopPluginLibraryPath = string.Empty;
foreach (var file in foundedFiles)
if (!file.Contains("\\Plugins\\bin\\"))
{
nopPluginLibraryPath = file;
break;
}

if (!string.IsNullOrEmpty(nopPluginLibraryPath))
{
_originalAssemblyFile = new FileInfo(nopPluginLibraryPath);

var pluginDescriptorFile = $"{_originalAssemblyFile.DirectoryName}\\{ NopPluginDefaults.DescriptionFileName }";

if (!File.Exists(pluginDescriptorFile))
throw new Exception($"Plugin descriptor for {pluginLibraryName} aren't found");

var descriptorText = File.ReadAllText(pluginDescriptorFile);

BaroquePluginDescriptor = PluginDescriptor.GetPluginDescriptorFromText(descriptorText);

BaroquePluginDescriptor.Installed = IsPluginInstalled();
}
}
this._originalAssemblyFile = new FileInfo(descriptor.OriginalAssemblyFile);
}

#endregion
Expand Down Expand Up @@ -172,16 +118,6 @@ protected virtual void UninstallLocalization()
}
}

/// <summary>
/// Check current plugin installation status in 'InstalledPlugins.txt' document
/// </summary>
/// <param name="systemName">Plugin system name</param>
/// <returns>True - when plugin marked like installed</returns>
protected static bool IsPluginInstalled()
{
return IsPluginInstalled(BaroquePluginDescriptor.SystemName);
}

#endregion

#region Methods
Expand All @@ -198,26 +134,6 @@ public override void Uninstall()
base.Uninstall();
}

/// <summary>
/// Check InstalledPlugins.txt file list on plugin system name
/// </summary>
/// <param name="systemName">Plugin system name</param>
/// <returns>True when plugin added to list</returns>
public static bool IsPluginInstalled(string systemName)
{
string installedPluginsFile = CommonHelper.DefaultFileProvider.MapPath(NopPluginDefaults.PluginsInfoFilePath);

if (File.Exists(installedPluginsFile))
{
var redisPluginsInfo = JsonConvert.DeserializeObject<PluginsInfo>(File.ReadAllText(installedPluginsFile));


return redisPluginsInfo.InstalledPluginNames.Contains(systemName);
}

return false;
}

#endregion
}
}
4 changes: 2 additions & 2 deletions Content/slider.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
.jssorb05 div, .jssorb05 div:hover, .jssorb05 .av {
position: absolute;
/* size of bullet elment */
width: 16px;
height: 16px;
width: 10px;
height: 10px;
/*background: url(../Content/Images/b14.png) no-repeat;*/
background:#4ab2f1;
overflow: hidden;
Expand Down
27 changes: 27 additions & 0 deletions Controllers/qBoSliderController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class qBoSliderController : BasePluginController
private readonly ILocalizationService _localizationService;
private readonly ILocalizedEntityService _localizedEntityService;
private readonly INotificationService _notificationService;
private readonly IPermissionService _permissionService;
private readonly IPictureService _pictureService;
private readonly ISettingService _settingService;
private readonly ISlideService _slideService;
Expand All @@ -58,6 +59,7 @@ public qBoSliderController(ICacheManager cacheManager,
ILocalizationService localizationService,
ILocalizedEntityService localizedEntityService,
INotificationService notificationService,
IPermissionService permissionService,
IPictureService pictureService,
ISettingService settingService,
ISlideService slideService,
Expand All @@ -75,6 +77,7 @@ public qBoSliderController(ICacheManager cacheManager,
this._localizationService = localizationService;
this._localizedEntityService = localizedEntityService;
this._notificationService = notificationService;
this._permissionService = permissionService;
this._pictureService = pictureService;
this._settingService = settingService;
this._slideService = slideService;
Expand Down Expand Up @@ -217,6 +220,9 @@ protected virtual void SaveCustomerRolesAcl(Slide slide, SlideModel model)

public IActionResult Configure()
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets))
return AccessDeniedView();

//load settings for a chosen store scope
var storeScope = _storeContext.ActiveStoreScopeConfiguration;
var qBoSliderSettings = _settingService.LoadSetting<qBoSliderSettings>(storeScope);
Expand Down Expand Up @@ -244,6 +250,9 @@ public IActionResult Configure()
[HttpPost]
public IActionResult Configure(ConfigurationModel model)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets))
return AccessDeniedView();

var storeScope = _storeContext.ActiveStoreScopeConfiguration;
var qBoSliderSettings = _settingService.LoadSetting<qBoSliderSettings>(storeScope);

Expand Down Expand Up @@ -272,6 +281,9 @@ public IActionResult Configure(ConfigurationModel model)
[HttpPost]
public IActionResult SlideList(SlideSearchModel searchModel)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets))
return AccessDeniedDataTablesJson();

var slides = _slideService.GetAllSlides(showHidden: true, pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize);
var gridModel = new SlideSearchModel.SlidePagedListModel().PrepareToGrid(searchModel, slides, () =>
{
Expand All @@ -296,6 +308,9 @@ public IActionResult SlideList(SlideSearchModel searchModel)

public IActionResult CreateSlidePopup()
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets))
return AccessDeniedView();

var model = new SlideModel();
AddLocales(_languageService, model.Locales);

Expand All @@ -311,6 +326,9 @@ public IActionResult CreateSlidePopup()
[HttpPost]
public IActionResult CreateSlidePopup(SlideModel model, string btnId, string formId)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets))
return AccessDeniedView();

var validator = new SlideValidator(_localizationService);
var validationResult = validator.Validate(model);

Expand Down Expand Up @@ -356,6 +374,9 @@ public IActionResult CreateSlidePopup(SlideModel model, string btnId, string for

public IActionResult EditSlidePopup(int id, string btnId, string formId)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets))
return AccessDeniedView();

var model = new SlideModel();
var slide = _slideService.GetSlideById(id);

Expand Down Expand Up @@ -388,6 +409,9 @@ public IActionResult EditSlidePopup(int id, string btnId, string formId)
[HttpPost]
public IActionResult EditSlidePopup(SlideModel model, string btnId, string formId)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets))
return AccessDeniedView();

var slide = _slideService.GetSlideById(model.Id);

//parent form data for refresh
Expand Down Expand Up @@ -446,6 +470,9 @@ public IActionResult EditSlidePopup(SlideModel model, string btnId, string formI
[HttpPost]
public IActionResult SlideDelete(int id)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets))
return AccessDeniedDataTablesJson();

var slide = _slideService.GetSlideById(id);

if (slide != null)
Expand Down
10 changes: 5 additions & 5 deletions Nop.Plugin.Widgets.qBoSlider.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageProjectUrl></PackageProjectUrl>
<RepositoryUrl></RepositoryUrl>
<RepositoryType></RepositoryType>
<Version>1.0.7</Version>
<Version>1.0.9</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down Expand Up @@ -78,10 +78,7 @@
<None Update="logo.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Scripts\jssor.js">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Scripts\jssor.slider.js">
<None Update="Scripts\jssor.slider.min.js">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Views\Admin\Configure.cshtml">
Expand All @@ -106,6 +103,9 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Scripts\" />
</ItemGroup>
<!-- This target execute after "Build" target -->
<Target Name="NopTarget" AfterTargets="Build">
<!-- Delete unnecessary libraries from plugins path -->
Expand Down
Loading

0 comments on commit 9bd5577

Please sign in to comment.