using System.Collections.Generic;
using Nop.Core;
using Nop.Services.Cms;
using Nop.Services.Configuration;
using Nop.Services.Localization;
using Nop.Services.Plugins;
using Nop.Web.Framework.Infrastructure;
namespace Nop.Plugin.Widgets.NopCliGeneric
{
///
/// PLugin
///
public class WidgetsNopCliGenericPlugin : BasePlugin, IWidgetPlugin
{
private readonly ILocalizationService _localizationService;
private readonly ISettingService _settingService;
private readonly IWebHelper _webHelper;
public WidgetsNopCliGenericPlugin(ILocalizationService localizationService,
ISettingService settingService,
IWebHelper webHelper )
{
_localizationService = localizationService;
_settingService = settingService;
_webHelper = webHelper;
}
///
/// Gets widget zones where this widget should be rendered
///
/// Widget zones
public IList GetWidgetZones()
{
return new List { PublicWidgetZones.HomepageTop };
}
///
/// Gets a configuration page URL
///
public override string GetConfigurationPageUrl()
{
return _webHelper.GetStoreLocation() + "Admin/WidgetsWidgetsNopCliGeneric/Configure";
}
///
/// Gets a name of a view component for displaying widget
///
/// Name of the widget zone
/// View component name
public string GetWidgetViewComponentName(string widgetZone)
{
return "WidgetsWidgetsNopCliGeneric";
}
///
/// Install plugin
///
public override void Install()
{
//settings
var settings = new WidgetsNopCliGenericSettings
{
Property = "NopCliGeneric"
};
_settingService.SaveSetting(settings);
_localizationService.AddPluginLocaleResource(new Dictionary
{
["Plugins.Widgets.WidgetsNopCliGeneric.Property"] = "NopCliGeneric",
});
base.Install();
}
///
/// Uninstall plugin
///
public override void Uninstall()
{
//settings
_settingService.DeleteSetting();
//locales
_localizationService.DeletePluginLocaleResources("Plugins.Widgets.WidgetsNopCliGeneric");
base.Uninstall();
}
///
/// Gets a value indicating whether to hide this plugin on the widget list page in the admin area
///
public bool HideInWidgetList => false;
}
}