コード例 #1
0
 public static void AddWaterMark(SiteInfo siteInfo, string imagePath)
 {
     try
     {
         var fileExtName = PathUtils.GetExtension(imagePath);
         if (EFileSystemTypeUtils.IsImage(fileExtName))
         {
             if (siteInfo.Additional.IsWaterMark)
             {
                 if (siteInfo.Additional.IsImageWaterMark)
                 {
                     if (!string.IsNullOrEmpty(siteInfo.Additional.WaterMarkImagePath))
                     {
                         ImageUtils.AddImageWaterMark(imagePath, PathUtility.MapPath(siteInfo, siteInfo.Additional.WaterMarkImagePath), siteInfo.Additional.WaterMarkPosition, siteInfo.Additional.WaterMarkTransparency, siteInfo.Additional.WaterMarkMinWidth, siteInfo.Additional.WaterMarkMinHeight);
                     }
                 }
                 else
                 {
                     if (!string.IsNullOrEmpty(siteInfo.Additional.WaterMarkFormatString))
                     {
                         var now = DateTime.Now;
                         ImageUtils.AddTextWaterMark(imagePath, string.Format(siteInfo.Additional.WaterMarkFormatString, DateUtils.GetDateString(now), DateUtils.GetTimeString(now)), siteInfo.Additional.WaterMarkFontName, siteInfo.Additional.WaterMarkFontSize, siteInfo.Additional.WaterMarkPosition, siteInfo.Additional.WaterMarkTransparency, siteInfo.Additional.WaterMarkMinWidth, siteInfo.Additional.WaterMarkMinHeight);
                     }
                 }
             }
         }
     }
     catch
     {
         // ignored
     }
 }
コード例 #2
0
        public string GetPreviewImageSrc(string adType)
        {
            var type     = EAdvertisementTypeUtils.GetEnumType(adType);
            var imageUrl = ImageUrl.Text;

            if (type == EAdvertisementType.ScreenDown)
            {
                imageUrl = ScreenDownImageUrl.Text;
            }
            if (!string.IsNullOrEmpty(imageUrl))
            {
                var extension = PathUtils.GetExtension(imageUrl);
                if (EFileSystemTypeUtils.IsImage(extension))
                {
                    return(PageUtility.ParseNavigationUrl(PublishmentSystemInfo, imageUrl));
                }
                else if (EFileSystemTypeUtils.IsFlash(extension))
                {
                    return(SiteServerAssets.GetIconUrl("flash.jpg"));
                }
                else if (EFileSystemTypeUtils.IsPlayer(extension))
                {
                    return(SiteServerAssets.GetIconUrl("player.gif"));
                }
            }
            return(SiteServerAssets.GetIconUrl("empty.gif"));
        }
コード例 #3
0
        public IHttpActionResult UploadAvatar(int id)
        {
            try
            {
                var oRequest = new ORequest(AccessTokenManager.ScopeUsers);
                if (!oRequest.IsApiAuthorized)
                {
                    return(Unauthorized());
                }

                if (!DataProvider.UserDao.ApiIsExists(id))
                {
                    return(NotFound());
                }

                var userInfo = DataProvider.UserDao.ApiGetUser(id);

                foreach (string name in HttpContext.Current.Request.Files)
                {
                    var postFile = HttpContext.Current.Request.Files[name];

                    if (postFile == null)
                    {
                        return(BadRequest("Could not read image from body"));
                    }

                    var directoryPath = PathUtils.GetUserUploadDirectoryPath(userInfo.UserName);
                    var fileName      = PathUtils.GetUserUploadFileName(postFile.FileName);
                    if (!EFileSystemTypeUtils.IsImage(PathUtils.GetExtension(fileName)))
                    {
                        return(BadRequest("image file extension is not correct"));
                    }

                    postFile.SaveAs(PathUtils.Combine(directoryPath, fileName));

                    userInfo.AvatarUrl = PageUtils.AddProtocolToUrl(PageUtils.GetUserFilesUrl(userInfo.UserName, fileName));

                    string errorMessage;
                    var    user = DataProvider.UserDao.ApiUpdate(id, new UserInfoCreateUpdate
                    {
                        AvatarUrl = userInfo.AvatarUrl
                    }, out errorMessage);

                    if (user == null)
                    {
                        return(BadRequest(errorMessage));
                    }
                }

                var oResponse = new OResponse(userInfo);

                return(Ok(oResponse));
            }
            catch (Exception ex)
            {
                LogUtils.AddErrorLog(ex);
                return(InternalServerError(ex));
            }
        }
コード例 #4
0
        public IHttpActionResult UploadAvatar(int id)
        {
            try
            {
                var request = new AuthenticatedRequest();
                var isAuth  = request.IsApiAuthenticated &&
                              AccessTokenManager.IsScope(request.ApiToken, AccessTokenManager.ScopeUsers) ||
                              request.IsUserLoggin &&
                              request.UserId == id ||
                              request.IsAdminLoggin &&
                              request.AdminPermissions.HasSystemPermissions(ConfigManager.SettingsPermissions.User);
                if (!isAuth)
                {
                    return(Unauthorized());
                }

                var userInfo = UserManager.GetUserInfoByUserId(id);
                if (userInfo == null)
                {
                    return(NotFound());
                }

                foreach (string name in HttpContext.Current.Request.Files)
                {
                    var postFile = HttpContext.Current.Request.Files[name];

                    if (postFile == null)
                    {
                        return(BadRequest("Could not read image from body"));
                    }

                    var fileName = UserManager.GetUserUploadFileName(postFile.FileName);
                    var filePath = UserManager.GetUserUploadPath(userInfo.Id, fileName);

                    if (!EFileSystemTypeUtils.IsImage(PathUtils.GetExtension(fileName)))
                    {
                        return(BadRequest("image file extension is not correct"));
                    }

                    DirectoryUtils.CreateDirectoryIfNotExists(filePath);
                    postFile.SaveAs(filePath);

                    userInfo.AvatarUrl = UserManager.GetUserUploadUrl(userInfo.Id, fileName);

                    DataProvider.UserDao.Update(userInfo);
                }

                return(Ok(new
                {
                    Value = userInfo
                }));
            }
            catch (Exception ex)
            {
                LogUtils.AddErrorLog(ex);
                return(InternalServerError(ex));
            }
        }
コード例 #5
0
        public IHttpActionResult Upload()
        {
            try
            {
                var request = new AuthenticatedRequest();
                var userId  = request.GetQueryInt("userId");
                if (!request.IsAdminLoggin)
                {
                    return(Unauthorized());
                }
                var adminInfo = AdminManager.GetAdminInfoByUserId(userId);
                if (adminInfo == null)
                {
                    return(NotFound());
                }
                if (request.AdminId != userId &&
                    !request.AdminPermissionsImpl.HasSystemPermissions(ConfigManager.SettingsPermissions.Admin))
                {
                    return(Unauthorized());
                }

                var avatarUrl = string.Empty;

                foreach (string name in HttpContext.Current.Request.Files)
                {
                    var postFile = HttpContext.Current.Request.Files[name];

                    if (postFile == null)
                    {
                        return(BadRequest("Could not read image from body"));
                    }

                    var fileName = AdminManager.GetUserUploadFileName(postFile.FileName);
                    var filePath = AdminManager.GetUserUploadPath(userId, fileName);

                    if (!EFileSystemTypeUtils.IsImage(PathUtils.GetExtension(fileName)))
                    {
                        return(BadRequest("image file extension is not correct"));
                    }

                    postFile.SaveAs(filePath);

                    avatarUrl = AdminManager.GetUserUploadUrl(userId, fileName);
                }

                return(Ok(new
                {
                    Value = avatarUrl
                }));
            }
            catch (Exception ex)
            {
                LogUtils.AddErrorLog(ex);
                return(InternalServerError(ex));
            }
        }
コード例 #6
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (hifUpload.PostedFile != null && "" != hifUpload.PostedFile.FileName)
            {
                var filePath = hifUpload.PostedFile.FileName;
                try
                {
                    var fileExtName        = PathUtils.GetExtension(filePath).ToLower();
                    var localDirectoryPath = AppDomain.CurrentDomain.BaseDirectory.ToString() + "\\upload\\images";
                    //Server.MapPath(".");
                    DirectoryUtils.CreateDirectoryIfNotExists(localDirectoryPath);

                    var localFileName = GetUploadFileName(filePath, DateTime.Now, true);
                    var localFilePath = PathUtils.Combine(localDirectoryPath, localFileName);

                    if (!PathUtils.IsFileExtenstionAllowed("jpg|gif|png|bmp", fileExtName))
                    {
                        FailMessage("上传失败,上传图片格式不正确!");
                        return;
                    }
                    if (hifUpload.PostedFile.ContentLength > 10 * 1024)
                    {
                        FailMessage("上传失败,上传图片超出规定文件大小!");
                        return;
                    }

                    hifUpload.PostedFile.SaveAs(localFilePath);

                    var isImage = EFileSystemTypeUtils.IsImage(fileExtName);


                    if (string.IsNullOrEmpty(_textBoxClientId))
                    {
                        PageUtils.CloseModalPage(Page);
                    }
                    else
                    {
                        var textBoxUrl = "@/upload/images/" + localFileName;

                        ltlScript.Text += $@"
if (parent.document.getElementById('{_textBoxClientId}') != null)
{{
    parent.document.getElementById('{_textBoxClientId}').value = '{textBoxUrl}';
}}
";

                        ltlScript.Text += PageUtils.HidePopWin;
                    }
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "图片上传失败!");
                }
            }
        }
コード例 #7
0
ファイル: RegexUtils.cs プロジェクト: yankaics/cms-1
        public static List <string> GetStyleImageUrls(string baseUrl, string html)
        {
            const string regex     = "url\\((?<url>[^\\(\\)]*)\\)";
            var          arraylist = GetUrls(regex, html, baseUrl);
            var          list      = new List <string>();

            foreach (var url in arraylist)
            {
                if (!list.Contains(url) && EFileSystemTypeUtils.IsImage(PathUtils.GetExtension(url)))
                {
                    list.Add(url);
                }
            }
            return(list);
        }
コード例 #8
0
ファイル: RegexUtils.cs プロジェクト: yankaics/cms-1
        public static List <string> GetOriginalStyleImageUrls(string html)
        {
            //background-image: url(../images/leftline.gif);
            const string regex     = "url\\((?<url>[^\\(\\)]*)\\)";
            var          arraylist = GetContents("url", regex, html);
            var          list      = new List <string>();

            foreach (var url in arraylist)
            {
                if (!list.Contains(url) && EFileSystemTypeUtils.IsImage(PathUtils.GetExtension(url)))
                {
                    list.Add(url);
                }
            }
            return(list);
        }
コード例 #9
0
        public IHttpActionResult Upload()
        {
            try
            {
                var request = new AuthenticatedRequest();
                if (!request.IsAdminLoggin ||
                    !request.AdminPermissionsImpl.HasSystemPermissions(ConfigManager.AppPermissions.SettingsConfigAdmin))
                {
                    return(Unauthorized());
                }

                var adminLogoUrl = string.Empty;

                foreach (string name in HttpContext.Current.Request.Files)
                {
                    var postFile = HttpContext.Current.Request.Files[name];

                    if (postFile == null)
                    {
                        return(BadRequest("Could not read image from body"));
                    }

                    var fileName = postFile.FileName;
                    var filePath = PathUtils.GetAdminDirectoryPath(fileName);

                    if (!EFileSystemTypeUtils.IsImage(PathUtils.GetExtension(fileName)))
                    {
                        return(BadRequest("image file extension is not correct"));
                    }

                    postFile.SaveAs(filePath);

                    adminLogoUrl = fileName;
                }

                return(Ok(new
                {
                    Value = adminLogoUrl
                }));
            }
            catch (Exception ex)
            {
                LogUtils.AddErrorLog(ex);
                return(InternalServerError(ex));
            }
        }
コード例 #10
0
        //将编辑器中图片上传至本机
        public static string SaveImage(SiteInfo siteInfo, string content)
        {
            var originalImageSrcs = RegexUtils.GetOriginalImageSrcs(content);

            foreach (var originalImageSrc in originalImageSrcs)
            {
                if (!PageUtils.IsProtocolUrl(originalImageSrc) ||
                    StringUtils.StartsWithIgnoreCase(originalImageSrc, PageUtils.ApplicationPath) ||
                    StringUtils.StartsWithIgnoreCase(originalImageSrc, siteInfo.Additional.WebUrl))
                {
                    continue;
                }
                var fileExtName = PageUtils.GetExtensionFromUrl(originalImageSrc);
                if (!EFileSystemTypeUtils.IsImageOrFlashOrPlayer(fileExtName))
                {
                    continue;
                }

                var fileName      = GetUploadFileName(siteInfo, originalImageSrc);
                var directoryPath = GetUploadDirectoryPath(siteInfo, fileExtName);
                var filePath      = PathUtils.Combine(directoryPath, fileName);

                try
                {
                    if (!FileUtils.IsFileExists(filePath))
                    {
                        WebClientUtils.SaveRemoteFileToLocal(originalImageSrc, filePath);
                        if (EFileSystemTypeUtils.IsImage(PathUtils.GetExtension(fileName)))
                        {
                            FileUtility.AddWaterMark(siteInfo, filePath);
                        }
                    }
                    var fileUrl = PageUtility.GetSiteUrlByPhysicalPath(siteInfo, filePath, true);
                    content = content.Replace(originalImageSrc, fileUrl);
                }
                catch
                {
                    // ignored
                }
            }
            return(content);
        }
コード例 #11
0
        public string GetPreviewImageSrc(string adType)
        {
            var imageUrl = ChildMenuIcon.Text;

            if (!string.IsNullOrEmpty(imageUrl))
            {
                var extension = PathUtils.GetExtension(imageUrl);
                if (EFileSystemTypeUtils.IsImage(extension))
                {
                    return(PageUtility.ParseNavigationUrl(PublishmentSystemInfo, imageUrl));
                }
                else if (EFileSystemTypeUtils.IsFlash(extension))
                {
                    return(SiteServerAssets.GetIconUrl("flash.jpg"));
                }
                else if (EFileSystemTypeUtils.IsPlayer(extension))
                {
                    return(SiteServerAssets.GetIconUrl("player.gif"));
                }
            }
            return(SiteServerAssets.GetIconUrl("empty.gif"));
        }
コード例 #12
0
        private void UploadForUEditor()
        {
            if (_fileType == "Image")
            {
                var info = new Hashtable();
                var up   = new UEditorUploaderForUser();
                info = up.upFile(HttpContext.Current);                               //获取上传状态

                var title   = up.getOtherInfo(HttpContext.Current, "pictitle");      //获取图片描述
                var oriName = up.getOtherInfo(HttpContext.Current, "fileName");      //获取原始文件名

                Response.ContentType = "text/plain";
                Response.Write("{'url':'" + info["url"] + "','title':'" + title + "','original':'" + oriName + "','state':'" + info["state"] + "'}");
                Response.End();
            }
            else if (_fileType == "Scrawl")
            {
                var action = Request["action"];

                if (action == "tmpImg")
                {
                    var info = new Hashtable();
                    var up   = new UEditorUploaderForUser();
                    info = up.upFile(HttpContext.Current); //获取上传状态

                    Response.ContentType = "text/html";
                    Response.Write("<script>parent.ue_callback('" + info["url"] + "','" + info["state"] + "')</script>");//回调函数
                    Response.End();
                }
                else
                {
                    var info = new Hashtable();
                    var up   = new UEditorUploaderForUser();
                    info = up.upScrawl(HttpContext.Current, Request["content"]); //获取上传状态

                    Response.ContentType = "text/plain";
                    Response.Write("{'url':'" + info["url"] + "',state:'" + info["state"] + "'}");
                    Response.End();
                }
            }
            else if (_fileType == "File")
            {
                var info = new Hashtable();
                var up   = new UEditorUploaderForUser();
                info = up.upFile(HttpContext.Current); //获取上传状态
                Response.ContentType = "text/plain";
                Response.Write("{'state':'" + info["state"] + "','url':'" + info["url"] + "','fileType':'" + info["currentType"] + "','original':'" + info["originalName"] + "'}");
                Response.End();
            }
            else if (_fileType == "ImageManager")
            {
                Response.ContentType = "text/plain";

                var      directoryPath = PathUtils.GetUserUploadDirectoryPath(string.Empty);
                string[] filetype      = { ".gif", ".png", ".jpg", ".jpeg", ".bmp" };           //文件允许格式

                var action = Server.HtmlEncode(Request["action"]);

                if (action == "get")
                {
                    var str = string.Empty;

                    //目录验证
                    if (DirectoryUtils.IsDirectoryExists(directoryPath))
                    {
                        var filePathArray = DirectoryUtils.GetFilePaths(directoryPath);
                        foreach (var filePath in filePathArray)
                        {
                            if (EFileSystemTypeUtils.IsImage(PathUtils.GetExtension(filePath)))
                            {
                                str += PageUtils.GetRootUrlByPhysicalPath(filePath) + "ue_separate_ue";
                            }
                        }
                    }
                    Response.Write(str);
                    Response.End();
                }
            }
            else if (_fileType == "GetMovie")
            {
                Response.ContentType = "text/html";
                var key  = Server.HtmlEncode(Request.Form["searchKey"]);
                var type = Server.HtmlEncode(Request.Form["videoType"]);

                var httpURL     = new Uri("http://api.tudou.com/v3/gw?method=item.search&appKey=myKey&format=json&kw=" + key + "&pageNo=1&pageSize=20&channelId=" + type + "&inDays=7&media=v&sort=s");
                var MyWebClient = new WebClient();

                //获取或设置用于向Internet资源的请求进行身份验证的网络凭据
                MyWebClient.Credentials = CredentialCache.DefaultCredentials;
                var pageData = MyWebClient.DownloadData(httpURL);

                Response.Write(Encoding.UTF8.GetString(pageData));
                Response.End();
            }
        }
コード例 #13
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (hifUpload.PostedFile != null && "" != hifUpload.PostedFile.FileName)
            {
                var filePath = hifUpload.PostedFile.FileName;
                try
                {
                    var fileExtName        = PathUtils.GetExtension(filePath).ToLower();
                    var localDirectoryPath = PathUtility.GetUploadDirectoryPath(PublishmentSystemInfo, fileExtName);
                    if (!string.IsNullOrEmpty(_currentRootPath))
                    {
                        localDirectoryPath = PathUtility.MapPath(PublishmentSystemInfo, _currentRootPath);
                        DirectoryUtils.CreateDirectoryIfNotExists(localDirectoryPath);
                    }
                    var localFileName = PathUtility.GetUploadFileName(PublishmentSystemInfo, filePath);
                    var localFilePath = PathUtils.Combine(localDirectoryPath, localFileName);

                    if (!PathUtility.IsImageExtenstionAllowed(PublishmentSystemInfo, fileExtName))
                    {
                        FailMessage("上传失败,上传图片格式不正确!");
                        return;
                    }
                    if (!PathUtility.IsImageSizeAllowed(PublishmentSystemInfo, hifUpload.PostedFile.ContentLength))
                    {
                        FailMessage("上传失败,上传图片超出规定文件大小!");
                        return;
                    }

                    hifUpload.PostedFile.SaveAs(localFilePath);

                    var isImage = EFileSystemTypeUtils.IsImage(fileExtName);

                    if (isImage && _isNeedWaterMark)
                    {
                        FileUtility.AddWaterMark(PublishmentSystemInfo, localFilePath);
                    }

                    if (string.IsNullOrEmpty(_textBoxClientId))
                    {
                        PageUtils.CloseModalPage(Page);
                    }
                    else
                    {
                        var imageUrl   = PageUtility.GetPublishmentSystemUrlByPhysicalPath(PublishmentSystemInfo, localFilePath);
                        var textBoxUrl = PageUtility.GetVirtualUrl(PublishmentSystemInfo, imageUrl);

                        ltlScript.Text += $@"
if (parent.document.getElementById('{_textBoxClientId}') != null)
{{
    parent.document.getElementById('{_textBoxClientId}').value = '{textBoxUrl}';
}}
";

                        ltlScript.Text += PageUtils.HidePopWin;
                    }
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "图片上传失败!");
                }
            }
        }
コード例 #14
0
ファイル: StlFlash.cs プロジェクト: zr53722/cms
        private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, bool isGetPicUrlFromAttribute, string channelIndex, string channelName, int upLevel, int topLevel, string type, string src, string altSrc, string width, string height)
        {
            var parsedContent = string.Empty;

            var contentId = 0;

            //判断是否图片地址由标签属性获得
            if (!isGetPicUrlFromAttribute)
            {
                contentId = contextInfo.ContentId;
            }
            var contentInfo = contextInfo.ContentInfo;

            string picUrl;

            if (!string.IsNullOrEmpty(src))
            {
                picUrl = src;
            }
            else
            {
                if (contentId != 0)//获取内容Flash
                {
                    if (contentInfo == null)
                    {
                        var nodeInfo  = ChannelManager.GetChannelInfo(contextInfo.SiteInfo.Id, contextInfo.ChannelId);
                        var tableName = ChannelManager.GetTableName(contextInfo.SiteInfo, nodeInfo);

                        //picUrl = DataProvider.ContentDao.GetValue(tableName, contentId, type);
                        picUrl = Content.GetValue(tableName, contentId, type);
                    }
                    else
                    {
                        picUrl = contextInfo.ContentInfo.GetString(type);
                    }
                }
                else//获取栏目Flash
                {
                    var channelId = StlDataUtility.GetChannelIdByLevel(pageInfo.SiteId, contextInfo.ChannelId, upLevel, topLevel);

                    channelId = StlDataUtility.GetChannelIdByChannelIdOrChannelIndexOrChannelName(pageInfo.SiteId, channelId, channelIndex, channelName);
                    var channel = ChannelManager.GetChannelInfo(pageInfo.SiteId, channelId);

                    picUrl = channel.ImageUrl;
                }
            }

            if (string.IsNullOrEmpty(picUrl))
            {
                picUrl = altSrc;
            }

            // 如果是实体标签则返回空
            if (contextInfo.IsStlEntity)
            {
                return(picUrl);
            }

            if (!string.IsNullOrEmpty(picUrl))
            {
                var extension = PathUtils.GetExtension(picUrl);
                if (EFileSystemTypeUtils.IsImage(extension))
                {
                    parsedContent = StlImage.Parse(pageInfo, contextInfo);
                }
                else if (EFileSystemTypeUtils.IsPlayer(extension))
                {
                    parsedContent = StlPlayer.Parse(pageInfo, contextInfo);
                }
                else
                {
                    pageInfo.AddPageBodyCodeIfNotExists(PageInfo.Const.JsAcSwfObject);

                    picUrl = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, picUrl, pageInfo.IsLocal);

                    if (string.IsNullOrEmpty(contextInfo.Attributes["quality"]))
                    {
                        contextInfo.Attributes["quality"] = "high";
                    }
                    if (string.IsNullOrEmpty(contextInfo.Attributes["wmode"]))
                    {
                        contextInfo.Attributes["wmode"] = "transparent";
                    }
                    var paramBuilder = new StringBuilder();
                    var uniqueId     = pageInfo.UniqueId;
                    foreach (var key in contextInfo.Attributes.AllKeys)
                    {
                        paramBuilder.Append($@"    so_{uniqueId}.addParam(""{key}"", ""{contextInfo.Attributes[key]}"");").Append(StringUtils.Constants.ReturnAndNewline);
                    }

                    parsedContent = $@"
<div id=""flashcontent_{uniqueId}""></div>
<script type=""text/javascript"">
    // <![CDATA[
    var so_{uniqueId} = new SWFObject(""{picUrl}"", ""flash_{uniqueId}"", ""{width}"", ""{height}"", ""7"", """");
{paramBuilder}
    so_{uniqueId}.write(""flashcontent_{uniqueId}"");
    // ]]>
</script>
";
                }
            }

            return(parsedContent);
        }
コード例 #15
0
ファイル: StlPlayer.cs プロジェクト: supadmins/cms-1
        private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, bool isGetPicUrlFromAttribute, string channelIndex, string channelName, int upLevel, int topLevel, string playUrl, string imageUrl, string playBy, int width, int height, string type, bool isAutoPlay)
        {
            var parsedContent = string.Empty;

            var contentId = 0;

            //判断是否图片地址由标签属性获得
            if (!isGetPicUrlFromAttribute)
            {
                contentId = contextInfo.ContentId;
            }

            if (string.IsNullOrEmpty(playUrl))
            {
                if (contentId != 0)//获取内容视频
                {
                    if (contextInfo.ContentInfo == null)
                    {
                        //playUrl = DataProvider.ContentDao.GetValue(pageInfo.SiteInfo.AuxiliaryTableForContent, contentId, type);
                        playUrl = Content.GetValue(pageInfo.SiteInfo.TableName, contentId, type);
                        if (string.IsNullOrEmpty(playUrl))
                        {
                            if (!StringUtils.EqualsIgnoreCase(type, BackgroundContentAttribute.VideoUrl))
                            {
                                //playUrl = DataProvider.ContentDao.GetValue(pageInfo.SiteInfo.AuxiliaryTableForContent, contentId, BackgroundContentAttribute.VideoUrl);
                                playUrl = Content.GetValue(pageInfo.SiteInfo.TableName, contentId, BackgroundContentAttribute.VideoUrl);
                            }
                        }
                        if (string.IsNullOrEmpty(playUrl))
                        {
                            if (!StringUtils.EqualsIgnoreCase(type, BackgroundContentAttribute.FileUrl))
                            {
                                //playUrl = DataProvider.ContentDao.GetValue(pageInfo.SiteInfo.AuxiliaryTableForContent, contentId, BackgroundContentAttribute.FileUrl);
                                playUrl = Content.GetValue(pageInfo.SiteInfo.TableName, contentId, BackgroundContentAttribute.FileUrl);
                            }
                        }
                    }
                    else
                    {
                        playUrl = contextInfo.ContentInfo.GetString(type);
                        if (string.IsNullOrEmpty(playUrl))
                        {
                            playUrl = contextInfo.ContentInfo.GetString(BackgroundContentAttribute.VideoUrl);
                        }
                        if (string.IsNullOrEmpty(playUrl))
                        {
                            playUrl = contextInfo.ContentInfo.GetString(BackgroundContentAttribute.FileUrl);
                        }
                    }
                }
            }

            if (string.IsNullOrEmpty(imageUrl))
            {
                if (contentId != 0)
                {
                    //imageUrl = contextInfo.ContentInfo == null ? DataProvider.ContentDao.GetValue(pageInfo.SiteInfo.AuxiliaryTableForContent, contentId, BackgroundContentAttribute.ImageUrl) : contextInfo.ContentInfo.GetString(BackgroundContentAttribute.ImageUrl);
                    imageUrl = contextInfo.ContentInfo == null?Content.GetValue(pageInfo.SiteInfo.TableName, contentId, BackgroundContentAttribute.ImageUrl) : contextInfo.ContentInfo.GetString(BackgroundContentAttribute.ImageUrl);
                }
            }
            if (string.IsNullOrEmpty(imageUrl))
            {
                var channelId = StlDataUtility.GetChannelIdByLevel(pageInfo.SiteId, contextInfo.ChannelId, upLevel, topLevel);
                channelId = StlDataUtility.GetChannelIdByChannelIdOrChannelIndexOrChannelName(pageInfo.SiteId, channelId, channelIndex, channelName);
                var channel = ChannelManager.GetChannelInfo(pageInfo.SiteId, channelId);
                imageUrl = channel.ImageUrl;
            }

            if (!string.IsNullOrEmpty(playUrl))
            {
                var extension = PathUtils.GetExtension(playUrl);
                if (EFileSystemTypeUtils.IsFlash(extension))
                {
                    parsedContent = StlFlash.Parse(pageInfo, contextInfo);
                }
                else if (EFileSystemTypeUtils.IsImage(extension))
                {
                    parsedContent = StlImage.Parse(pageInfo, contextInfo);
                }
                else
                {
                    var uniqueId = pageInfo.UniqueId;
                    playUrl  = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, playUrl, pageInfo.IsLocal);
                    imageUrl = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, imageUrl, pageInfo.IsLocal);

                    var fileType = EFileSystemTypeUtils.GetEnumType(extension);
                    if (fileType == EFileSystemType.Avi)
                    {
                        parsedContent = $@"
<object id=""palyer_{uniqueId}"" width=""{width}"" height=""{height}"" border=""0"" classid=""clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"">
<param name=""ShowDisplay"" value=""0"">
<param name=""ShowControls"" value=""1"">
<param name=""AutoStart"" value=""{(isAutoPlay ? "1" : "0")}"">
<param name=""AutoRewind"" value=""0"">
<param name=""PlayCount"" value=""0"">
<param name=""Appearance"" value=""0"">
<param name=""BorderStyle"" value=""0"">
<param name=""MovieWindowHeight"" value=""240"">
<param name=""MovieWindowWidth"" value=""320"">
<param name=""FileName"" value=""{playUrl}"">
<embed width=""{width}"" height=""{height}"" border=""0"" showdisplay=""0"" showcontrols=""1"" autostart=""{(isAutoPlay
                            ? "1"
                            : "0")}"" autorewind=""0"" playcount=""0"" moviewindowheight=""240"" moviewindowwidth=""320"" filename=""{playUrl}"" src=""{playUrl}"">
</embed>
</object>
";
                    }
                    else if (fileType == EFileSystemType.Mpg)
                    {
                        parsedContent = $@"
<object classid=""clsid:05589FA1-C356-11CE-BF01-00AA0055595A"" id=""palyer_{uniqueId}"" width=""{width}"" height=""{height}"">
<param name=""Appearance"" value=""0"">
<param name=""AutoStart"" value=""{(isAutoPlay ? "true" : "false")}"">
<param name=""AllowChangeDisplayMode"" value=""-1"">
<param name=""AllowHideDisplay"" value=""0"">
<param name=""AllowHideControls"" value=""-1"">
<param name=""AutoRewind"" value=""-1"">
<param name=""Balance"" value=""0"">
<param name=""CurrentPosition"" value=""0"">
<param name=""DisplayBackColor"" value=""0"">
<param name=""DisplayForeColor"" value=""16777215"">
<param name=""DisplayMode"" value=""0"">
<param name=""Enabled"" value=""-1"">
<param name=""EnableContextMenu"" value=""-1"">
<param name=""EnablePositionControls"" value=""-1"">
<param name=""EnableSelectionControls"" value=""0"">
<param name=""EnableTracker"" value=""-1"">
<param name=""Filename"" value=""{playUrl}"" valuetype=""ref"">
<param name=""FullScreenMode"" value=""0"">
<param name=""MovieWindowSize"" value=""0"">
<param name=""PlayCount"" value=""1"">
<param name=""Rate"" value=""1"">
<param name=""SelectionStart"" value=""-1"">
<param name=""SelectionEnd"" value=""-1"">
<param name=""ShowControls"" value=""-1"">
<param name=""ShowDisplay"" value=""-1"">
<param name=""ShowPositionControls"" value=""0"">
<param name=""ShowTracker"" value=""-1"">
<param name=""Volume"" value=""-480"">
</object>
";
                    }
                    else if (fileType == EFileSystemType.Mpg)
                    {
                        parsedContent = $@"
<OBJECT id=""palyer_{uniqueId}"" classid=""clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"" width=""{width}"" height=""{height}"">
<param name=""_ExtentX"" value=""6350"">
<param name=""_ExtentY"" value=""4763"">
<param name=""AUTOSTART"" value=""{(isAutoPlay ? "true" : "false")}"">
<param name=""SHUFFLE"" value=""0"">
<param name=""PREFETCH"" value=""0"">
<param name=""NOLABELS"" value=""-1"">
<param name=""SRC"" value=""{playUrl}"">
<param name=""CONTROLS"" value=""ImageWindow"">
<param name=""CONSOLE"" value=""console1"">
<param name=""LOOP"" value=""0"">
<param name=""NUMLOOP"" value=""0"">
<param name=""CENTER"" value=""0"">
<param name=""MAINTAINASPECT"" value=""0"">
<param name=""BACKGROUNDCOLOR"" value=""#000000"">
<embed src=""{playUrl}"" type=""audio/x-pn-realaudio-plugin"" console=""Console1"" controls=""ImageWindow"" width=""{width}"" height=""{height}"" autostart=""{(isAutoPlay
                            ? "true"
                            : "false")}""></OBJECT>
";
                    }
                    else if (fileType == EFileSystemType.Rm)
                    {
                        parsedContent = $@"
<OBJECT id=""palyer_{uniqueId}"" CLASSID=""clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"" WIDTH=""{width}"" HEIGHT=""{height}"">
<param name=""_ExtentX"" value=""9313"">
<param name=""_ExtentY"" value=""7620"">
<param name=""AUTOSTART"" value=""{(isAutoPlay ? "true" : "false")}"">
<param name=""SHUFFLE"" value=""0"">
<param name=""PREFETCH"" value=""0"">
<param name=""NOLABELS"" value=""0"">
<param name=""SRC"" value=""{playUrl}"">
<param name=""CONTROLS"" value=""ImageWindow"">
<param name=""CONSOLE"" value=""Clip1"">
<param name=""LOOP"" value=""0"">
<param name=""NUMLOOP"" value=""0"">
<param name=""CENTER"" value=""0"">
<param name=""MAINTAINASPECT"" value=""0"">
<param name=""BACKGROUNDCOLOR"" value=""#000000"">
<embed SRC type=""audio/x-pn-realaudio-plugin"" CONSOLE=""Clip1"" CONTROLS=""ImageWindow"" WIDTH=""{width}"" HEIGHT=""{height}"" AUTOSTART=""{(isAutoPlay
                            ? "true"
                            : "false")}"">
</OBJECT>
";
                    }
                    else if (fileType == EFileSystemType.Wmv)
                    {
                        parsedContent = $@"
<object id=""palyer_{uniqueId}"" WIDTH=""{width}"" HEIGHT=""{height}"" classid=""CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"" codebase=""http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715"" standby=""Loading Microsoft Windows Media Player components..."" type=""application/x-oleobject"" align=""right"" hspace=""5"">
<param name=""AutoRewind"" value=""1"">
<param name=""ShowControls"" value=""1"">
<param name=""ShowPositionControls"" value=""0"">
<param name=""ShowAudioControls"" value=""1"">
<param name=""ShowTracker"" value=""0"">
<param name=""ShowDisplay"" value=""0"">
<param name=""ShowStatusBar"" value=""0"">
<param name=""ShowGotoBar"" value=""0"">
<param name=""ShowCaptioning"" value=""0"">
<param name=""AutoStart"" value=""{(isAutoPlay ? "1" : "0")}"">
<param name=""FileName"" value=""{playUrl}"">
<param name=""Volume"" value=""-2500"">
<param name=""AnimationAtStart"" value=""0"">
<param name=""TransparentAtStart"" value=""0"">
<param name=""AllowChangeDisplaySize"" value=""0"">
<param name=""AllowScan"" value=""0"">
<param name=""EnableContextMenu"" value=""0"">
<param name=""ClickToPlay"" value=""0"">
</object>
";
                    }
                    else if (fileType == EFileSystemType.Wma)
                    {
                        parsedContent = $@"
<object classid=""clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"" id=""palyer_{uniqueId}"">
<param name=""Filename"" value=""{playUrl}"">
<param name=""PlayCount"" value=""1"">
<param name=""AutoStart"" value=""{(isAutoPlay ? "1" : "0")}"">
<param name=""ClickToPlay"" value=""1"">
<param name=""DisplaySize"" value=""0"">
<param name=""EnableFullScreen Controls"" value=""1"">
<param name=""ShowAudio Controls"" value=""1"">
<param name=""EnableContext Menu"" value=""1"">
<param name=""ShowDisplay"" value=""1"">
</object>
";
                    }
                    else if (fileType == EFileSystemType.Rm || fileType == EFileSystemType.Rmb || fileType == EFileSystemType.Rmvb)
                    {
                        if (!contextInfo.Attributes.ContainsKey("ShowDisplay"))
                        {
                            contextInfo.Attributes["ShowDisplay"] = "0";
                        }
                        if (!contextInfo.Attributes.ContainsKey("ShowControls"))
                        {
                            contextInfo.Attributes["ShowControls"] = "1";
                        }
                        contextInfo.Attributes["AutoStart"] = isAutoPlay ? "1" : "0";
                        if (!contextInfo.Attributes.ContainsKey("AutoRewind"))
                        {
                            contextInfo.Attributes["AutoRewind"] = "0";
                        }
                        if (!contextInfo.Attributes.ContainsKey("PlayCount"))
                        {
                            contextInfo.Attributes["PlayCount"] = "0";
                        }
                        if (!contextInfo.Attributes.ContainsKey("Appearance"))
                        {
                            contextInfo.Attributes["Appearance"] = "0";
                        }
                        if (!contextInfo.Attributes.ContainsKey("BorderStyle"))
                        {
                            contextInfo.Attributes["BorderStyle"] = "0";
                        }
                        if (!contextInfo.Attributes.ContainsKey("Controls"))
                        {
                            contextInfo.Attributes["ImageWindow"] = "0";
                        }
                        contextInfo.Attributes["moviewindowheight"] = height.ToString();
                        contextInfo.Attributes["moviewindowwidth"]  = width.ToString();
                        contextInfo.Attributes["filename"]          = playUrl;
                        contextInfo.Attributes["src"] = playUrl;

                        var paramBuilder = new StringBuilder();
                        var embedBuilder = new StringBuilder();
                        foreach (string key in contextInfo.Attributes.Keys)
                        {
                            paramBuilder.Append($@"<param name=""{key}"" value=""{contextInfo.Attributes[key]}"">").Append(StringUtils.Constants.ReturnAndNewline);
                            embedBuilder.Append($@" {key}=""{contextInfo.Attributes[key]}""");
                        }

                        parsedContent = $@"
<object id=""video_{uniqueId}"" width=""{width}"" height=""{height}"" border=""0"" classid=""clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"">
{paramBuilder}
<embed{embedBuilder}>
</embed>
</object>
";
                    }
                    else
                    {
                        if (StringUtils.EqualsIgnoreCase(playBy, PlayByJwPlayer))
                        {
                            pageInfo.AddPageBodyCodeIfNotExists(PageInfo.Const.JsAcJwPlayer6);
                            var ajaxElementId = StlParserUtility.GetAjaxDivId(pageInfo.UniqueId);
                            parsedContent = $@"
<div id='{ajaxElementId}'></div>
<script type='text/javascript'>
	jwplayer('{ajaxElementId}').setup({{
        autostart: {isAutoPlay.ToString().ToLower()},
		file: ""{playUrl}"",
		width: ""{width}"",
		height: ""{height}"",
		image: ""{imageUrl}""
	}});
</script>
";
                        }
                        else
                        {
                            var ajaxElementId = StlParserUtility.GetAjaxDivId(pageInfo.UniqueId);
                            pageInfo.AddPageBodyCodeIfNotExists(PageInfo.Const.JsAcFlowPlayer);

                            var swfUrl = SiteFilesAssets.GetUrl(pageInfo.ApiUrl, SiteFilesAssets.FlowPlayer.Swf);
                            parsedContent = $@"
<a href=""{playUrl}"" style=""display:block;width:{width}px;height:{height}px;"" id=""player_{ajaxElementId}""></a>
<script language=""javascript"">
    flowplayer(""player_{ajaxElementId}"", ""{swfUrl}"", {{
        clip:  {{
            autoPlay: {isAutoPlay.ToString().ToLower()}
        }}
    }});
</script>
";
                        }
                    }
                }
            }

            return(parsedContent);
        }
コード例 #16
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (cbIsTitleImage.Checked && string.IsNullOrEmpty(tbTitleImageWidth.Text) && string.IsNullOrEmpty(tbTitleImageHeight.Text))
            {
                FailMessage("缩略图尺寸不能为空!");
                return;
            }
            if (cbIsSmallImage.Checked && string.IsNullOrEmpty(tbSmallImageWidth.Text) && string.IsNullOrEmpty(tbSmallImageHeight.Text))
            {
                FailMessage("缩略图尺寸不能为空!");
                return;
            }

            ConfigSettings(false);

            if (hifUpload.PostedFile != null && "" != hifUpload.PostedFile.FileName)
            {
                var filePath = hifUpload.PostedFile.FileName;
                try
                {
                    var fileExtName        = PathUtils.GetExtension(filePath).ToLower();
                    var localDirectoryPath = PathUtility.GetUploadDirectoryPath(PublishmentSystemInfo, fileExtName);
                    var localFileName      = PathUtility.GetUploadFileName(PublishmentSystemInfo, filePath);
                    var localTitleFileName = StringUtils.Constants.TitleImageAppendix + localFileName;
                    var localSmallFileName = StringUtils.Constants.SmallImageAppendix + localFileName;
                    var localFilePath      = PathUtils.Combine(localDirectoryPath, localFileName);
                    var localTitleFilePath = PathUtils.Combine(localDirectoryPath, localTitleFileName);
                    var localSmallFilePath = PathUtils.Combine(localDirectoryPath, localSmallFileName);

                    if (!PathUtility.IsImageExtenstionAllowed(PublishmentSystemInfo, fileExtName))
                    {
                        FailMessage("上传失败,上传图片格式不正确!");
                        return;
                    }
                    if (!PathUtility.IsImageSizeAllowed(PublishmentSystemInfo, hifUpload.PostedFile.ContentLength))
                    {
                        FailMessage("上传失败,上传图片超出规定文件大小!");
                        return;
                    }

                    hifUpload.PostedFile.SaveAs(localFilePath);

                    var isImage = EFileSystemTypeUtils.IsImage(fileExtName);

                    //处理上半部分
                    if (isImage)
                    {
                        FileUtility.AddWaterMark(PublishmentSystemInfo, localFilePath);
                        if (cbIsTitleImage.Checked)
                        {
                            var width  = TranslateUtils.ToInt(tbTitleImageWidth.Text);
                            var height = TranslateUtils.ToInt(tbTitleImageHeight.Text);
                            ImageUtils.MakeThumbnail(localFilePath, localTitleFilePath, width, height, cbIsTitleImageLessSizeNotThumb.Checked);
                        }
                    }

                    var imageUrl = PageUtility.GetPublishmentSystemUrlByPhysicalPath(PublishmentSystemInfo, localFilePath);
                    if (cbIsTitleImage.Checked)
                    {
                        imageUrl = PageUtility.GetPublishmentSystemUrlByPhysicalPath(PublishmentSystemInfo, localTitleFilePath);
                    }

                    var textBoxUrl = PageUtility.GetVirtualUrl(PublishmentSystemInfo, imageUrl);

                    ltlScript.Text += $@"
if (parent.document.getElementById('{_textBoxClientId}'))
{{
    parent.document.getElementById('{_textBoxClientId}').value = '{textBoxUrl}';
}}
";

                    //处理下半部分
                    if (cbIsShowImageInTextEditor.Checked && isImage)
                    {
                        imageUrl = PageUtility.GetPublishmentSystemUrlByPhysicalPath(PublishmentSystemInfo, localFilePath);
                        var smallImageUrl = imageUrl;
                        if (cbIsSmallImage.Checked)
                        {
                            smallImageUrl = PageUtility.GetPublishmentSystemUrlByPhysicalPath(PublishmentSystemInfo, localSmallFilePath);
                        }

                        if (cbIsSmallImage.Checked)
                        {
                            var width  = TranslateUtils.ToInt(tbSmallImageWidth.Text);
                            var height = TranslateUtils.ToInt(tbSmallImageHeight.Text);
                            ImageUtils.MakeThumbnail(localFilePath, localSmallFilePath, width, height, cbIsSmallImageLessSizeNotThumb.Checked);
                        }

                        var insertHtml = string.Empty;
                        if (cbIsLinkToOriginal.Checked)
                        {
                            insertHtml =
                                $@"<a href=""{imageUrl}"" target=""_blank""><img src=""{smallImageUrl}"" border=""0"" /></a>";
                        }
                        else
                        {
                            insertHtml = $@"<img src=""{smallImageUrl}"" border=""0"" />";
                        }

                        ltlScript.Text += "if(parent." + ETextEditorTypeUtils.GetEditorInstanceScript() + ") parent." + ETextEditorTypeUtils.GetInsertHtmlScript("Content", insertHtml);
                    }

                    ltlScript.Text += PageUtils.HidePopWin;
                }
                catch (Exception ex)
                {
                    FailMessage(ex, ex.Message);
                }
            }
        }
コード例 #17
0
ファイル: StlFlash.cs プロジェクト: yankaics/cms-1
        private static string ParseImpl(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo, bool isGetPicUrlFromAttribute, string channelIndex, string channelName, int upLevel, int topLevel, string type, string src, string altSrc, string width, string height, NameValueCollection parameters)
        {
            var parsedContent = string.Empty;

            var contentID = 0;

            //判断是否图片地址由标签属性获得
            if (!isGetPicUrlFromAttribute)
            {
                contentID = contextInfo.ContentID;
            }
            var contentInfo = contextInfo.ContentInfo;

            string picUrl;

            if (!string.IsNullOrEmpty(src))
            {
                picUrl = src;
            }
            else
            {
                if (contentID != 0)//获取内容Flash
                {
                    if (contentInfo == null)
                    {
                        var nodeInfo  = NodeManager.GetNodeInfo(contextInfo.PublishmentSystemInfo.PublishmentSystemId, contextInfo.ChannelID);
                        var tableName = NodeManager.GetTableName(contextInfo.PublishmentSystemInfo, nodeInfo);

                        picUrl = BaiRongDataProvider.ContentDao.GetValue(tableName, contentID, type);
                    }
                    else
                    {
                        picUrl = contextInfo.ContentInfo.GetExtendedAttribute(type);
                    }
                }
                else//获取栏目Flash
                {
                    var channelID = StlDataUtility.GetNodeIdByLevel(pageInfo.PublishmentSystemId, contextInfo.ChannelID, upLevel, topLevel);

                    channelID = StlCacheManager.NodeId.GetNodeIdByChannelIdOrChannelIndexOrChannelName(pageInfo.PublishmentSystemId, channelID, channelIndex, channelName);
                    var channel = NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, channelID);

                    picUrl = channel.ImageUrl;
                }
            }

            if (string.IsNullOrEmpty(picUrl))
            {
                picUrl = altSrc;
            }

            if (!string.IsNullOrEmpty(picUrl))
            {
                var extension = PathUtils.GetExtension(picUrl);
                if (EFileSystemTypeUtils.IsImage(extension))
                {
                    parsedContent = StlImage.Parse(stlElement, node, pageInfo, contextInfo);
                }
                else if (EFileSystemTypeUtils.IsPlayer(extension))
                {
                    parsedContent = StlPlayer.Parse(stlElement, node, pageInfo, contextInfo);
                }
                else
                {
                    pageInfo.AddPageScriptsIfNotExists(PageInfo.JsAcSwfObject);

                    picUrl = PageUtility.ParseNavigationUrl(pageInfo.PublishmentSystemInfo, picUrl);

                    if (string.IsNullOrEmpty(parameters["quality"]))
                    {
                        parameters["quality"] = "high";
                    }
                    if (string.IsNullOrEmpty(parameters["wmode"]))
                    {
                        parameters["wmode"] = "transparent";
                    }
                    var paramBuilder = new StringBuilder();
                    var uniqueID     = pageInfo.UniqueId;
                    foreach (string key in parameters.Keys)
                    {
                        paramBuilder.Append($@"    so_{uniqueID}.addParam(""{key}"", ""{parameters[key]}"");").Append(StringUtils.Constants.ReturnAndNewline);
                    }

                    parsedContent = $@"
<div id=""flashcontent_{uniqueID}""></div>
<script type=""text/javascript"">
    // <![CDATA[
    var so_{uniqueID} = new SWFObject(""{picUrl}"", ""flash_{uniqueID}"", ""{width}"", ""{height}"", ""7"", """");
{paramBuilder}
    so_{uniqueID}.write(""flashcontent_{uniqueID}"");
    // ]]>
</script>
";
                }
            }

            return(parsedContent);
        }
コード例 #18
0
ファイル: PageFileManagement.cs プロジェクト: yankaics/cms-1
        private void FillFileSystemsToImage(bool isReload)
        {
            var builder = new StringBuilder();

            builder.Append("<table class=\"table table-noborder table-hover\">");

            var directoryUrl = PageUtility.GetPublishmentSystemUrl(PublishmentSystemInfo, _relatedPath);

            var backgroundImageUrl = SiteServerAssets.GetIconUrl("filesystem/management/background.gif");
            var directoryImageUrl  = SiteServerAssets.GetFileSystemIconUrl(EFileSystemType.Directory, true);

            var fileSystemInfoExtendCollection = FileManager.GetFileSystemInfoExtendCollection(_directoryPath, isReload);

            var mod = 0;

            foreach (FileSystemInfoExtend subDirectoryInfo in fileSystemInfoExtendCollection.Folders)
            {
                if (string.IsNullOrEmpty(_relatedPath))
                {
                    if (StringUtils.EqualsIgnoreCase(subDirectoryInfo.Name, "api"))
                    {
                        continue;
                    }
                }
                if (mod % 5 == 0)
                {
                    builder.Append("<tr>");
                }
                var linkUrl = GetRedirectUrl(PublishmentSystemId, PageUtils.Combine(_relatedPath, subDirectoryInfo.Name));

                builder.Append($@"
<td>
		<table cellspacing=""0"" cellpadding=""0"" border=""0"" align=""center"">
			<tr>
				<td style=""height:100px; width:100px; text-align:center; vertical-align:middle;"">
					<table cellspacing=""0"" cellpadding=""0"" border=""0"" align=""center"">
						<tr>
							<td background=""{backgroundImageUrl}"" style=""background-repeat:no-repeat; background-position:center;height:96px; width:96px; text-align:center; vertical-align:middle;"" align=""center""><a href=""{linkUrl}""><img src=""{directoryImageUrl}"" border=0 /></a></td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td style=""height:20px; width:100%; text-align:center; vertical-align:middle;""><a href=""{linkUrl}"">{StringUtils
				    .MaxLengthText(subDirectoryInfo.Name, 7)}</a> <input type=""checkbox"" name=""DirectoryNameCollection"" value=""{subDirectoryInfo
				    .Name}"" /></td>
			</tr>
		</table>
	</td>
");

                if (mod % 5 == 4)
                {
                    builder.Append("</tr>");
                }
                mod++;
            }

            foreach (FileSystemInfoExtend fileInfo in fileSystemInfoExtendCollection.Files)
            {
                if (mod % 5 == 0)
                {
                    builder.Append("<tr>");
                }
                var fileSystemType       = EFileSystemTypeUtils.GetEnumType(fileInfo.Type);
                var showPopWinString     = ModalFileView.GetOpenWindowString(PublishmentSystemId, _relatedPath, fileInfo.Name);
                var linkUrl              = PageUtils.Combine(directoryUrl, fileInfo.Name);
                var fileImageUrl         = string.Empty;
                var imageStyleAttributes = string.Empty;
                if (EFileSystemTypeUtils.IsImage(fileInfo.Type))
                {
                    var imagePath = PathUtils.Combine(_directoryPath, fileInfo.Name);
                    try
                    {
                        var image = ImageUtils.GetImage(imagePath);
                        if (image.Height > image.Width)
                        {
                            if (image.Height > 94)
                            {
                                imageStyleAttributes = @"style=""height:94px;""";
                            }
                        }
                        else
                        {
                            if (image.Width > 94)
                            {
                                imageStyleAttributes = @"style=""width:94px;""";
                            }
                        }
                        fileImageUrl = PageUtils.Combine(directoryUrl, fileInfo.Name);
                        image.Dispose();
                    }
                    catch
                    {
                        fileImageUrl = SiteServerAssets.GetFileSystemIconUrl(fileSystemType, true);
                    }
                }
                else
                {
                    fileImageUrl = SiteServerAssets.GetFileSystemIconUrl(fileSystemType, true);
                }

                builder.Append($@"
<td>
		<table cellspacing=""0"" cellpadding=""0"" border=""0"" align=""center"">
			<tr>
				<td style=""height:100px; width:100px; text-align:center; vertical-align:middle;"">
					<table cellspacing=""0"" cellpadding=""0"" border=""0"" align=""center"">
						<tr>
							<td background=""{backgroundImageUrl}"" style=""background-repeat:no-repeat; background-position:center;height:96px; width:96px; text-align:center; vertical-align:middle;"" align=""center""><a href=""javascript:;"" onclick=""{showPopWinString}"" target=""_blank""><img src=""{fileImageUrl}"" {imageStyleAttributes} border=0 /></a></td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td style=""height:20px; width:100%; text-align:center; vertical-align:middle;""><a href=""{linkUrl}"" target=""_blank"">{StringUtils
                    .MaxLengthText(fileInfo.Name, 7)}</a> <input type=""checkbox"" name=""FileNameCollection"" value=""{fileInfo
                    .Name}"" /></td>
			</tr>
		</table>
	</td>
");

                if (mod % 5 == 4)
                {
                    builder.Append("</tr>");
                }
                mod++;
            }

            builder.Append("</table>");
            ltlFileSystems.Text = builder.ToString();
        }
コード例 #19
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (HifUpload.PostedFile == null || "" == HifUpload.PostedFile.FileName)
            {
                return;
            }

            var filePath = HifUpload.PostedFile.FileName;

            try
            {
                var fileExtName        = PathUtils.GetExtension(filePath).ToLower();
                var localDirectoryPath = PathUtility.GetUploadDirectoryPath(SiteInfo, fileExtName);
                if (!string.IsNullOrEmpty(_currentRootPath))
                {
                    localDirectoryPath = PathUtility.MapPath(SiteInfo, _currentRootPath);
                    DirectoryUtils.CreateDirectoryIfNotExists(localDirectoryPath);
                }
                var localFileName = PathUtility.GetUploadFileName(SiteInfo, filePath);

                var localFilePath = PathUtils.Combine(localDirectoryPath, localFileName);

                if (!PathUtility.IsImageExtenstionAllowed(SiteInfo, fileExtName))
                {
                    FailMessage("上传失败,上传图片格式不正确!");
                    return;
                }
                if (!PathUtility.IsImageSizeAllowed(SiteInfo, HifUpload.PostedFile.ContentLength))
                {
                    FailMessage("上传失败,上传图片超出规定文件大小!");
                    return;
                }

                HifUpload.PostedFile.SaveAs(localFilePath);

                var isImage = EFileSystemTypeUtils.IsImage(fileExtName);

                if (isImage && _isNeedWaterMark)
                {
                    FileUtility.AddWaterMark(SiteInfo, localFilePath);
                }

                if (string.IsNullOrEmpty(_textBoxClientId))
                {
                    LayerUtils.Close(Page);
                }
                else
                {
                    var imageUrl   = PageUtility.GetSiteUrlByPhysicalPath(SiteInfo, localFilePath, true);
                    var textBoxUrl = PageUtility.GetVirtualUrl(SiteInfo, imageUrl);

                    LtlScript.Text = $@"
<script type=""text/javascript"" language=""javascript"">
if (parent.document.getElementById('{_textBoxClientId}') != null)
{{
    parent.document.getElementById('{_textBoxClientId}').value = '{textBoxUrl}';
}}
{LayerUtils.CloseScript}
</script>";
                }
            }
            catch (Exception ex)
            {
                FailMessage(ex, "图片上传失败!");
            }
        }
コード例 #20
0
        public IHttpActionResult Submit()
        {
            try
            {
                var request = new RequestImpl();

                var siteId                 = request.GetPostInt("siteId");
                var channelId              = request.GetPostInt("channelId");
                var isFix                  = request.GetPostBool("isFix");
                var fixWidth               = request.GetPostString("fixWidth");
                var fixHeight              = request.GetPostString("fixHeight");
                var isEditor               = request.GetPostBool("isEditor");
                var editorIsFix            = request.GetPostBool("editorIsFix");
                var editorFixWidth         = request.GetPostString("editorFixWidth");
                var editorFixHeight        = request.GetPostString("editorFixHeight");
                var editorIsLinkToOriginal = request.GetPostBool("editorIsLinkToOriginal");
                var filePaths              = TranslateUtils.StringCollectionToStringList(request.GetPostString("filePaths"));

                if (!request.IsUserLoggin ||
                    !request.UserPermissionsImpl.HasChannelPermissions(siteId, channelId,
                                                                       ConfigManager.ChannelPermissions.ContentAdd))
                {
                    return(Unauthorized());
                }

                var siteInfo = SiteManager.GetSiteInfo(siteId);
                if (siteInfo == null)
                {
                    return(BadRequest("无法确定内容对应的站点"));
                }

                var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId);
                if (channelInfo == null)
                {
                    return(BadRequest("无法确定内容对应的栏目"));
                }

                var retval  = new List <string>();
                var editors = new List <object>();

                foreach (var filePath in filePaths)
                {
                    if (string.IsNullOrEmpty(filePath))
                    {
                        continue;
                    }

                    var fileExtName = PathUtils.GetExtension(filePath).ToLower();
                    var fileName    = PathUtility.GetUploadFileName(siteInfo, filePath);

                    var directoryPath     = PathUtility.GetUploadDirectoryPath(siteInfo, fileExtName);
                    var fixFilePath       = PathUtils.Combine(directoryPath, StringUtils.Constants.TitleImageAppendix + fileName);
                    var editorFixFilePath = PathUtils.Combine(directoryPath, StringUtils.Constants.SmallImageAppendix + fileName);

                    var isImage = EFileSystemTypeUtils.IsImage(fileExtName);

                    if (isImage)
                    {
                        if (isFix)
                        {
                            var width  = TranslateUtils.ToInt(fixWidth);
                            var height = TranslateUtils.ToInt(fixHeight);
                            ImageUtils.MakeThumbnail(filePath, fixFilePath, width, height, true);
                        }

                        if (isEditor)
                        {
                            if (editorIsFix)
                            {
                                var width  = TranslateUtils.ToInt(editorFixWidth);
                                var height = TranslateUtils.ToInt(editorFixHeight);
                                ImageUtils.MakeThumbnail(filePath, editorFixFilePath, width, height, true);
                            }
                        }
                    }

                    var imageUrl          = PageUtility.GetSiteUrlByPhysicalPath(siteInfo, filePath, true);
                    var fixImageUrl       = PageUtility.GetSiteUrlByPhysicalPath(siteInfo, fixFilePath, true);
                    var editorFixImageUrl = PageUtility.GetSiteUrlByPhysicalPath(siteInfo, editorFixFilePath, true);

                    retval.Add(isFix ? fixImageUrl : imageUrl);

                    editors.Add(new
                    {
                        ImageUrl    = isFix ? editorFixImageUrl : imageUrl,
                        OriginalUrl = imageUrl
                    });
                }

                var changed = false;
                if (siteInfo.Additional.ConfigImageIsFix != isFix)
                {
                    changed = true;
                    siteInfo.Additional.ConfigImageIsFix = isFix;
                }
                if (siteInfo.Additional.ConfigImageFixWidth != fixWidth)
                {
                    changed = true;
                    siteInfo.Additional.ConfigImageFixWidth = fixWidth;
                }
                if (siteInfo.Additional.ConfigImageFixHeight != fixHeight)
                {
                    changed = true;
                    siteInfo.Additional.ConfigImageFixHeight = fixHeight;
                }
                if (siteInfo.Additional.ConfigImageIsEditor != isEditor)
                {
                    changed = true;
                    siteInfo.Additional.ConfigImageIsEditor = isEditor;
                }
                if (siteInfo.Additional.ConfigImageEditorIsFix != editorIsFix)
                {
                    changed = true;
                    siteInfo.Additional.ConfigImageEditorIsFix = editorIsFix;
                }
                if (siteInfo.Additional.ConfigImageEditorFixWidth != editorFixWidth)
                {
                    changed = true;
                    siteInfo.Additional.ConfigImageEditorFixWidth = editorFixWidth;
                }
                if (siteInfo.Additional.ConfigImageEditorFixHeight != editorFixHeight)
                {
                    changed = true;
                    siteInfo.Additional.ConfigImageEditorFixHeight = editorFixHeight;
                }
                if (siteInfo.Additional.ConfigImageEditorIsLinkToOriginal != editorIsLinkToOriginal)
                {
                    changed = true;
                    siteInfo.Additional.ConfigImageEditorIsLinkToOriginal = editorIsLinkToOriginal;
                }

                if (changed)
                {
                    DataProvider.SiteDao.Update(siteInfo);
                }

                return(Ok(new
                {
                    Value = retval,
                    Editors = editors
                }));
            }
            catch (Exception ex)
            {
                LogUtils.AddErrorLog(ex);
                return(InternalServerError(ex));
            }
        }
コード例 #21
0
ファイル: StlPlayer.cs プロジェクト: ym1100/siteserver-cms
        private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, string playUrl, string imageUrl, string playBy, int width, int height, string type, bool isAutoPlay)
        {
            if (string.IsNullOrEmpty(playUrl))
            {
                var contentId = contextInfo.ContentId;
                if (contentId != 0)//获取内容视频
                {
                    if (contextInfo.ContentInfo == null)
                    {
                        playUrl = StlContentCache.GetValue(pageInfo.SiteInfo.TableName, contentId, type);
                        if (string.IsNullOrEmpty(playUrl))
                        {
                            if (!StringUtils.EqualsIgnoreCase(type, BackgroundContentAttribute.VideoUrl))
                            {
                                playUrl = StlContentCache.GetValue(pageInfo.SiteInfo.TableName, contentId, BackgroundContentAttribute.VideoUrl);
                            }
                        }
                    }
                    else
                    {
                        playUrl = contextInfo.ContentInfo.GetString(type);
                        if (string.IsNullOrEmpty(playUrl))
                        {
                            playUrl = contextInfo.ContentInfo.GetString(BackgroundContentAttribute.VideoUrl);
                        }
                    }
                }
            }

            if (string.IsNullOrEmpty(playUrl))
            {
                return(string.Empty);
            }

            playUrl  = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, playUrl, pageInfo.IsLocal);
            imageUrl = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, imageUrl, pageInfo.IsLocal);

            var extension = PathUtils.GetExtension(playUrl);
            var uniqueId  = pageInfo.UniqueId;

            var fileType = EFileSystemTypeUtils.GetEnumType(extension);

            if (EFileSystemTypeUtils.IsFlash(extension))
            {
                return(StlFlash.Parse(pageInfo, contextInfo));
            }

            if (EFileSystemTypeUtils.IsImage(extension))
            {
                return(StlImage.Parse(pageInfo, contextInfo));
            }

            if (fileType == EFileSystemType.Avi)
            {
                return(ParseAvi(uniqueId, width, height, isAutoPlay, playUrl));
            }

            if (fileType == EFileSystemType.Mpg)
            {
                return(ParseMpg(uniqueId, width, height, isAutoPlay, playUrl));
            }

            if (fileType == EFileSystemType.Rm || fileType == EFileSystemType.Rmb || fileType == EFileSystemType.Rmvb)
            {
                return(ParseRm(contextInfo, uniqueId, width, height, isAutoPlay, playUrl));
            }

            if (fileType == EFileSystemType.Wmv)
            {
                return(ParseWmv(uniqueId, width, height, isAutoPlay, playUrl));
            }

            if (fileType == EFileSystemType.Wma)
            {
                return(ParseWma(uniqueId, isAutoPlay, playUrl));
            }

            if (StringUtils.EqualsIgnoreCase(playBy, PlayByJwPlayer))
            {
                pageInfo.AddPageBodyCodeIfNotExists(PageInfo.Const.JsAcJwPlayer6);
                var ajaxElementId = StlParserUtility.GetAjaxDivId(pageInfo.UniqueId);
                return($@"
<div id='{ajaxElementId}'></div>
<script type='text/javascript'>
	jwplayer('{ajaxElementId}').setup({{
        autostart: {isAutoPlay.ToString().ToLower()},
		file: ""{playUrl}"",
		width: ""{width}"",
		height: ""{height}"",
		image: ""{imageUrl}""
	}});
</script>
");
            }

            if (StringUtils.EqualsIgnoreCase(playBy, PlayByFlowPlayer))
            {
                var ajaxElementId = StlParserUtility.GetAjaxDivId(pageInfo.UniqueId);
                pageInfo.AddPageBodyCodeIfNotExists(PageInfo.Const.JsAcFlowPlayer);

                var imageHtml = string.Empty;
                if (!string.IsNullOrEmpty(imageUrl))
                {
                    imageHtml = $@"<img src=""{imageUrl}"" style=""{(width > 0 ? $"width:{width}px;" : string.Empty)}{(height > 0 ? $"height:{height}px;" : string.Empty)}"" />";
                }

                var swfUrl = SiteFilesAssets.GetUrl(pageInfo.ApiUrl, SiteFilesAssets.FlowPlayer.Swf);
                return($@"
<a href=""{playUrl}"" style=""display:block;{(width > 0 ? $"width:{width}px;" : string.Empty)}{(height > 0 ? $"height:{height}px;" : string.Empty)}"" id=""player_{ajaxElementId}"">{imageHtml}</a>
<script language=""javascript"">
    flowplayer(""player_{ajaxElementId}"", ""{swfUrl}"", {{
        clip:  {{
            autoPlay: {isAutoPlay.ToString().ToLower()}
        }}
    }});
</script>
");
            }

            return(StlVideo.Parse(pageInfo, contextInfo));
        }
コード例 #22
0
ファイル: StlFlash.cs プロジェクト: googlaq/siteservercms
        private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, bool isGetPicUrlFromAttribute, string channelIndex, string channelName, int upLevel, int topLevel, string type, string src, string altSrc, string width, string height)
        {
            var parsedContent = string.Empty;

            var contentId = 0;

            //判断是否图片地址由标签属性获得
            if (!isGetPicUrlFromAttribute)
            {
                contentId = contextInfo.ContentId;
            }
            var contentInfo = contextInfo.ContentInfo;

            string flashUrl;

            if (!string.IsNullOrEmpty(src))
            {
                flashUrl = src;
            }
            else
            {
                if (contentId != 0)//获取内容Flash
                {
                    if (contentInfo == null)
                    {
                        var nodeInfo  = ChannelManager.GetChannelInfo(contextInfo.SiteInfo.Id, contextInfo.ChannelId);
                        var tableName = ChannelManager.GetTableName(contextInfo.SiteInfo, nodeInfo);

                        //picUrl = DataProvider.ContentDao.GetValue(tableName, contentId, type);
                        flashUrl = StlContentCache.GetValue(tableName, contentId, type);
                    }
                    else
                    {
                        flashUrl = contextInfo.ContentInfo.GetString(type);
                    }
                }
                else//获取栏目Flash
                {
                    var channelId = StlDataUtility.GetChannelIdByLevel(pageInfo.SiteId, contextInfo.ChannelId, upLevel, topLevel);

                    channelId = StlDataUtility.GetChannelIdByChannelIdOrChannelIndexOrChannelName(pageInfo.SiteId, channelId, channelIndex, channelName);
                    var channel = ChannelManager.GetChannelInfo(pageInfo.SiteId, channelId);

                    flashUrl = channel.ImageUrl;
                }
            }

            if (string.IsNullOrEmpty(flashUrl))
            {
                flashUrl = altSrc;
            }

            // 如果是实体标签则返回空
            if (contextInfo.IsStlEntity)
            {
                return(flashUrl);
            }

            if (!string.IsNullOrEmpty(flashUrl))
            {
                var extension = PathUtils.GetExtension(flashUrl);
                if (EFileSystemTypeUtils.IsImage(extension))
                {
                    parsedContent = StlImage.Parse(pageInfo, contextInfo);
                }
                else if (EFileSystemTypeUtils.IsPlayer(extension))
                {
                    parsedContent = StlPlayer.Parse(pageInfo, contextInfo);
                }
                else
                {
                    flashUrl = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, flashUrl, pageInfo.IsLocal);

                    parsedContent = $@"
<embed src=""{flashUrl}"" allowfullscreen=""true"" width=""{width}"" height=""{height}"" align=""middle"" allowscriptaccess=""always"" type=""application/x-shockwave-flash"" />
";
                }
            }

            return(parsedContent);
        }
コード例 #23
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (CbIsTitleImage.Checked && string.IsNullOrEmpty(TbTitleImageWidth.Text) && string.IsNullOrEmpty(TbTitleImageHeight.Text))
            {
                FailMessage("缩略图尺寸不能为空!");
                return;
            }
            if (CbIsSmallImage.Checked && string.IsNullOrEmpty(TbSmallImageWidth.Text) && string.IsNullOrEmpty(TbSmallImageHeight.Text))
            {
                FailMessage("缩略图尺寸不能为空!");
                return;
            }

            ConfigSettings(false);

            if (HifUpload.PostedFile == null || "" == HifUpload.PostedFile.FileName)
            {
                return;
            }

            var filePath = HifUpload.PostedFile.FileName;

            try
            {
                var fileExtName        = PathUtils.GetExtension(filePath).ToLower();
                var localDirectoryPath = PathUtility.GetUploadDirectoryPath(SiteInfo, fileExtName);
                var localFileName      = PathUtility.GetUploadFileName(SiteInfo, filePath);
                var localTitleFileName = Constants.TitleImageAppendix + localFileName;
                var localSmallFileName = Constants.SmallImageAppendix + localFileName;
                var localFilePath      = PathUtils.Combine(localDirectoryPath, localFileName);
                var localTitleFilePath = PathUtils.Combine(localDirectoryPath, localTitleFileName);
                var localSmallFilePath = PathUtils.Combine(localDirectoryPath, localSmallFileName);

                if (!PathUtility.IsImageExtenstionAllowed(SiteInfo, fileExtName))
                {
                    FailMessage("上传失败,上传图片格式不正确!");
                    return;
                }
                if (!PathUtility.IsImageSizeAllowed(SiteInfo, HifUpload.PostedFile.ContentLength))
                {
                    FailMessage("上传失败,上传图片超出规定文件大小!");
                    return;
                }

                HifUpload.PostedFile.SaveAs(localFilePath);

                var isImage = EFileSystemTypeUtils.IsImage(fileExtName);

                //处理上半部分
                if (isImage)
                {
                    FileUtility.AddWaterMark(SiteInfo, localFilePath);
                    if (CbIsTitleImage.Checked)
                    {
                        var width  = TranslateUtils.ToInt(TbTitleImageWidth.Text);
                        var height = TranslateUtils.ToInt(TbTitleImageHeight.Text);
                        ImageUtils.MakeThumbnail(localFilePath, localTitleFilePath, width, height, true);
                    }
                }

                var imageUrl = PageUtility.GetSiteUrlByPhysicalPath(SiteInfo, localFilePath, true);
                if (CbIsTitleImage.Checked)
                {
                    imageUrl = PageUtility.GetSiteUrlByPhysicalPath(SiteInfo, localTitleFilePath, true);
                }

                var textBoxUrl = PageUtility.GetVirtualUrl(SiteInfo, imageUrl);

                var script = $@"
if (parent.document.getElementById('{_textBoxClientId}'))
{{
    parent.document.getElementById('{_textBoxClientId}').value = '{textBoxUrl}';
}}
";

                //处理下半部分
                if (CbIsShowImageInTextEditor.Checked && isImage)
                {
                    imageUrl = PageUtility.GetSiteUrlByPhysicalPath(SiteInfo, localFilePath, true);
                    var smallImageUrl = imageUrl;
                    if (CbIsSmallImage.Checked)
                    {
                        smallImageUrl = PageUtility.GetSiteUrlByPhysicalPath(SiteInfo, localSmallFilePath, true);
                    }

                    if (CbIsSmallImage.Checked)
                    {
                        var width  = TranslateUtils.ToInt(TbSmallImageWidth.Text);
                        var height = TranslateUtils.ToInt(TbSmallImageHeight.Text);
                        ImageUtils.MakeThumbnail(localFilePath, localSmallFilePath, width, height, true);
                    }

                    var insertHtml = CbIsLinkToOriginal.Checked ? $@"<a href=""{imageUrl}"" target=""_blank""><img src=""{smallImageUrl}"" border=""0"" /></a>" : $@"<img src=""{smallImageUrl}"" border=""0"" />";

                    script += "if(parent." + UEditorUtils.GetEditorInstanceScript() + ") parent." + UEditorUtils.GetInsertHtmlScript("Content", insertHtml);
                }

                LtlScript.Text = $@"
<script type=""text/javascript"" language=""javascript"">
    {script}
    {LayerUtils.CloseScript}
</script>";
            }
            catch (Exception ex)
            {
                FailMessage(ex, ex.Message);
            }
        }
コード例 #24
0
        private void FillFileSystemsToImage(bool isReload)
        {
            var builder = new StringBuilder();

            builder.Append(@"<table class=""table table-noborder table-hover"">");

            var directoryUrl       = PageUtility.GetSiteUrlByPhysicalPath(SiteInfo, _directoryPath, true);
            var backgroundImageUrl = SiteServerAssets.GetIconUrl("filesystem/management/background.gif");
            var directoryImageUrl  = SiteServerAssets.GetFileSystemIconUrl(EFileSystemType.Directory, true);

            var fileSystemInfoExtendCollection = FileManager.GetFileSystemInfoExtendCollection(_directoryPath, isReload);

            var mod = 0;

            foreach (FileSystemInfoExtend subDirectoryInfo in fileSystemInfoExtendCollection.Folders)
            {
                if (mod % 4 == 0)
                {
                    builder.Append("<tr>");
                }
                var linkUrl = GetRedirectUrl(PageUtils.Combine(_currentRootPath, subDirectoryInfo.Name));

                builder.Append($@"
<td>
		<table cellspacing=""0"" cellpadding=""0"" border=""0"" align=""center"">
			<tr>
				<td style=""height:100px; width:100px; text-align:center; vertical-align:middle;"">
					<table cellspacing=""0"" cellpadding=""0"" border=""0"" align=""center"">
						<tr>
							<td background=""{backgroundImageUrl}"" style=""background-repeat:no-repeat; background-position:center;height:96px; width:96px; text-align:center; vertical-align:middle;"" align=""center""><a href=""{linkUrl}""><img src=""{directoryImageUrl}"" border=0 /></a></td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td style=""height:20px; width:100%; text-align:center; vertical-align:middle;""><a href=""{linkUrl}"">{StringUtils
				    .MaxLengthText(subDirectoryInfo.Name, 8)}</a></td>
			</tr>
		</table>
	</td>
");

                if (mod % 4 == 3)
                {
                    builder.Append("</tr>");
                }
                mod++;
            }

            foreach (FileSystemInfoExtend fileInfo in fileSystemInfoExtendCollection.Files)
            {
                if (mod % 4 == 0)
                {
                    builder.Append("<tr>");
                }
                var    fileSystemType = EFileSystemTypeUtils.GetEnumType(fileInfo.Type);
                var    linkUrl        = PageUtils.Combine(directoryUrl, fileInfo.Name);
                string fileImageUrl;
                var    imageStyleAttributes = string.Empty;
                if (EFileSystemTypeUtils.IsImage(fileInfo.Type))
                {
                    var imagePath = PathUtils.Combine(_directoryPath, fileInfo.Name);
                    try
                    {
                        var image = ImageUtils.GetImage(imagePath);
                        if (image.Height > image.Width)
                        {
                            if (image.Height > 94)
                            {
                                imageStyleAttributes = @"style=""height:94px;""";
                            }
                        }
                        else
                        {
                            if (image.Width > 94)
                            {
                                imageStyleAttributes = @"style=""width:94px;""";
                            }
                        }
                        fileImageUrl = PageUtils.Combine(directoryUrl, fileInfo.Name);
                        image.Dispose();
                    }
                    catch
                    {
                        fileImageUrl = SiteServerAssets.GetFileSystemIconUrl(fileSystemType, true);
                    }
                }
                else
                {
                    fileImageUrl = GetFileSystemIconUrl(SiteInfo, fileInfo, true);
                }

                var attachmentUrl = PageUtility.GetVirtualUrl(SiteInfo, linkUrl);
                //string fileViewUrl = Modal.FileView.GetOpenWindowString(base.SiteId, attachmentUrl);
                var fileViewUrl = ModalFileView.GetOpenWindowStringHidden(SiteId, attachmentUrl, _hiddenClientId);

                builder.Append($@"
<td>
		<table cellspacing=""0"" cellpadding=""0"" border=""0"" align=""center"">
			<tr>
				<td style=""height:100px; width:100px; text-align:center; vertical-align:middle;"">
					<table cellspacing=""0"" cellpadding=""0"" border=""0"" align=""center"">
						<tr>
							<td background=""{backgroundImageUrl}"" style=""background-repeat:no-repeat; background-position:center;height:96px; width:96px; text-align:center; vertical-align:middle;"" align=""center""><a href=""javascript:;"" onClick=""window.parent.SelectAttachment('{_hiddenClientId}', '{attachmentUrl
				    .Replace("'", "\\'")}', '{fileViewUrl.Replace("'", "\\'")}');{LayerUtils.CloseScript}"" title=""{fileInfo.Name}""><img src=""{fileImageUrl}"" {imageStyleAttributes} border=0 /></a></td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td style=""height:20px; width:100%; text-align:center; vertical-align:middle;""><a href=""{linkUrl}"" title=""点击此项浏览此附件"" target=""_blank"">{StringUtils
				    .MaxLengthText(fileInfo.Name, 8)}</a></td>
			</tr>
		</table>
	</td>
");

                if (mod % 4 == 3)
                {
                    builder.Append("</tr>");
                }
                mod++;
            }

            builder.Append("</table>");
            LtlFileSystems.Text = builder.ToString();
        }