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

Skip to content

Commit fb8ffba

Browse files
committed
dao
1 parent a7ed3e3 commit fb8ffba

24 files changed

+391
-237
lines changed

SiteServer.BackgroundPages/Cms/PageTemplateReference.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void Page_Load(object sender, EventArgs e)
5454
</a>
5555
</td>
5656
<td>{stlAttribute.Title}</td>
57-
<td><a href=""https://docs.siteserver.cn/stl#/{tagName}/"" target=""_blank"" class=""{(elementName == _elementName ? "text-white" : string.Empty)}"">https://docs.siteserver.cn/stl#/{tagName}/</a></td>
57+
<td><a href=""https://www.siteserver.cn/docs/stl/{tagName}/"" target=""_blank"" class=""{(elementName == _elementName ? "text-white" : string.Empty)}"">https://www.siteserver.cn/docs/stl/{tagName}/</a></td>
5858
</tr>");
5959
}
6060

@@ -96,16 +96,18 @@ public void Page_Load(object sender, EventArgs e)
9696

9797
if (attr != null)
9898
{
99+
var attrUrl =
100+
$"https://www.siteserver.cn/docs/stl/{tagName}/#{fieldName.ToLower()}-{attr.Title.ToLower()}";
99101
attrBuilder.Append($@"
100102
<tr>
101103
<td>{fieldName}</td>
102104
<td>{attr.Title}</td>
103-
<td><a href=""https://docs.siteserver.cn/stl#/{tagName}/attributes?id={fieldName}"" target=""_blank"">https://docs.siteserver.cn/stl#/{tagName}/attributes?id={fieldName}</a></td>
105+
<td><a href=""{attrUrl}"" target=""_blank"">{attrUrl}</a></td>
104106
</tr>");
105107
}
106108
}
107109

108-
var helpUrl = $"https://docs.siteserver.cn/stl#/{tagName}/";
110+
var helpUrl = $"https://www.siteserver.cn/docs/stl/{tagName}/";
109111

110112
var stlAttribute = (StlElementAttribute)Attribute.GetCustomAttribute(elementType, typeof(StlElementAttribute));
111113

SiteServer.CMS/Core/DirectoryUtility.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public static void ChangeSiteDir(string parentPsPath, string oldPsDir, string ne
2828

2929
public static void DeleteSiteFiles(SiteInfo siteInfo)
3030
{
31+
if (siteInfo == null) return;
32+
3133
var sitePath = PathUtility.GetSitePath(siteInfo);
3234

3335
if (siteInfo.IsRoot)

SiteServer.CMS/Core/InputParserUtility.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,9 @@ public static string GetVideoHtml(SiteInfo siteInfo, string videoUrl, NameValueC
321321

322322
public static string GetFileHtmlWithCount(SiteInfo siteInfo, int channelId, int contentId, string fileUrl, NameValueCollection attributes, string innerHtml, bool isStlEntity, bool isLower, bool isUpper)
323323
{
324-
var retVal = string.Empty;
325-
if (siteInfo == null) return retVal;
326-
if (string.IsNullOrEmpty(fileUrl)) return retVal;
324+
if (siteInfo == null || string.IsNullOrEmpty(fileUrl)) return string.Empty;
327325

326+
string retVal;
328327
if (isStlEntity)
329328
{
330329
retVal = ApiRouteActionsDownload.GetUrl(ApiManager.ApiUrl, siteInfo.Id, channelId, contentId,
@@ -356,10 +355,9 @@ public static string GetFileHtmlWithCount(SiteInfo siteInfo, int channelId, int
356355

357356
public static string GetFileHtmlWithoutCount(SiteInfo siteInfo, string fileUrl, NameValueCollection attributes, string innerHtml, bool isStlEntity, bool isLower, bool isUpper)
358357
{
359-
var retVal = string.Empty;
360-
if (siteInfo == null) return retVal;
361-
if (string.IsNullOrEmpty(fileUrl)) return retVal;
358+
if (siteInfo == null || string.IsNullOrEmpty(fileUrl)) return string.Empty;
362359

360+
string retVal;
363361
if (isStlEntity)
364362
{
365363
retVal = ApiRouteActionsDownload.GetUrl(ApiManager.ApiUrl, siteInfo.Id, fileUrl);

SiteServer.CMS/Plugin/PluginManager.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ public static SortedList<string, PluginInstance> GetPluginSortedList()
184184

185185
public static void LoadPlugins(string applicationPhysicalPath)
186186
{
187-
WebConfigUtils.Load(applicationPhysicalPath);
188-
_pluginInfoListRunnable = PluginInfoListRunnable;
187+
WebConfigUtils.Load(applicationPhysicalPath, PathUtils.Combine(applicationPhysicalPath, WebConfigUtils.WebConfigFileName));
189188

190189
Context.Initialize(new EnvironmentImpl(WebConfigUtils.DatabaseType, WebConfigUtils.ConnectionString, WebConfigUtils.AdminDirectory, WebConfigUtils.PhysicalApplicationPath), new ApiCollectionImpl
191190
{
@@ -200,6 +199,8 @@ public static void LoadPlugins(string applicationPhysicalPath)
200199
UserApi = UserApi.Instance,
201200
UtilsApi = UtilsApi.Instance
202201
});
202+
203+
_pluginInfoListRunnable = PluginInfoListRunnable;
203204
}
204205

205206
public static void ClearCache()

SiteServer.CMS/Provider/AdministratorDao.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ public class AdministratorDao : DataProviderBase
9191
new TableColumn
9292
{
9393
AttributeName = nameof(AdministratorInfoDatabase.SiteIdCollection),
94-
DataType = DataType.VarChar,
95-
DataLength = 50
94+
DataType = DataType.Text
9695
},
9796
new TableColumn
9897
{

SiteServer.CMS/Provider/DatabaseDao.cs

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -655,19 +655,43 @@ public void AlterPluginTable(string pluginId, string tableName, List<TableColumn
655655
var columnNameList = TableColumnManager.GetTableColumnNameList(tableName);
656656
foreach (var tableColumn in tableColumns)
657657
{
658-
if (StringUtils.ContainsIgnoreCase(columnNameList, tableColumn.AttributeName)) continue;
659-
660-
var columnSqlString = SqlUtils.GetColumnSqlString(tableColumn);
661-
var sqlString = SqlUtils.GetAddColumnsSqlString(tableName, columnSqlString);
662-
663-
try
658+
if (StringUtils.ContainsIgnoreCase(columnNameList, tableColumn.AttributeName))
664659
{
665-
DataProvider.DatabaseDao.ExecuteSql(sqlString);
666-
isAltered = true;
660+
var databaseColumn = TableColumnManager.GetTableColumnInfo(tableName, tableColumn.AttributeName);
661+
if (databaseColumn != null && !tableColumn.IsIdentity)
662+
{
663+
if (databaseColumn.DataType != tableColumn.DataType ||
664+
(databaseColumn.DataType == DataType.VarChar && tableColumn.DataType == DataType.VarChar && databaseColumn.DataLength != tableColumn.DataLength))
665+
{
666+
var sqlString = SqlUtils.GetModifyColumnsSqlString(tableName, tableColumn.AttributeName,
667+
SqlUtils.GetColumnTypeString(tableColumn));
668+
669+
try
670+
{
671+
DataProvider.DatabaseDao.ExecuteSql(sqlString);
672+
isAltered = true;
673+
}
674+
catch (Exception ex)
675+
{
676+
LogUtils.AddErrorLog(pluginId, ex, sqlString);
677+
}
678+
}
679+
}
667680
}
668-
catch (Exception ex)
681+
else
669682
{
670-
LogUtils.AddErrorLog(pluginId, ex, sqlString);
683+
var columnSqlString = SqlUtils.GetColumnSqlString(tableColumn);
684+
var sqlString = SqlUtils.GetAddColumnsSqlString(tableName, columnSqlString);
685+
686+
try
687+
{
688+
DataProvider.DatabaseDao.ExecuteSql(sqlString);
689+
isAltered = true;
690+
}
691+
catch (Exception ex)
692+
{
693+
LogUtils.AddErrorLog(pluginId, ex, sqlString);
694+
}
671695
}
672696
}
673697

@@ -831,7 +855,19 @@ public void AlterSystemTable(string tableName, List<TableColumn> tableColumns, L
831855
var columnNameList = TableColumnManager.GetTableColumnNameList(tableName);
832856
foreach (var tableColumn in tableColumns)
833857
{
834-
if (!StringUtils.ContainsIgnoreCase(columnNameList, tableColumn.AttributeName))
858+
if (StringUtils.ContainsIgnoreCase(columnNameList, tableColumn.AttributeName))
859+
{
860+
var databaseColumn = TableColumnManager.GetTableColumnInfo(tableName, tableColumn.AttributeName);
861+
if (databaseColumn != null && !tableColumn.IsIdentity)
862+
{
863+
if (tableColumn.DataType != databaseColumn.DataType ||
864+
tableColumn.DataType == databaseColumn.DataType && tableColumn.DataLength > databaseColumn.DataLength)
865+
{
866+
list.Add(SqlUtils.GetModifyColumnsSqlString(tableName, tableColumn.AttributeName, SqlUtils.GetColumnTypeString(tableColumn)));
867+
}
868+
}
869+
}
870+
else
835871
{
836872
list.Add(SqlUtils.GetAddColumnsSqlString(tableName, SqlUtils.GetColumnSqlString(tableColumn)));
837873
}

SiteServer.CMS/StlParser/FileSystemObjectAsync.cs

Lines changed: 53 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -82,46 +82,41 @@ private static async Task CreateChannelAsync(int siteId, int channelId)
8282
var contentBuilder = new StringBuilder(TemplateManager.GetTemplateContent(siteInfo, templateInfo));
8383

8484
var stlLabelList = StlParserUtility.GetStlLabelList(contentBuilder.ToString());
85-
var stlPageContentElement = string.Empty;
86-
foreach (var label in stlLabelList)
87-
{
88-
if (!StlParserUtility.IsStlChannelElement(label, ChannelAttribute.PageContent)) continue;
89-
stlPageContentElement = label;
90-
break;
91-
}
9285

9386
//如果标签中存在<stl:channel type="PageContent"></stl:channel>
94-
if (!string.IsNullOrEmpty(stlPageContentElement)) //内容存在
87+
if (StlParserUtility.IsStlChannelElementWithTypePageContent(stlLabelList)) //内容存在
9588
{
96-
var innerBuilder = new StringBuilder(stlPageContentElement);
89+
var stlElement = StlParserUtility.GetStlChannelElementWithTypePageContent(stlLabelList);
90+
var stlElementTranslated = StlParserManager.StlEncrypt(stlElement);
91+
contentBuilder.Replace(stlElement, stlElementTranslated);
92+
93+
var innerBuilder = new StringBuilder(stlElement);
9794
StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);
98-
var contentAttributeHtml = innerBuilder.ToString();
99-
var pageCount =
100-
StringUtils.GetCount(ContentUtility.PagePlaceHolder, contentAttributeHtml) + 1; //一共需要的页数
95+
var pageContentHtml = innerBuilder.ToString();
96+
var pageCount = StringUtils.GetCount(ContentUtility.PagePlaceHolder, pageContentHtml) + 1; //一共需要的页数
10197

102-
pageInfo.AddPageBodyCodeIfNotExists(PageInfo.Const.Jquery);
10398
Parser.Parse(pageInfo, contextInfo, contentBuilder, filePath, false);
10499

105100
for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
106101
{
107102
var thePageInfo = pageInfo.Clone();
108-
var index = contentAttributeHtml.IndexOf(ContentUtility.PagePlaceHolder, StringComparison.Ordinal);
109-
var length = index == -1 ? contentAttributeHtml.Length : index;
110-
var pagedContentAttributeHtml = contentAttributeHtml.Substring(0, length);
111-
var pagedBuilder = new StringBuilder(contentBuilder.ToString()
112-
.Replace(stlPageContentElement, pagedContentAttributeHtml));
103+
104+
var index = pageContentHtml.IndexOf(ContentUtility.PagePlaceHolder, StringComparison.Ordinal);
105+
var length = index == -1 ? pageContentHtml.Length : index;
106+
107+
var pageHtml = pageContentHtml.Substring(0, length);
108+
var pagedBuilder =
109+
new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml));
113110
StlParserManager.ReplacePageElementsInChannelPage(pagedBuilder, thePageInfo, stlLabelList,
114111
thePageInfo.PageChannelId, currentPageIndex, pageCount, 0);
115112

116113
filePath = PathUtility.GetChannelPageFilePath(siteInfo, thePageInfo.PageChannelId,
117114
currentPageIndex);
118-
119115
await GenerateFileAsync(filePath, pageInfo.TemplateInfo.Charset, pagedBuilder);
120116

121117
if (index != -1)
122118
{
123-
contentAttributeHtml =
124-
contentAttributeHtml.Substring(length + ContentUtility.PagePlaceHolder.Length);
119+
pageContentHtml = pageContentHtml.Substring(length + ContentUtility.PagePlaceHolder.Length);
125120
}
126121
}
127122
}
@@ -293,6 +288,43 @@ private static async Task CreateContentAsync(SiteInfo siteInfo, ChannelInfo chan
293288
}
294289
}
295290
}
291+
//如果标签中存在<stl:channel type="PageContent"></stl:channel>
292+
else if (StlParserUtility.IsStlChannelElementWithTypePageContent(stlLabelList)) //内容存在
293+
{
294+
var stlElement = StlParserUtility.GetStlChannelElementWithTypePageContent(stlLabelList);
295+
var stlElementTranslated = StlParserManager.StlEncrypt(stlElement);
296+
contentBuilder.Replace(stlElement, stlElementTranslated);
297+
298+
var innerBuilder = new StringBuilder(stlElement);
299+
StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);
300+
var pageContentHtml = innerBuilder.ToString();
301+
var pageCount = StringUtils.GetCount(ContentUtility.PagePlaceHolder, pageContentHtml) + 1; //一共需要的页数
302+
303+
Parser.Parse(pageInfo, contextInfo, contentBuilder, filePath, false);
304+
305+
for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
306+
{
307+
var thePageInfo = pageInfo.Clone();
308+
309+
var index = pageContentHtml.IndexOf(ContentUtility.PagePlaceHolder, StringComparison.Ordinal);
310+
var length = index == -1 ? pageContentHtml.Length : index;
311+
312+
var pageHtml = pageContentHtml.Substring(0, length);
313+
var pagedBuilder =
314+
new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml));
315+
StlParserManager.ReplacePageElementsInContentPage(pagedBuilder, thePageInfo, stlLabelList,
316+
channelInfo.Id, contentId, currentPageIndex, pageCount);
317+
318+
filePath = PathUtility.GetContentPageFilePath(siteInfo, thePageInfo.PageChannelId, contentInfo,
319+
currentPageIndex);
320+
await GenerateFileAsync(filePath, pageInfo.TemplateInfo.Charset, pagedBuilder);
321+
322+
if (index != -1)
323+
{
324+
pageContentHtml = pageContentHtml.Substring(length + ContentUtility.PagePlaceHolder.Length);
325+
}
326+
}
327+
}
296328
//如果标签中存在<stl:pageContents>
297329
else if (StlParserUtility.IsStlElementExists(StlPageContents.ElementName, stlLabelList))
298330
{

SiteServer.CMS/StlParser/Model/StlListBase.cs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ public class StlListBase
1717
[StlAttribute(Title = "从首页向下的栏目级别")]
1818
public const string TopLevel = nameof(TopLevel);
1919

20-
[StlAttribute(Title = "内容范围")]
20+
[StlAttribute(Title = "范围")]
2121
public const string Scope = nameof(Scope);
2222

23-
[StlAttribute(Title = "指定显示的栏目组")]
23+
[StlAttribute(Title = "指定栏目组")]
2424
public const string GroupChannel = nameof(GroupChannel);
2525

26-
[StlAttribute(Title = "指定不显示的栏目组")]
26+
[StlAttribute(Title = "排除栏目组")]
2727
public const string GroupChannelNot = nameof(GroupChannelNot);
2828

29-
[StlAttribute(Title = "指定显示的内容组")]
29+
[StlAttribute(Title = "指定内容组")]
3030
public const string GroupContent = nameof(GroupContent);
3131

32-
[StlAttribute(Title = "指定不显示的内容组")]
32+
[StlAttribute(Title = "排除内容组")]
3333
public const string GroupContentNot = nameof(GroupContentNot);
3434

3535
[StlAttribute(Title = "指定标签")]
@@ -47,13 +47,14 @@ public class StlListBase
4747
[StlAttribute(Title = "仅显示醒目内容")]
4848
public const string IsColor = nameof(IsColor);
4949

50-
[StlAttribute(Title = "显示内容数目")]
50+
[StlAttribute(Title = "显示信息总数")]
5151
public const string TotalNum = nameof(TotalNum);
5252

5353
[StlAttribute(Title = "从第几条信息开始显示")]
5454
public const string StartNum = nameof(StartNum);
5555

56-
[StlAttribute(Title = "排序")] public const string Order = nameof(Order);
56+
[StlAttribute(Title = "排序")]
57+
public const string Order = nameof(Order);
5758

5859
[StlAttribute(Title = "仅显示图片内容")]
5960
public const string IsImage = nameof(IsImage);
@@ -67,40 +68,40 @@ public class StlListBase
6768
741A [StlAttribute(Title = "显示相关内容列表")]
6869
public const string IsRelatedContents = nameof(IsRelatedContents);
6970

70-
[StlAttribute(Title = "获取内容列表的条件判断")]
71+
[StlAttribute(Title = "条件判断")]
7172
public const string Where = nameof(Where);
7273

74+
[StlAttribute(Title = "布局")]
75+
public const string Layout = nameof(Layout);
76+
7377
[StlAttribute(Title = "列数")]
7478
public const string Columns = nameof(Columns);
7579

7680
[StlAttribute(Title = "方向")]
7781
public const string Direction = nameof(Direction);
7882

79-
[StlAttribute(Title = "指定列表布局方式")]
80-
public const string Height = nameof(Height);
81-
8283
[StlAttribute(Title = "整体高度")]
83-
public const string Width = nameof(Width);
84+
public const string Height = nameof(Height);
8485

8586
[StlAttribute(Title = "整体宽度")]
86-
public const string Align = nameof(Align);
87+
public const string Width = nameof(Width);
8788

8889
[StlAttribute(Title = "整体对齐")]
89-
public const string ItemHeight = nameof(ItemHeight);
90+
public const string Align = nameof(Align);
9091

9192
[StlAttribute(Title = "项高度")]
92-
public const string ItemWidth = nameof(ItemWidth);
93+
public const string ItemHeight = nameof(ItemHeight);
9394

9495
[StlAttribute(Title = "项宽度")]
95-
public const string ItemAlign = nameof(ItemAlign);
96+
public const string ItemWidth = nameof(ItemWidth);
9697

9798
[StlAttribute(Title = "项水平对齐")]
98-
public const string ItemVerticalAlign = nameof(ItemVerticalAlign);
99+
public const string ItemAlign = nameof(ItemAlign);
99100

100101
[StlAttribute(Title = "项垂直对齐")]
101-
public const string ItemClass = nameof(ItemClass);
102+
public const string ItemVerticalAlign = nameof(ItemVerticalAlign);
102103

103104
[StlAttribute(Title = "项Css类")]
104-
public const string Layout = nameof(Layout);
105+
public const string ItemClass = nameof(ItemClass);
105106
}
106107
}

0 commit comments

Comments
 (0)
0