Skip to content

Commit

Permalink
downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
starlying committed Mar 22, 2019
1 parent 6d96ef2 commit a7ed3e3
Show file tree
Hide file tree
Showing 20 changed files with 701 additions and 342 deletions.
21 changes: 21 additions & 0 deletions SiteServer.BackgroundPages/Cms/ModalContentAttributes.cs
Expand Up @@ -20,6 +20,7 @@ public class ModalContentAttributes : BasePageCms
protected CheckBox CbIsTop;
protected HtmlInputHidden HihType;
protected TextBox TbHits;
protected TextBox TbDownloads;

private ChannelInfo _channelInfo;
private List<int> _idList;
Expand Down Expand Up @@ -91,6 +92,7 @@ public override void Submit_OnClick(object sender, EventArgs e)
}

break;

case "2":
if (CbIsRecommend.Checked || CbIsHot.Checked || CbIsColor.Checked || CbIsTop.Checked)
{
Expand Down Expand Up @@ -125,6 +127,7 @@ public override void Submit_OnClick(object sender, EventArgs e)
}

break;

case "3":
var hits = TranslateUtils.ToInt(TbHits.Text);

Expand All @@ -140,6 +143,24 @@ public override void Submit_OnClick(object sender, EventArgs e)

AuthRequest.AddSiteLog(SiteId, "设置内容点击量");

isChanged = true;
break;

case "4":
var downloads = TranslateUtils.ToInt(TbDownloads.Text);

foreach (var contentId in _idList)
{
var contentInfo = ContentManager.GetContentInfo(SiteInfo, _channelInfo, contentId);
if (contentInfo != null)
{
contentInfo.Downloads = downloads;
DataProvider.ContentDao.Update(SiteInfo, _channelInfo, contentInfo);
}
}

AuthRequest.AddSiteLog(SiteId, "设置内容下载量");

isChanged = true;
break;
}
Expand Down
30 changes: 17 additions & 13 deletions SiteServer.BackgroundPages/Cms/PageContentAddAfter.cs
Expand Up @@ -74,21 +74,25 @@ public void RblOperation_SelectedIndexChanged(object sender, EventArgs e)
if (after == EContentAddAfter.ContinueAdd)
{
PageUtils.Redirect(WebUtils.GetContentAddAddUrl(SiteId, _channelInfo, AuthRequest.GetQueryString("ReturnUrl")));
return;
}
else if (after == EContentAddAfter.ManageContents)
{
PageUtils.Redirect(_returnUrl);
}
else if (after == EContentAddAfter.Contribute)
{
CrossSiteTransUtility.LoadSiteIdDropDownList(DdlSiteId, SiteInfo, _channelInfo.Id);

if (DdlSiteId.Items.Count > 0)
{
DdlSiteId_SelectedIndexChanged(sender, e);
}
PhSiteId.Visible = PhSubmit.Visible = true;
}
if (after == EContentAddAfter.ManageContents)
{
PageUtils.Redirect(_returnUrl);
return;
}

if (after == EContentAddAfter.Contribute)
{
CrossSiteTransUtility.LoadSiteIdDropDownList(DdlSiteId, SiteInfo, _channelInfo.Id);

if (DdlSiteId.Items.Count > 0)
{
DdlSiteId_SelectedIndexChanged(sender, e);
}
PhSiteId.Visible = PhSubmit.Visible = true;
}
}

public void DdlSiteId_SelectedIndexChanged(object sender, EventArgs e)
Expand Down
145 changes: 145 additions & 0 deletions SiteServer.BackgroundPages/Cms/PageTemplateReference.cs
@@ -0,0 +1,145 @@
using System;
using System.Collections.Specialized;
using System.Reflection;
using System.Text;
using System.Web.UI.WebControls;
using SiteServer.CMS.DataCache;
using SiteServer.CMS.StlParser.Model;
using SiteServer.Utils;

namespace SiteServer.BackgroundPages.Cms
{
public class PageTemplateReference : BasePageCms
{
public Literal LtlAll;
public PlaceHolder PhRefenreces;
public Literal LtlReferences;

public static string GetRedirectUrl(int siteId, string elementName)
{
return PageUtils.GetCmsUrl(siteId, nameof(PageTemplateReference), new NameValueCollection
{
{"elementName", elementName}
});
}

private string _elementName = string.Empty;

public void Page_Load(object sender, EventArgs e)
{
if (IsForbidden) return;

PageUtils.CheckRequestParameter("siteId");

_elementName = AuthRequest.GetQueryString("elementName");

if (IsPostBack) return;

VerifySitePermissions(ConfigManager.WebSitePermissions.Template);

var elements = StlAll.Elements;
var allBuilder = new StringBuilder();
foreach (var elementName in elements.Keys)
{
if (!elements.TryGetValue(elementName, out var elementType)) continue;

var tagName = elementName.Substring(4);
var stlAttribute = (StlElementAttribute)Attribute.GetCustomAttribute(elementType, typeof(StlElementAttribute));

allBuilder.Append($@"
<tr class=""{(elementName == _elementName ? "bg-secondary text-white" : string.Empty)}"">
<td>
<a href=""{GetRedirectUrl(SiteId, elementName)}"" class=""{(elementName == _elementName ? "text-white" : string.Empty)}"">
{elementName}
</a>
</td>
<td>{stlAttribute.Title}</td>
<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>
</tr>");
}

LtlAll.Text = $@"
<div class=""panel panel-default m-t-10"">
<div class=""panel-body p-0"">
<div class=""table-responsive"">
<table class=""table tablesaw table-striped m-0"">
<thead>
<tr>
<th>标签</th>
<th>说明</th>
<th>参考</th>
</tr>
</thead>
<tbody>
{allBuilder}
</tbody>
</table>
</div>
</div>
</div>
";

if (!string.IsNullOrEmpty(_elementName))
{
if (elements.TryGetValue(_elementName, out var elementType))
{
var tagName = _elementName.Substring(4);
PhRefenreces.Visible = true;

var attrBuilder = new StringBuilder();

var fields = elementType.GetFields(BindingFlags.Static | BindingFlags.NonPublic);
foreach (var field in fields)
{
var fieldName = field.Name.ToCamelCase();
var attr = (StlAttributeAttribute)Attribute.GetCustomAttribute(field, typeof(StlAttributeAttribute));

if (attr != null)
{
attrBuilder.Append($@"
<tr>
<td>{fieldName}</td>
<td>{attr.Title}</td>
<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>
</tr>");
}
}

var helpUrl = $"https://docs.siteserver.cn/stl#/{tagName}/";

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

LtlReferences.Text = $@"
<div class=""tab-pane"" style=""display: block;"">
<h4 class=""m-t-0 header-title"">
&lt;{_elementName}&gt; {stlAttribute.Title}
</h4>
<p>
{stlAttribute.Description}
<a href=""{helpUrl}"" target=""_blank"">详细使用说明</a>
</p>
<div class=""panel panel-default m-t-10"">
<div class=""panel-body p-0"">
<div class=""table-responsive"">
<table class=""table tablesaw table-striped m-0"">
<thead>
<tr>
<th>属性</th>
<th>说明</th>
<th>参考</th>
</tr>
</thead>
<tbody>
{attrBuilder}
</tbody>
</table>
</div>
</div>
</div>
</div>
";
}
}
}
}
}
4 changes: 4 additions & 0 deletions SiteServer.BackgroundPages/Core/TextUtility.cs
Expand Up @@ -108,6 +108,10 @@ private static string GetColumnValue(Dictionary<string, string> nameValueCacheDi
{
value = DateUtils.GetDateAndTimeString(contentInfo.LastHitsDate);
}
else if (StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.Downloads))
{
value = contentInfo.Downloads.ToString();
}
else if (StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.IsTop) || StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.IsColor) || StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.IsHot) || StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.IsRecommend))
{
value = StringUtils.GetTrueImageHtml(contentInfo.GetString(styleInfo.AttributeName));
Expand Down
3 changes: 3 additions & 0 deletions SiteServer.BackgroundPages/SiteServer.BackgroundPages.csproj
Expand Up @@ -410,6 +410,9 @@
</Compile>
<Compile Include="Cms\ModalTextEditorInsertImageHandler.cs" />
<Compile Include="Cms\ModalUploadWordHandler.cs" />
<Compile Include="Cms\PageTemplateReference.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Controls\Alerts.cs" />
<Compile Include="Controls\AuxiliaryControl.cs" />
<Compile Include="Controls\ChannelAuxiliaryControl.cs" />
Expand Down
6 changes: 6 additions & 0 deletions SiteServer.CMS/Core/ContentUtility.cs
Expand Up @@ -362,6 +362,12 @@ public static List<TableStyleInfo> GetAllTableStyleInfoList(List<TableStyleInfo>
Taxis = taxis++
},
new TableStyleInfo
{
AttributeName = ContentAttribute.Downloads,
DisplayName = "下载量",
Taxis = taxis++
},
new TableStyleInfo
{
AttributeName = ContentAttribute.CheckUserName,
DisplayName = "审核人",
Expand Down

0 comments on commit a7ed3e3

Please sign in to comment.