雅灰网站显示图片(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 &gt; 0)
            {
                imgsetting = " onload='if(this.width&gt;" + imgWidth + ") this.width=" + imgWidth + "'";
            }
            else
            {
                imgWidth = 550;
            }
            if (imgHeight &lt;= 0)
            {
                imgHeight = 400;
            }

            newphotourl.Append("&lt;div id='imgBox'&gt;&lt;/div&gt;");
            newphotourl.Append("&lt;script language='javascript'&gt;\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=\"&lt;a href='\"+PhotoUrl+\"' target='PhotoView'&gt;&lt;img src='\"+PhotoUrl+\"' border='0'" + imgsetting + "&gt;&lt;/a&gt;\";\n");
            newphotourl.Append("  }else if(FileExt=='swf'){\n");
            newphotourl.Append("    strHtml=\"&lt;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'&gt;&lt;param name='movie' value='\"+PhotoUrl+\"'&gt;&lt;param name='quality' value='high'&gt;&lt;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'&gt;&lt;/embed&gt;&lt;/object&gt;\";\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("&lt;/script&gt;\n");

            return newphotourl.ToString();
        }


        public string GetUrlArray(string originUrl,string uploadfiledir)
        {
            StringBuilder urlArray = new StringBuilder("");
            int i = 0;
            urlArray.Append("&lt;script language='javascript'&gt;\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("&lt;/script&gt;\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 &lt; 1)
            {
                cols = 1;
            }
            if (maxPerPage &lt; 1)
            {
                maxPerPage = 1;
            }

            string urls = GetUrlArray(originUrl,uploadfiledir);
            photoUrlList.Append(urls);

            photoUrlList.Append("&lt;div id='PhotoUrlList'&gt;&lt;/div&gt;");
            photoUrlList.Append("&lt;script language='javascript'&gt;\n");
            if (showType == 0)
            {
                photoUrlList.Append("for(var i=0;i&lt;arrUrl.length;i++){\n");
                photoUrlList.Append("  document.write(\"&lt;a href='#Title' onclick=ViewPhoto('\"+arrUrl[i]+\"')&gt;\"+arrUrlName[i]+\"&lt;/a&gt;&amp;nbsp;&amp;nbsp;\");\n");
                photoUrlList.Append("  if((i+1)%" + cols + "==0&amp;&amp;i+1&lt;arrUrl.length){document.write('&lt;br /&gt;');}\n");
                photoUrlList.Append("}\n");
            }
            else
            {
                string imgsetting = "";
                if (imgWidth &gt; 0)
                {
                    imgsetting += " width='" + imgWidth + "'";
                }
                if (imgHeight &gt; 0)
                {
                    imgsetting += " heigth='" + imgHeight + "'";

                }
                photoUrlList.Append("function ShowUrlList(page){\n");
                photoUrlList.Append("  if(arrUrl.length&lt;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&lt;1) page=1;\n");
                photoUrlList.Append("  if(page&gt;TotalPage) page=TotalPage;\n");
                photoUrlList.Append("  var strPage='&lt;table&gt;&lt;tr&gt;';\n");
                photoUrlList.Append("  for(var i=(page-1)*MaxPerPage;i&lt;arrUrl.length&amp;&amp;i&lt;page*MaxPerPage;i++){\n");
                photoUrlList.Append("    strPage+=\"&lt;td&gt;&lt;a href='#Title' onclick=ViewPhoto('\"+arrUrl[i]+\"')&gt;&lt;img src='\"+arrUrl[i]+\"' border='0' " + imgsetting + "&gt;&lt;/a&gt;&lt;/td&gt;\";\n");
                photoUrlList.Append("    if((i+1)%" + cols + "==0&amp;&amp;i+1&lt;MaxPerPage){strPage+='&lt;/tr&gt;&lt;tr&gt;';}\n");
                photoUrlList.Append("  }\n");
                photoUrlList.Append("  strPage+=\"&lt;/tr&gt;&lt;/table&gt;\";\n");
                photoUrlList.Append("  if(TotalPage&gt;1){strPage+=\"&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;a href='javascript:ShowUrlList(1)'&gt;[第一张]&lt;/a&gt; &lt;a href='javascript:ShowUrlList(\"+(page-1)+\")'&gt;[上一张]&lt;/a&gt;\"; \n");
                photoUrlList.Append("    strPage+=\"&lt;select name='imagelist' onChange='ShowUrlList(this[this.selectedIndex].value)'&gt;\";\n");
                photoUrlList.Append("    for(var j=1;j&lt;=arrUrl.length;j++){\n");
                photoUrlList.Append("      strPage+=\"&lt;option value=\"+j+\"\";\n");
                photoUrlList.Append("      if(j==page){strPage+=\" selected \";}\n");
                photoUrlList.Append("      strPage+=\"&gt;第\"+j+\"张&lt;/option&gt;\";\n");
                photoUrlList.Append("    }\n");
                photoUrlList.Append("    strPage+=\"&lt;/select&gt;\";\n");
                photoUrlList.Append("    strPage+=\"&lt;a href='javascript:ShowUrlList(\"+(page+1)+\")'&gt;[下一张]&lt;/a&gt; &lt;a href='javascript:ShowUrlList(\"+TotalPage+\")'&gt;[最后一张]&lt;/a&gt; 第\"+i+\"张 共\"+TotalPage+\"张&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;\";}\n");
                photoUrlList.Append("  document.getElementById('PhotoUrlList').innerHTML=strPage;\n");
                photoUrlList.Append("}\n");
                photoUrlList.Append("ShowUrlList(1);\n");
            }
            photoUrlList.Append("&lt;/script&gt;\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 + -
显示快捷键?