雅灰网站显示图片(1).config
来自「动易SiteFactory网上商店系统正式版动易SiteFactory网上商店系」· CONFIG 代码 · 共 213 行
CONFIG
213 行
<root>
<LabelType>图片列表</LabelType>
<LabelImage>../../Admin/Images/LabelIco/GetArticleCustom.gif</LabelImage>
<LabelIntro>JavaScript脚本驱动的FLASH幻灯标签</LabelIntro>
<LabelDataType>sql_sysquery</LabelDataType>
<LabelSqlString>SELECT PhotoUrl FROM PE_U_Photo WHERE ID =(SELECT TOP 1 ItemID FROM PE_CommonModel WHERE GeneralId=@generalid AND Status=99)</LabelSqlString>
<LabelTemplate><![CDATA[<?xml version="1.0" encoding="utf-8"?>
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:pe="labelproc"
xmlns:ms="urn:schemas-microsoft-com:xslt"
xmlns:csharp="urn:the-xml-files:xslt-csharp"
exclude-result-prefixes="pe ms csharp"
>
<ms:script language="c#" implements-prefix="csharp">
public string GetFirstPhotoUrl(string originUrl,string uploadfiledir)
{
string newUrl = string.Empty;
string[] urls = originUrl.Split(new string[] { "$$$" }, StringSplitOptions.RemoveEmptyEntries);
foreach (string url in urls)
{
return SplitUrl(url,uploadfiledir);
break;
}
return newUrl;
}
public string SplitUrl(string url,string uploadfiledir)
{
string[] photourls = url.Split(new string[] { "|" },StringSplitOptions.None);
string photoUrl=string.Empty;
string newUrl=string.Empty;
if(photourls.Length>1){
photoUrl=photourls[1];
}
if(!string.IsNullOrEmpty(photoUrl))
{
if(photoUrl.StartsWith("/")||photoUrl.StartsWith("http://",StringComparison.CurrentCultureIgnoreCase)
||photoUrl.StartsWith("https://",StringComparison.CurrentCultureIgnoreCase)
||photoUrl.StartsWith("www",StringComparison.CurrentCultureIgnoreCase))
{
newUrl=photoUrl;
}else{
newUrl = uploadfiledir+photoUrl;
}
}
return newUrl;
}
public string ViewPhoto(int imgWidth, int imgHeight, string originUrl,string uploadfiledir)
{
string photourl = "";
StringBuilder newphotourl = new StringBuilder("");
string imgsetting = "";
photourl = GetFirstPhotoUrl(originUrl,uploadfiledir);
if (string.IsNullOrEmpty(photourl))
{
photourl = "Images/nopic.gif";
}
if (imgWidth > 0)
{
imgsetting = " onload='if(this.width>" + imgWidth + ") this.width=" + imgWidth + "'";
}
else
{
imgWidth = 550;
}
if (imgHeight <= 0)
{
imgHeight = 400;
}
newphotourl.Append("<div id='imgBox'></div>");
newphotourl.Append("<script language='javascript'>\n");
newphotourl.Append("function ViewPhoto(PhotoUrl){\n");
newphotourl.Append(" var strHtml;\n");
newphotourl.Append(" var FileExt=PhotoUrl.substr(PhotoUrl.lastIndexOf('.')+1).toLowerCase();\n");
newphotourl.Append(" if(FileExt=='gif'||FileExt=='jpg'||FileExt=='png'||FileExt=='bmp'||FileExt=='jpeg'){\n");
newphotourl.Append(" strHtml=\"<a href='\"+PhotoUrl+\"' target='PhotoView'><img src='\"+PhotoUrl+\"' border='0'" + imgsetting + "></a>\";\n");
newphotourl.Append(" }else if(FileExt=='swf'){\n");
newphotourl.Append(" strHtml=\"<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='" + imgWidth + "' height='" + imgHeight + "' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0'><param name='movie' value='\"+PhotoUrl+\"'><param name='quality' value='high'><embed src='\"+PhotoUrl+\"' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='550' height='400'></embed></object>\";\n");
newphotourl.Append(" }else{\n");
newphotourl.Append(" strHtml=PhotoUrl;\n");
newphotourl.Append(" }");
newphotourl.Append(" document.getElementById('imgBox').innerHTML=strHtml;\n");
newphotourl.Append("}\n");
newphotourl.Append("ViewPhoto('");
newphotourl.Append(photourl);
newphotourl.Append("');\n");
newphotourl.Append("</script>\n");
return newphotourl.ToString();
}
public string GetUrlArray(string originUrl,string uploadfiledir)
{
StringBuilder urlArray = new StringBuilder("");
int i = 0;
urlArray.Append("<script language='javascript'>\n");
urlArray.Append("var arrUrlName=new Array();\n");
urlArray.Append("var arrUrl=new Array();\n");
string[] urls = originUrl.Split(new string[] { "$$$" }, StringSplitOptions.RemoveEmptyEntries);
foreach (string url in urls)
{
string[] photourls = url.Split(new string[] { "|" },StringSplitOptions.RemoveEmptyEntries);
urlArray.Append("arrUrlName[");
urlArray.Append(i);
urlArray.Append("]='");
urlArray.Append(photourls[0]);
urlArray.Append("';\n");
urlArray.Append("arrUrl[");
urlArray.Append(i);
urlArray.Append("]='");
urlArray.Append(SplitUrl(url,uploadfiledir));
urlArray.Append("';\n");
i = i + 1;
}
urlArray.Append("</script>\n");
return urlArray.ToString();
}
public string GetPhotoUrlList(int showType, int imgWidth, int imgHeight, int cols, int maxPerPage, string originUrl,string uploadfiledir)
{
StringBuilder photoUrlList = new StringBuilder("");
if (string.IsNullOrEmpty(originUrl))
{
return string.Empty;
}
if (cols < 1)
{
cols = 1;
}
if (maxPerPage < 1)
{
maxPerPage = 1;
}
string urls = GetUrlArray(originUrl,uploadfiledir);
photoUrlList.Append(urls);
photoUrlList.Append("<div id='PhotoUrlList'></div>");
photoUrlList.Append("<script language='javascript'>\n");
if (showType == 0)
{
photoUrlList.Append("for(var i=0;i<arrUrl.length;i++){\n");
photoUrlList.Append(" document.write(\"<a href='#Title' onclick=ViewPhoto('\"+arrUrl[i]+\"')>\"+arrUrlName[i]+\"</a>&nbsp;&nbsp;\");\n");
photoUrlList.Append(" if((i+1)%" + cols + "==0&&i+1<arrUrl.length){document.write('<br />');}\n");
photoUrlList.Append("}\n");
}
else
{
string imgsetting = "";
if (imgWidth > 0)
{
imgsetting += " width='" + imgWidth + "'";
}
if (imgHeight > 0)
{
imgsetting += " heigth='" + imgHeight + "'";
}
photoUrlList.Append("function ShowUrlList(page){\n");
photoUrlList.Append(" if(arrUrl.length<1) return '';\n");
photoUrlList.Append(" var dTotalPage=arrUrl.length/" + maxPerPage + ";\n");
photoUrlList.Append(" var TotalPage;\n");
photoUrlList.Append(" var MaxPerPage=" + maxPerPage + ";\n");
photoUrlList.Append(" if(arrUrl.length%MaxPerPage==0){TotalPage=Math.floor(dTotalPage);}else{TotalPage=Math.floor(dTotalPage)+1;}\n");
photoUrlList.Append(" if(page<1) page=1;\n");
photoUrlList.Append(" if(page>TotalPage) page=TotalPage;\n");
photoUrlList.Append(" var strPage='<table><tr>';\n");
photoUrlList.Append(" for(var i=(page-1)*MaxPerPage;i<arrUrl.length&&i<page*MaxPerPage;i++){\n");
photoUrlList.Append(" strPage+=\"<td><a href='#Title' onclick=ViewPhoto('\"+arrUrl[i]+\"')><img src='\"+arrUrl[i]+\"' border='0' " + imgsetting + "></a></td>\";\n");
photoUrlList.Append(" if((i+1)%" + cols + "==0&&i+1<MaxPerPage){strPage+='</tr><tr>';}\n");
photoUrlList.Append(" }\n");
photoUrlList.Append(" strPage+=\"</tr></table>\";\n");
photoUrlList.Append(" if(TotalPage>1){strPage+=\"<table><tr><td><a href='javascript:ShowUrlList(1)'>[第一张]</a> <a href='javascript:ShowUrlList(\"+(page-1)+\")'>[上一张]</a>\"; \n");
photoUrlList.Append(" strPage+=\"<select name='imagelist' onChange='ShowUrlList(this[this.selectedIndex].value)'>\";\n");
photoUrlList.Append(" for(var j=1;j<=arrUrl.length;j++){\n");
photoUrlList.Append(" strPage+=\"<option value=\"+j+\"\";\n");
photoUrlList.Append(" if(j==page){strPage+=\" selected \";}\n");
photoUrlList.Append(" strPage+=\">第\"+j+\"张</option>\";\n");
photoUrlList.Append(" }\n");
photoUrlList.Append(" strPage+=\"</select>\";\n");
photoUrlList.Append(" strPage+=\"<a href='javascript:ShowUrlList(\"+(page+1)+\")'>[下一张]</a> <a href='javascript:ShowUrlList(\"+TotalPage+\")'>[最后一张]</a> 第\"+i+\"张 共\"+TotalPage+\"张</td></tr></table>\";}\n");
photoUrlList.Append(" document.getElementById('PhotoUrlList').innerHTML=strPage;\n");
photoUrlList.Append("}\n");
photoUrlList.Append("ShowUrlList(1);\n");
}
photoUrlList.Append("</script>\n");
return photoUrlList.ToString();
}
</ms:script>
<xsl:param name="generalid" />
<xsl:output method="html" />
<xsl:template match="/">
<xsl:value-of disable-output-escaping="yes" select="csharp:GetPhotoUrlList(1,760,400,5,1,NewDataSet/Table/PhotoUrl,pe:UpLoadDir())"/>
</xsl:template>
</xsl:transform>]]></LabelTemplate>
<OutType>
</OutType>
<CacheTime>60</CacheTime>
<attributes>
<name>generalid</name>
<default>1</default>
<intro>图片ID</intro>
</attributes>
</root>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?