Merge pull request #6103 from sbwalker/dev
Global Replace should include settings
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="site" HelpText="Specify if site properties should be updated (ie. name, headcontent, bodycontent)" ResourceKey="Site">Site Properties? </Label>
|
||||
<Label Class="col-sm-3" For="site" HelpText="Specify if site information should be updated (ie. name, head content, body content, settings)" ResourceKey="Site">Site Info? </Label>
|
||||
<div class="col-sm-9">
|
||||
<select id="site" class="form-select" @bind="@_site">
|
||||
<option value="True">@SharedLocalizer["Yes"]</option>
|
||||
@@ -37,7 +37,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="pages" HelpText="Specify if page properties should be updated (ie. name, title, headcontent, bodycontent)" ResourceKey="Pages">Page Properties? </Label>
|
||||
<Label Class="col-sm-3" For="pages" HelpText="Specify if page information should be updated (ie. name, title, head content, body content, settings)" ResourceKey="Pages">Page Info? </Label>
|
||||
<div class="col-sm-9">
|
||||
<select id="pages" class="form-select" @bind="@_pages">
|
||||
<option value="True">@SharedLocalizer["Yes"]</option>
|
||||
@@ -46,7 +46,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="modules" HelpText="Specify if module properties should be updated (ie. title, header, footer)" ResourceKey="Modules">Module Properties? </Label>
|
||||
<Label Class="col-sm-3" For="modules" HelpText="Specify if module information should be updated (ie. title, header, footer, settings)" ResourceKey="Modules">Module Info? </Label>
|
||||
<div class="col-sm-9">
|
||||
<select id="modules" class="form-select" @bind="@_modules">
|
||||
<option value="True">@SharedLocalizer["Yes"]</option>
|
||||
|
||||
@@ -130,16 +130,16 @@
|
||||
<value>Specify if module content should be updated</value>
|
||||
</data>
|
||||
<data name="Pages.Text" xml:space="preserve">
|
||||
<value>Page Properties?</value>
|
||||
<value>Page Info?</value>
|
||||
</data>
|
||||
<data name="Pages.HelpText" xml:space="preserve">
|
||||
<value>Specify if page properties should be updated (ie. name, title, headcontent, bodycontent)</value>
|
||||
<value>Specify if page information should be updated (ie. name, title, head content, body content settings)</value>
|
||||
</data>
|
||||
<data name="Site.Text" xml:space="preserve">
|
||||
<value>Site Properties?</value>
|
||||
<value>Site Info?</value>
|
||||
</data>
|
||||
<data name="Site.HelpText" xml:space="preserve">
|
||||
<value>Specify if site properties should be updated (ie. name, headcontent, bodycontent)</value>
|
||||
<value>Specify if site information should be updated (ie. name, head content, body content, settings)</value>
|
||||
</data>
|
||||
<data name="Replace.Text" xml:space="preserve">
|
||||
<value>Replace With:</value>
|
||||
@@ -148,10 +148,10 @@
|
||||
<value>Specify the replacement content</value>
|
||||
</data>
|
||||
<data name="Modules.Text" xml:space="preserve">
|
||||
<value>Module Properties?</value>
|
||||
<value>Module Info?</value>
|
||||
</data>
|
||||
<data name="Modules.HelpText" xml:space="preserve">
|
||||
<value>Specify if module properties should be updated (ie. title, header, footer)</value>
|
||||
<value>Specify if module information should be updated (ie. title, header, footer settings)</value>
|
||||
</data>
|
||||
<data name="Success.Save" xml:space="preserve">
|
||||
<value>Your Global Replace Request Has Been Submitted And Will Be Executed Shortly. Please Be Patient.</value>
|
||||
|
||||
@@ -20,7 +20,8 @@ namespace Oqtane.Infrastructure
|
||||
var siteRepository = provider.GetRequiredService<ISiteRepository>();
|
||||
var pageRepository = provider.GetRequiredService<IPageRepository>();
|
||||
var pageModuleRepository = provider.GetRequiredService<IPageModuleRepository>();
|
||||
var TenantManager = provider.GetRequiredService<ITenantManager>();
|
||||
var settingRepository = provider.GetRequiredService<ISettingRepository>();
|
||||
var tenantManager = provider.GetRequiredService<ITenantManager>();
|
||||
var syncManager = provider.GetRequiredService<ISyncManager>();
|
||||
|
||||
if (!string.IsNullOrEmpty(parameters))
|
||||
@@ -59,6 +60,14 @@ namespace Oqtane.Infrastructure
|
||||
log += $"Site Updated<br />";
|
||||
refresh = true;
|
||||
}
|
||||
if (globalReplace.Site)
|
||||
{
|
||||
if (UpdateSettings(settingRepository, EntityNames.Site, site.SiteId, find, replace, comparisonType))
|
||||
{
|
||||
log += $"Site Settings Updated<br />";
|
||||
refresh = true;
|
||||
}
|
||||
}
|
||||
|
||||
var pages = pageRepository.GetPages(site.SiteId).ToList();
|
||||
var pageModules = pageModuleRepository.GetPageModules(site.SiteId).ToList();
|
||||
@@ -94,6 +103,14 @@ namespace Oqtane.Infrastructure
|
||||
log += $"Page Updated: /{page.Path}<br />";
|
||||
refresh = true;
|
||||
}
|
||||
if (globalReplace.Pages)
|
||||
{
|
||||
if (UpdateSettings(settingRepository, EntityNames.Page, page.PageId, find, replace, comparisonType))
|
||||
{
|
||||
log += $"Page Settings Updated<br />";
|
||||
refresh = true;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var pageModule in pageModules.Where(item => item.PageId == page.PageId))
|
||||
{
|
||||
@@ -120,6 +137,14 @@ namespace Oqtane.Infrastructure
|
||||
log += $"Module Updated: {pageModule.Title} Page: /{page.Path}<br />";
|
||||
refresh = true;
|
||||
}
|
||||
if (globalReplace.Modules)
|
||||
{
|
||||
if (UpdateSettings(settingRepository, EntityNames.Module, pageModule.ModuleId, find, replace, comparisonType))
|
||||
{
|
||||
log += $"Module Settings Updated<br />";
|
||||
refresh = true;
|
||||
}
|
||||
}
|
||||
|
||||
// module content
|
||||
if (pageModule.Module.ModuleDefinition != null && pageModule.Module.ModuleDefinition.ServerManagerType != "")
|
||||
@@ -150,7 +175,7 @@ namespace Oqtane.Infrastructure
|
||||
if (refresh)
|
||||
{
|
||||
// clear cache
|
||||
syncManager.AddSyncEvent(TenantManager.GetAlias(), EntityNames.Site, site.SiteId, SyncEventActions.Refresh);
|
||||
syncManager.AddSyncEvent(tenantManager.GetAlias(), EntityNames.Site, site.SiteId, SyncEventActions.Refresh);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -160,5 +185,21 @@ namespace Oqtane.Infrastructure
|
||||
|
||||
return log;
|
||||
}
|
||||
|
||||
private bool UpdateSettings(ISettingRepository settingRepository, string entityName, int entityId, string find, string replace, StringComparison comparisonType)
|
||||
{
|
||||
var changed = false;
|
||||
var settings = settingRepository.GetSettings(entityName, entityId).ToList();
|
||||
foreach (var setting in settings)
|
||||
{
|
||||
if (setting.SettingValue != null && setting.SettingValue.Contains(find, comparisonType))
|
||||
{
|
||||
setting.SettingValue = setting.SettingValue.Replace(find, replace, comparisonType);
|
||||
settingRepository.UpdateSetting(setting);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user