<%@ Page Language="C#" AutoEventWireup="false" %>
<%@ Register TagPrefix="Hishop" Namespace="Hishop.Web.Controls" Assembly="Hishop.Web.Controls" %>
<%@ Register TagPrefix="Hishop" Namespace="Hishop.Web.Management" Assembly="Hishop.Web.Management" %>
<%@ Register TagPrefix="Kindeditor" Namespace="kindeditor.Net" Assembly="kindeditor.Net" %>
<%@ Register TagPrefix="Hishop" Namespace="Hishop.Web.Validator" Assembly="Hishop.Web.Validator" %>
<%@ Register TagPrefix="UI" Namespace="ASPNET.WebControls" Assembly="ASPNET.WebControls" %>
<%@ Import Namespace="Hishop.SystemServices" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <Hishop:HeadContainer ID="HeadContainer1" runat="server" />
    <Hishop:PageTitle ID="PageTitle1" runat="server" />
    <link rel="stylesheet" href="../../utility/validate/pagevalidator.css" type="text/css" />
    <link rel="stylesheet" href="../css/Hishopv5.css" type="text/css" />
    <script type="text/javascript" src="../../utility/jquery-1.3.2.min.js"></script>
    <script type="text/javascript" src="../../utility/validate/pagevalidator.js"></script>
    
    <script type="text/javascript" src="../js/Hishopv5.js"></script>
<script type="text/javascript" language="javascript">
    $(document).ready(function() {
        $("#ImageDataList table td div").mouseover(function() {
            var className = $(this).attr("class");
            if (className.indexOf("imageLink")) {
                $(this).attr("class", "imageItem imageOver");
            }
        }).mouseout(function() {
            $(this).attr("class", "imageItem imageLink");
        });
    });
    jQuery.myfn = {
        OpenWindow: function(dlg) {
            if (dlg == 1) {
                if (dialogChangeName.get_isShowing()) {
                    dialogChangeName.Close();
                }
                else {
                    dialogChangeName.Show();
                }
            } else if (dlg == 2) {
                if (dialogReplace.get_isShowing()) {
                    dialogReplace.Close();
                }
                else {
                    dialogReplace.Show();
                }
            } else if (dlg == 3) {
                if (dialogMove.get_isShowing()) {
                    dialogMove.Close();
                }
                else {
                    dialogMove.Show();
                }
            }
        }
    };

    //文件移动
    function MoveImg() {
        var frm = document.aspnetForm;
        var isFlag = false;
        for (i = 0; i < frm.length; i++) {
            var e = frm.elements[i];
            if (e.checked) {
                isFlag = true;
                break;
            }
        }
        if (isFlag)
            $.myfn.OpenWindow(3);
        else
            alert("请选择需要移动的图片！");
    }
    //确定移除
    function TrueMoveImg() {
        if (confirm("真的确定移到此分类？")) {
            return true;
        }
        else
            return false;
    }

    //替换
    function RePlaceImg(imgSrc, imgId) {
        document.getElementById("ImageGallery_RePlaceImg").value = imgSrc;
        document.getElementById("ImageGallery_RePlaceId").value = imgId;
        $.myfn.OpenWindow(2);
    }

    //改名
    function ReImgName(imgName, imgId) {
        document.getElementById("ImageGallery_ReImageDataName").value = imgName;
        document.getElementById("ImageGallery_ReImageDataNameId").value = imgId;
        //DivWindowOpen(640, 200, 'ImageDataWindowName');
        $.myfn.OpenWindow(1);
        document.getElementById("ImageGallery_ReImageDataName").focus();
    }

    //复制
    function CopyImgUrl(txt) {
        var myHerf = window.location.host;
        var txt = "http://" + myHerf + applicationPath + txt;
        if (window.clipboardData) {
            window.clipboardData.clearData();
            window.clipboardData.setData("Text", txt);
            alert("复制成功！")
        }
        else if (navigator.userAgent.indexOf("Opera") != -1) {
            window.location = txt;
        }
        else if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            }
            catch (e) {
                alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将 'signed.applets.codebase_principal_support'设置为'true'");
            }
            var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
            if (!clip)
                return;
            var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
            if (!trans)
                return;
            trans.addDataFlavor('text/unicode');
            var str = new Object();
            var len = new Object();
            var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
            var copytext = txt;
            str.data = copytext;
            trans.setTransferData("text/unicode", str, copytext.length * 2);
            var clipid = Components.interfaces.nsIClipboard;
            if (!clip)
                return false;
            clip.setData(trans, null, clipid.kGlobalClipboard);
            alert("复制成功！")
        }
    }
    //反选
    function CheckReverse() {
        var frm = document.aspnetForm;
        for (i = 0; i < frm.length; i++) {
            e = frm.elements[i];
            if (e.type == 'checkbox' && e.name.indexOf('checkboxCol') != -1) {
                if (e.checked == false)
                    e.checked = true;
                else
                    e.checked = false;
            }
        }
    }

    //全选
    function CheckClickAll() {
        var frm = document.aspnetForm;
        for (i = 0; i < frm.length; i++) {
            e = frm.elements[i];
            if (e.type == 'checkbox' && e.name.indexOf('checkboxCol') != -1) {
                e.checked = true;
            }
            if (e.type == 'checkbox' && e.name.indexOf('checkboxHead') != -1)
                e.checked = false;
        }
    }
  </script>    
</head>
<body>
    <form id="aspnetForm" runat="server">
        <div>           
            <div class="PageTitleArea">
                <div class="PageTitle">图库管理</div>
                <div style="width: 80%;">图库管理</div>
            </div>
            <div>
                <ul class="anchors clearfix">
                <li class="tabs-selected"><a href='./ImageGallery.aspx'><img src="../images/bmquanxian.gif" alt="" />图库管理</a></li>
                <li><a href='./ImageUploader.aspx'><img src="../images/guoqidecuxiao.gif" alt="" />上传图片</a></li>
                <li><a href='./ImageCategorys.aspx'><img src="../images/shiyoudecuxiao.gif" alt="" />分类管理</a></li>
                </ul>
            </div>
            <Hishop:ImageGallery ID="ImageGallery" runat="server">
                <SkinTemplate> 
                    <Hishop:StatusMessage ID="Status" runat="server" Visible="False" />
<div class="dataarea mainwidth clearfix">
  <table width="100%" border="0" cellspacing="5" cellpadding="0">
  <tr>
    <td valign="top" style="padding-right:5px;">
    <!--搜索-->
    <div class="functionHandleArea">
			<!--分页功能-->
			<div class="pageHandleArea">
			  <table width="100%" border="0" cellspacing="5" cellpadding="0">
			    <tr>
			      <td width="72%" nowrap="nowrap"> <ul>
				<li class="paginalNum"><span>图片数量：</span><a class="selectthis"><asp:Label ID="lblImageData" runat="server" Text=""></asp:Label></a></li>
			  </ul></td>
			  <td width="19%"><asp:TextBox ID="txtWordName" Width="180" runat="server" CssClass="forminput" /></td>
			  <td width="9%"><a class="linkSub"><asp:Button ID="btnImagetSearch" runat="server" Text="查询" CssClass="searchbutton"/></a></td>
		        </tr>
		      </table>			 
	        </div>
			<!--结束-->
      <div class="batchHandleArea">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
          <td width="77%">
				<a href="javascript:void(0)" onclick="CheckClickAll()">全选</a>
				<a href="javascript:void(0)" onclick="CheckReverse()">反选</a>
				<a href="javascript:void(0)" onclick="MoveImg()">移动到</a>
                 <Hishop:ImageLinkButton ID="btnDelete" OnClientClick="return confirm('确定删除所选图片吗？')" runat="server" Text="删除" IsShow="true"  />
		    </td>
            <td width="20%" nowrap="nowrap">
            排序:          
             <Hishop:ImageOrderDropDownList AutoPostBack="true" runat="server" ID="ImageOrder"  />
            </td>
          </tr>
        </table>        
      </div>
	</div>
    <!--图片列表-->
    <div class="imageDataLeft" id="ImageDataList">
        <!--图片列表begin-->
		 <asp:DataList ID="photoDataList" runat="server" RepeatColumns="4" ShowFooter="False" ShowHeader="False"  DataKeyField="PhotoId" CellPadding="0" RepeatDirection="Horizontal">
              <itemtemplate>
              <div class="imageItem imageLink">
		        <dl>
                   <dd>                   
                     <a href='<%=ImageGallery.GlobalsPath%><%# Eval("PhotoPath")%>' target="_blank" title="<%# Eval("PhotoName")%>">
                         <img src='<%=ImageGallery.GlobalsPath%>/Admin/PicRar.aspx?P=<%# Eval("PhotoPath")%>&W=140&H=110'/>
                         <asp:HiddenField ID="HiddenFieldImag" Value= '<%# DataBinder.Eval(Container.DataItem, "PhotoPath")%> ' runat="server" />
                     </a>
                   </dd> 
                  </dl>
                  <ul>
                    <p><%# ImageGallery.TruncStr(DataBinder.Eval(Container.DataItem, "PhotoName").ToString(), 20)%></p>
		            <label><asp:CheckBox ID="checkboxCol" runat="server"/>选择</label>
                    <em>
                        <a href="javascript:CopyImgUrl('<%# DataBinder.Eval(Container.DataItem, "PhotoPath")%>')">复制</a>
                        <a href="javascript:RePlaceImg('<%# DataBinder.Eval(Container.DataItem, "PhotoPath")%>','<%# DataBinder.Eval(Container.DataItem, "PhotoId")%>')">替换</a>
                        <a href="javascript:ReImgName('<%# DataBinder.Eval(Container.DataItem, "PhotoName")%>','<%# DataBinder.Eval(Container.DataItem, "PhotoId")%>')">改名</a>
                        <!--<a href="javascript:DelImg('<%# DataBinder.Eval(Container.DataItem, "PhotoPath")%>','<%# DataBinder.Eval(Container.DataItem, "PhotoId")%>')">删除</a>--> 
                        <Hishop:ImageLinkButton ID="btnDelPhoto" OnClientClick="return confirm('确定删除此图片吗？')" runat="server" Text="删除" IsShow="true"  /> 
                       </em>
                  </ul>
		        </div>
              </itemtemplate>
            </asp:DataList> 
        <!--图片列表-->
      </div>
      <!--翻页页码-->
          <div class="pageNumber">
			   <UI:Pager runat="server" PageSize="20"  ListToPaging="photoDataList" RunningMode="Get" ID="pager" />
        </div>
    </td>
    <td valign="top" width="10%">
    <!--右边-->
     <div class="imageDataRight">
       <div class="borderthin">
        <ul class="RightHead">图片分类:</ul>
         <Hishop:ImageTypeLabel runat="server" ID="ImageTypeID" />
        <ul class="pad10"><a href="<%= ImageGallery.GlobalsPath%>/admin/shop/ImageCategorys.aspx" class="submit_type">分类管理</a></ul>
      </div>
      </div> 
    </td>
  </tr>
</table>
</div>	
<!--更改图片名称-->
        <UI:Dialog AnimationType="Live" ShowTransition="Fade" AnimationSlide="ExponentialDecelerate"
            CloseTransition="Fade" AnimationDuration="600" Modal="false"
            AllowDrag="true" Alignment="MiddleCentre" Title="文件名称更改"
            ID="dialogChangeName" runat="server" Width="430" Height="200" X="200" Y="300" >
            <Content>
             <div style="padding:10px;">
                  <span class="formitemtitle Pw_100">图片名称：<em>*</em></span>
                  <asp:TextBox name="ReImageDataName" runat="server" Text='' CssClass="forminput" ID="ReImageDataName" Width="250"></asp:TextBox>
                  <asp:HiddenField ID="ReImageDataNameId" Value='' runat="server" />
                  <div id="ReImageDataNameTip" style="height:30px;" runat="server"></div>
                    <Hishop:ValidateTarget ID="validateTargetName" ContainerId="ValidatorContainer" runat="server" ControlToValidate="ReImageDataName" Description="长度限制在30个字符以内" Nullable="false" ValidateGroup="NameSet">
                        <Validators>
                            <Hishop:InputStringClientValidator ErrorMessage="图片名称长度请在1到30个字符之间" LowerBound="1" UpperBound="30" />
                        </Validators>
                    </Hishop:ValidateTarget>
               <asp:Button ID="btnSaveImageDataName" runat="server" OnClientClick="return PageIsValid('NameSet');" Text="确 定"  style="float:right;margin-right:20px;margin-bottom:10px;"/>
            </div>
            </Content>
        </UI:Dialog>

<!--图片路径替换-->
        <UI:Dialog AnimationType="Live" ShowTransition="Fade" AnimationSlide="ExponentialDecelerate"
            CloseTransition="Fade" AnimationDuration="600" Modal="false"
            AllowDrag="true" Alignment="MiddleCentre" Title="请上传替换的图片文件"
            ID="dialogReplace" runat="server" Width="430" X="200" Y="300" >
            <Content>
            <div style="padding:10px;">
                  <span>上传图片：<em>*</em></span>
                  <asp:FileUpload ID="FileUpload" runat="server"/>
               <asp:HiddenField ID="RePlaceImg" Value='' runat="server" />
               <asp:HiddenField ID="RePlaceId" Value='' runat="server" />
               <asp:Button ID="btnSaveImageData" runat="server" Text="确定替换"  CssClass="submit_DAqueding"/>
            </div>
            </Content>
        </UI:Dialog>

<!--文件移动-->
        <UI:Dialog AnimationType="Live" ShowTransition="Fade" AnimationSlide="ExponentialDecelerate"
            CloseTransition="Fade" AnimationDuration="600" Modal="false"
            AllowDrag="true" Alignment="MiddleCentre" Title="请选择移动保存的目录位置"
            ID="dialogMove" runat="server" Width="400" X="200" Y="300" >
            <Content>
               <ul>
                    <table cellspacing="4" cellpadding="0" border="0" width="100%">
                    <tbody>
                    <tr>
                    <th>
                    <span class="formitemtitle Pw_100">保存位置：</span>
                    </th>
                    <td>
                       <Hishop:ImageDataGradeDropDownList ID="dropImageFtp" runat="server" />
                    </td>
                    </tr>       
                    </tbody>
                    </table>    
               </ul>
               <ul class="up Pa_100">
               <li></li>
               <li>
                   <asp:Button ID="btnMoveImageData" runat="server" Text="确定移除"  CssClass="submit_DAqueding" OnClientClick="return TrueMoveImg()"/>
               </li>
              </ul>
            </Content>
        </UI:Dialog>
                </SkinTemplate>
            </Hishop:ImageGallery>
        </div>
        <br />
       <div style="margin:0px auto;width:500px;clear:both;">
            <hr style="width:500px;" />
            <Hishop:SiteCopyright ID="SiteCopyright1" runat="server" />
        </div>
        <br />
        <Hishop:ValidatorContainer runat="server" ID="ValidatorContainer" />
    </form>
</body>
</html>