mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
@@ -9,6 +9,8 @@ namespace Orchard.Email.Drivers {
|
||||
// Thus the encryption/decryption will be done when accessing the part's property
|
||||
|
||||
public class SmtpSettingsPartDriver : ContentPartDriver<SmtpSettingsPart> {
|
||||
private const string TemplateName = "Parts/SmtpSettings";
|
||||
|
||||
public SmtpSettingsPartDriver() {
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
@@ -18,12 +20,14 @@ namespace Orchard.Email.Drivers {
|
||||
protected override string Prefix { get { return "SmtpSettings"; } }
|
||||
|
||||
protected override DriverResult Editor(SmtpSettingsPart part, dynamic shapeHelper) {
|
||||
return ContentPartTemplate(part, "Parts/Smtp.SiteSettings");
|
||||
return ContentShape("Parts_SmtpSettings_Editor",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: part, Prefix: Prefix));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(SmtpSettingsPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
updater.TryUpdateModel(part, Prefix, null, null);
|
||||
return Editor(part, shapeHelper);
|
||||
return ContentShape("Parts_SmtpSettings_Editor",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: part, Prefix: Prefix));
|
||||
}
|
||||
}
|
||||
}
|
@@ -82,7 +82,7 @@
|
||||
<Content Include="Views\Web.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\EditorTemplates\Parts\Smtp.SiteSettings.cshtml" />
|
||||
<Content Include="Views\EditorTemplates\Parts\SmtpSettings.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
|
||||
@@ -98,6 +98,9 @@
|
||||
<Name>Orchard.Users</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Placement.info" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
3
src/Orchard.Web/Modules/Orchard.Email/Placement.info
Normal file
3
src/Orchard.Web/Modules/Orchard.Email/Placement.info
Normal file
@@ -0,0 +1,3 @@
|
||||
<Placement>
|
||||
<Place Parts_SmtpSettings_Editor="Primary:10"/>
|
||||
</Placement>
|
@@ -15,6 +15,7 @@ using Orchard.Data.Migration.Interpreters;
|
||||
using Orchard.Data.Migration.Schema;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.ShellBuilders;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
@@ -28,6 +29,7 @@ using Orchard.Themes;
|
||||
using Orchard.Environment.State;
|
||||
using Orchard.Data.Migration;
|
||||
using Orchard.Widgets.Models;
|
||||
using Orchard.Widgets;
|
||||
|
||||
namespace Orchard.Setup.Services {
|
||||
public class SetupService : ISetupService {
|
||||
@@ -163,113 +165,7 @@ namespace Orchard.Setup.Services {
|
||||
shellSettings.State = new TenantState("Running");
|
||||
using (var environment = _orchardHost.CreateStandaloneEnvironment(shellSettings)) {
|
||||
try {
|
||||
// create superuser
|
||||
var membershipService = environment.Resolve<IMembershipService>();
|
||||
var user =
|
||||
membershipService.CreateUser(new CreateUserParams(context.AdminUsername, context.AdminPassword,
|
||||
String.Empty, String.Empty, String.Empty,
|
||||
true));
|
||||
|
||||
// set site name and settings
|
||||
var siteService = environment.Resolve<ISiteService>();
|
||||
var siteSettings = siteService.GetSiteSettings().As<SiteSettingsPart>();
|
||||
siteSettings.Record.SiteSalt = Guid.NewGuid().ToString("N");
|
||||
siteSettings.Record.SiteName = context.SiteName;
|
||||
siteSettings.Record.SuperUser = context.AdminUsername;
|
||||
siteSettings.Record.PageTitleSeparator = " - ";
|
||||
siteSettings.Record.SiteCulture = "en-US";
|
||||
|
||||
// set site theme
|
||||
var themeService = environment.Resolve<IThemeService>();
|
||||
themeService.SetSiteTheme("TheThemeMachine");
|
||||
|
||||
// add default culture
|
||||
var cultureManager = environment.Resolve<ICultureManager>();
|
||||
cultureManager.AddCulture("en-US");
|
||||
|
||||
var contentManager = environment.Resolve<IContentManager>();
|
||||
|
||||
// this needs to exit the standalone environment? rework this process entirely?
|
||||
// simulate installation-time module activation events
|
||||
//var hackInstallationGenerator = environment.Resolve<IHackInstallationGenerator>();
|
||||
//hackInstallationGenerator.GenerateInstallEvents();
|
||||
|
||||
var contentDefinitionManager = environment.Resolve<IContentDefinitionManager>();
|
||||
//todo: (heskew) pull these definitions (and initial content creation) out into more appropriate modules
|
||||
contentDefinitionManager.AlterTypeDefinition("BlogPost", cfg => cfg
|
||||
.WithPart("CommentsPart")
|
||||
.WithPart("TagsPart")
|
||||
.WithPart("LocalizationPart")
|
||||
.Indexed()
|
||||
);
|
||||
contentDefinitionManager.AlterTypeDefinition("Page", cfg => cfg
|
||||
.WithPart("CommonPart")
|
||||
.WithPart("PublishLaterPart")
|
||||
.WithPart("RoutePart")
|
||||
.WithPart("BodyPart")
|
||||
.WithPart("TagsPart")
|
||||
.WithPart("LocalizationPart")
|
||||
.Creatable()
|
||||
.Indexed()
|
||||
);
|
||||
contentDefinitionManager.AlterPartDefinition("BodyPart", cfg => cfg
|
||||
.WithSetting("BodyPartSettings.FlavorDefault", BodyPartSettings.FlavorDefaultDefault));
|
||||
|
||||
|
||||
// add a layer for the homepage
|
||||
var homepageLayer = contentManager.Create("Layer");
|
||||
homepageLayer.As<LayerPart>().Name = "TheHomepage";
|
||||
homepageLayer.As<LayerPart>().LayerRule = "url \"~/\"";
|
||||
contentManager.Publish(homepageLayer);
|
||||
|
||||
// and three more for the tripel...really need this elsewhere...
|
||||
var tripelFirst = contentManager.Create("HtmlWidget");
|
||||
tripelFirst.As<WidgetPart>().LayerPart = homepageLayer.As<LayerPart>();
|
||||
tripelFirst.As<WidgetPart>().Title = T("First Leader Aside").Text;
|
||||
tripelFirst.As<WidgetPart>().Zone = "TripelFirst";
|
||||
tripelFirst.As<WidgetPart>().Position = "5";
|
||||
tripelFirst.As<BodyPart>().Text = "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur a nibh ut tortor dapibus vestibulum. Aliquam vel sem nibh. Suspendisse vel condimentum tellus.</p>";
|
||||
tripelFirst.As<CommonPart>().Owner = user;
|
||||
contentManager.Publish(tripelFirst);
|
||||
|
||||
var tripelSecond = contentManager.Create("HtmlWidget");
|
||||
tripelSecond.As<WidgetPart>().LayerPart = homepageLayer.As<LayerPart>();
|
||||
tripelSecond.As<WidgetPart>().Title = T("Second Leader Aside").Text;
|
||||
tripelSecond.As<WidgetPart>().Zone = "TripelSecond";
|
||||
tripelSecond.As<WidgetPart>().Position = "5";
|
||||
tripelSecond.As<BodyPart>().Text = "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur a nibh ut tortor dapibus vestibulum. Aliquam vel sem nibh. Suspendisse vel condimentum tellus.</p>";
|
||||
tripelSecond.As<CommonPart>().Owner = user;
|
||||
contentManager.Publish(tripelSecond);
|
||||
|
||||
var tripelThird = contentManager.Create("HtmlWidget");
|
||||
tripelThird.As<WidgetPart>().LayerPart = homepageLayer.As<LayerPart>();
|
||||
tripelThird.As<WidgetPart>().Title = T("Third Leader Aside").Text;
|
||||
tripelThird.As<WidgetPart>().Zone = "TripelThird";
|
||||
tripelThird.As<WidgetPart>().Position = "5";
|
||||
tripelThird.As<BodyPart>().Text = "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur a nibh ut tortor dapibus vestibulum. Aliquam vel sem nibh. Suspendisse vel condimentum tellus.</p>";
|
||||
tripelThird.As<CommonPart>().Owner = user;
|
||||
contentManager.Publish(tripelThird);
|
||||
|
||||
// create a welcome page that's promoted to the home page
|
||||
var page = contentManager.Create("Page");
|
||||
page.As<RoutePart>().Title = T("Welcome to Orchard!").Text;
|
||||
page.As<BodyPart>().Text = "<p>Congratulations, you've successfully set-up your Orchard site.</p><p>This is the home page of your new site. We've taken the liberty to write here about a few things you could look at next in order to get familiar with the application. Once you feel confident you don't need this anymore, just click <a href=\"/Admin/Contents/Edit/7\">Edit</a> to go into edit mode and replace this with whatever you want on your home page to make it your own.</p><p>One thing you could do (but you don't have to) is go into <a href=\"Admin/Settings\">Manage Settings</a> (follow the <a href=\"Admin\">Admin</a> link and then look for it under \"Settings\" in the menu on the left) and check that everything is configured the way you want.</p><p>You probably want to make the site your own. One of the ways you can do that is by clicking <a href=\"Admin/Themes\">Manage Themes</a> in the admin menu. A theme is a packaged look and feel that affects the whole site.</p><p>Next, you can start playing with the content types that we installed. For example, go ahead and click <a href=\"Admin/Pages/Create\">Add New Page</a> in the admin menu and create an \"about\" page. Then, add it to the navigation menu by going to <a href=\"Admin/Navigation\">Manage Menu</a>. You can also click <a href=\"Admin/Blogs/Create\">Add New Blog</a> and start posting by clicking \"Add New Post\".</p><p>Finally, Orchard has been designed to be extended. It comes with a few built-in modules such as pages and blogs or themes. You can install new themes by going to <a href=\"Admin/Themes\">Manage Themes</a> and clicking <a href=\"Admin/Themes/Install\">Install a new Theme</a>. Like for themes, modules are created by other users of Orchard just like you so if you feel up to it, please <a href=\"http://www.orchardproject.net/\">consider participating</a>.</p><p>--The Orchard Crew</p>";
|
||||
page.As<CommonPart>().Owner = user;
|
||||
contentManager.Publish(page);
|
||||
siteSettings.Record.HomePage = "RoutableHomePageProvider;" + page.Id;
|
||||
|
||||
// add a menu item for the shiny new home page
|
||||
var menuItem = contentManager.Create("MenuItem");
|
||||
menuItem.As<MenuPart>().MenuPosition = "1";
|
||||
menuItem.As<MenuPart>().MenuText = T("Home").ToString();
|
||||
menuItem.As<MenuPart>().OnMainMenu = true;
|
||||
menuItem.As<MenuItemPart>().Url = "";
|
||||
|
||||
//Temporary fix for running setup on command line
|
||||
if (HttpContext.Current != null) {
|
||||
var authenticationService = environment.Resolve<IAuthenticationService>();
|
||||
authenticationService.SignIn(user, true);
|
||||
}
|
||||
CreateTenantData(context, environment);
|
||||
}
|
||||
catch {
|
||||
environment.Resolve<ITransactionManager>().Cancel();
|
||||
@@ -279,5 +175,123 @@ namespace Orchard.Setup.Services {
|
||||
|
||||
_shellSettingsManager.SaveSettings(shellSettings);
|
||||
}
|
||||
|
||||
private void CreateTenantData(SetupContext context, IWorkContextScope environment) {
|
||||
// create superuser
|
||||
var membershipService = environment.Resolve<IMembershipService>();
|
||||
var user =
|
||||
membershipService.CreateUser(new CreateUserParams(context.AdminUsername, context.AdminPassword,
|
||||
String.Empty, String.Empty, String.Empty,
|
||||
true));
|
||||
|
||||
// set superuser as current user for request (it will be set as the owner of all content items)
|
||||
var authenticationService = environment.Resolve<IAuthenticationService>();
|
||||
authenticationService.SetAuthenticatedUserForRequest(user);
|
||||
|
||||
// set site name and settings
|
||||
var siteService = environment.Resolve<ISiteService>();
|
||||
var siteSettings = siteService.GetSiteSettings().As<SiteSettingsPart>();
|
||||
siteSettings.Record.SiteSalt = Guid.NewGuid().ToString("N");
|
||||
siteSettings.Record.SiteName = context.SiteName;
|
||||
siteSettings.Record.SuperUser = context.AdminUsername;
|
||||
siteSettings.Record.PageTitleSeparator = " - ";
|
||||
siteSettings.Record.SiteCulture = "en-US";
|
||||
|
||||
// set site theme
|
||||
var themeService = environment.Resolve<IThemeService>();
|
||||
themeService.SetSiteTheme("TheThemeMachine");
|
||||
|
||||
// add default culture
|
||||
var cultureManager = environment.Resolve<ICultureManager>();
|
||||
cultureManager.AddCulture("en-US");
|
||||
|
||||
var contentManager = environment.Resolve<IContentManager>();
|
||||
|
||||
// this needs to exit the standalone environment? rework this process entirely?
|
||||
// simulate installation-time module activation events
|
||||
//var hackInstallationGenerator = environment.Resolve<IHackInstallationGenerator>();
|
||||
//hackInstallationGenerator.GenerateInstallEvents();
|
||||
|
||||
var contentDefinitionManager = environment.Resolve<IContentDefinitionManager>();
|
||||
//todo: (heskew) pull these definitions (and initial content creation) out into more appropriate modules
|
||||
contentDefinitionManager.AlterTypeDefinition("BlogPost", cfg => cfg
|
||||
.WithPart("CommentsPart")
|
||||
.WithPart("TagsPart")
|
||||
.WithPart("LocalizationPart")
|
||||
.Indexed()
|
||||
);
|
||||
contentDefinitionManager.AlterTypeDefinition("Page", cfg => cfg
|
||||
.WithPart("CommonPart")
|
||||
.WithPart("PublishLaterPart")
|
||||
.WithPart("RoutePart")
|
||||
.WithPart("BodyPart")
|
||||
.WithPart("TagsPart")
|
||||
.WithPart("LocalizationPart")
|
||||
.Creatable()
|
||||
.Indexed()
|
||||
);
|
||||
contentDefinitionManager.AlterPartDefinition("BodyPart", cfg => cfg
|
||||
.WithSetting("BodyPartSettings.FlavorDefault", BodyPartSettings.FlavorDefaultDefault));
|
||||
|
||||
// If "Orchard.Widgets" is enabled, setup default layers and widgets
|
||||
var extensionManager = environment.Resolve<IExtensionManager>();
|
||||
var shellDescriptor = environment.Resolve<ShellDescriptor>();
|
||||
if (extensionManager.EnabledFeatures(shellDescriptor).Where(d => d.Name == "Orchard.Widgets").Any()) {
|
||||
// Create default layers
|
||||
var layerInitializer = environment.Resolve<IDefaultLayersInitializer>();
|
||||
layerInitializer.CreateDefaultLayers();
|
||||
|
||||
// add a layer for the homepage
|
||||
var homepageLayer = contentManager.Create("Layer");
|
||||
homepageLayer.As<LayerPart>().Name = "TheHomepage";
|
||||
homepageLayer.As<LayerPart>().LayerRule = "url \"~/\"";
|
||||
contentManager.Publish(homepageLayer);
|
||||
|
||||
// and three more for the tripel...really need this elsewhere...
|
||||
var tripelFirst = contentManager.Create("HtmlWidget");
|
||||
tripelFirst.As<WidgetPart>().LayerPart = homepageLayer.As<LayerPart>();
|
||||
tripelFirst.As<WidgetPart>().Title = T("First Leader Aside").Text;
|
||||
tripelFirst.As<WidgetPart>().Zone = "TripelFirst";
|
||||
tripelFirst.As<WidgetPart>().Position = "5";
|
||||
tripelFirst.As<BodyPart>().Text = "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur a nibh ut tortor dapibus vestibulum. Aliquam vel sem nibh. Suspendisse vel condimentum tellus.</p>";
|
||||
contentManager.Publish(tripelFirst);
|
||||
|
||||
var tripelSecond = contentManager.Create("HtmlWidget");
|
||||
tripelSecond.As<WidgetPart>().LayerPart = homepageLayer.As<LayerPart>();
|
||||
tripelSecond.As<WidgetPart>().Title = T("Second Leader Aside").Text;
|
||||
tripelSecond.As<WidgetPart>().Zone = "TripelSecond";
|
||||
tripelSecond.As<WidgetPart>().Position = "5";
|
||||
tripelSecond.As<BodyPart>().Text = "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur a nibh ut tortor dapibus vestibulum. Aliquam vel sem nibh. Suspendisse vel condimentum tellus.</p>";
|
||||
contentManager.Publish(tripelSecond);
|
||||
|
||||
var tripelThird = contentManager.Create("HtmlWidget");
|
||||
tripelThird.As<WidgetPart>().LayerPart = homepageLayer.As<LayerPart>();
|
||||
tripelThird.As<WidgetPart>().Title = T("Third Leader Aside").Text;
|
||||
tripelThird.As<WidgetPart>().Zone = "TripelThird";
|
||||
tripelThird.As<WidgetPart>().Position = "5";
|
||||
tripelThird.As<BodyPart>().Text = "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur a nibh ut tortor dapibus vestibulum. Aliquam vel sem nibh. Suspendisse vel condimentum tellus.</p>";
|
||||
contentManager.Publish(tripelThird);
|
||||
}
|
||||
|
||||
// create a welcome page that's promoted to the home page
|
||||
var page = contentManager.Create("Page");
|
||||
page.As<RoutePart>().Title = T("Welcome to Orchard!").Text;
|
||||
page.As<BodyPart>().Text = "<p>Congratulations, you've successfully set-up your Orchard site.</p><p>This is the home page of your new site. We've taken the liberty to write here about a few things you could look at next in order to get familiar with the application. Once you feel confident you don't need this anymore, just click <a href=\"/Admin/Contents/Edit/7\">Edit</a> to go into edit mode and replace this with whatever you want on your home page to make it your own.</p><p>One thing you could do (but you don't have to) is go into <a href=\"Admin/Settings\">Manage Settings</a> (follow the <a href=\"Admin\">Admin</a> link and then look for it under \"Settings\" in the menu on the left) and check that everything is configured the way you want.</p><p>You probably want to make the site your own. One of the ways you can do that is by clicking <a href=\"Admin/Themes\">Manage Themes</a> in the admin menu. A theme is a packaged look and feel that affects the whole site.</p><p>Next, you can start playing with the content types that we installed. For example, go ahead and click <a href=\"Admin/Pages/Create\">Add New Page</a> in the admin menu and create an \"about\" page. Then, add it to the navigation menu by going to <a href=\"Admin/Navigation\">Manage Menu</a>. You can also click <a href=\"Admin/Blogs/Create\">Add New Blog</a> and start posting by clicking \"Add New Post\".</p><p>Finally, Orchard has been designed to be extended. It comes with a few built-in modules such as pages and blogs or themes. You can install new themes by going to <a href=\"Admin/Themes\">Manage Themes</a> and clicking <a href=\"Admin/Themes/Install\">Install a new Theme</a>. Like for themes, modules are created by other users of Orchard just like you so if you feel up to it, please <a href=\"http://www.orchardproject.net/\">consider participating</a>.</p><p>--The Orchard Crew</p>";
|
||||
|
||||
contentManager.Publish(page);
|
||||
siteSettings.Record.HomePage = "RoutableHomePageProvider;" + page.Id;
|
||||
|
||||
// add a menu item for the shiny new home page
|
||||
var menuItem = contentManager.Create("MenuItem");
|
||||
menuItem.As<MenuPart>().MenuPosition = "1";
|
||||
menuItem.As<MenuPart>().MenuText = T("Home").ToString();
|
||||
menuItem.As<MenuPart>().OnMainMenu = true;
|
||||
menuItem.As<MenuItemPart>().Url = "";
|
||||
|
||||
//null check: temporary fix for running setup in command line
|
||||
if (HttpContext.Current != null) {
|
||||
authenticationService.SignIn(user, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -36,12 +36,8 @@ namespace Orchard.Tags.Drivers {
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ApplyTag, CurrentUser, part))
|
||||
return null;
|
||||
|
||||
var model = new EditTagsViewModel {
|
||||
Tags = string.Join(", ", part.CurrentTags.Select((t, i) => t.TagName).ToArray())
|
||||
};
|
||||
|
||||
return ContentShape("Parts_Tags_Editor",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
|
||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: BuildEditorViewModel(part), Prefix: Prefix));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(TagsPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
@@ -59,5 +55,11 @@ namespace Orchard.Tags.Drivers {
|
||||
return ContentShape("Parts_Tags_Editor",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
|
||||
}
|
||||
|
||||
private static EditTagsViewModel BuildEditorViewModel(TagsPart part) {
|
||||
return new EditTagsViewModel {
|
||||
Tags = string.Join(", ", part.CurrentTags.Select((t, i) => t.TagName).ToArray())
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -113,7 +113,9 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Placement.info" />
|
||||
<Content Include="Placement.info">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
|
@@ -5,14 +5,11 @@ using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.ContentManagement.MetaData.Builders;
|
||||
using Orchard.Core.Contents.Extensions;
|
||||
using Orchard.Data.Migration;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Environment.State;
|
||||
using Orchard.Events;
|
||||
using Orchard.Widgets.Models;
|
||||
|
||||
namespace Orchard.Widgets {
|
||||
public interface IDefaultLayersInitializer : IEventHandler {
|
||||
public interface IDefaultLayersInitializer : IDependency {
|
||||
void CreateDefaultLayers();
|
||||
}
|
||||
|
||||
@@ -34,16 +31,6 @@ namespace Orchard.Widgets {
|
||||
}
|
||||
|
||||
public class WidgetsDataMigration : DataMigrationImpl {
|
||||
private readonly IProcessingEngine _processingEngine;
|
||||
private readonly ShellSettings _shellSettings;
|
||||
private readonly ShellDescriptor _shellDescriptor;
|
||||
|
||||
public WidgetsDataMigration(IProcessingEngine processingEngine, ShellSettings shellSettings, ShellDescriptor shellDescriptor) {
|
||||
_processingEngine = processingEngine;
|
||||
_shellSettings = shellSettings;
|
||||
_shellDescriptor = shellDescriptor;
|
||||
}
|
||||
|
||||
public int Create() {
|
||||
SchemaBuilder.CreateTable("LayerPartRecord", table => table
|
||||
.ContentPartRecord()
|
||||
@@ -73,8 +60,6 @@ namespace Orchard.Widgets {
|
||||
.WithSetting("Stereotype", "Widget")
|
||||
);
|
||||
|
||||
CreateDefaultLayers();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -108,13 +93,5 @@ namespace Orchard.Widgets {
|
||||
);
|
||||
return 2;
|
||||
}
|
||||
|
||||
private void CreateDefaultLayers() {
|
||||
_processingEngine.AddTask(
|
||||
_shellSettings,
|
||||
_shellDescriptor,
|
||||
"IDefaultLayersInitializer.CreateDefaultLayers",
|
||||
new Dictionary<string, object>());
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,12 @@
|
||||
@{
|
||||
@functions {
|
||||
string CalcuClassify(string[] zoneNames, string classNamePrefix)
|
||||
{
|
||||
var zoneCounter = 0;
|
||||
var zoneNumsFilled = string.Join("", zoneNames.Select(zoneName => { ++zoneCounter; return Model[zoneName] != null ? zoneCounter.ToString() : "";}).ToArray());
|
||||
return HasText(zoneNumsFilled) ? classNamePrefix + zoneNumsFilled : "";
|
||||
}
|
||||
}
|
||||
@{
|
||||
Style.Include("http://fonts.googleapis.com/css?family=Lobster&subset=latin");
|
||||
Style.Include("site.css");
|
||||
|
||||
@@ -28,22 +36,20 @@
|
||||
// {WorkContext.Layout.FooterQuadThird.Add("3 This is some test text to see if zones are working. This is some test text to see if zones are working.");}
|
||||
|
||||
//Add classes to the wrapper div to toggle quad widget zones on and off
|
||||
var tripelClass = CalcuClassify(new [] {"TripelFirst", "TripelSecond", "TripelThird"}, "tripel-");
|
||||
if (HasText(tripelClass)) {
|
||||
Model.Classes.Add(tripelClass);
|
||||
}
|
||||
|
||||
if (Model.FooterQuadFirst == null && Model.FooterQuadSecond != null && Model.FooterQuadThird != null && Model.FooterQuadFourth != null) {
|
||||
Model.Classes.Add("split-234");
|
||||
//Add classes to the wrapper div to toggle quad widget zones on and off
|
||||
var footerQuadClass = CalcuClassify(new [] {"FooterQuadFirst", "FooterQuadSecond", "FooterQuadThird", "FooterQuadFourth"}, "split-");
|
||||
if (HasText(footerQuadClass)) {
|
||||
Model.Classes.Add(footerQuadClass);
|
||||
}
|
||||
else if (Model.FooterQuadFirst != null && Model.FooterQuadSecond == null && Model.FooterQuadThird != null && Model.FooterQuadFourth != null) {
|
||||
Model.Classes.Add("split-134");
|
||||
}
|
||||
else if (Model.FooterQuadFirst != null && Model.FooterQuadSecond != null && Model.FooterQuadThird == null && Model.FooterQuadFourth != null) {
|
||||
Model.Classes.Add("split-124");
|
||||
}
|
||||
else if (Model.FooterQuadFirst != null && Model.FooterQuadSecond != null && Model.FooterQuadThird != null && Model.FooterQuadFourth == null) {
|
||||
Model.Classes.Add("split-123");
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
@*<span>debug: </span>*@
|
||||
@*<span>tripelClass:@tripelClass</span>*@
|
||||
@*<span>footerQuadClass:@footerQuadClass</span>*@
|
||||
|
||||
Model.Id = "layout-wrapper";
|
||||
var tag = Tag (Model, "div");
|
||||
|
@@ -163,6 +163,4 @@ namespace Orchard.Environment {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@
|
||||
public interface IAuthenticationService : IDependency {
|
||||
void SignIn(IUser user, bool createPersistentCookie);
|
||||
void SignOut();
|
||||
void SetAuthenticatedUserForRequest(IUser user);
|
||||
IUser GetAuthenticatedUser();
|
||||
}
|
||||
}
|
||||
|
@@ -11,6 +11,7 @@ namespace Orchard.Security.Providers {
|
||||
private readonly IClock _clock;
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private IUser _signedInUser;
|
||||
|
||||
public FormsAuthenticationService(IClock clock, IContentManager contentManager, IHttpContextAccessor httpContextAccessor) {
|
||||
_clock = clock;
|
||||
@@ -52,13 +53,22 @@ namespace Orchard.Security.Providers {
|
||||
|
||||
var httpContext = _httpContextAccessor.Current();
|
||||
httpContext.Response.Cookies.Add(cookie);
|
||||
_signedInUser = user;
|
||||
}
|
||||
|
||||
public void SignOut() {
|
||||
_signedInUser = null;
|
||||
FormsAuthentication.SignOut();
|
||||
}
|
||||
|
||||
public void SetAuthenticatedUserForRequest(IUser user) {
|
||||
_signedInUser = user;
|
||||
}
|
||||
|
||||
public IUser GetAuthenticatedUser() {
|
||||
if (_signedInUser != null)
|
||||
return _signedInUser;
|
||||
|
||||
var httpContext = _httpContextAccessor.Current();
|
||||
if (!httpContext.Request.IsAuthenticated || !(httpContext.User.Identity is FormsIdentity)) {
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user