예제 #1
0
        public static void UpdatePluginStatus(this PluginSettings pluginSettings, string systemName, bool installed,
                                              bool active)
        {
            var pluginStatus = pluginSettings.GetSitePlugins();
            var ps           = pluginStatus.FirstOrDefault(x => x.PluginSystemName == systemName);

            if (ps == null)
            {
                ps = new PluginStatus()
                {
                    PluginSystemName = systemName
                };
                pluginStatus.Add(ps);
            }
            ps.Installed = installed;
            var storeId = ApplicationEngine.CurrentStore.Id;

            ps.ActiveStoreIds = ps.ActiveStoreIds ?? new List <int>();
            if (active)
            {
                if (!ps.ActiveStoreIds.Contains(storeId))
                {
                    ps.ActiveStoreIds.Add(storeId);
                }
            }
            else
            {
                ps.ActiveStoreIds.Remove(storeId);
            }
            pluginSettings.SetSitePlugins(pluginStatus, true);
        }
예제 #2
0
        public static void UpdatePluginStatus(this PluginSettings pluginSettings, string systemName, bool installed,
                                              bool active)
        {
            var pluginStatus = pluginSettings.GetSitePlugins();
            var ps           = pluginStatus.FirstOrDefault(x => x.PluginSystemName == systemName);

            if (ps == null)
            {
                ps = new PluginStatus()
                {
                    PluginSystemName = systemName
                };
                pluginStatus.Add(ps);
            }
            ps.Active    = active;
            ps.Installed = installed;
            pluginSettings.SetSitePlugins(pluginStatus, true);
        }
예제 #3
0
        public static IList <WidgetStatus> GetSiteWidgets(this PluginSettings pluginSettings, bool activeOnly = false)
        {
            var siteWidgets = pluginSettings.SiteWidgets;

            if (siteWidgets.IsNullEmptyOrWhiteSpace())
            {
                return(new List <WidgetStatus>());
            }

            var dataSerializer = DependencyResolver.Resolve <IDataSerializer>();
            var widgets        = dataSerializer.DeserializeAs <IList <WidgetStatus> >(siteWidgets);

            if (activeOnly)
            {
                var sitePlugins = pluginSettings.GetSitePlugins().Where(x => x.Active).Select(x => x.PluginSystemName);
                widgets = widgets.Where(x => x.PluginSystemName == ApplicationConfig.InbuiltWidgetPluginName || sitePlugins.Contains(x.PluginSystemName)).ToList();
            }
            return(widgets.OrderBy(x => x.DisplayOrder).ToList());
        }