Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
701 additions
and
342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
145 changes: 145 additions & 0 deletions
145
SiteServer.BackgroundPages/Cms/PageTemplateReference.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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""> | ||
<{_elementName}> {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> | ||
"; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.