10000 menus · githubsunyf/cms@aaf5565 · GitHub
[go: up one dir, main page]

Skip to content

Commit aaf5565

Browse files
committed
menus
1 parent 5e04df4 commit aaf5565

File tree

6 files changed

+34
-46
lines changed

6 files changed

+34
-46
lines changed

SiteServer.BackgroundPages/Core/TextUtility.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using SiteServer.CMS.Core;
99
using SiteServer.CMS.DataCache;
1010
using SiteServer.CMS.Model.Attributes;
11+
using SiteServer.CMS.Plugin;
1112
using SiteServer.CMS.Plugin.Impl;
1213
using SiteServer.Plugin;
1314

@@ -206,7 +207,7 @@ public static string GetColumnsHtml(Dictionary<string, string> nameValueCacheDic
206207
return builder.ToString();
207208
}
208209

209-
public static string GetCommandsHtml(SiteInfo siteInfo, List<Menu> pluginMenus, ContentInfo contentInfo, string pageUrl, string administratorName, bool isEdit)
210+
public static string GetCommandsHtml(SiteInfo siteInfo, List<PluginMenu> pluginMenus, ContentInfo contentInfo, string pageUrl, string administratorName, bool isEdit)
210211
{
211212
var builder = new StringBuilder();
212213

SiteServer.CMS/Core/TabManager.cs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,34 +121,26 @@ public static List<Tab> GetTabList(string topId, int siteId)
121121
}
122122
}
123123

124-
var menus = new Dictionary<string, SiteServer.Plugin.Menu>();
124+
var menus = new List<PluginMenu>();
125125
if (siteId > 0 && topId == string.Empty)
126126
{
127127
var siteMenus = PluginMenuManager.GetSiteMenus(siteId);
128128
if (siteMenus != null)
129129
{
130-
foreach (var siteMenu in siteMenus)
131-
{
132-
menus.Add(siteMenu.Key, siteMenu.Value);
133-
}
130+
menus.AddRange(siteMenus);
134131
}
135132
}
136133
else if (topId == "Plugins")
137134
{
138135
var topMenus = PluginMenuManager.GetTopMenus();
139136
if (topMenus != null)
140137
{
141-
foreach (var topMenu in topMenus)
142-
{
143-
menus.Add(topMenu.Key, topMenu.Value);
144-
}
138+
menus.AddRange(topMenus);
145139
}
146140
}
147141

148-
foreach (var pluginId in menus.Keys)
142+
foreach (var menu in menus)
149143
{
150-
var menu = menus[pluginId];
151-
152144
var isExists = false;
153145
foreach (var childTab in tabs)
154146
{
@@ -160,7 +152,7 @@ public static List<Tab> GetTabList(string topId, int siteId)
160152

161153
if (isExists) continue;
162154

163-
tabs.Add(GetPluginTab(menu, pluginId));
155+
tabs.Add(GetPluginTab(menu, menu.PluginId));
164156

165157
//if (string.IsNullOrEmpty(menu.ParentId))
166158
//{

SiteServer.CMS/Plugin/Apis/DatabaseApi.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -740,10 +740,6 @@ public virtual int ExecuteNonQuery(IDbCommand command)
740740

741741
if (command == null) throw new ArgumentNullException(nameof(command));
742742

743-
#if (DEBUG)
744-
DataProvider.RecordDao.RecordCommandExecute(command, nameof(ExecuteNonQuery));
745-
#endif
746-
747743
int returnVal = command.ExecuteNonQuery();
748744

749745
if (mustCloseConnection)
@@ -1169,10 +1165,6 @@ protected virtual IDataReader ExecuteReader(IDbCommand command, AdoConnectionOwn
11691165

11701166
// Create a reader
11711167

1172-
#if (DEBUG)
1173-
DataProvider.RecordDao.RecordCommandExecute(command, nameof(ExecuteReader));
1174-
#endif
1175-
11761168
// Call ExecuteReader with the appropriate CommandBehavior
11771169
var dataReader = connectionOwnership == AdoConnectionOwnership.External
11781170
? command.ExecuteReader()
@@ -1391,10 +1383,6 @@ public virtual object ExecuteScalar(IDbCommand command)
13911383
mustCloseConnection = true;
13921384
}
13931385

1394-
#if (DEBUG)
1395-
DataProvider.RecordDao.RecordCommandExecute(command, nameof(ExecuteScalar));
1396-
#endif
1397-
13981386
// Execute the command & return the results
13991387
var retval = command.ExecuteScalar();
14001388

SiteServer.CMS/Plugin/PluginMenu.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using SiteServer.Plugin;
2+
3+
namespace SiteServer.CMS.Plugin
4+
{
5+
public class PluginMenu: Menu
6+
{
7+
public string PluginId { get; set; }
8+
}
9+
}

SiteServer.CMS/Plugin/PluginMenuManager.cs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,9 @@ public static string GetHomeDefaultPageUrl()
5454
return pageUrl;
5555
}
5656

57-
private static string GetMenuId(string serviceId, int i)
57+
public static List<PluginMenu> GetTopMenus()
5858
{
59-
return $"{serviceId}_{i}";
60-
}
61-
62-
public static Dictionary<string, Menu> GetTopMenus()
63-
{
64-
var menus = new Dictionary<string, Menu>();
59+
var menus = new List<PluginMenu>();
6560

6661
foreach (var service in PluginManager.Services)
6762
{
@@ -85,8 +80,8 @@ public static Dictionary<string, Menu> GetTopMenus()
8580
var i = 0;
8681
foreach (var metadataMenu in metadataMenus)
8782
{
88-
var pluginMenu = GetMenu(service.PluginId, 0, 0, 0, metadataMenu, 0);
89-
menus[GetMenuId(service.PluginId, ++i)] = pluginMenu;
83+
var pluginMenu = GetMenu(service.PluginId, 0, 0, 0, metadataMenu, ++i);
84+
menus.Add(pluginMenu);
9085
}
9186
}
9287
catch (Exception ex)
@@ -98,9 +93,9 @@ public static Dictionary<string, Menu> GetTopMenus()
9893
return menus;
9994
}
10095

101-
public static Dictionary<string, Menu> GetSiteMenus(int siteId)
96+
public static List<PluginMenu> GetSiteMenus(int siteId)
10297
{
103-
var menus = new Dictionary<string, Menu>();
98+
var menus = new List<PluginMenu>();
10499

105100
foreach (var service in PluginManager.Services)
106101
{
@@ -124,8 +119,8 @@ public static Dictionary<string, Menu> GetSiteMenus(int siteId)
124119
var i = 0;
125120
foreach (var metadataMenu in metadataMenus)
126121
{
127-
var pluginMenu = GetMenu(service.PluginId, siteId, 0, 0, metadataMenu, 0);
128-
menus[GetMenuId(service.PluginId, ++i)] = pluginMenu;
122+
var pluginMenu = GetMenu(service.PluginId, siteId, 0, 0, metadataMenu, ++i);
123+
menus.Add(pluginMenu);
129124
}
130125
}
131126
catch (Exception ex)
@@ -137,9 +132,9 @@ public static Dictionary<string, Menu> GetSiteMenus(int siteId)
137132
return menus;
138133
}
139134

140-
public static List<Menu> GetContentMenus(List<string> pluginIds, ContentInfo contentInfo)
135+
public static List<PluginMenu> GetContentMenus(List<string> pluginIds, ContentInfo contentInfo)
141136
{
142-
var menus = new List<Menu>();
137+
var menus = new List<PluginMenu>();
143138
if ( E377 pluginIds == null || pluginIds.Count == 0) return menus;
144139

145140
foreach (var service in PluginManager.Services)
@@ -162,10 +157,11 @@ public static List<Menu> GetContentMenus(List<string> pluginIds, ContentInfo con
162157
}
163158

164159
if (metadataMenus.Count == 0) continue;
165-
160+
161+
var i = 0;
166162
foreach (var metadataMenu in metadataMenus)
167163
{
168-
var pluginMenu = GetMenu(service.PluginId, contentInfo.SiteId, contentInfo.ChannelId, contentInfo.Id, metadataMenu, 0);
164+
var pluginMenu = GetMenu(service.PluginId, contentInfo.SiteId, contentInfo.ChannelId, contentInfo.Id, metadataMenu, ++i);
169165
menus.Add(pluginMenu);
170166
}
171167
}
@@ -244,15 +240,16 @@ private static string GetMenuHref(string pluginId, string href, int siteId, int
244240
// });
245241
//}
246242

247-
private static Menu GetMenu(string pluginId, int siteId, int channelId, int contentId, Menu metadataMenu, int i)
243+
private static PluginMenu GetMenu(string pluginId, int siteId, int channelId, int contentId, Menu metadataMenu, int i)
248244
{
249-
var menu = new Menu
245+
var menu = new PluginMenu
250246
{
251247
Id = metadataMenu.Id,
252248
Text = metadataMenu.Text,
253249
Href = metadataMenu.Href,
254250
Target = metadataMenu.Target,
255-
IconClass = metadataMenu.IconClass
251+
IconClass = metadataMenu.IconClass,
252+
PluginId = pluginId
256253
};
257254

258255
if (string.IsNullOrEmpty(menu.Id))

SiteServer.CMS/SiteServer.CMS.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@
323323
<Compile Include="Plugin\PluginDatabaseTableManager.cs" />
324324
<Compile Include="Plugin\PluginDebugger.cs" />
325325
<Compile Include="Plugin\PluginManager.cs" />
326+
<Compile Include="Plugin\PluginMenu.cs" />
326327
<Compile Include="Plugin\PluginMenuManager.cs" />
327328
<Compile Include="Plugin\PluginJobManager.cs" />
328329
<Compile Include="Plugin\PluginStlParserManager.cs" />

0 commit comments

Comments
 (0)
0