public static string GetNodeTreeLastImageHtml(SiteInfo siteInfo, ChannelInfo nodeInfo) { var imageHtml = string.Empty; if (nodeInfo.ParentId == 0) { var treeDirectoryUrl = SiteServerAssets.GetIconUrl("tree"); if (siteInfo.IsRoot == false) { imageHtml = $@"<img align=""absmiddle"" title=""站点"" border=""0"" src=""{PageUtils.Combine(treeDirectoryUrl, "site.gif")}"" /></a>"; } else { imageHtml = $@"<img align=""absmiddle"" title=""站点"" border=""0"" src=""{PageUtils.Combine(treeDirectoryUrl, "siteHQ.gif")}"" />"; } } if (!string.IsNullOrEmpty(nodeInfo.ContentRelatedPluginIds)) { foreach (var service in PluginContentManager.GetContentPlugins(nodeInfo, false)) { imageHtml += $@"<img align=""absmiddle"" title=""插件:{service.Metadata.Title}"" border=""0"" src=""{PluginManager.GetPluginIconUrl(service)}"" width=""18"" height=""18"" />"; } } return(imageHtml); }
public async Task <ActionResult <GetResult> > Get([FromQuery] int siteId) { if (!await _authManager.HasSitePermissionsAsync(siteId, Types.SitePermissions.WxAccount)) { return(Unauthorized()); } var account = await _wxAccountRepository.GetBySiteIdAsync(siteId); var defaultTenPayAuthorizeUrl = Request.Scheme + "://" + PageUtils.Combine(Request.Host.Host, Constants.ApiWxPrefix, TenPayController.Route.Replace("{siteId}", siteId.ToString())); var defaultTenPayNotifyUrl = Request.Scheme + "://" + PageUtils.Combine(Request.Host.Host, Constants.ApiWxPrefix, TenPayController.Route.Replace("{siteId}", siteId.ToString())); if (string.IsNullOrEmpty(account.TenPayAuthorizeUrl)) { account.TenPayAuthorizeUrl = defaultTenPayAuthorizeUrl; } if (string.IsNullOrEmpty(account.TenPayNotifyUrl)) { account.TenPayNotifyUrl = defaultTenPayNotifyUrl; } var mpUrl = Request.Scheme + "://" + PageUtils.Combine(Request.Host.Host, Constants.ApiWxPrefix, Controllers.Wx.IndexController.Route.Replace("{siteId}", siteId.ToString())); return(new GetResult { MpUrl = mpUrl, DefaultTenPayAuthorizeUrl = defaultTenPayAuthorizeUrl, DefaultTenPayNotifyUrl = defaultTenPayNotifyUrl, Account = account }); }
private async Task GetDirectoriesAndFilesAsync(List <Cascade <string> > directories, List <KeyValuePair <string, string> > files, Site site, string virtualPath, string extName) { extName = "." + extName; var directoryPath = await _pathManager.GetSitePathAsync(site, virtualPath); DirectoryUtils.CreateDirectoryIfNotExists(directoryPath); var fileNames = DirectoryUtils.GetFileNames(directoryPath); foreach (var fileName in fileNames) { if (StringUtils.EqualsIgnoreCase(PathUtils.GetExtension(fileName), extName)) { files.Add(new KeyValuePair <string, string>(virtualPath, fileName)); } } var dir = new Cascade <string> { Label = PathUtils.GetDirectoryName(directoryPath, false), Value = virtualPath }; var children = DirectoryUtils.GetDirectoryNames(directoryPath); dir.Children = new List <Cascade <string> >(); foreach (var directoryName in children) { await GetDirectoriesAndFilesAsync(dir.Children, files, site, PageUtils.Combine(virtualPath, directoryName), extName); } directories.Add(dir); }
private ChannelTreeItem(SiteInfo siteInfo, ChannelInfo channelInfo, bool enabled, PermissionManager permissionManager) { _siteInfo = siteInfo; _channelInfo = channelInfo; _enabled = enabled; _permissionManager = permissionManager; var treeDirectoryUrl = SiteServerAssets.GetIconUrl("tree"); _contentModelIconUrl = PageUtils.Combine(treeDirectoryUrl, "folder.gif"); _iconEmptyUrl = PageUtils.Combine(treeDirectoryUrl, "empty.gif"); _iconMinusUrl = PageUtils.Combine(treeDirectoryUrl, "minus.png"); _iconPlusUrl = PageUtils.Combine(treeDirectoryUrl, "plus.png"); if (!string.IsNullOrEmpty(channelInfo.ContentModelPluginId)) { _contentModelIconClass = PluginMenuManager.GetPluginIconClass(channelInfo.ContentModelPluginId); if (string.IsNullOrEmpty(_contentModelIconClass)) { var iconUrl = PluginManager.GetPluginIconUrl(channelInfo.ContentModelPluginId); if (!string.IsNullOrEmpty(iconUrl)) { _contentModelIconUrl = iconUrl; } } } }
public static string MapPath(string directoryPath, string virtualPath) { var resolvedPath = virtualPath; if (string.IsNullOrEmpty(virtualPath)) { virtualPath = "@"; } if (!virtualPath.StartsWith("@") && !virtualPath.StartsWith("~")) { virtualPath = "@" + virtualPath; } if (virtualPath.StartsWith("@")) { if (string.IsNullOrEmpty(directoryPath)) { resolvedPath = string.Concat("~", virtualPath.Substring(1)); } else { return(PageUtils.Combine(directoryPath, virtualPath.Substring(1))); } } return(PathUtils.MapPath(resolvedPath)); }
public async Task <ActionResult <UploadResult> > Upload([FromQuery] int siteId, [FromForm] IFormFile file) { var site = await _siteRepository.GetAsync(siteId); if (file == null) { return(this.Error("请选择有效的文件上传")); } var fileName = PathUtils.GetFileName(file.FileName); var extName = PathUtils.GetExtension(fileName); if (!_pathManager.IsImageExtensionAllowed(site, extName)) { return(this.Error("此图片格式已被禁止上传,请转换格式后上传!")); } var materialFileName = PathUtils.GetMaterialFileName(fileName); var virtualDirectoryPath = PathUtils.GetMaterialVirtualDirectoryPath(UploadType.Image); var directoryPath = PathUtils.Combine(_pathManager.WebRootPath, virtualDirectoryPath); var filePath = PathUtils.Combine(directoryPath, materialFileName); await _pathManager.UploadAsync(file, filePath); await _pathManager.AddWaterMarkAsync(site, filePath); return(new UploadResult { Name = fileName, Path = PageUtils.Combine(virtualDirectoryPath, materialFileName) }); }
private ChannelTreeItem(SiteInfo siteInfo, ChannelInfo channelInfo, bool enabled, PermissionManager permissionManager) { _siteInfo = siteInfo; _channelInfo = channelInfo; _enabled = enabled; _permissionManager = permissionManager; var treeDirectoryUrl = SiteServerAssets.GetIconUrl("tree"); //为后台栏目树中的首页和外链栏目添加图标 if (_channelInfo.ParentId == 0) { _contentModelIconClass = "ion-ios-home"; } else if (_channelInfo.LinkUrl.Length != 0) { _contentModelIconClass = "ion-link"; } else { _contentModelIconClass = "ion-folder"; } _iconEmptyUrl = PageUtils.Combine(treeDirectoryUrl, "empty.gif"); _iconMinusUrl = PageUtils.Combine(treeDirectoryUrl, "minus.png"); _iconPlusUrl = PageUtils.Combine(treeDirectoryUrl, "plus.png"); }
public static string GetUrl(string apiUrl, string relatedUrl) { if (string.IsNullOrEmpty(apiUrl)) { apiUrl = "/api"; } apiUrl = apiUrl.Trim().ToLower(); if (apiUrl == "/api") { apiUrl = "/"; } else if (apiUrl.EndsWith("/api")) { apiUrl = apiUrl.Substring(0, apiUrl.LastIndexOf("/api", StringComparison.Ordinal)); } else if (apiUrl.EndsWith("/api/")) { apiUrl = apiUrl.Substring(0, apiUrl.LastIndexOf("/api/", StringComparison.Ordinal)); } if (string.IsNullOrEmpty(apiUrl)) { apiUrl = "/"; } return(PageUtils.Combine(apiUrl, "sitefiles/assets", relatedUrl)); }
private static string GetLocalSiteUrl(SiteInfo siteInfo, string requestPath) { var url = PageUtils.ParseNavigationUrl($"~/{siteInfo.SiteDir}"); if (string.IsNullOrEmpty(url)) { url = "/"; } else { if (url != "/" && url.EndsWith("/")) { url = url.Substring(0, url.Length - 1); } } if (string.IsNullOrEmpty(requestPath)) { return(url); } requestPath = requestPath.Replace(PathUtils.SeparatorChar, PageUtils.SeparatorChar); requestPath = PathUtils.RemovePathInvalidChar(requestPath); if (requestPath.StartsWith("/")) { requestPath = requestPath.Substring(1); } url = PageUtils.Combine(url, requestPath); return(url); }
public static string GetUrl(string apiUrl, int publishmentSystemId, int styleId) { apiUrl = PageUtils.Combine(apiUrl, Route); apiUrl = apiUrl.Replace("{publishmentSystemId}", publishmentSystemId.ToString()); apiUrl = apiUrl.Replace("{styleId}", styleId.ToString()); return(apiUrl); }
private void UpdateByUpload() { if (HifFile.PostedFile == null || HifFile.PostedFile.FileName == "") { return; } var filePath = HifFile.PostedFile.FileName; if (!StringUtils.EqualsIgnoreCase(Path.GetExtension(filePath), ".nupkg")) { FailMessage("必须上传后缀为.nupkg的文件"); return; } var idAndVersion = Path.GetFileNameWithoutExtension(filePath); var directoryPath = PathUtils.GetPackagesPath(idAndVersion); var localFilePath = PathUtils.Combine(directoryPath, idAndVersion + ".nupkg"); if (!Directory.Exists(directoryPath)) { Directory.CreateDirectory(directoryPath); } HifFile.PostedFile.SaveAs(localFilePath); ZipUtils.ExtractZip(localFilePath, directoryPath); AuthRequest.AddAdminLog("手动升级 SiteServer CMS 版本:" + idAndVersion); LayerUtils.CloseAndRedirect(Page, PageUtils.GetAdminUrl(PageUtils.Combine("plugins/manage.cshtml"))); }
public static string GetUrl(string pluginId, string routeResource = "", string routeId = "", string routeAction = "") { var apiUrl = ApiManager.GetApiUrl(Route); apiUrl = apiUrl.Replace("{pluginId}", pluginId); if (!string.IsNullOrEmpty(routeResource)) { apiUrl = PageUtils.Combine(apiUrl, routeResource); if (!string.IsNullOrEmpty(routeId)) { apiUrl = PageUtils.Combine(apiUrl, routeId); if (!string.IsNullOrEmpty(routeAction)) { apiUrl = PageUtils.Combine(apiUrl, "actions", routeAction); } } else if (!string.IsNullOrEmpty(routeAction)) { apiUrl = PageUtils.Combine(apiUrl, "actions", routeAction); } } else if (!string.IsNullOrEmpty(routeAction)) { apiUrl = PageUtils.Combine(apiUrl, "actions", routeAction); } return(apiUrl); }
public static string GetUrl(string apiUrl, int siteId, int inputId) { apiUrl = PageUtils.Combine(apiUrl, Route); apiUrl = apiUrl.Replace("{siteId}", siteId.ToString()); apiUrl = apiUrl.Replace("{inputId}", inputId.ToString()); return(apiUrl); }
public static string GetLoginUrl(string homeUrl, string returnUrl) { return(PageUtils.AddQueryString(PageUtils.Combine(homeUrl, "#/login"), new NameValueCollection { { "returnUrl", returnUrl } })); }
public static string GetUrl(string apiUrl, string filePath) { return(PageUtils.AddQueryString(PageUtils.Combine(apiUrl, Route), new NameValueCollection { { "filePath", TranslateUtils.EncryptStringBySecretKey(filePath) } })); }
public static string GetPublishmentSystemVirtualUrlByAbsoluteUrl(PublishmentSystemInfo publishmentSystemInfo, string absoluteUrl) { if (publishmentSystemInfo == null) { var publishmentSystemId = PathUtility.GetCurrentPublishmentSystemId(); publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId); } if (!string.IsNullOrEmpty(absoluteUrl)) { if (PageUtils.IsProtocolUrl(absoluteUrl) || absoluteUrl.StartsWith("/")) { absoluteUrl = absoluteUrl.ToLower(); var publishmentSystemUrl = GetPublishmentSystemUrl(publishmentSystemInfo, string.Empty).ToLower(); if (PageUtils.IsProtocolUrl(absoluteUrl)) { publishmentSystemUrl = PageUtils.AddProtocolToUrl(publishmentSystemUrl); } absoluteUrl = StringUtils.ReplaceFirst(publishmentSystemUrl, absoluteUrl, string.Empty); } else if (absoluteUrl.StartsWith(".")) { absoluteUrl = absoluteUrl.Replace("../", string.Empty); absoluteUrl = absoluteUrl.Replace("./", string.Empty); } return(PageUtils.Combine("@", absoluteUrl)); } else { return(string.Empty); } }
public static string GetUserFilesUrl(string apiUrl, string relatedUrl) { if (string.IsNullOrEmpty(apiUrl)) { apiUrl = "/api"; } apiUrl = apiUrl.Trim().ToLower(); if (apiUrl == "/api") { apiUrl = "/"; } else if (apiUrl.EndsWith("/api")) { apiUrl = apiUrl.Substring(0, apiUrl.LastIndexOf("/api", StringComparison.Ordinal)); } else if (apiUrl.EndsWith("/api/")) { apiUrl = apiUrl.Substring(0, apiUrl.LastIndexOf("/api/", StringComparison.Ordinal)); } if (string.IsNullOrEmpty(apiUrl)) { apiUrl = "/"; } return(PageUtils.Combine(apiUrl, DirectoryUtils.SiteFiles.DirectoryName, DirectoryUtils.SiteFiles.UserFiles, relatedUrl)); }
public static void ChangeToSubSite(PublishmentSystemInfo publishmentSystemInfo, string psDir, ArrayList fileSystemNameArrayList) { if (publishmentSystemInfo.IsHeadquarters) { publishmentSystemInfo.IsHeadquarters = false; publishmentSystemInfo.PublishmentSystemDir = psDir.Trim(); publishmentSystemInfo.PublishmentSystemUrl = PageUtils.Combine(WebConfigUtils.ApplicationPath, psDir.Trim()); DataProvider.PublishmentSystemDao.Update(publishmentSystemInfo); var psPath = PathUtils.Combine(WebConfigUtils.PhysicalApplicationPath, psDir); DirectoryUtils.CreateDirectoryIfNotExists(psPath); if (fileSystemNameArrayList != null && fileSystemNameArrayList.Count > 0) { foreach (string fileSystemName in fileSystemNameArrayList) { var srcPath = PathUtils.Combine(WebConfigUtils.PhysicalApplicationPath, fileSystemName); if (DirectoryUtils.IsDirectoryExists(srcPath)) { var destDirectoryPath = PathUtils.Combine(psPath, fileSystemName); DirectoryUtils.CreateDirectoryIfNotExists(destDirectoryPath); DirectoryUtils.MoveDirectory(srcPath, destDirectoryPath, false); DirectoryUtils.DeleteDirectoryIfExists(srcPath); } else if (FileUtils.IsFileExists(srcPath)) { FileUtils.CopyFile(srcPath, PathUtils.Combine(psPath, fileSystemName)); FileUtils.DeleteFileIfExists(srcPath); } } } } }
public static string GetRoute(string routeResource, string routeId, string routeAction) { var route = string.Empty; if (!string.IsNullOrEmpty(routeResource)) { route = PageUtils.Combine(route, routeResource); if (!string.IsNullOrEmpty(routeId)) { route = PageUtils.Combine(route, routeId); if (!string.IsNullOrEmpty(routeAction)) { route = PageUtils.Combine(route, "actions", routeAction); } } else if (!string.IsNullOrEmpty(routeAction)) { route = PageUtils.Combine(route, "actions", routeAction); } } else if (!string.IsNullOrEmpty(routeAction)) { route = PageUtils.Combine(route, "actions", routeAction); } return(route); }
public string GetDownloadApiUrl(bool isInner, string filePath) { return(PageUtils.AddQueryString(PageUtils.Combine(_settingsManager.ApiHost, Constants.ApiPrefix, Constants.ApiStlPrefix, Constants.RouteStlActionsDownload), new NameValueCollection { { "filePath", _settingsManager.Encrypt(filePath) } })); }
private string SaveImages(string content) { var originalImageSrcs = RegexUtils.GetOriginalImageSrcs(content); foreach (var originalImageSrc in originalImageSrcs) { if (!PageUtils.IsProtocolUrl(originalImageSrc)) { continue; } var extName = "png"; if (StringUtils.Contains(originalImageSrc, "wx_fmt=")) { extName = originalImageSrc.Substring(originalImageSrc.LastIndexOf("=", StringComparison.Ordinal) + 1); } var materialFileName = PathUtils.GetMaterialFileNameByExtName(extName); var virtualDirectoryPath = PathUtils.GetMaterialVirtualDirectoryPath(UploadType.Image); var directoryPath = PathUtils.Combine(_settingsManager.WebRootPath, virtualDirectoryPath); var filePath = PathUtils.Combine(directoryPath, materialFileName); WebClientUtils.Download(originalImageSrc, filePath); var imageUrl = PageUtils.Combine(virtualDirectoryPath, materialFileName); content = content.Replace(" data-src=", "src="); content = content.Replace(originalImageSrc, imageUrl); } return(content); }
public static string GetUrl(string apiUrl, int siteId, int channelId, int contentId) { return(PageUtils.Combine(apiUrl, Route .Replace("{siteId}", siteId.ToString()) .Replace("{channelId}", channelId.ToString()) .Replace("{contentId}", contentId.ToString()))); }
public string GetDownloadApiUrl(int siteId, string fileUrl) { return(PageUtils.AddQueryString(PageUtils.Combine(_settingsManager.ApiHost, Constants.ApiPrefix, Constants.ApiStlPrefix, Constants.RouteStlActionsDownload), new NameValueCollection { { "siteId", siteId.ToString() }, { "fileUrl", _settingsManager.Encrypt(fileUrl) } })); }
public static string GetUrl(string apiUrl, int siteId, string fileUrl) { return(PageUtils.AddQueryString(PageUtils.Combine(apiUrl, Route), new NameValueCollection { { "siteId", siteId.ToString() }, { "fileUrl", TranslateUtils.EncryptStringBySecretKey(fileUrl) } })); }
public static string GetUrl(string apiUrl, int publishmentSystemId, int channelId, int contentId) { apiUrl = PageUtils.Combine(apiUrl, Route); apiUrl = apiUrl.Replace("{publishmentSystemId}", publishmentSystemId.ToString()); apiUrl = apiUrl.Replace("{channelId}", channelId.ToString()); apiUrl = apiUrl.Replace("{contentId}", contentId.ToString()); return(apiUrl); }
public static string GetUrl(string apiUrl, int publishmentSystemId, int channelId, int contentId) { return(PageUtils.AddQueryString(PageUtils.Combine(apiUrl, Route), new NameValueCollection { { "publishmentSystemId", publishmentSystemId.ToString() }, { "channelId", channelId.ToString() }, { "contentId", contentId.ToString() } })); }
public static string GetUrl(string apiUrl, int siteId, string type) { apiUrl = PageUtils.Combine(apiUrl, Route); apiUrl = apiUrl.Replace("{siteId}", siteId.ToString()); return(PageUtils.AddQueryString(apiUrl, new NameValueCollection { { "type", type } })); }
private DepartmentTreeItem() { var treeDirectoryUrl = SiteServerAssets.GetIconUrl("tree"); _iconFolderUrl = PageUtils.Combine(treeDirectoryUrl, "folder.gif"); _iconEmptyUrl = PageUtils.Combine(treeDirectoryUrl, "empty.gif"); _iconMinusUrl = PageUtils.Combine(treeDirectoryUrl, "minus.png"); _iconPlusUrl = PageUtils.Combine(treeDirectoryUrl, "plus.png"); }
public async Task <ActionResult <GetResult> > Get([FromQuery] GetRequest request) { if (request.FileType == "html") { if (!await _authManager.HasSitePermissionsAsync(request.SiteId, Types.SitePermissions.TemplatesIncludes)) { return(Unauthorized()); } } else { if (!await _authManager.HasSitePermissionsAsync(request.SiteId, Types.SitePermissions.TemplatesAssets)) { return(Unauthorized()); } } var site = await _siteRepository.GetAsync(request.SiteId); if (site == null) { return(NotFound()); } var filePath = await _pathManager.GetSitePathAsync(site, request.DirectoryPath, request.FileName); var content = string.Empty; if (FileUtils.IsFileExists(filePath)) { content = await FileUtils.ReadTextAsync(filePath); } var path = string.Empty; if (StringUtils.EqualsIgnoreCase(request.FileType, "html")) { path = PageUtils.Combine(StringUtils.ReplaceStartsWithIgnoreCase(request.DirectoryPath, site.TemplatesAssetsIncludeDir, string.Empty), request.FileName); } else if (StringUtils.EqualsIgnoreCase(request.FileType, "css")) { path = PageUtils.Combine(StringUtils.ReplaceStartsWithIgnoreCase(request.DirectoryPath, site.TemplatesAssetsCssDir, string.Empty), request.FileName); } else if (StringUtils.EqualsIgnoreCase(request.FileType, "js")) { path = PageUtils.Combine(StringUtils.ReplaceStartsWithIgnoreCase(request.DirectoryPath, site.TemplatesAssetsJsDir, string.Empty), request.FileName); } return(new GetResult { Path = StringUtils.TrimSlash(PathUtils.RemoveExtension(path)), Content = content }); }
private CategoryTreeItem() { var treeDirectoryUrl = PageUtils.GetIconUrl("tree"); iconFolderUrl = PageUtils.Combine(treeDirectoryUrl, "folder.gif"); iconEmptyUrl = PageUtils.Combine(treeDirectoryUrl, "empty.gif"); iconMinusUrl = PageUtils.Combine(treeDirectoryUrl, "minus.png"); iconPlusUrl = PageUtils.Combine(treeDirectoryUrl, "plus.png"); }