Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
starlying committed Feb 27, 2018
1 parent db47aaf commit 0b3388e
Show file tree
Hide file tree
Showing 25 changed files with 191 additions and 203 deletions.
2 changes: 1 addition & 1 deletion SiteServer.BackgroundPages/BasePage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void AddWaitAndReloadMainPage()
{
_scripts += @"
setTimeout(function() {{
window.top.location.reload();
window.top.location.reload(true);
}}, 1500);
";
}
Expand Down
10 changes: 5 additions & 5 deletions SiteServer.BackgroundPages/Cms/ModalContentAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class ModalContentAttributes : BasePageCms

private int _channelId;
private string _tableName;
private List<int> _idArrayList;
private List<int> _idList;

public static string GetOpenWindowString(int siteId, int channelId)
{
Expand All @@ -46,7 +46,7 @@ public void Page_Load(object sender, EventArgs e)

_channelId = Body.GetQueryInt("channelId");
_tableName = ChannelManager.GetTableName(SiteInfo, _channelId);
_idArrayList = TranslateUtils.StringCollectionToIntList(Body.GetQueryString("contentIdCollection"));
_idList = TranslateUtils.StringCollectionToIntList(Body.GetQueryString("contentIdCollection"));
}

public override void Submit_OnClick(object sender, EventArgs e)
Expand All @@ -59,7 +59,7 @@ public override void Submit_OnClick(object sender, EventArgs e)
{
if (CbIsRecommend.Checked || CbIsHot.Checked || CbIsColor.Checked || CbIsTop.Checked)
{
foreach (var contentId in _idArrayList)
foreach (var contentId in _idList)
{
var contentInfo = DataProvider.ContentDao.GetContentInfo(_tableName, contentId);
if (contentInfo != null)
Expand Down Expand Up @@ -93,7 +93,7 @@ public override void Submit_OnClick(object sender, EventArgs e)
{
if (CbIsRecommend.Checked || CbIsHot.Checked || CbIsColor.Checked || CbIsTop.Checked)
{
foreach (var contentId in _idArrayList)
foreach (var contentId in _idList)
{
var contentInfo = DataProvider.ContentDao.GetContentInfo(_tableName, contentId);
if (contentInfo != null)
Expand Down Expand Up @@ -127,7 +127,7 @@ public override void Submit_OnClick(object sender, EventArgs e)
{
var hits = TranslateUtils.ToInt(TbHits.Text);

foreach (var contentId in _idArrayList)
foreach (var contentId in _idList)
{
DataProvider.ContentDao.SetValue(_tableName, contentId, ContentAttribute.Hits, hits.ToString());
}
Expand Down
2 changes: 1 addition & 1 deletion SiteServer.BackgroundPages/Core/WebUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static string GetContentTitle(SiteInfo siteInfo, ContentInfo contentInfo,
string url;
var title = ContentUtility.FormatTitle(contentInfo.GetString(BackgroundContentAttribute.TitleFormatString), contentInfo.Title);

var displayString = contentInfo.IsTop ? $"<span style='color:#ff0000;text-decoration:none' title='醒目'>{title}</span>" : title;
var displayString = contentInfo.IsColor ? $"<span style='color:#ff0000;text-decoration:none' title='醒目'>{title}</span>" : title;

if (contentInfo.ChannelId < 0)
{
Expand Down
8 changes: 4 additions & 4 deletions SiteServer.BackgroundPages/Plugins/PageManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void Page_Load(object sender, EventArgs e)
CacheUtils.ClearAll();
CacheDbUtils.Clear();

AddScript(AlertUtils.Success("插件删除成功", "插件删除成功,系统需要重载页面", "重新载入", "window.top.location.reload();"));
AddScript(AlertUtils.Success("插件删除成功", "插件删除成功,系统需要重载页面", "重新载入", "window.top.location.reload(true);"));
}
if (Body.IsQueryExists("enable"))
{
Expand All @@ -56,7 +56,7 @@ public void Page_Load(object sender, EventArgs e)
CacheUtils.ClearAll();
CacheDbUtils.Clear();

AddScript(AlertUtils.Success("插件启用成功", "插件启用成功,系统需要重载页面", "重新载入", "window.top.location.reload();"));
AddScript(AlertUtils.Success("插件启用成功", "插件启用成功,系统需要重载页面", "重新载入", "window.top.location.reload(true);"));
}
else if (Body.IsQueryExists("disable"))
{
Expand All @@ -68,7 +68,7 @@ public void Page_Load(object sender, EventArgs e)
CacheUtils.ClearAll();
CacheDbUtils.Clear();

AddScript(AlertUtils.Success("插件禁用成功", "插件禁用成功,系统需要重载页面", "重新载入", "window.top.location.reload();"));
AddScript(AlertUtils.Success("插件禁用成功", "插件禁用成功,系统需要重载页面", "重新载入", "window.top.location.reload(true);"));
}

if (Page.IsPostBack) return;
Expand All @@ -81,7 +81,7 @@ public void BtnReload_Click(object sender, EventArgs e)
CacheUtils.ClearAll();
CacheDbUtils.Clear();

AddScript(AlertUtils.Success("插件重新加载成功", "插件重新加载成功,系统需要重载页面", "重新载入", "window.top.location.reload();"));
AddScript(AlertUtils.Success("插件重新加载成功", "插件重新加载成功,系统需要重载页面", "重新载入", "window.top.location.reload(true);"));
}

// private void RptRunnable_ItemDataBound(object sender, RepeaterItemEventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion SiteServer.CMS/Plugin/Apis/ParseApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public string XmlToHtml(string xml)
public string GetCurrentUrl(IParseContext context)
{
var siteInfo = SiteManager.GetSiteInfo(context.SiteId);
return StlUtility.GetStlCurrentUrl(siteInfo, context.ChannelId, context.ContentId,
return StlParserUtility.GetStlCurrentUrl(siteInfo, context.ChannelId, context.ContentId,
context.ContentInfo, context.TemplateType, context.TemplateId, false);
}
}
Expand Down
1 change: 0 additions & 1 deletion SiteServer.CMS/SiteServer.CMS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,6 @@
<Compile Include="StlParser\Utility\StlParserUtility.cs" />
<Compile Include="StlParser\Utility\StlScriptUtility.cs" />
<Compile Include="StlParser\Utility\StlTemplateManager.cs" />
<Compile Include="StlParser\Utility\StlUtility.cs" />
<Compile Include="StlParser\Utility\TemplateUtility.cs" />
<Compile Include="UEditor\Config.cs" />
<Compile Include="UEditor\ConfigHandler.cs" />
Expand Down
1 change: 0 additions & 1 deletion SiteServer.CMS/StlParser/Model/PageInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using SiteServer.CMS.Model;
using SiteServer.Plugin;
using System.Text;
using SiteServer.CMS.StlParser.Utility;

namespace SiteServer.CMS.StlParser.Model
{
Expand Down
121 changes: 120 additions & 1 deletion SiteServer.CMS/StlParser/StlElement/StlDynamic.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using SiteServer.Utils;
using SiteServer.CMS.Controllers.Sys.Stl;
using SiteServer.CMS.Core;
using SiteServer.CMS.StlParser.Model;
using SiteServer.CMS.StlParser.StlEntity;
using SiteServer.CMS.StlParser.Utility;
using SiteServer.Plugin;

namespace SiteServer.CMS.StlParser.StlElement
{
Expand Down Expand Up @@ -62,8 +66,10 @@ private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, stri
return string.Empty;
}

StlParserManager.ParseInnerContent(new StringBuilder(templateContent), pageInfo, contextInfo);

var apiUrl = ApiRouteActionsDynamic.GetUrl(pageInfo.ApiUrl);
var currentPageUrl = StlUtility.GetStlCurrentUrl(pageInfo.SiteInfo, contextInfo.ChannelId, contextInfo.ContentId, contextInfo.ContentInfo, pageInfo.TemplateInfo.TemplateType, pageInfo.TemplateInfo.Id, pageInfo.IsLocal);
var currentPageUrl = StlParserUtility.GetStlCurrentUrl(pageInfo.SiteInfo, contextInfo.ChannelId, contextInfo.ContentId, contextInfo.ContentInfo, pageInfo.TemplateInfo.TemplateType, pageInfo.TemplateInfo.Id, pageInfo.IsLocal);
currentPageUrl = PageUtils.AddQuestionOrAndToUrl(currentPageUrl);
var apiParameters = ApiRouteActionsDynamic.GetParameters(pageInfo.SiteId, contextInfo.ChannelId, contextInfo.ContentId, pageInfo.TemplateInfo.Id, currentPageUrl, ajaxDivId, isPageRefresh, templateContent);

Expand Down Expand Up @@ -97,5 +103,118 @@ internal static string ParseDynamicElement(string stlElement, PageInfo pageInfo,
stlElement = StringUtils.ReplaceIgnoreCase(stlElement, "isdynamic=\"true\"", string.Empty);
return ParseImpl(pageInfo, contextInfo, stlElement, false);
}

public static string ParseDynamicContent(int siteId, int channelId, int contentId, int templateId, bool isPageRefresh, string templateContent, string pageUrl, int pageIndex, string ajaxDivId, NameValueCollection queryString, IUserInfo userInfo)
{
var templateInfo = TemplateManager.GetTemplateInfo(siteId, templateId);
//TemplateManager.GetTemplateInfo(siteID, channelID, templateType);
var siteInfo = SiteManager.GetSiteInfo(siteId);
var pageInfo = new PageInfo(channelId, contentId, siteInfo, templateInfo, new Dictionary<string, object>())
{
UniqueId = 1000,
UserInfo = userInfo
};
var contextInfo = new ContextInfo(pageInfo);

templateContent = StlRequestEntities.ParseRequestEntities(queryString, templateContent);
var contentBuilder = new StringBuilder(templateContent);
var stlElementList = StlParserUtility.GetStlElementList(contentBuilder.ToString());

//如果标签中存在<stl:pageContents>
if (StlParserUtility.IsStlElementExists(StlPageContents.ElementName, stlElementList))
{
var stlElement = StlParserUtility.GetStlElement(StlPageContents.ElementName, stlElementList);
var stlPageContentsElement = stlElement;
var stlPageContentsElementReplaceString = stlElement;

var pageContentsElementParser = new StlPageContents(stlPageContentsElement, pageInfo, contextInfo, true);
int totalNum;
var pageCount = pageContentsElementParser.GetPageCount(out totalNum);

for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
{
if (currentPageIndex == pageIndex)
{
var pageHtml = pageContentsElementParser.Parse(totalNum, currentPageIndex, pageCount, false);
contentBuilder.Replace(stlPageContentsElementReplaceString, pageHtml);

StlParserManager.ReplacePageElementsInDynamicPage(contentBuilder, pageInfo, stlElementList, pageUrl, pageInfo.PageChannelId, currentPageIndex, pageCount, totalNum, isPageRefresh, ajaxDivId);

break;
}
}
}
//如果标签中存在<stl:pageChannels>
else if (StlParserUtility.IsStlElementExists(StlPageChannels.ElementName, stlElementList))
{
var stlElement = StlParserUtility.GetStlElement(StlPageChannels.ElementName, stlElementList);
var stlPageChannelsElement = stlElement;
var stlPageChannelsElementReplaceString = stlElement;

var pageChannelsElementParser = new StlPageChannels(stlPageChannelsElement, pageInfo, contextInfo, true);
int totalNum;
var pageCount = pageChannelsElementParser.GetPageCount(out totalNum);

for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
{
if (currentPageIndex == pageIndex)
{
var pageHtml = pageChannelsElementParser.Parse(currentPageIndex, pageCount);
contentBuilder.Replace(stlPageChannelsElementReplaceString, pageHtml);

StlParserManager.ReplacePageElementsInDynamicPage(contentBuilder, pageInfo, stlElementList, pageUrl, pageInfo.PageChannelId, currentPageIndex, pageCount, totalNum, isPageRefresh, ajaxDivId);

break;
}
}
}
//如果标签中存在<stl:pageSqlContents>
else if (StlParserUtility.IsStlElementExists(StlPageSqlContents.ElementName, stlElementList))
{
var stlElement = StlParserUtility.GetStlElement(StlPageSqlContents.ElementName, stlElementList);
var stlPageSqlContentsElement = stlElement;
var stlPageSqlContentsElementReplaceString = stlElement;

var pageSqlContentsElementParser = new StlPageSqlContents(stlPageSqlContentsElement, pageInfo, contextInfo, true);
int totalNum;
var pageCount = pageSqlContentsElementParser.GetPageCount(out totalNum);

for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
{
if (currentPageIndex == pageIndex)
{
var pageHtml = pageSqlContentsElementParser.Parse(currentPageIndex, pageCount);
contentBuilder.Replace(stlPageSqlContentsElementReplaceString, pageHtml);

StlParserManager.ReplacePageElementsInDynamicPage(contentBuilder, pageInfo, stlElementList, pageUrl, pageInfo.PageChannelId, currentPageIndex, pageCount, totalNum, isPageRefresh, ajaxDivId);

break;
}
}
}

else if (StlParserUtility.IsStlElementExists(StlPageItems.ElementName, stlElementList))
{
var pageCount = TranslateUtils.ToInt(queryString["pageCount"]);
var totalNum = TranslateUtils.ToInt(queryString["totalNum"]);
var pageContentsAjaxDivId = queryString["pageContentsAjaxDivId"];

for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
{
if (currentPageIndex == pageIndex)
{
StlParserManager.ReplacePageElementsInDynamicPage(contentBuilder, pageInfo, stlElementList, pageUrl, pageInfo.PageChannelId, currentPageIndex, pageCount, totalNum, isPageRefresh, pageContentsAjaxDivId);

break;
}
}
}

StlParserManager.ParseInnerContent(contentBuilder, pageInfo, contextInfo);

//var parsedContent = StlParserUtility.GetBackHtml(contentBuilder.ToString(), pageInfo);
//return pageInfo.HeadCodesHtml + pageInfo.BodyCodesHtml + parsedContent + pageInfo.FootCodesHtml;
return StlParserUtility.GetBackHtml(contentBuilder.ToString(), pageInfo);
}
}
}
5 changes: 4 additions & 1 deletion SiteServer.CMS/StlParser/StlElement/StlIf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, stri
StringUtils.EqualsIgnoreCase(testType, TypeIsAdministratorLoggin) ||
StringUtils.EqualsIgnoreCase(testType, TypeIsUserOrAdministratorLoggin))
{
StlParserManager.ParseInnerContent(new StringBuilder(successTemplateString), pageInfo, contextInfo);
StlParserManager.ParseInnerContent(new StringBuilder(failureTemplateString), pageInfo, contextInfo);

return TestTypeDynamic(pageInfo, contextInfo, testType, testValue, testOperate, successTemplateString,
failureTemplateString);
}
Expand Down Expand Up @@ -381,7 +384,7 @@ private static string TestTypeDynamic(PageInfo pageInfo, ContextInfo contextInfo
return string.Empty;
}

var pageUrl = StlUtility.GetStlCurrentUrl(pageInfo.SiteInfo, contextInfo.ChannelId, contextInfo.ContentId, contextInfo.ContentInfo, pageInfo.TemplateInfo.TemplateType, pageInfo.TemplateInfo.Id, pageInfo.IsLocal);
var pageUrl = StlParserUtility.GetStlCurrentUrl(pageInfo.SiteInfo, contextInfo.ChannelId, contextInfo.ContentId, contextInfo.ContentInfo, pageInfo.TemplateInfo.TemplateType, pageInfo.TemplateInfo.Id, pageInfo.IsLocal);

var ifApiUrl = ApiRouteActionsIf.GetUrl(pageInfo.ApiUrl);
var ifApiParms = ApiRouteActionsIf.GetParameters(pageInfo.SiteId, contextInfo.ChannelId, contextInfo.ContentId, pageInfo.TemplateInfo.Id, ajaxDivId, pageUrl, testType, testValue, testOperate, successTemplateString, failureTemplateString);
Expand Down
2 changes: 1 addition & 1 deletion SiteServer.CMS/StlParser/StlEntity/StlStlEntities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ internal static string Parse(string stlEntity, PageInfo pageInfo, ContextInfo co
}
else if (StringUtils.EqualsIgnoreCase(CurrentUrl, attributeName))//当前页地址
{
parsedContent = StlUtility.GetStlCurrentUrl(pageInfo.SiteInfo, contextInfo.ChannelId, contextInfo.ContentId, contextInfo.ContentInfo, pageInfo.TemplateInfo.TemplateType, pageInfo.TemplateInfo.Id, pageInfo.IsLocal);
parsedContent = StlParserUtility.GetStlCurrentUrl(pageInfo.SiteInfo, contextInfo.ChannelId, contextInfo.ContentId, contextInfo.ContentInfo, pageInfo.TemplateInfo.TemplateType, pageInfo.TemplateInfo.Id, pageInfo.IsLocal);
}
else if (StringUtils.EqualsIgnoreCase(ChannelUrl, attributeName))//栏目页地址
{
Expand Down
2 changes: 2 additions & 0 deletions SiteServer.CMS/StlParser/Utility/StlParserManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public static string ParseTemplatePreview(SiteInfo siteInfo, TemplateType templa

public static void ParseInnerContent(StringBuilder builder, PageInfo pageInfo, ContextInfo contextInfo)
{
if (builder == null || builder.Length == 0) return;

var isInnerElement = contextInfo.IsInnerElement;
contextInfo.IsInnerElement = true;
StlElementParser.ReplaceStlElements(builder, pageInfo, contextInfo);
Expand Down
33 changes: 33 additions & 0 deletions SiteServer.CMS/StlParser/Utility/StlParserUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using SiteServer.CMS.Core;
using SiteServer.CMS.Model;
using SiteServer.CMS.StlParser.Model;
using SiteServer.Plugin;

namespace SiteServer.CMS.StlParser.Utility
{
Expand Down Expand Up @@ -582,5 +583,37 @@ public static string GetStlElement(string stlElementName, NameValueCollection at
{innerContent}
</{stlElementName}>";
}

public static string GetStlCurrentUrl(SiteInfo siteInfo, int channelId, int contentId, IContentInfo contentInfo, TemplateType templateType, int templateId, bool isLocal)
{
var currentUrl = string.Empty;
if (templateType == TemplateType.IndexPageTemplate)
{
currentUrl = siteInfo.Additional.WebUrl;
}
else if (templateType == TemplateType.ContentTemplate)
{
if (contentInfo == null)
{
var nodeInfo = ChannelManager.GetChannelInfo(siteInfo.Id, channelId);
currentUrl = PageUtility.GetContentUrl(siteInfo, nodeInfo, contentId, isLocal);
}
else
{
currentUrl = PageUtility.GetContentUrl(siteInfo, contentInfo, isLocal);
}
}
else if (templateType == TemplateType.ChannelTemplate)
{
currentUrl = PageUtility.GetChannelUrl(siteInfo, ChannelManager.GetChannelInfo(siteInfo.Id, channelId), isLocal);
}
else if (templateType == TemplateType.FileTemplate)
{
currentUrl = PageUtility.GetFileUrl(siteInfo, templateId, isLocal);
}
//currentUrl是当前页面的地址,前后台分离的时候,不允许带上protocol
//return PageUtils.AddProtocolToUrl(currentUrl);
return currentUrl;
}
}
}
Loading

0 comments on commit 0b3388e

Please sign in to comment.