private static void RegisterToolboxItem(Telerik.Sitefinity.DynamicModules.Builder.Model.DynamicModule dynamicModule, DynamicModuleType moduleType) { MvcWidgetInstaller.UnregisterToolboxItem(moduleType.GetFullTypeName()); var configurationManager = ConfigManager.GetManager(); var toolboxesConfig = configurationManager.GetSection <ToolboxesConfig>(); var section = MvcWidgetInstaller.GetModuleToolboxSection(dynamicModule, toolboxesConfig); if (section == null) { return; } var toolboxItem = new ToolboxItem(section.Tools) { Name = moduleType.GetFullTypeName() + "_MVC", Title = PluralsResolver.Instance.ToPlural(moduleType.DisplayName), Description = string.Empty, ModuleName = dynamicModule.Name, ControlType = typeof(MvcWidgetProxy).AssemblyQualifiedName, ControllerType = typeof(DynamicContentController).FullName, CssClass = "sfNewsViewIcn sfMvcIcn", Parameters = new NameValueCollection() { { "WidgetName", moduleType.TypeName }, { "ControllerName", typeof(DynamicContentController).FullName } } }; section.Tools.Add(toolboxItem); configurationManager.SaveSection(toolboxesConfig); }
private static void RegisterTemplates(Telerik.Sitefinity.DynamicModules.Builder.Model.DynamicModule dynamicModule, DynamicModuleType dynamicModuleType, string transactionName) { MvcWidgetInstaller.TemplateGaneratorAction( templateGenerator => { templateGenerator.InstallMasterTemplate(dynamicModule, dynamicModuleType); templateGenerator.InstallDetailTemplate(dynamicModule, dynamicModuleType); }, transactionName); }
private static void DynamicModuleTypeDeletingEventHandler(IDynamicModuleTypeDeletingEvent @event) { if (@event == null || @event.Item == null || @event.Item.Provider == null) { return; } var transactionName = MvcWidgetInstaller.GetTransactionName(@event.Item); MvcWidgetInstaller.TemplateGaneratorAction( templateGenerator => templateGenerator.UnregisterTemplates(@event.Item.GetFullTypeName()), transactionName); MvcWidgetInstaller.UnregisterToolboxItem(@event.Item.GetFullTypeName()); }
/// <summary> /// Initializes this instance. /// </summary> public static void Initialize() { if (SystemManager.GetModule("ModuleBuilder") == null) { return; } MvcWidgetInstaller.Initialize(); DynamicWidgetInitializer.RegisterDynamicTemplatableControl(); DynamicWidgetInitializer.RegisterFields(); string mvcControllerProxySettingsPropertyDescriptorName = string.Format("{0}.{1}", typeof(MvcWidgetProxy).FullName, "Settings"); ObjectFactory.Container.RegisterType <IControlPropertyDescriptor, ControllerSettingsPropertyDescriptor>(mvcControllerProxySettingsPropertyDescriptorName); }
private static void DynamicModuleUpdatingEventHandler(IDynamicModuleUpdatingEvent @event) { if (@event == null || @event.ChangedProperties == null || @event.Item == null || @event.Item.Types == null || @event.Item.Types.Length == 0) { return; } if (@event.ChangedProperties.ContainsKey("Status")) { var statusChange = @event.ChangedProperties["Status"]; if ((DynamicModuleStatus)statusChange.NewValue == DynamicModuleStatus.Active && (int)statusChange.OldValue == (int)DynamicModuleStatus.NotInstalled) { var transactionName = MvcWidgetInstaller.GetTransactionName(@event.Item); foreach (var moduleType in @event.Item.Types) { MvcWidgetInstaller.Install(@event.Item, moduleType, transactionName); } } } }
private static void DynamicModuleTypeEventHandler(IDynamicModuleTypeItemEvent @event) { if (@event == null || @event.Item == null) { return; } var updatingEvent = @event as IDynamicModuleTypeUpdatingEvent; if (updatingEvent != null && updatingEvent.ShouldUpdateWidgetTemplates == false) { return; } var transactionName = MvcWidgetInstaller.GetTransactionName(@event.Item); var module = ModuleBuilderManager.GetManager(null, transactionName).Provider.GetDynamicModules().SingleOrDefault(m => m.Id == @event.Item.ParentModuleId); if (module != null && module.Status != DynamicModuleStatus.NotInstalled) { MvcWidgetInstaller.Install(module, @event.Item, transactionName); } }
private static void Install(DynamicModule module, DynamicModuleType type, string transactionName) { MvcWidgetInstaller.RegisterTemplates(module, type, transactionName); MvcWidgetInstaller.RegisterToolboxItem(module, type); }
/// <summary> /// Removes the toolbox item. /// </summary> /// <param name="contentTypeName">Name of the content type.</param> private static void UnregisterToolboxItem(string contentTypeName) { var configurationManager = ConfigManager.GetManager(); var toolboxesConfig = configurationManager.GetSection <ToolboxesConfig>(); var pageControls = toolboxesConfig.Toolboxes["PageControls"]; var moduleSectionName = contentTypeName.Substring(0, contentTypeName.LastIndexOf('.')); var section = pageControls.Sections.Where <ToolboxSection>(e => e.Name == moduleSectionName).FirstOrDefault(); if (section != null) { var itemToDelete = section.Tools.FirstOrDefault <ToolboxItem>(e => e.Name == MvcWidgetInstaller.GetToolboxItemName(contentTypeName)); if (itemToDelete != null) { section.Tools.Remove(itemToDelete); } if (!section.Tools.Any <ToolboxItem>()) { pageControls.Sections.Remove(section); } } configurationManager.SaveSection(toolboxesConfig); }
/// <summary> /// Deactivates this instance. /// </summary> public static void Deactivate() { DynamicWidgetInitializer.RegisterFields(); MvcWidgetInstaller.Deactivate(); }