mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Shuffling around where the Admin link appears on the front
--HG-- branch : dev
This commit is contained in:
@@ -17,10 +17,11 @@ namespace Orchard.Core.Navigation.Models {
|
||||
set { Record.MenuText = value; }
|
||||
}
|
||||
|
||||
[HiddenInput(DisplayValue = false)]
|
||||
public string MenuPosition {
|
||||
get { return Record.MenuPosition; }
|
||||
set { Record.MenuPosition = value; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<object>" %>
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BaseViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<div id="logindisplay">
|
||||
<% if (Request.IsAuthenticated) { %>
|
||||
<%=_Encoded("Welcome")%> <strong><%=Html.Encode(Page.User.Identity.Name) %></strong>!
|
||||
[<%=Html.ActionLink(T("Log Off").ToString(), "LogOff", new { Controller = "Account", Area = "Orchard.Users" })%>]
|
||||
<%=T("Welcome, <strong>{0}</strong>!", Html.Encode(Page.User.Identity.Name)) %>
|
||||
<%=Html.Link(T("Admin").ToString(), "/admin/blogs") %> /
|
||||
<%=Html.ActionLink(T("Log Off").ToString(), "LogOff", new { Controller = "Account", Area = "Orchard.Users" }) %>
|
||||
<% } else { %>
|
||||
[<%=Html.ActionLink(T("Log On").ToString(), "LogOn", new { Controller = "Account", Area = "Orchard.Users", ReturnUrl = Context.Request.RawUrl })%>]
|
||||
<%=Html.ActionLink(T("Log On").ToString(), "LogOn", new { Controller = "Account", Area = "Orchard.Users", ReturnUrl = Context.Request.RawUrl }) %>
|
||||
<% } %>
|
||||
</div>
|
||||
@@ -95,27 +95,20 @@ namespace Orchard.Setup.Controllers {
|
||||
|
||||
// create home page as a CMS page
|
||||
var page = contentManager.Create("page");
|
||||
page.As<BodyAspect>().Text = "Welcome to Orchard";
|
||||
page.As<BodyAspect>().Text = "<p>Welcome to Orchard!</p><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 [Edit] 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 [Manage Settings] (follow the [Admin] 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 [Manage Themes] in the admin menu. A theme is a packaged look and feel that affects the whole site. We have installed a few themes already, but you'll also be able to browse through an online gallery of themes created by other users of Orchard.</p><p>Next, you can start playing with the content types that we installed. For example, go ahead and click [Add New Page] in the admin menu and create an \"about\" page. Then, add it to the navigation menu by going to [Manage Navigation]. You can also click [Add New Blog] 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 but you can install new ones by going to [Manage Themes] and clicking [Install a new Theme]. Like for themes, modules are created by other users of Orchard just like you so if you feel up to it, please [consider participating].</p><p>--The Orchard Crew</p>";
|
||||
page.As<RoutableAspect>().Slug = "";
|
||||
page.As<RoutableAspect>().Title = model.SiteName;
|
||||
page.As<RoutableAspect>().Title = T("Home").ToString();
|
||||
page.As<HasComments>().CommentsShown = false;
|
||||
page.As<CommonAspect>().Owner = user;
|
||||
contentManager.Publish(page);
|
||||
siteSettings.Record.HomePage = "PagesHomePageProvider;" + page.Id;
|
||||
|
||||
// add a menu item for the shiny new home page
|
||||
page.As<MenuPart>().MenuPosition = "1";
|
||||
page.As<MenuPart>().MenuText = T("Home").ToString();
|
||||
page.As<MenuPart>().OnMainMenu = true;
|
||||
|
||||
// add a menu item for the admin
|
||||
var adminMenuItem = contentManager.Create("menuitem");
|
||||
adminMenuItem.As<MenuPart>().MenuPosition = "2";
|
||||
adminMenuItem.As<MenuPart>().MenuText = T("Admin").ToString();
|
||||
adminMenuItem.As<MenuPart>().OnMainMenu = true;
|
||||
//adminMenuItem.As<MenuItem>().Permissions = new [] {StandardPermissions.AccessAdminPanel};
|
||||
//todo: (heskew) pull "/blogs" once the is a ~/admin
|
||||
adminMenuItem.As<MenuItem>().Url = string.Format("{0}admin/blogs", Request.Url.AbsolutePath);
|
||||
var menuItem = contentManager.Create("menuitem");
|
||||
menuItem.As<MenuPart>().MenuPosition = "1";
|
||||
menuItem.As<MenuPart>().MenuText = T("Home").ToString();
|
||||
menuItem.As<MenuPart>().OnMainMenu = true;
|
||||
menuItem.As<MenuItem>().Url = "";
|
||||
|
||||
var authenticationService = finiteEnvironment.Resolve<IAuthenticationService>();
|
||||
authenticationService.SignIn(user, true);
|
||||
@@ -131,8 +124,6 @@ namespace Orchard.Setup.Controllers {
|
||||
|
||||
_orchardHost.Reinitialize();
|
||||
|
||||
_notifier.Information(T("Setup succeeded"));
|
||||
|
||||
// redirect to the welcome page.
|
||||
return Redirect("~/");
|
||||
}
|
||||
|
||||
@@ -286,6 +286,7 @@
|
||||
<Compile Include="Mvc\ViewModels\AdminViewModel.cs" />
|
||||
<Compile Include="Mvc\ViewModels\BaseViewModel.cs" />
|
||||
<Compile Include="UI\Navigation\INavigationManager.cs" />
|
||||
<Compile Include="UI\Navigation\NavigationItemBuilder.cs" />
|
||||
<Compile Include="UI\PageClass\IPageClassBuilder.cs" />
|
||||
<Compile Include="UI\PageClass\PageClassBuilder.cs" />
|
||||
<Compile Include="UI\PageTitle\IPageTitleBuilder.cs" />
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Mvc.Filters;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
using Orchard.UI.Navigation;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Routing;
|
||||
using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.UI.Navigation {
|
||||
public class NavigationBuilder {
|
||||
@@ -39,64 +37,4 @@ namespace Orchard.UI.Navigation {
|
||||
return (Contained ?? Enumerable.Empty<MenuItem>()).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public class NavigationItemBuilder : NavigationBuilder {
|
||||
private readonly MenuItem _item;
|
||||
|
||||
public NavigationItemBuilder() {
|
||||
_item = new MenuItem();
|
||||
}
|
||||
|
||||
public NavigationItemBuilder Caption(string caption) {
|
||||
_item.Text = caption;
|
||||
return this;
|
||||
}
|
||||
|
||||
public NavigationItemBuilder Position(string position) {
|
||||
_item.Position = position;
|
||||
return this;
|
||||
}
|
||||
|
||||
public NavigationItemBuilder Url(string url) {
|
||||
_item.Url = url;
|
||||
return this;
|
||||
}
|
||||
|
||||
public NavigationItemBuilder Permission(Permission permission) {
|
||||
_item.Permissions = _item.Permissions.Concat(new[]{permission});
|
||||
return this;
|
||||
}
|
||||
|
||||
public new IEnumerable<MenuItem> Build() {
|
||||
_item.Items = base.Build();
|
||||
return new[] { _item };
|
||||
}
|
||||
|
||||
public NavigationItemBuilder Action(RouteValueDictionary values) {
|
||||
return values != null
|
||||
? Action(values["action"] as string, values["controller"] as string, values)
|
||||
: Action(null, null, new RouteValueDictionary());
|
||||
}
|
||||
|
||||
public NavigationItemBuilder Action(string actionName) {
|
||||
return Action(actionName, null, new RouteValueDictionary());
|
||||
}
|
||||
|
||||
public NavigationItemBuilder Action(string actionName, string controllerName) {
|
||||
return Action(actionName, controllerName, new RouteValueDictionary());
|
||||
}
|
||||
|
||||
public NavigationItemBuilder Action(string actionName, string controllerName, object values) {
|
||||
return Action(actionName, controllerName, new RouteValueDictionary(values));
|
||||
}
|
||||
|
||||
public NavigationItemBuilder Action(string actionName, string controllerName, RouteValueDictionary values) {
|
||||
_item.RouteValues = new RouteValueDictionary(values);
|
||||
if (!string.IsNullOrEmpty(actionName))
|
||||
_item.RouteValues["action"] = actionName;
|
||||
if (!string.IsNullOrEmpty(controllerName))
|
||||
_item.RouteValues["controller"] = controllerName;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
66
src/Orchard/UI/Navigation/NavigationItemBuilder.cs
Normal file
66
src/Orchard/UI/Navigation/NavigationItemBuilder.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Routing;
|
||||
using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.UI.Navigation {
|
||||
public class NavigationItemBuilder : NavigationBuilder {
|
||||
private readonly MenuItem _item;
|
||||
|
||||
public NavigationItemBuilder() {
|
||||
_item = new MenuItem();
|
||||
}
|
||||
|
||||
public NavigationItemBuilder Caption(string caption) {
|
||||
_item.Text = caption;
|
||||
return this;
|
||||
}
|
||||
|
||||
public NavigationItemBuilder Position(string position) {
|
||||
_item.Position = position;
|
||||
return this;
|
||||
}
|
||||
|
||||
public NavigationItemBuilder Url(string url) {
|
||||
_item.Url = url;
|
||||
return this;
|
||||
}
|
||||
|
||||
public NavigationItemBuilder Permission(Permission permission) {
|
||||
_item.Permissions = _item.Permissions.Concat(new[]{permission});
|
||||
return this;
|
||||
}
|
||||
|
||||
public new IEnumerable<MenuItem> Build() {
|
||||
_item.Items = base.Build();
|
||||
return new[] { _item };
|
||||
}
|
||||
|
||||
public NavigationItemBuilder Action(RouteValueDictionary values) {
|
||||
return values != null
|
||||
? Action(values["action"] as string, values["controller"] as string, values)
|
||||
: Action(null, null, new RouteValueDictionary());
|
||||
}
|
||||
|
||||
public NavigationItemBuilder Action(string actionName) {
|
||||
return Action(actionName, null, new RouteValueDictionary());
|
||||
}
|
||||
|
||||
public NavigationItemBuilder Action(string actionName, string controllerName) {
|
||||
return Action(actionName, controllerName, new RouteValueDictionary());
|
||||
}
|
||||
|
||||
public NavigationItemBuilder Action(string actionName, string controllerName, object values) {
|
||||
return Action(actionName, controllerName, new RouteValueDictionary(values));
|
||||
}
|
||||
|
||||
public NavigationItemBuilder Action(string actionName, string controllerName, RouteValueDictionary values) {
|
||||
_item.RouteValues = new RouteValueDictionary(values);
|
||||
if (!string.IsNullOrEmpty(actionName))
|
||||
_item.RouteValues["action"] = actionName;
|
||||
if (!string.IsNullOrEmpty(controllerName))
|
||||
_item.RouteValues["controller"] = controllerName;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,10 @@ using Orchard.UI.Navigation;
|
||||
namespace Orchard.Utility {
|
||||
public static class Position {
|
||||
public static string GetNext(IEnumerable<MenuItem> menuItems) {
|
||||
//TODO: (erikpo) Clean up query to not hardcode to exclude 99, which is the admin menu item as of right now
|
||||
var maxMenuItem = menuItems.FirstOrDefault().Items.Where(mi => mi.Position != "99").OrderByDescending(mi => mi.Position, new PositionComparer()).FirstOrDefault();
|
||||
var topMenuItem = menuItems.FirstOrDefault();
|
||||
|
||||
if (maxMenuItem != null) {
|
||||
if (topMenuItem != null) {
|
||||
var maxMenuItem = topMenuItem.Items.OrderByDescending(mi => mi.Position, new PositionComparer()).FirstOrDefault();
|
||||
var positionParts = maxMenuItem.Position.Split(new[] {'.'}, StringSplitOptions.RemoveEmptyEntries).Where(s => s.Trim() != "");
|
||||
if (positionParts.Count() > 0) {
|
||||
int result;
|
||||
|
||||
Reference in New Issue
Block a user