模板管理 编辑文件功能

来源:互联网 发布:杂志制作软件 编辑:程序博客网 时间:2024/05/22 09:44
文件编辑功能:
1、
<span>
    <a href="templateResourceMgt.action?templateListType=${templateListType}&operatorType=3&template.templateId=<s:property value="#temp.templateId"/>"><s:text name="msg.portalMS.template.file.manage"/></a>
</span>
http://localhost:8080/portalMS/template/templateResourceMgt.action?templateListType=0&operatorType=3&template.templateId=59006
2、
<!-- 模板文件管理 -->
<action name="templateResourceMgt" class="templateAction" method="templateResourceMgt">
        <result name="templateFile_iframe">/template/templateFile_iframe.jsp</result>
</action>
templateFile_iframe.jsp
<!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">
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="../common/language.jsp"  %>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="page" uri="/WEB-INF/tlds/paginated.tld"%>
<link rel="stylesheet" type="text/css"
    href="../js/ext/resources/css/ext-all.css" />
<link href="../style/base<%=language_css%>.css" rel="stylesheet" type="text/css" />
<%@ include file="../common/commonJS.jsp" %>
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript" src="../js/jquery.validate.js"></script>
<script type="text/javascript" src="../js/tree.js"></script>
<script type="text/javascript" src="../js/resourcemanage.js"></script>
<script type="text/javascript" src="../js/resourcedialogShow.js"></script>
<script type="text/javascript" src="../js/dialogShow.js"></script>
<script type="text/javascript" src="<%=path%>/dwr/engine.js"></script>
<script type="text/javascript" src="<%=path%>/dwr/interface/TreeDWR.js"></script>
<script type="text/javascript" src="../js/fullHeight.js"></script>
<script type="text/javascript" src="../js/Calendar/WdatePicker.js"></script>
<script type="text/javascript" src="../js/tree/jsframework.js"></script>

<title><s:text name="msg.portalMS.template.file.manage"/></title>  
<style>
* { padding:0; margin:0; }
html, body { height:100%; border:none 0; ie6PngRepair:true;}
iframe { width:100%; height:100%; border:none 0;}
</style>
    
  <!---导航 --->
  <div class="r_nav">
    <div class="left"><img src="../images/nav_l.gif" width="5" height="29" /></div>
    <div class="ct"><s:text name="msg.portalMS.system.current.position"/><s:text name="msg.portalMS.template.manager"/> &gt;
<!--    <s:if test='%{type=="1"}'><s:text name="msg.portalMS.template.type.index"/></s:if>-->
<!--    <s:if test='%{type=="2"}'><s:text name="msg.portalMS.template.type.column"/></s:if>-->
<!--    <s:if test='%{type=="3"}'><s:text name="msg.portalMS.template.type.asset"/></s:if>-->
<!--    <s:if test='%{type=="4"}'><s:text name="msg.portalMS.template.type.detail"/></s:if> -->
    <s:text name="msg.portalMS.template.edition"/>&gt;
    <s:text name="msg.portalMS.template.file.manage"/>
    </div>
    <div class="right"><img src="../images/nav_r.jpg" width="5" height="29" /></div>
  </div>
</head>  

<body>  
<input type="hidden" id="templateListType" name="templateListType" value="${templateListType}"/>
<input type="hidden" id="operatorType" name="operatorType" value="${operatorType}"/>
<input type="hidden" name="template.templateId" value="${template.templateId}"/>
<input type="hidden" id="templateFilePath" name="templateFilePath" value="${templateFilePath}"/>
<iframe id="frame_content" src="../template/templateFile_frame.jsp?templateListType=<%=request.getParameter("templateListType")%>&operatorType=<%=request.getParameter("operatorType")%>&template.templateId=<%=request.getParameter("template.templateId")%>&templateFilePath=<%=request.getParameter("templateFilePath")%>" scrolling="no" frameborder="0"  >
</iframe>  
</body>  
</html>  

tree.js
/**************************************************************************
    Copyright (c) 2009 xxxxxx dhm.portalMS
    JavaScript Tree
    Version 1.0
**************************************************************************/

// Arrays for nodes and icons
var nodes            = new Array();;
var openNodes    = new Array();
var icons            = new Array(6);
var iconsWithStatus = new Array(8);
var ckNode     = null;
var chooseNodes = null;
var rootNodeParent = null;
var hasStatus = false;

function nodeObj(nodeID,bottom){
    this.nodeID = nodeID;
    this.bottom = bottom;
}
// Loads all icons that are used in the tree
function preloadIcons() {
    icons[0] = new Image();
    icons[0].src = "../images/plus.gif";
    icons[1] = new Image();
    icons[1].src = "../images/plusbottom.gif";
    icons[2] = new Image();
    icons[2].src = "../images/minus.gif";
    icons[3] = new Image();
    icons[3].src = "../images/minusbottom.gif";
    icons[4] = new Image();
    icons[4].src = "../images/folder.gif";
    icons[5] = new Image();
    icons[5].src = "../images/folderopen.gif";
    
    iconsWithStatus[0] = new Image();
    iconsWithStatus[0].src = "../images/folder_waitaudit.gif";
    iconsWithStatus[1] = new Image();
    iconsWithStatus[1].src = "../images/folder_waitaudit_open.gif";
    iconsWithStatus[2] = new Image();
    iconsWithStatus[2].src = "../images/folder_waitdistribute.gif";
    iconsWithStatus[3] = new Image();
    iconsWithStatus[3].src = "../images/folder_waitdistribute_open.gif";
    iconsWithStatus[4] = new Image();
    iconsWithStatus[4].src = "../images/folder_unthread.gif";
    iconsWithStatus[5] = new Image();
    iconsWithStatus[5].src = "../images/folder_unthread_open.gif";
    iconsWithStatus[6] = new Image();
    iconsWithStatus[6].src = "../images/folder_pass.gif";
    iconsWithStatus[7] = new Image();
    iconsWithStatus[7].src = "../images/folder_pass_open.gif";
}
// Create the tree
function createTree(arrName, startNode, clickNode, chseNodes) {
    nodes = arrName;
    chooseNodes = chseNodes;
    if (nodes.length > 0) {
        preloadIcons();
        if (startNode == null) startNode = 0;
        rootNodeParent = startNode;
        if(clickNode != null){
            ckNode = clickNode;
        }else{
            ckNode = null;
        }
        //if (openNode != 0 || openNode != null) setOpenNodes(openNode);
    
        /*if (startNode !=0) {
            var nodeValues = nodes[getArrayId(startNode)].split("|");
            document.write("<a href=\"" + nodeValues[3] + "\" onmouseover=\"window.status='" + nodeValues[2] + "';return true;\" onmouseout=\"window.status=' ';return true;\"><img src=\"../images/folderopen.gif\" align=\"absbottom\" alt=\"\" />" + nodeValues[2] + "</a><br />");
        } else document.write("<img src=\"../images/base.gif\" align=\"absbottom\" alt=\"\" />Website<br />");*/
    
        var recursedNodes = new Array();
        addNode(startNode, recursedNodes);
        setChooseNodes();
    }
}
// Returns the position of a node in the array
function getArrayId(node) {
    for (i=0; i<nodes.length; i++) {
        var nodeValues = nodes[i].split("|");
        if (nodeValues[0]==node) return i;
    }
}
// Puts in array nodes that will be open
function setOpenNodes(openNode) {
    for (i=0; i<nodes.length; i++) {
        var nodeValues = nodes[i].split("|");
        if (nodeValues[0]==openNode) {
            openNodes.push(nodeValues[0]);
            setOpenNodes(nodeValues[1]);
        }
    }
}
// Checks if a node is open
function isNodeOpen(node) {
    for (i=0; i<openNodes.length; i++)
        if (openNodes[i]==node) return true;
    return false;
}
// Checks if a node has any children
function hasChildNode(parentNode) {
    for (i=0; i< nodes.length; i++) {
        var nodeValues = nodes[i].split("|");
        if (nodeValues[1] == parentNode) return true;
    }
    return false;
}
// Checks if a node is the last sibling
function lastSibling (node, parentNode) {
    var lastChild = 0;
    for (i=0; i< nodes.length; i++) {
        var nodeValues = nodes[i].split("|");
        if (nodeValues[1] == parentNode)
            lastChild = nodeValues[0];
    }
    if (lastChild==node) return true;
    return false;
}
// Adds a new node to the tree
function addNode(parentNode, recursedNodes) {
    for (var i = 0; i < nodes.length; i++) {

        var nodeValues = nodes[i].split("|");
        if (nodeValues[1] == parentNode) {
            
            var ls    = lastSibling(nodeValues[0], nodeValues[1]);
            var hcn    = hasChildNode(nodeValues[0]);
            //var ino = isNodeOpen(nodeValues[0]);
            var ino = true;
            //show stauts true:yes false:no
            if(nodeValues.length >= 7){
                hasStatus = true;
            }
            // Write out line & empty icons
            
            for (g=0; g<recursedNodes.length; g++) {
                if (recursedNodes[g] == 1) document.write("<img src=\"../images/line.gif\" align=\"absbottom\" alt=\"\" />");
                else  document.write("<img src=\"../images/empty.gif\" align=\"absbottom\" alt=\"\" />");
            }

            // put in array line & empty icons
            if (ls) recursedNodes.push(0);
            else recursedNodes.push(1);
            //document.write("<input type=\"checkbox\"/>");
            
            // Write out join icons
            if (hcn) {
                if (ls) {
                    if(hasStatus){
                        document.write("<a href=\"javascript: ocs(" + nodeValues[0] + "," + nodeValues[6] + ", 1);\"><img id=\"join" + nodeValues[0] + "\" src=\"../images/");
                    }else{
                        document.write("<a href=\"javascript: oc(" + nodeValues[0] + ", 1);\"><img id=\"join" + nodeValues[0] + "\" src=\"../images/");
                    }
                         if (ino) document.write("minus");
                        else document.write("plus");
                    document.write("bottom.gif\" align=\"absbottom\" alt=\"Open/Close node\" /></a>");
                } else {
                    if(hasStatus){
                        document.write("<a href=\"javascript: ocs(" + nodeValues[0] + "," + nodeValues[6] + ", 0);\"><img id=\"join" + nodeValues[0] + "\" src=\"../images/");
                    }else{
                        document.write("<a href=\"javascript: oc(" + nodeValues[0] + ", 0);\"><img id=\"join" + nodeValues[0] + "\" src=\"../images/");
                    }
                        if (ino) document.write("minus");
                        else document.write("plus");
                    document.write(".gif\" align=\"absbottom\" alt=\"Open/Close node\" /></a>");
                }
            } else {
                if (ls) document.write("<img src=\"../images/joinbottom.gif\" align=\"absbottom\" alt=\"\" />");
                else document.write("<img src=\"../images/join.gif\" align=\"absbottom\" alt=\"\" />");
            }
            //根据风格生成radio或checkBox
            if(nodeValues[5] == 'radio'){
                if(ls){
                    if(nodeValues[0]==ckNode){
                        document.write("<input type=\"radio\" checked=\"checked\" name=\"portalMS_radio\" id=\"portalMS_" + nodeValues[0] + "\" value=\""+nodes[i]+"\"/>");
                    }else{
                        document.write("<input type=\"radio\" name=\"portalMS_radio\" id=\"portalMS_" + nodeValues[0] + "\" value=\""+nodes[i]+"\"/>");
                    }
                }else{
                    if(nodeValues[0]==ckNode){
                        document.write("<input type=\"radio\" checked=\"checked\" name=\"portalMS_radio\" id=\"portalMS_" + nodeValues[0] + "\" value=\""+nodes[i]+"\"/>");
                    }else{
                        document.write("<input type=\"radio\" name=\"portalMS_radio\" id=\"portalMS_" + nodeValues[0] + "\" value=\""+nodes[i]+"\"/>");
                    }
                }
            }else{
                
                if(ls){
                    //var nodeobj = new nodeObj(nodeValues[0],1);
                    if(hasStatus){
                        document.write("<input type=\"checkbox\" id=\"portalMS_" + nodeValues[0] + "\" name=\"1\" value=\"" + nodeValues[0] + "$" + nodeValues[1] + "\" onclick=\"onCheckBoxClickWithStatus(" + nodeValues[0] + "," + nodeValues[6] + ")\"/>");
                    }else{
                        document.write("<input type=\"checkbox\" id=\"portalMS_" + nodeValues[0] + "\" name=\"1\" value=\"" + nodeValues[0] + "$" + nodeValues[1] + "\" onclick=\"onCheckBoxClick(" + nodeValues[0] + ")\"/>");
                    }
                }else{
                    //var nodeobj = new nodeObj(nodeValues[0],0);
                    if(hasStatus){
                        document.write("<input type=\"checkbox\" id=\"portalMS_" + nodeValues[0] + "\" name=\"0\" value=\"" + nodeValues[0] + "$" + nodeValues[1] + "\" onclick=\"onCheckBoxClickWithStatus(" + nodeValues[0] + "," + nodeValues[6] + ")\"/>");
                    }else{
                        document.write("<input type=\"checkbox\" id=\"portalMS_" + nodeValues[0] + "\" name=\"0\" value=\"" + nodeValues[0] + "$" + nodeValues[1] + "\" onclick=\"onCheckBoxClick(" + nodeValues[0] + ")\"/>");
                    }
                }
            }
            // Start link
            document.write("<a href=\"" + nodeValues[3] + "\" onmouseover=\"window.status='" + nodeValues[2] + "';return true;\" onmouseout=\"window.status=' ';return true;\">");
            
            
            // Write out folder & page icons
            //if(nodeValues.length >=5){
            //    document.write("<img id=\"icon" + nodeValues[0] + "\" src=\"../images/folder")
            //    if (ino) document.write("open");
            //    document.write(".gif\" align=\"absbottom\" alt=\"Folder\" />");
            //}else{
            //根据类型生成文件夹或文件样式
            if(hasStatus){
                if (nodeValues[4] == 0 || nodeValues[4] == 2) {
                    document.write("<img id=\"icon" + nodeValues[0] + "\" src=\"../images/folder");
                    if(nodeValues[6] ==0){
                        document.write("_waitaudit");
                        if (ino) document.write("_open");
                        document.write(".gif\" align=\"absbottom\" alt="+$CON.WAIT_CHECK+" />");
                    }else if(nodeValues[6] ==2){
                        document.write("_waitdistribute");
                        if (ino) document.write("_open");
                        document.write(".gif\" align=\"absbottom\" alt="+$CON.WAIT_SYSAUTOPUB+" />");
                    }else if(nodeValues[6] ==1){
                        document.write("_unthread");
                        if (ino) document.write("_open");
                        document.write(".gif\" align=\"absbottom\" alt="+$CON.CHECK_FAIL+" />");
                    }else if(nodeValues[6] ==3){
                        document.write("_pass");
                        if (ino) document.write("_open");
                        document.write(".gif\" align=\"absbottom\" alt="+$CON.SYSAUTOPUB+" />");
                    }else{
                        if (ino) document.write("open");
                        document.write(".gif\" align=\"absbottom\" alt=\"Folder\" />");
                    }
                        //if (ino) document.write("open");
                    //document.write(".gif\" align=\"absbottom\" alt=\"Folder\" />");
                } else document.write("<img id=\"icon" + nodeValues[0] + "\" src=\"../images/page.gif\" align=\"absbottom\" alt=\"Page\" />");
            }else{
                if(nodeValues[4] == 0 || nodeValues[4] == 2) {
                    document.write("<img id=\"icon" + nodeValues[0] + "\" src=\"../images/folder");
                        if (ino) document.write("open");
                    document.write(".gif\" align=\"absbottom\" alt=\"Folder\" />");
                }else if(nodeValues[4] == 4){
                    document.write("<img id=\"icon" + nodeValues[0] + "\" src=\"../images/dataTemplate.gif\" align=\"absbottom\" alt=\"Page\" />");
                }else{
                    document.write("<img id=\"icon" + nodeValues[0] + "\" src=\"../images/page.gif\" align=\"absbottom\" alt=\"Page\" />");
                }
            }
            //}
            
            // Write out node name
            if(nodeValues[0] == ckNode){
                document.write("<span style='color:blue'>" + nodeValues[2] + "</span>");
                
            }else{                
                document.write("<span>" + nodeValues[2] + "</span>");
            }
            /*
            //如果要标识状态会用到nodeValues[6]
            if(nodeValues.length >= 7){
                if(nodeValues[6] ==0){
                    document.write("<img src=\"../images/u385.gif\" align=\"absbottom\" alt=\"待审核\" />");                
                }else if(nodeValues[6] ==2){
                    document.write("<img src=\"../images/u386.gif\" align=\"absbottom\" alt=\"待发布\" />");
                }else if(nodeValues[6] ==1){
                    document.write("<img src=\"../images/u388.gif\" align=\"absbottom\" alt=\"审核未通过\" />");
                }else if(nodeValues[6] ==3){
                    document.write("<img src=\"../images/u390.gif\" align=\"absbottom\" alt=\"已发布\" />");
                }else{
                    document.write("<img src=\"../images/u385.gif\" align=\"absbottom\" alt=\"待审核\" />");
                }
            }*/
            // End link
            document.write("</a><br />");
            
            // If node has children write out divs and go deeper
            if (hcn) {
                document.write("<div id=\"div" + nodeValues[0] + "\"");
                    if (!ino) document.write(" style=\"display: none;\"");
                document.write(">");
                addNode(nodeValues[0], recursedNodes);
                document.write("</div>");
            }
            
            // remove last line or empty icon
            recursedNodes.pop();
        }
    }
}
// Opens or closes a node
function oc(node, bottom) {
    var theDiv = document.getElementById("div" + node);
    var theJoin    = document.getElementById("join" + node);
    var theIcon = document.getElementById("icon" + node);
    
    if (theDiv.style.display == 'none') {
        if (bottom==1) theJoin.src = icons[3].src;
        else theJoin.src = icons[2].src;
        theIcon.src = icons[5].src;
        theDiv.style.display = '';
    } else {
        if (bottom==1) theJoin.src = icons[1].src;
        else theJoin.src = icons[0].src;
        theIcon.src = icons[4].src;
        theDiv.style.display = 'none';
    }
}
//Opens or closes a node with status
function ocs(node, status,bottom) {
    var theDiv = document.getElementById("div" + node);
    var theJoin    = document.getElementById("join" + node);
    var theIcon = document.getElementById("icon" + node);
    
    if (theDiv.style.display == 'none') {
        if (bottom==1) theJoin.src = icons[3].src;
        else theJoin.src = icons[2].src;
        if(status == 0){//待审核
            theIcon.src = iconsWithStatus[1].src;
        }else if(status == 1){//审核未通过
            theIcon.src = iconsWithStatus[5].src;
        }else if(status == 2){//待发布
            theIcon.src = iconsWithStatus[3].src;
        }else if(status == 3){//已发布
            theIcon.src = iconsWithStatus[7].src;
        }else{//Folder
            theIcon.src = icons[5].src;
        }        
        theDiv.style.display = '';
    } else {
        if (bottom==1) theJoin.src = icons[1].src;
        else theJoin.src = icons[0].src;
        if(status == 0){//待审核
            theIcon.src = iconsWithStatus[0].src;
        }else if(status == 1){//审核未通过
            theIcon.src = iconsWithStatus[4].src;
        }else if(status == 2){//待发布
            theIcon.src = iconsWithStatus[2].src;
        }else if(status == 3){//已发布
            theIcon.src = iconsWithStatus[6].src;
        }else{//Folder
            theIcon.src = icons[4].src;
        }        
        theDiv.style.display = 'none';
    }
}
// Opens a node
function on(node,bottom){
    var theDiv = document.getElementById("div" + node);
    var theJoin    = document.getElementById("join" + node);
    var theIcon = document.getElementById("icon" + node);
    if(theDiv != null && theJoin != null && theIcon != null){
        if (theDiv.style.display == 'none') {
            if (bottom==1) theJoin.src = icons[3].src;
            else theJoin.src = icons[2].src;
            theIcon.src = icons[5].src;
            theDiv.style.display = '';
        }
    }    
}
//Opens a node with status
function ons(node,status,bottom){
    var theDiv = document.getElementById("div" + node);
    var theJoin    = document.getElementById("join" + node);
    var theIcon = document.getElementById("icon" + node);
    if(theDiv != null && theJoin != null && theIcon != null){
        if (theDiv.style.display == 'none') {
            if (bottom==1) theJoin.src = icons[3].src;
            else theJoin.src = icons[2].src;
            if(status == 0){//待审核
                theIcon.src = iconsWithStatus[1].src;
            }else if(status == 1){//审核未通过
                theIcon.src = iconsWithStatus[5].src;
            }else if(status == 2){//待发布
                theIcon.src = iconsWithStatus[3].src;
            }else if(status == 3){//已发布
                theIcon.src = iconsWithStatus[7].src;
            }else{//Folder
                theIcon.src = icons[5].src;
            }        
            theDiv.style.display = '';
        }
    }    
}
// Push and pop not implemented in IE
if(!Array.prototype.push) {
    function array_push() {
        for(var i=0;i<arguments.length;i++)
            this[this.length]=arguments[i];
        return this.length;
    }
    Array.prototype.push = array_push;
}
if(!Array.prototype.pop) {
    function array_pop(){
        lastElement = this[this.length-1];
        this.length = Math.max(this.length-1,0);
        return lastElement;
    }
    Array.prototype.pop = array_pop;
}
//当checkbox被选择或取消时,设置该节点所有子节点也被选择或取消
function onCheckBoxClick(node){
    var isChecked = document.getElementById("portalMS_"+node).checked;    
    var isBottom = document.getElementById("portalMS_"+node).name;
    //打开当前节点的所有子节点
    on(node,isBottom);
    //设置所有子节点选中或取消状态
    setChildrenChecked(node,isChecked);
    //设置父节点选中或取消息状态
    setParentsChecked(node, isChecked);
}

function onCheckBoxClickWithStatus(node,status){
    var isChecked = document.getElementById("portalMS_"+node).checked;    
    var isBottom = document.getElementById("portalMS_"+node).name;
    ons(node,status,isBottom);
    setChildrenCheckedWithStatus(node,isChecked);
}
//递归设置所有子节点选中或取消状态
function setChildrenChecked(parentNode,isChecked){
    for(var i=0; i<nodes.length; i++){
        var nodeValues = nodes[i].split("|");
        if (nodeValues[1] == parentNode) {            
            //set checkbox checked
            document.getElementById("portalMS_"+nodeValues[0]).checked = isChecked;
            var isBottom = document.getElementById("portalMS_"+nodeValues[0]).name;
            on(nodeValues[0],isBottom);
            var hcn    = hasChildNode(nodeValues[0]);
            if(hcn){                
                setChildrenChecked(nodeValues[0],isChecked);    
            }
        }        
    }
}
//递归设置父节点选中或取消状态(目前只支持取消状态)
function setParentsChecked(currentNode, isChecked){
    //只支持取消息状态,因为删除时可能只删除所有子节点而不包括父节点
    if(isChecked == false){
        var parentId = null;
        for(var i=0; i<nodes.length; i++){
            var nodeValues = nodes[i].split("|");
            if(nodeValues[0] == currentNode){
                parentId = nodeValues[1];
                //当父节点为根时不用设置
                if(parentId != rootNodeParent){
                    document.getElementById("portalMS_"+nodeValues[1]).checked = isChecked;
                }
            }
        }
        //当父节点为根时停止递归
        if(parentId != rootNodeParent){
            setParentsChecked(parentId, isChecked);
        }
    }
}

function setChildrenCheckedWithStatus(parentNode,isChecked){
    for(var i=0; i<nodes.length; i++){
        var nodeValues = nodes[i].split("|");
        if (nodeValues[1] == parentNode) {            
            //set checkbox checked
            document.getElementById("portalMS_"+nodeValues[0]).checked = isChecked;
            var isBottom = document.getElementById("portalMS_"+nodeValues[0]).name;
            ons(nodeValues[0],nodeValues[6],isBottom);
            var hcn    = hasChildNode(nodeValues[0]);
            if(hcn){                
                setChildrenCheckedWithStatus(nodeValues[0],isChecked);    
            }
        }        
    }
}
function setChooseNodes(){
    if(chooseNodes != null && chooseNodes != ''){
        for(var i=0; i<chooseNodes.length; i++){
            var chkBox = document.getElementById("portalMS_"+chooseNodes[i]);
            if(chkBox != null && chkBox != '' && chkBox.type == 'checkbox'){
                chkBox.checked = true;
            }
        }
    }
}
function getDatasOfRadio(){
    var nodeString = "";
    var radios = document.getElementsByName("portalMS_radio");
    if(radios != null){
        for(var i=0; i<radios.length; i++){
            if(radios[i].checked){
                nodeString = radios[i].value;
            }
        }
    }
    return nodeString;
}
function getDatasOfCheckedBox(){
    var ids="";
    var j=0;
    for(var i=0;i<nodes.length;i++){
       var nodeValues = nodes[i].split("|");
       if(document.getElementById("portalMS_"+nodeValues[0])!= null && document.getElementById("portalMS_"+nodeValues[0]).checked){
           if(ids == ""){
               ids = ids + nodeValues[0];
           }else{
               ids = ids + "," + nodeValues[0];
           }           
       }
    }
//    if(ids.length == 0){
//        showText('信息提示','请选择一个再提交!',400,200,0,true);       
//    }
    return ids;
}  

WdatePicker.js
/*
 * 工程名: portalMS
 * 文 件名: WdatePicker.js
 * 版      权: Copyright (c) 2009 xxxxxx All Rights Reserved.
 * 描      述: 日期控件
 * 修 改 人:
 * 修改时间:
 * 跟踪单号:
 * 修改单号:
 * 修改内容:
 */
var $dp,WdatePicker;(function(){
    var _={
$wdate:true,
$dpPath:"",
$crossFrame:true,
doubleCalendar:false,
position:{},
lang:"auto",
skin:"default",
dateFmt:"yyyy-MM-dd",
realDateFmt:"yyyy-MM-dd",
realTimeFmt:"HH:mm:ss",
realFullFmt:"%Date %Time",
minDate:"1900-01-01 00:00:00",
maxDate:"2099-12-31 23:59:59",
startDate:"",
alwaysUseStartDate:false,
yearOffset:1911,
firstDayOfWeek:0,
isShowWeek:false,
highLineWeekDay:true,
isShowClear:true,
isShowToday:true,
isShowOthers:true,
readOnly:false,
errDealMode:0,
autoPickDate:null,
qsEnabled:true,

specialDates:null,
specialDays:null,
disabledDates:null,
disabledDays:null,
opposite:false,
onpicking:null,
onpicked:null,
onclearing:null,
oncleared:null,
ychanging:null,
ychanged:null,
Mchanging:null,
Mchanged:null,
dchanging:null,
dchanged:null,
Hchanging:null,
Hchanged:null,
mchanging:null,
mchanged:null,
schanging:null,
schanged:null,
eCont:null,
vel:null,
errMsg:"",
quickSel:[],has:{}};
WdatePicker=U;
var X=window,
O="document",
J="documentElement",
C="getElementsByTagName",
V,A,T,I,b;
switch(navigator.appName)
{
    case"Microsoft Internet Explorer":
        T=true;
        break;
    case"Opera":
        b=true;
        break;
    default:
        I=true;
        break;
}
A=L();
if(_.$wdate){
    M("../../style/"+A+"skin/WdatePicker.css");
}
V=X;
if(_.$crossFrame)
{
    try{
        while(V.parent[O]!=V[O]&&V.parent[O][C]("frameset").length==0)
            V=V.parent
    }catch(P){
        
    }
}
if(!V.$dp)
    V.$dp={
        ff:I,
        ie:T,
        opera:b,
        el:null,
        win:X,
        status:0,
        defMinDate:_.minDate,
        defMaxDate:_.maxDate,
        flatCfgs:[]
    };
    B();
if($dp.status==0)
    Z(X,function()
            {
                U(null,true)
            }
    );
if(!X[O].docMD)
{
    E(X[O],"onmousedown",D);
    X[O].docMD=true
}
if(!V[O].docMD)
{
    E(V[O],"onmousedown",D);
    V[O].docMD=true
}
E(X,"onunload",function()
{
    if($dp.dd)
        Q($dp.dd,"none")
}
);
function B()
{
    V.$dp=V.$dp||{};
    obj=
    {
        $:function($)
        {
            return(typeof $=="string")?this.win[O].getElementById($):$
        },
        $D:function($,_)
        {
            return this.$DV(this.$($).value,_)
        },
        $DV:function(_,$)
        {
            if(_!="")
            {
                this.dt=$dp.cal.splitDate(_,$dp.cal.dateFmt);
                if($)
                    for(var A in $)
                    {
                        if(this.dt[A]===undefined)
                            this.errMsg="invalid property:"+A;
                        this.dt[A]+=$[A]
                    }
                if(this.dt.refresh())
                    return this.dt
            }
            return""
        },
        show:function()
        {
            Q(this.dd,"block")
        },
        hide:function()
        {
            Q(this.dd,"none")
        },
        attachEvent:E
    };
    for(var $ in obj)
        V.$dp[$]=obj[$];
    $dp=V.$dp
}
function E(A,$,_)
{
    if(T)
        A.attachEvent($,_);
    else
    {
        var B=$.replace(/on/,"");
        _._ieEmuEventHandler=function($)
        {
            return _($)
        };
        A.addEventListener(B,_._ieEmuEventHandler,false)
    }
}
function L()
{
    var _,A,$=X[O][C]("script");
    for(var B=0;B<$.length;B++)
    {
        _=$[B].src.substring(0,$[B].src.toLowerCase().indexOf("wdatepicker.js"));
        _=_.replace(/js/,"common");
        A=_.lastIndexOf("/");
        if(A>0)
            _=_.substring(0,A+1);
        if(_)
            break;
    }
    return _
}
function F(F)
{
    var E,C;
    if(F.substring(0,1)!="/"&&F.indexOf("://")==-1)
    {
        E=V.location.href;C=location.href;
        if(E.indexOf("?")>-1)
            E=E.substring(0,E.indexOf("?"));
        if(C.indexOf("?")>-1)
            C=C.substring(0,C.indexOf("?"));
        var G,I,$="",D="",A="",J,H,B="";
        for(J=0;J<Math.max(E.length,C.length);J++)
        {
            G=E.charAt(J).toLowerCase();
            I=C.charAt(J).toLowerCase();
            if(G==I)
            {
                if(G=="/")H=J
            }else
            {
                $=E.substring(H+1,E.length);
                $=$.substring(0,$.lastIndexOf("/"));
                D=C.substring(H+1,C.length);
                D=D.substring(0,D.lastIndexOf("/"));
                break;
            }
        }
        if($!="")
            for(J=0;J<$.split("/").length;J++)
                B+="../";
        if(D!="")
            B+=D+"/";
        F=E.substring(0,E.lastIndexOf("/")+1)+B+F}_.$dpPath=F
}
function M(A,$,B)
{
    var D=X[O][C]("HEAD").item(0),_=X[O].createElement("link");
    if(D)
    {
        _.href=A;_.rel="stylesheet";
        _.type="text/css";
        if($)
            _.title=$;
        if(B)
            _.charset=B;
        D.appendChild(_)
    }
    
}
function Z($,_)
{
    E($,"onload",_)
}
function G($)
{
    $=$||V;
    var A=0,_=0;
    while($!=V)
    {
        var D=$.parent[O][C]("iframe");
        for(var F=0;F<D.length;F++)
        {
            try{
                if(D[F].contentWindow==$)
                {
                    var E=W(D[F]);
                    A+=E.left;
                    _+=E.top;
                    break;
                }
            }catch(B)
            {
                
            }
        }
        $=$.parent
    }
    return{"leftM":A,"topM":_}
}
function W(E)
{
    if(T)
        return E.getBoundingClientRect();
    else
    {
        var A=
        {
                ROOT_TAG:/^body|html$/i,OP_SCROLL:/^(?:inline|table-row)$/i
        },
        G=null,
        _=E.offsetTop,
        F=E.offsetLeft,
        D=E.offsetWidth,
        B=E.offsetHeight,
        C=E.offsetParent;
        if(C!=E)
            while(C)
            {
                F+=C.offsetLeft;
                _+=C.offsetTop;
                if(C.tagName.toLowerCase()=="body")
                    G=C.ownerDocument.defaultView;
                C=C.offsetParent
            }
        C=E.parentNode;
        while(C.tagName&&!A.ROOT_TAG.test(C.tagName))
        {
            if(C.scrollTop||C.scrollLeft)
                if(!A.OP_SCROLL.test(Q(C)))
                    if(!b||C.style.overflow!=="visible")
                    {
                        F-=C.scrollLeft;
                        _-=C.scrollTop
                    }
            C=C.parentNode
        }
        var $=a(G);F-=$.left;_-=$.top;D+=F;B+=_;
        return{"left":F,"top":_,"right":D,"bottom":B}
    }
}
function N($)
{
    $=$||V;
    var _=$[O];
    _=_[J]&&_[J].clientHeight&&_[J].clientHeight<=_.body.clientHeight?_[J]:_.body;
    return{"width":_.clientWidth,"height":_.clientHeight}
}
function a($)
{
    $=$||V;
    var B=$[O],A=B[J],_=B.body;
    B=(A&&A.scrollTop!=null&&(A.scrollTop>_.scrollLeft||A.scrollLeft>_.scrollLeft))?A:_;
    return{"top":B.scrollTop,"left":B.scrollLeft}
}
function D($)
{
    src=$?($.srcElement||$.target):null;
    if($dp&&$dp.cal&&!$dp.eCont&&$dp.dd&&Q($dp.dd)=="block"&&src!=$dp.el)
        $dp.cal.close()
}
function Y()
{
    $dp.status=2;
    H()
}
function H()
{
    if($dp.flatCfgs.length>0)
    {
        var $=$dp.flatCfgs.shift();
        $.el={innerHTML:""};
        $.autoPickDate=true;
        $.qsEnabled=false;
        K($)
    }
}
var R,$;
function U(E,_)
{
    $dp.win=X;
    B();
    E=E||{};
    if(_)
    {
        if(!D())
        {
            $=$||setInterval(function()
                    {
                        if(V[O].readyState=="complete")clearInterval($);
                        U(null,true)
                    },50);
            return
        }
        if($dp.status==0)
        {
            $dp.status=1;
            K({el:{innerHTML:""}},true)
        }else
            return
    }else if(E.eCont)
    {
        E.eCont=$dp.$(E.eCont);
        $dp.flatCfgs.push(E);
        if($dp.status==2)H()
    }else
    {
        if($dp.status==0)
        {
            U(null,true);
            return
        }
        if($dp.status!=2)
            return;
        var C=A();
        if(C)
        {
            $dp.srcEl=C.srcElement||C.target;C.cancelBubble=true
        }
        E.el=$dp.$(E.el||$dp.srcEl);
        if(!E.el||E.el.disabled||(E.el==$dp.el&&Q($dp.dd)!="none"&&$dp.dd.style.left!="-1970px"))return;
        K(E)
    }
    function D()
    {
        if(T&&V!=X&&V[O].readyState!="complete")
            return false;
        return true
    }
    function A()
    {
        if(I)
        {
            func=A.caller;
            while(func!=null)
            {
                var $=func.arguments[0];
                if($&&($+"").indexOf("Event")>=0)return $;
                func=func.caller
            }
            return null
        }
        return event
    }
}
function S(_,$)
{
    return _.currentStyle?_.currentStyle[$]:document.defaultView.getComputedStyle(_,false)[$]
}
function Q(_,$)
{
    if(_)
        if($!=null)_.style.display=$;
    else
        return S(_,"display")
}
function K(H,$)
{
    for(var D in _)
        if(D.substring(0,1)!="$")$dp[D]=_[D];
    for(D in H)if($dp[D]!==undefined)$dp[D]=H[D];
    var E=$dp.el?$dp.el.nodeName:"INPUT";
    if($||$dp.eCont||new RegExp(/input|textarea|div|span|p|a/ig).test(E))
        $dp.elProp=E=="INPUT"?"value":"innerHTML";
    else
        return;
    if($dp.lang=="auto")
        $dp.lang=T?navigator.browserLanguage.toLowerCase():navigator.language.toLowerCase();
        if(!$dp.dd||$dp.eCont||($dp.lang&&$dp.realLang&&$dp.realLang.name!=$dp.lang&&$dp.getLangIndex&&$dp.getLangIndex($dp.lang)>=0))
        {
            if($dp.dd&&!$dp.eCont)V[O].body.removeChild($dp.dd);
            if(_.$dpPath=="")F(A);
            var B="<iframe src=\""+_.$dpPath+"Calendar.htm\" frameborder=\"0\" border=\"0\" scrolling=\"no\"></iframe>";
            if($dp.eCont)
            {
                $dp.eCont.innerHTML=B;
                Z($dp.eCont.childNodes[0],Y)
            }else
            {
                $dp.dd=V[O].createElement("DIV");
                $dp.dd.style.cssText="position:absolute;z-index:19700";
                $dp.dd.innerHTML=B;
                V[O].body.insertBefore($dp.dd,V[O].body.firstChild);
                Z($dp.dd.childNodes[0],Y);
                if($)$dp.dd.style.left=$dp.dd.style.top="-1970px";
                else
                {
                    $dp.show();C()
                }
            }
        }else if($dp.cal)
        {
            $dp.show();
            $dp.cal.init();
            if(!$dp.eCont)C()
        }
        function C()
        {
            var F=$dp.position.left,B=$dp.position.top,C=$dp.el;
            if(C!=$dp.srcEl&&(Q(C)=="none"||C.type=="hidden"))C=$dp.srcEl;
            var H=W(C),$=G(X),D=N(V),A=a(V),E=$dp.dd.offsetHeight,_=$dp.dd.offsetWidth;
            if(isNaN(B))
            {
                if(B=="above"||(B!="under"&&(($.topM+H.bottom+E>D.height)&&($.topM+H.top-E>0))))B=A.top+$.topM+H.top-E-3;
                else B=A.top+$.topM+H.bottom;B+=T?-1:1
            }else
                B+=A.top+$.topM;
            if(isNaN(F))
                F=A.left+Math.min($.leftM+H.left,D.width-_-5)-(T?2:0);
            else
                F+=A.left+$.leftM;$dp.dd.style.top=B+"px";$dp.dd.style.left=F+"px"
        }
}
})()

jsframework.js
/*---------------------------------------------------------------------------*\
|  Subject: JavaScript Framework
|  Author:  meizz
|  Created: 2005-02-27
|  Version: 2006-08-11
|-----------------------------------
|  MSN:huangfr@msn.com  QQ:112889082
|  http://www.meizz.com  Copyright (c) meizz   MIT-style license
|  The above copyright notice and this permission notice shall be
|  included in all copies or substantial portions of the Software
\*---------------------------------------------------------------------------*/

window.System = function(){this.setHashCode();}

System.debug=true; //false
System._codebase={};
try
{
  if (window!=parent && parent.System && parent.System._codebase)
    System._codebase = parent.System._codebase;
  else if ("undefined"!=typeof opener&&opener.System&&opener.System._codebase)
    System._codebase = opener.System._codebase;
  else if ("undefined"!=typeof dialogArguments && dialogArguments.System)
    System._codebase = dialogArguments.System._codebase;
}


catch(ex){}

System.MISSING_ARGUMENT="Missing argument";
System.ARGUMENT_PARSE_ERROR="The argument cannot be parsed";
System.NOT_SUPPORTED_XMLHTTP="Your browser do not support XMLHttp";
System.FILE_NOT_FOUND="File not found";
System.MISCODING="Maybe file encoding is not ANSI or UTF-8";
System.NAMESPACE_ERROR=" nonstandard namespace";

System.hashCounter=0;
System.currentVersion="20060811";
var t=document.getElementsByTagName("SCRIPT");
t=(System.scriptElement=t[t.length-1]).src.replace(/\\/g, "/");
System.incorporate=function(d,s){for(var i in s)d[i]=s[i];return d;};
System.path=(t.lastIndexOf("/")<0)?".":t.substring(0, t.lastIndexOf("/"));
System.getUniqueId=function(){return "mz_"+(System.hashCounter++).toString(36);};
System.toHashCode=function(e)
{
  if("undefined"!=typeof e.hashCode) return e.hashCode;
  return e.hashCode=System.getUniqueId();
};
System.supportsXmlHttp=function()
{
  return "object"==typeof(System._xmlHttp||(System._xmlHttp=new XMLHttpRequest()));
};
System._getPrototype=function(namespace, argu)
{
  if("undefined"==typeof System._prototypes[namespace])return new System();
  for(var a=[], i=0; i<argu.length; i++) a[i]="argu["+ i +"]";
  return eval("new (System._prototypes['"+namespace+"'])("+a.join(",")+")");
};
System.ie=navigator.userAgent.indexOf("MSIE")>0 && !window.opera;
System.ns=navigator.vendor=="Netscape";
System._alert=function(msg){if(System.debug)alert(msg);};
System._parseResponseText=function(s)
{
    if (null==s||"\uFFFD"==s.charAt(0)){System._alert(System.MISCODING);return "";}
    if ("\xef"==s.charAt(0))s=s.substr(3); //for firefox
    return s.replace(/(^|\n)\s*\/\/+\s*((Using|Import|Include)\((\"|\'))/g,"$1$2");
};

if(window.ActiveXObject && (System.ie || !window.XMLHttpRequest))
{
  window.XMLHttpRequest = function()
  {
    var msxmls=['MSXML3','MSXML2','Microsoft'], ex;
    for(var i=0;i<msxmls.length;i++)
      try{return new ActiveXObject(msxmls[i]+'.XMLHTTP')} catch(ex){}
    System._xmlHttp="mz"; throw new Error(System.NOT_SUPPORTED_XMLHTTP);
  }
}
System.load = function(namespace, path)
{
  try
  {
    if(System.supportsXmlHttp()){path=System._mapPath(namespace, path);
    var x=System._xmlHttp; x.open("GET",path,false); x.send(null);
    if (x.readyState==4)
    {
      if(x.status==0||/^file\:/i.test(path))
        return System._parseResponseText(x.responseText);
      else if(x.status==200)return System._parseResponseText(x.responseText);
      else if(x.status==404)System._alert(namespace+"\n"+System.FILE_NOT_FOUND);
      else throw new Error(x.status +": "+ x.statusText);}
    } else System._alert(System.NOT_SUPPORTED_XMLHTTP);
  }
  catch(ex){System._alert(namespace+"\n"+ex.message);}return "";
};
System._eval = function(namespace, path)
{
  //alert("System._eval(\""+namespace+"\")=\r\n"+System._codebase[namespace]);
  try{if(window.execScript)window.execScript(System._codebase[namespace]);else
  {
    var script=document.createElement("SCRIPT");script.type="text/javascript";
    script.innerHTML="eval(System._codebase['"+ namespace +"']);";
    document.getElementsByTagName("HEAD")[0].appendChild(script);
    setTimeout(function(){script.parentNode.removeChild(script)},99);
  }}catch(ex){System._alert("Syntax error on load "+ namespace);}
  System._existences[namespace]=System._mapPath(namespace, path);
};
System._exist = function(namespace, path)
{
  if("undefined"==typeof System._existences[namespace]) return false;
  return System._existences[namespace]==System._mapPath(namespace,path);

};
System._mapPath = function(namespace, path)
{
  if("string"==typeof path && path.length>3)return path;
  var jspath=(namespace.replace(/\./g,"/")+".js").toLowerCase();
  var p=(System.path+"/"+jspath);
  return p +(("undefined"==typeof path||path) ? "" : "?t="+ Math.random());
};

window.Using = function(namespace, path, rename)
{
  if(System._exist(namespace, path)){
  var s=window[namespace.substr(namespace.lastIndexOf(".")+1)];
  if(s!=System._prototypes[namespace])s=System._prototypes[namespace];return}
  var code=namespace +"."; if(!/((^|\.)[\w\$]+)+$/.test(namespace))
  throw new Error(namespace+System.NAMESPACE_ERROR);
  for(var i=code.indexOf("."); i>-1; i=code.indexOf(".", i+1)){
  var e= code.substring(0,i), s=(e.indexOf(".")==-1) ? "window[\""+e+"\"]":e;
  if(e&&"undefined"==typeof(s)){
  eval(s+"=function(){return System._getPrototype(\""+e+"\", arguments)}");}}
  if("undefined"==typeof path &&"string"==typeof System._codebase[namespace])
  {
    System._eval(namespace, path);}else{if(code=System.load(namespace,path)){
    e = "$"+ System.getUniqueId() +"__id"+ new Date().getTime() +"$";
    s = "function "+e+"(){\r\n"+code+";\r\nSystem._prototypes['";
    code=namespace.substr(namespace.lastIndexOf(".")+1);
    s += namespace+"']=window['"+(rename||code)+"']="+code+";\r\n}"+e+"();";
    System._codebase[namespace]=s;s="";System._eval(namespace, path);}
  }
};
window.Import=function(namespace,path,rename){Using(namespace,path,rename)};
window.Instance=function(hashCode){return System._instances[hashCode]};
window.Include=function(namespace, path)
{
  if(System._exist(namespace, path)) return;
  var code;if(!/((^|\.)[\w\$]+)+$/.test(namespace))
  throw new Error(namespace + System.NAMESPACE_ERROR);
  if("undefined"==typeof path&&"string"==typeof(System._codebase[namespace]))
  {
    System._eval(namespace, path);}else if(System.supportsXmlHttp()){
    if(code=System.load(namespace, path)){System._codebase[namespace]=code;
    System._eval(namespace, path);}}else{
    var script=document.createElement("SCRIPT");script.type="text/javascript";
    script.src=System._existences[namespace]=System._mapPath(namespace,path);
    document.getElementsByTagName("HEAD")[0].appendChild(script);
    setTimeout(function(){script.parentNode.removeChild(script)},99);
  }
};

Function.READ=1;Function.WRITE=2;Function.READ_WRITE=3;
Function.prototype.addProperty=function(name,initValue,r_w)
{
  var capital=name.charAt(0).toUpperCase()+name.substr(1);
  r_w=r_w||Function.READ_WRITE; name="_"+name; var p=this.prototype;
  if("undefined"!=typeof initValue) p[name]=initValue;
  if(r_w&Function.READ) p["get"+ capital]=function(){return this[name];};
  if(r_w&Function.WRITE) p["set"+ capital]=function(v){this[name]=v;};
};
Function.prototype.Extends=function(SuperClass,ClassName)
{
  var op=this.prototype, i, p=this.prototype=new SuperClass();
  if(ClassName)p._className=ClassName; for(i in op)p[i]=op[i];
  if(p.hashCode)delete System._instances[p.hashCode];return p;
};
System._instances={};
System._prototypes=
{
  "System":System,
  "System.Object":System,
  "System.Event":System.Event
};
System._existences=
{
  "System":System._mapPath("System"),
  "System.Event":System._mapPath("System.Event"),
  "System.Object":System._mapPath("System.Object")
};
t=System.Extends(Object, "System"); System.Object = System;
t.decontrol=function(){var t;if(t=this.hashCode)delete System._instances[t]};
t.addEventListeners=function(type, handle)
{
  if("function"!=typeof handle)
    throw new Error(this+" addEventListener: "+handle+" is not a function");
  if(!this._listeners) this._listeners={};
  var id=System.toHashCode(handle), t=this._listeners;
  if("object"!=typeof t[type]) t[type]={}; t[type][id]=handle;
};
t.removeEventListener=function(type, handle)
{
  if(!this._listeners)this._listeners={}; var t=this._listeners;
  if(!t[type]) return; var id=System.toHashCode(handle);
  if( t[type][id])delete t[type][id];if(t[type])delete t[type];
};
t.dispatchEvent=function(evt)
{
  if(!this._listeners)this._listeners={};
  var i, t =this._listeners, p =evt.type;
  evt.target=evt.srcElement=this; if(this[p])this[p](evt);
  if("object"==typeof t[p]) for(i in t[p]) t[p][i].call(this,evt);
  delete evt.target; delete evt.srcElement;return evt.returnValue;
};
t.setHashCode=function()
{
  System._instances[(this.hashCode=System.getUniqueId())]=this;
};
t.getHashCode=function()
{
  if(!this.hashCode)this.setHashCode(); return this.hashCode;
};
t.toString=function(){return "[object "+(this._className||"Object")+"]";};
System.Event=function(type){this.type=type;};
t=System.Event.Extends(System, "System.Event");
t.returnValue=true;
t.cancelBubble=false;
t.target=t.srcElement=null;
t.stopPropagation=function(){this.cancelBubble=true;};
t.preventDefault =function(){this.returnValue=false;};

if(System.ie && !System.debug) Include("System.Plugins.IE"); //IE UserData
if(window.opera) Include("System.Plugins.Opera"); //Opera support
Include("System.Global");

templateFile_frame.jsp
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<head>
<title></title>
<link rel="shortcut icon" href="images/coship.ico" />
</head>
<input type="hidden" id="rightwidth"  />
<input type="hidden" id="leftwidth"  />
  <frameset  id="sFrame"  name="sFrame" cols="210,*" frameborder="no" border="0" framespacing= "3"  borderColor= "#ffffff">
    <frame src="initTemplateResourceTree.action?templateListType=<%=request.getParameter("templateListType")%>&operatorType=<%=request.getParameter("operatorType")%>&template.templateId=<%=request.getParameter("template.templateId")%>" name="lFrame" scrolling="auto" id="lFrame" title="lFrame" />
    <frame  src="showTemplateResourceDetail.action?templateListType=<%=request.getParameter("templateListType")%>&operatorType=<%=request.getParameter("operatorType")%>&template.templateId=<%=request.getParameter("template.templateId")%>&templateResFile.fileType=1" scrolling="auto" name="mFrame" id="mFrame" title="mFrame" />
  </frameset>
<noframes>
<body>
</body>
</noframes>
</html>

<!-- 模板文件树 -->
    <action name="initTemplateResourceTree" class="templateAction" method="initTemplateResourceTree">
            <result name="templateResourceTree">/template/templateResourceTree.jsp</result>
    </action>
    
templateResourceTree.jsp

<!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">
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ include file="../common/language.jsp"  %>

<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="page" uri="/WEB-INF/tlds/paginated.tld"%>
<link rel="stylesheet" type="text/css"
    href="../js/ext/resources/css/ext-all.css" />
<link href="../style/base<%=language_css%>.css" rel="stylesheet" type="text/css" />
<%@ include file="../common/commonJS.jsp" %>
<title><s:text name="msg.portalMS.template.File.manage"/></title>
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript" src="../js/jquery.validate.js"></script>
<script type="text/javascript" src="../js/ex.jquery.validate.js"></script>
<script type="text/javascript" src="../js/resourcemanage.js"></script>
<script type="text/javascript" src="../js/resourcedialogShow.js"></script>
<script type="text/javascript" src="../js/dialogShow.js"></script>
<script type="text/javascript" src="<%=path%>/dwr/engine.js"></script>
<script type="text/javascript" src="<%=path%>/dwr/interface/TreeDWR.js"></script>
<script type="text/javascript" src="../js/fullHeight.js"></script>
<script type="text/javascript" src="../js/Calendar/WdatePicker.js"></script>
<script type="text/javascript" src="../js/tree/jsframework.js"></script>

<script type="text/javascript">


</script>
</head>
<style type="text/css">
    body{background-color:#e9f0f9;font-size:12px}
</style>
<body>
<input type="hidden" id="templateListType" name="templateListType" value="${templateListType}"/>
<input type="hidden" id="type" name="type" value="${operatorType}"/>
<input type="hidden" name="template.templateId" value="${template.templateId}"/>
<div class="r_main">
  <div id="pcolumn_delete" align="left">
        <s:if test="templateListType==0">
        <!-- <button id="referenceColumn" onclick="createDir()">新增目录</button> -->
        </s:if>
  </div>
  <div>
        <script type="text/javascript">
        ${filetree}
         Using('System.Web.UI.WebControls.MzTreeView');     
         var a = new MzTreeView();         
          a.autoSort=false;
          a.useCheckbox=false;   
          a.canOperate=true;  
          a.dataSource = data ;     
          //a.targets="";
          a.useUrl = true; // url连接是否有效
          a.autoCheck = false; // 支持连动选择
          //a.useCategoryType = true; 用于设置导航不能选中
          document.write(a.render());
          a.expandLevel(1); // 展开1级节点

          function createDir()
          {
              var selectNode = a.currentNode;
              var fileType;
              var filePath;
              var fileName = selectNode.text;
              var nodeUrl = selectNode.get("url");
              var myArray = nodeUrl.split('&');
              // alert(myArray);
              for( i = 0; i < myArray.length ; i++)
              {
                  if(null != myArray[i].match("templateResFile.fileType"))
                  {
                      var fileTypeVar = myArray[i].split('=');
                      fileType = fileTypeVar[1];
                      if(0 == fileType)
                      {
                          alert("<s:text name='msg.portalMS.template.File.tip'/>");
                          return;
                      }
                  }
                  if(null != myArray[i].match("templateResFile.filePath"))
                  {
                      var filePathVar = myArray[i].split('=');
                      filePath = filePathVar[1];
                      filePath = filePath.substring(1, filePath.length - 1);
                      filePath = filePath.replaceAll("!","/");
                  }
              }
                var url = "../template/createTempResFileDir.action?templateResFile.filePath=" + filePath + "/" + fileName;    
              
                // showPage('新增目录', url, 200, 160);
              window.open (url, '<s:text name="msg.portalMS.template.direction.add"/>', 'height=150, width=250, top=300, left=420, toolbar=no, menubar=no, scrollbars=yes,resizable=yes,location=no, status=no'); //写成一行
          }  
        </script>  
   </div>
</div>
</body>
</html>

mztreeview.js

/*---------------------------------------------------------------------------*\
|  Subject:    MzTreeView 2.0
|  NameSpace:  System.Web.UI.WebControls.MzTreeView
|  Author:     meizz
|  Created:    2005-12-28
|  Version:    2006-05-03
|-------------------------------------------------------------
|  MSN: huangfr@msn.com   QQ: 112889082   http://www.meizz.com
|  Email: mz@126.com      CSDN ID:meizz   Copyright (c)  meizz
\*---------------------------------------------------------------------------*/
//Using("System.Data.MzData");
//Using("System.Web.Forms.MzEffect");

function MzTreeView(){MzData.call(this);this.index = this.hashCode;}
t=MzTreeView.Extends(MzData, "MzTreeView");

MzTreeView.addProperty("defaultUrl", "#");
MzTreeView.addProperty("defaultTarget", "_self");
t.iconPath = System.path+"/system/_resource/mztreeview/";

//[configuration]
t.showPlus  = true;

t.showLines = true;
t.showToolTip = true;
t.showNodeIcon = true;

t.autoSort = true;
t.useArrow = true;
t.dynamic  = true;
t.useCheckbox = false;
t.autoFocused = false;
t.useContextMenu = false;
t.convertRootIcon = true;
t.canOperate = false;
//初始化target 防止在servlet中多次拼装   by liangfuming
t.targets="mFrame";
alert("t.targets"+t.targets);
MzTreeView.icons =
{
  line :
  {
    "l0" :"_line0.gif",
    "l1" :"_line1.gif",
    "l2" :"_line2.gif",
    "l3" :"_line3.gif",
    "l4" :"_line4.gif",
    "ll" :"_line5.gif",
    "c0" :"_checkbox0.gif",
    "c1" :"_checkbox1.gif",
    "c2" :"_checkbox2.gif"
  },
  collapse:
  {
    "pm0":"_plus0.gif",
    "pm1":"_plus1.gif",
    "pm2":"_plus2.gif",
    "pm3":"_plus3.gif",

    "root":"root.gif",
    "file":"file.gif",
    "exit":"exit.gif",
    "folder":"folder.gif"
  },
  expand :
  {
    "pm0":"_minus0.gif",
    "pm1":"_minus1.gif",
    "pm2":"_minus2.gif",
    "pm3":"_minus3.gif",

    "folder":"folderopen.gif"
  }
};
MzTreeView.textLoading="&#27491;&#22312;&#21152;&#36733;...";


//public: entry
MzTreeView.prototype.render = function()
{
  function loadImg(C){for(var i in C){if("string"==typeof C[i]){
  var a=new Image(); a.src=me.iconPath + C[i]; C[i]=a;}}} var me=this;
  loadImg(MzTreeView.icons.expand);loadImg(MzTreeView.icons.collapse);
  loadImg(MzTreeView.icons.line); me.firstNode=null;
  loadCssFile(this.iconPath +"mztreeview.css", "MzTreeView_CSS");

  this.initialize(); var str="no data", i, root=this.rootNode;
  if (root.hasChild){var a = [], c = root.childNodes; me.firstNode=c[0];
  for(i=0;i<c.length;i++)a[i]=c[i].render(i==c.length-1);str=a.join("");}
  setTimeout(function(){me.afterRender();}, 10);
  return "<div class='mztreeview' id='MTV_root_"+ this.index +"' "+
    "onclick='Instance(\""+ this.index +"\").clickHandle(event)' "+
    "ondblclick='Instance(\""+ this.index +"\").dblClickHandle(event)' "+
    ">"+ str +"</div>";
};
MzTreeView.prototype.afterRender=function()
{
  var me=this;
  if(document.getElementById("MTV_root_"+ me.index))
  {
    if(me.firstNode)(me.currentNode=me.firstNode).focus();
    this.dispatchEvent(new System.Event("onrender"));
    if(me.useArrow) me.attachEventArrow();
  }
  else setTimeout(function(){me.afterRender();}, 100);
};
//private: attachEvent onTreeKeyDown
MzTreeView.prototype.attachEventArrow = function()
{
  var a = document.getElementById("MTV_root_"+ this.index); if(!a) return;
  var me= this;  a.attachEvent("onkeydown", function(e)
  {
    e = window.event || e; var key = e.keyCode || e.which;
    alert("key"+key);
    switch(key)
    {
      case 37 : me.focusUpperNode();      break;  //Arrow left,  shrink child node
      case 38 : me.focusPreviousSibling();break;  //Arrow up
      case 39 : me.focusLowerNode();      break;  //Arrow right, expand child node
      case 40 : me.focusNextSibling();    break;  //Arrow down
      case 46 : if(me.canOperate) me.currentNode.removeNode(); break; //delete
    }
  });
};
MzTreeView.prototype.appendIcon=function(index, src, flag)
{
  if(/^pm\d$/.test(index))return;
  var a=new Image(); a.src=src;
  if(flag){MzTreeView.icons.expand[index]=a;return;}
  MzTreeView.icons.collapse[index]=a;
}
MzTreeView.prototype.setIconPath=function(path)
{
  if(path.length>0) this.iconPath = path.replace(/[\\\/]*$/, "/");
}
//public: loadChildNodes(sourceId)
MzTreeView.prototype.loadChildNodes = function(id)
{
  var n; if(n=this.getNodeById(id)) n.loadChildNodes();
};

//private: build treeline onTreeNodeBuild
MzTreeView.prototype.buildPrefix = function(prefix)
{
  var a=prefix.replace(/^,+/,"").split(","); for(var i=0; i<a.length; i++)
  if (a[i]) a[i]="<img src='"+ MzTreeView.icons.line[a[i]].src +"' alt='' />";
  return this.showLines?(prefix ?a.join(""):""):(prefix ?"<div style='width:"+
    (MzTreeView.icons.collapse["pm3"].width*a.length)+"px'>&nbsp;<\/div>":"");
};
//public: expand/collapse node
MzTreeView.prototype.expand = function(id)
{
  var n; if(n=this.getNodeById(id)) n.expand();
};
MzTreeView.prototype.collapse = function(id)
{
  var n; if(n=this.getNodeById(id)) n.collapse();
};
//private: attachEvent tree onClick
MzTreeView.prototype.clickHandle = function(e)
{
  e = window.event || e; var B;
  e = e.srcElement || e.target;
  if(B=(e.id && 0==e.id.indexOf(this.index +"_")))
  {
    var n=this.currentNode=this.nodes[e.id.substr(e.id.lastIndexOf("_")+1)];
  }
  switch(e.tagName)
  {
    case "IMG" :
      if(B)
      {
        if(e.id.indexOf(this.index +"_expand_")==0){
          n.expanded ? n.collapse() : n.expand();}
        else if(e.id.indexOf(this.index +"_icon_")==0){
          n.focus();}
        else if(e.id.indexOf(this.index +"_checkbox_")==0){
          n.check(!n.checked); n.upCheck();}
      }
      break;
    case "A":
      if(B){ n.focus(); this.dispatchEvent(new System.Event("onclick"));}
      break;
    default :
      if(System.ns) e = e.parentNode;
      break;
  }
};
//private: onTreeDoubleClick
MzTreeView.prototype.dblClickHandle = function(e)
{
  e = window.event || e; e = e.srcElement || e.target;
  if((e.tagName=="A" || e.tagName=="IMG")&& e.id)
  {
    e=this.nodes[e.id.substr(e.id.lastIndexOf("_") +1)];
    e.expanded ? e.collapse() : e.expand();
    this.currentNode=e;this.dispatchEvent(new System.Event("ondblclick"));
  }
};
//public: focus a treeNode by node's clientIndex
MzTreeView.prototype.focus = function(id)
{
  if(!this.selectedNode) this.selectedNode=this.rootNode;
  var n; if(n=this.getNodeById(id)) n.focus();
};
MzTreeView.prototype.focusNodeByPath = function(path)
{
  var me=this, n;
  if ((n=path.indexOf(this.divider))>0)
  {
    var node = this.getNodeById(path.substring(0, n));
    if(node){if(node!=this.rootNode && !node.expanded) node.expand();
    node.focus();} else return;
    path = path.substr(n + this.divider.length);
    setTimeout(function(){me.focusNodeByPath(path)}, 1);
  }
  else this.getNodeById(path).focus();
};
//*
MzTreeView.prototype.focusUpperNode = function()
{
  var e = this.selectedNode, r = this.rootNode; if(e){
  if(e.parentNode==r && !e.expanded) return;
  if(e.expanded) e.collapse(); else e.parentNode.focus();}
};

MzTreeView.prototype.focusLowerNode = function()
{
  var e = this.selectedNode; if(e && e.hasChild){
  if(e.expanded)e.childNodes[0].focus();else e.expand();}
}

MzTreeView.prototype.focusPreviousSibling = function()
{
  var e = this.selectedNode;if(e && e.parentNode){
  var c = e.parentNode.childNodes;for(var i=c.length-1; i>=0; i--){
  if(c[i]==e){if(i==0) return; c[i-1].focus();}}}
};

MzTreeView.prototype.focusNextSibling = function()
{
  var e = this.selectedNode; if(e && e.parentNode){
  var c = e.parentNode.childNodes; for(var i=0; i<c.length; i++){
  if(c[i]==e){ if(i==c.length-1) return; c[i+1].focus();}}}
};
MzTreeView.prototype.appendNode=function(sourceIndex, dataString)
{
  if(!this.canOperate) return;
  var a=sourceIndex.split(this.divider); if(a.length!=2) return;
  var d={},pid=a[0],id=a[1];d[sourceIndex]=dataString;this.appendData(d);
  var node=this.getNodeById(pid); if(!node) return; node.hasChild=true;
  if(!node.isLoaded){node.updateNode(); node.expand();} else
  node.appendNode(node.DTO(this.nodePrototype, sourceIndex));
  this.currentNode=this.getNodeById(id);
  this.dispatchEvent(new System.Event("onappendnode"));
  if(this.useCheckbox && node.checked) node.check(true);
};

MzTreeView.prototype.updateNode = function(id)
{
  if(!this.canOperate) return;
  var node; if(node=this.getNodeById(id)) node.updateNode();
};

MzTreeView.prototype.removeNode = function(id)
{
  if(!this.canOperate) return;
  var node; if(node=this.getNodeById(id)) node.removeNode();
};
//************************ can expand a node all childNodes
MzTreeView.prototype.expandAll = function(id)
{
  if("undefined"==typeof id) return;
  var node=this.getNodeById(id);
  if(!node||node.hasChlid) return;
  node.expandAll();
};
MzTreeView.prototype.collapseAll = function(id)
{
  if("undefined"==typeof id) return;
  var node=this.getNodeById(id);
  if(!node||node.childNodes.length==0) return;
  node.collapseAll();
};
MzTreeView.prototype.expandLevel=function(level)
{
  if(!/\d+/.test(level) || level==0)return;var r;
  if((r=this.rootNode).hasChild)
  {
      alert("r"+r.childNodes.length);
    for(var i=0, n=r.childNodes.length; i<n; i++)
      r.childNodes[i].expandLevel(level);
  }
};


window.MzTreeNode=function(){MzDataNode.call(this);};
t=MzTreeNode.Extends(MzDataNode, "MzTreeNode");
MzTreeView.prototype.nodePrototype=MzTreeNode;
MzTreeNode.htmlChildPrefix="";
t.checked = t.expanded = false;
t.childPrefix = "";

//private: load all node's node and init
MzTreeNode.prototype.loadChildNodes = function()
{
  MzDataNode.prototype.loadChildNodes.call(this, MzTreeNode);
  if(this.$$caller.useCheckbox)
  {
    var r=/^true$/i, data=this.$$caller.dataSource;
    for(var i=0, n=this.childNodes.length; i<n; i++)
    {
      var node=this.childNodes[i];
      var b=data[node.sourceIndex].getAttribute("checked");
      if(b!=null) node.checked=r.test(b);
      node.checked=node.parentNode.checked || node.checked;
    }
    if(n>0) this.childNodes[0].upCheck();
  }
};

//private: single node build to HTML
MzTreeNode.prototype.render = function(last)
{
    
  var $=this.$$caller, s=$.dataSource[this.sourceIndex],target,data,url;
  var icon=s.getAttribute("icon");
  if(!(target=s.getAttribute("target")))target=$.getDefaultTarget();
  //初始化target by liangfuming
  target=$.targets;
  var hint=$.showToolTip ? s.getAttribute("hint") || this.text : "";
  if(!(url=s.getAttribute("url"))) url = $.getDefaultUrl();
  if(data=s.getAttribute("data"))url+=(url.indexOf("?")==-1?"?":"&")+data;

  var id=this.index, s="";
  var isRoot=this.parentNode==$.rootNode;
  if( isRoot && $.convertRootIcon && !icon) icon = "root";
  //在这里先得到
  if(!isRoot)this.childPrefix=this.parentNode.childPrefix+(last?",ll":",l4");
  if(!icon || typeof(MzTreeView.icons.collapse[icon])=="undefined"){
      this.icon = this.hasChild ? "folder" : "folder";
  }
  else this.icon = icon;
  this.line = this.hasChild ? (last ? "pm2" : "pm1") : (last ? "l2" : "l1");
  if(!$.showLines) this.line = this.hasChild ? "pm3" : "ll";

  s += "<div><table border='0' cellpadding='0' cellspacing='0'>"+
       "<tr title='"+ hint +"'><td>";
  if (MzTreeNode.htmlChildPrefix)
  {
    s += MzTreeNode.htmlChildPrefix +"</td><td>";
  }
  if(!isRoot)
  s += "<img border='0' id='"+ $.index +"_expand_"+ id +"' src='"+
       (this.hasChild ? MzTreeView.icons.collapse[this.line].src :
       MzTreeView.icons.line[this.line].src)+"'>"; if($.showNodeIcon)
  s += "<img border='0' id='"+ $.index +"_icon_"+ id +"' src='"+
       MzTreeView.icons.collapse[this.icon].src +"'>"; if($.useCheckbox)
  s += "<img border='0' id='"+$.index +"_checkbox_"+ id +"' src='"+
       MzTreeView.icons.line["c"+ (this.checked?1:0)].src +"'>";
  s += "</td><td style='padding-left: 3px' nowrap='true'><a href='"+ url +
       "' target='"+ target +"' id='"+$.index +"_link_"+ id +
       "' class='MzTreeView'>"+ this.text +"</a></td></tr></table><div ";
       if(isRoot&&this.text=="") s="<div><div ";
  s += "id='"+$.index+"_tree_"+id+"' style='display: none;'></div></div>";
  return s;
};
//private: build all node's node
MzTreeNode.prototype.buildChildNodes = function()
{
    
  var me = this, mtv = me.$$caller, box;
  if(box = document.getElementById(mtv.index +"_tree_"+ me.index))
  {
    var a = new Array(me.childNodes.length);
    
    MzTreeNode.htmlChildPrefix=mtv.buildPrefix(me.childPrefix);
    
    if(/(^|\s|;)(JS|XML|UL)Data\s*:/i.test(mtv.dataSource[me.sourceIndex]))
    {
        function cond(a, b){if(a.hasChild!=b.hasChild)
          return (a.hasChild ? -1 : 1); else return(a.index>b.index?1:-1);}
        if(mtv.autoSort) me.childNodes=me.childNodes.sort(cond);
    }
    for(var i=0; i<a.length; i++){

        a[i]=me.childNodes[i].render(i==a.length-1);

        }
    box.innerHTML=a.join("");
     a=null;
    if(me.checked) me.check(me.checked);

  }
};
//private: check checkbox
MzTreeNode.prototype.check = function(checked)
{
  var me=this, mtv=me.$$caller, B=checked?"true":"false", mc=me.childNodes;
  var chk; if(chk=document.getElementById(mtv.index+"_checkbox_"+ me.index)){
  chk.src=MzTreeView.icons.line["c"+((me.checked=(checked==true))?1:0)].src;}
  var x=mtv.index; for(var i=0, chk=mc.length; i<chk; i++)
  setTimeout("Instance('"+x+"').nodes['"+mc[i].index+"'].check("+B+")",1);
};
//private: set checkbox status on childNode has checked
//private: set checkbox status on childNode has checked
MzTreeNode.prototype.upCheck = function()
{
  var node = this, mtv=node.$$caller, chk; if(node.parentNode){
  for(var i=0; i<node.parentNode.childNodes.length; i++)
  {
    if(node.parentNode.childNodes[i].checked != node.checked)
    {
      while(node=node.parentNode){
          node.checked = false;
        if (chk = document.getElementById(mtv.index+"_checkbox_"+node.index))
        //chk.src = MzTreeView.icons.line["c2"].src;
            //modify by liangfuming 修改下级全选不会选中上级
            chk.src = MzTreeView.icons.line["c0"].src;
        } return;}
    }
    node = node.parentNode;
    //modify by liangfuming 修改下级全选不会选中上级
    if(!this.checked){node.checked = this.checked;}
    if (chk = document.getElementById(mtv.index +"_checkbox_"+ node.index))
    chk.src = MzTreeView.icons.line["c"+(node.checked?1:0)].src;node.upCheck();
  }
};
//private: expand node
MzTreeNode.prototype.expand = function()
{
  if(!this.hasChild) return; var me=this, $ = me.$$caller;
  var box = document.getElementById($.index +"_tree_"+ this.index);
  if (!box) {System._alert("error in getElementById"); return;}

  this.expanded = box.style.display=="none";
  box.style.display = "block"; if($.dynamic) MzEffect.show(box);
  var line = document.getElementById($.index+"_expand_"+ this.index);
  var icon = document.getElementById($.index+"_icon_"+ this.index);

  var ies=MzTreeView.icons.expand, ics=MzTreeView.icons.collapse;

  if(line && typeof(ies[this.line])=="object")line.src = ies[this.line].src;
  if(icon && typeof(ies[this.icon])=="object")icon.src = ies[this.icon].src;

  if(!this.isLoaded)
  {
      
    this.loadChildNodes();

    if(this.hasChild && (this.childNodes.length>200
      || /(^|\s|;)(JS|XML|UL)Data\s*:/i.test($.dataSource[this.sourceIndex])))
    {
      setTimeout(function(){me.buildChildNodes();}, 1);
    }
    else this.buildChildNodes();
  }

  $.currentNode=this; $.dispatchEvent(new System.Event("onexpand"));

  if(this.parentNode==$.rootNode)
  {
    if(this.text=="" && this.hasChild)
    {
      var node = this.childNodes[0];
      line = document.getElementById($.index+"_expand_"+node.index);
      if(node.line.indexOf("pm")==0)
      {
        if(node.line=="pm1") node.line="pm0";
        else if(node.line=="pm2") node.line="pm3";
        line.src= ics[node.line].src;
      }
      else
      {
        if(node.line=="l1") node.line="l0";
        else if(node.line=="l2") node.line="l3";
        line.src= MzTreeView.icons.line[node.line].src;
      }
    }
  }
};
MzTreeNode.prototype.expandAll = function()
{
  if(this.hasChild && !this.expanded) this.expand();
  for(var x=this.$$caller.index, i=0; i<this.childNodes.length; i++)
  {
    var node = this.childNodes[i]; if (node.hasChild)
    setTimeout("Instance('"+x+"').nodes['"+ node.index +"'].expandAll()", 1);
  }
};
MzTreeNode.prototype.expandLevel=function(level)
{
  if(level<=0) return; level--; var me=this;
  if(this.hasChild && !this.expanded) this.expand();
  for(var x=this.$$caller.index, i=0, n=this.childNodes.length; i<n; i++)
  {
    var node=this.childNodes[i], d=node.index; if(node.hasChild)
    setTimeout("Instance('"+x+"').nodes['"+d+"'].expandLevel("+level+")",1);
  }
};
MzTreeNode.prototype.collapse=function()
{
  var $ = this.$$caller;
  var box=document.getElementById($.index +"_tree_"+ this.index);
  if (!box) {System._alert("error in getElementByid"); return;}

  var line=document.getElementById($.index+"_expand_"+ this.index);
  var icon=document.getElementById($.index+"_icon_"+ this.index);
  if($.dynamic)MzEffect.hide(box);else box.style.display="none";
  box=MzTreeView.icons.collapse;
  if(line) line.src= box[this.line].src; this.expanded=false;
  if(icon) icon.src=(box[this.icon]||box["file"]).src;
  if($.selectedNode && 0==$.selectedNode.path.indexOf(this.path)
    && $.selectedNode.path!=this.path) this.focus();
  $.currentNode=this; $.dispatchEvent(new System.Event("oncollapse"));
};
MzTreeNode.prototype.collapseAll = function()
{
  if(this.hasChild && this.expanded) this.collapse();
  for(var x=this.$$caller.index, i=0; i<this.childNodes.length; i++)
  {
    var node = this.childNodes[i]; if (node.hasChild && node.isLoaded)
    setTimeout("Instance('"+x+"').nodes['"+ node.index +"'].collapseAll()", 1);
  }
};
MzTreeNode.prototype.focus=function()
{
  var $ = this.$$caller, a=$.rootNode, o;
  if(!$.selectedNode) $.selectedNode=a;
  if(a = document.getElementById($.index +"_link_"+ this.index)){
  if(o = document.getElementById($.index +"_link_"+ $.selectedNode.index))
  o.className="";a.className="selected";
  if($.autoFocused){try{a.focus();}catch(ex){}} $.selectedNode=this;
  $.currentNode=this;  $.dispatchEvent(new System.Event("onfocus"));}
};




//append update remove  --node method
//if the node is not loaded then don't use this method!!
MzTreeNode.prototype.appendNode=function(node)
{
    var me = this, mtv = me.$$caller;
  var $=this.$$caller; if(!$.canOperate) return;
  if(this.hasChild && !this.isLoaded){this.expand(); return;}
  this.childNodes.push(node); this.hasChild=this.isLoaded=true;
  var div=document.getElementById($.index +"_tree_"+ this.index);
  MzTreeNode.htmlChildPrefix=mtv.buildPrefix(this.childPrefix);
  if(div.insertAdjacentHTML){ div.insertAdjacentHTML("beforeEnd",node.render(true));
  }
  else{var d=document.createElement("DIV"); d.innerHTML=node.render(true);
  div.appendChild(d); div.insertBefore(d.firstChild, d); div.removeChild(d);
  }
  if(this.childNodes.length>1){this.childNodes[this.childNodes.length-2].updateNodeLine();
  this.childNodes[this.childNodes.length-2].editPreviousNodes(true,'add');
  }
  else {this.updateNodeLine(); this.updateNodeIcon();  } this.expand();this.expanded=true;
};

String.prototype.replaceAll = function(s1,s2) {
    return this.replace(new RegExp(s1,"gm"),s2);
};





MzTreeNode.prototype.updateNode=function()
{
  var $=this.$$caller; if(!$.canOperate)return;
  $.currentNode=this; var e=new System.Event("onupdatenode");
  $.dispatchEvent(e); if(!e.returnValue) return;

  this.updateNodeLine();
  this.updateNodeIcon();
  this.updateNodeLink();
};
MzTreeNode.prototype.updateNodeLine=function()
{
  var $=this.$$caller, pcs=this.parentNode.childNodes;
  this.hasChild=this.isLoaded?this.childNodes.length>0:this.hasChildNodes();

  var line=document.getElementById($.index +"_expand_"+ this.index);
  if(line){var i=MzTreeView.icons; if($.showLines)
  {
    var b=pcs.indexOf(this)==(pcs.length-1);
    if(b)this.line=this.hasChild?"pm2":"l2";
    else this.line=this.hasChild?"pm1":"l1";
  }
  else   this.line=this.hasChild?"pm3":"ll";
  i=this.hasChild ? (this.expanded?i.expand:i.collapse) : i.line;
  line.src=i[this.line].src;}

};



MzTreeNode.prototype.updateNodeIcon=function()
{
  var $=this.$$caller;
  this.hasChild=this.isLoaded?this.childNodes.length>0:this.hasChildNodes();
  if($.showNodeIcon)
  {
    var icon=document.getElementById($.index +"_icon_"+ this.index);
    var ico=this.$$caller.dataSource[this.sourceIndex].getAttribute("icon");
    if(ico!="folder"&&ico!="file"&&(this.icon=="folder"||this.icon=="file"))
     // this.icon = this.hasChild ? "folder" : "file";
         this.icon = this.hasChild ? "folder" : "folder";
    var i=MzTreeView.icons; ico="undefined"==typeof i.expand[this.icon];
    if(this.expanded) {i=ico?i.collapse:i.expand;icon.src=i[this.icon].src;}
    else icon.src=MzTreeView.icons.collapse[this.icon].src;
  }
};
MzTreeNode.prototype.updateNodeText=function()
{
  document.getElementById(this.$$caller.index+"_link_"+this.index).innerHTML=this.text;
};
MzTreeNode.prototype.updateNodeLink=function()
{
  var $=this.$$caller;
  var link=document.getElementById($.index +"_link_"+ this.index);
  var s = $.dataSource[this.sourceIndex], target, url;
  var cs= $.selectedNode==this?"selected":"MzTreeView";
  if(!(target=s.getAttribute("target")))target=$.getDefaultTarget();
  //初始化target by liangfuming
  target=$.targets;
  if(!(url=s.getAttribute("url"))) url = $.getDefaultUrl(); if($.showToolTip)
  searchByTagName(link, "TR").title=s.getAttribute("hint")||this.text;
  if(data=s.getAttribute("data"))url+=(url.indexOf("?")==-1?"?":"&")+data;
  s="<a target='"+ target +"' id='"+$.index +"_link_"+ this.index +
    "' href='"+ url +"' class='"+ cs +"'>"+ this.text +"</a>";
  link.parentNode.innerHTML=s;
};
MzTreeNode.prototype.removeNode=function()
{
  var $=this.$$caller; if(!$.canOperate) return;
  $.currentNode=this; var evt=new System.Event("onremovenode");
  $.dispatchEvent(evt); if(!evt.returnValue) return;
 
  if(this.parentNode)
  {
      if(document.getElementById($.index +"_tree_"+ this.index)!=null)
      {
            var div=document.getElementById($.index +"_tree_"+ this.index).parentNode;
            $.indexes=$.indexes.replace($.get__() + this.sourceIndex, "");
        
            var p=this.parentNode, pcs=p.childNodes, n=pcs.indexOf(this), a=[];
            for(var i=0; i<pcs.length; i++){if(i==n) continue; a.push(pcs[i]);}
            p.childNodes=a; pcs=$.dataSource[this.sourceIndex];
            $.dataSource[this.sourceIndex]=pcs.deleteAttribute("index_"+ $.index);
            if(a.length==0){p.collapse();p.updateNode();MzEffect.hide(div.parentNode);}
            else if(n==a.length)
            {
                a[a.length-1].updateNode();
                var upNode = a[a.length-1];
                upNode.editPreviousNodes(true,'remove');
                
            } pcs=a=null;
      
            this.checked=false;
            div.parentNode.removeChild(div); p.focus();
      }
  }
};


/**
 * 替换字符串 修改已经存在的节点的结构
 * @param index
 * @param str1
 * @param str2
 * @param str3
 * @param str4
 * @return
 */
String.prototype.replaceContent = function(index,str1,str2,str3,str4) {
    var i =1;
    var me = this;
    while( me.indexOf(str1) != -1 ) {
        if(i==index)
        {
            me = me.replace(str1,str2);
            me = me.replaceAll(str3,str4);
            return me;
        }
        else
            me = me.replace(str4,str3);
     i++;
    }
    return me;
};

/**
 * 编辑上一个节点的所有元素
 * @param flag
 * @param type
 * @param temp
 * @return
 */
MzTreeNode.prototype.editPreviousNodes=function(flag,type,temp)
{
var me = this;var cc="";var bb="";
var mtv = this.$$caller;

            var div=document.getElementById(mtv.index +"_tree_"+ this.index);
            //将里面的值换掉
            
             cc=div.innerHTML;
            var level = this.path.split('_').length;
            if(flag==true){
                if(temp==null)
                temp = level-2;
                    var arrays = cc.split("<TABLE");
                    for(var i=0;i<arrays.length;i++)
                    {
                        if(type=='add')
                        arrays[i] = arrays[i].replaceContent(level-2,"line5","line4","lfine","line");
                        else if(type=='remove')
                        arrays[i] = arrays[i].replaceContent(level-2,"line4","line5","lfine","line");
                    }
                bb = arrays.join("<TABLE");
                div.innerHTML = bb;
            }
            if(type=='add')
            this.childPrefix = this.childPrefix.replaceContent(temp,"ll","l4",",v",",l");
            else if(type=='remove')
            this.childPrefix = this.childPrefix.replaceContent(temp,"l4","ll",",v",",l");
            
             for(var i=0;i<me.childNodes.length;i++)
             {
                    var childNode = me.childNodes[i];
                    if(type=='add')
                    childNode.editPreviousNodes(false,'add',temp);
                    else if(type=='remove')
                    childNode.editPreviousNodes(false,'remove',temp);
             }
};



/****** MzTreeView Inputer *****/
t=[];
t.push("<table border='0' cellspacing='1' id='MzTreeInputer' widht='100%'>");
t.push("<colgroup><col class='caption'/><col class='content' /></colgroup>");
t.push("<tr><td>&#33410;&#28857;ID</td><td><input class='text' id='mtinputerId' maxlength='16'/></td></tr>");
t.push("<tr><td>&#29238;&#33410;&#28857;ID</td><td><input class='text' id='mtinputerParentId' maxlength='16'/></td></tr>");
t.push("<tr><td>&#33410;&#28857;&#25991;&#23383;</td><td><input class='text' id='mtinputerText' maxlength='64'/></td></tr>");
t.push("<tr><td>&nbsp;</td><td id='mtinputeroption' onclick='MzTreeView.inputerhs(this)'>&#20854;&#23427;&#36873;&#39033; &gt;&gt;&gt;</td></tr>");
t.push("<tr style='display: none'><td>&#33410;&#28857;&#22270;&#26631;</td><td><select id='mtinputerIcon'><option value=''>&#35831;&#36873;&#25321;</option></select></td></tr>");
t.push("<tr style='display: none'><td>&#33410;&#28857;&#38142;&#25509;</td><td><input class='text' maxlength='128' id='mtinputerUrl'/></td></tr>");
t.push("<tr style='display: none'><td>Target</td><td><input class='text' id='mtinputerTarget' maxlength='32'/></td></tr>");
t.push("<tr style='display: none'><td>&#25552;&#31034;&#20449;&#24687;</td><td><input class='text' maxlength='64' id='mtinputerHint'/></td></tr>");
t.push("<tr style='display: none'><td>&#38468;&#21152;&#25968;&#25454;</td><td><input class='text' maxlength='255' id='mtinputerData' title='key=value&key=value&key=value&...'/></td></tr>");
t.push("<tr style='display: none'><td>&#36873;&#20013;&#29366;&#24577;</td><td><input type='checkbox' id='mtinputerCheck'/></td></tr>");
t.push("<tr><td><input class='button' type='button' value='&#30830;&#23450;' /></td><td><input class='button' type='button' value='&#21462;&#28040;' /></td></tr>")
MzTreeView.htmlInputer=t.join("") +"</table>";
MzTreeView.inputerhs=function(td)
{
  var tab = searchByTagName(td, "TABLE");
  var b=tab.rows[td.parentNode.rowIndex+1].style.display=="none";
  for(var i=td.parentNode.rowIndex+1; i<tab.rows.length-1; i++)
  b?MzEffect.show(tab.rows[i]):MzEffect.hide(tab.rows[i]);tab=td.innerHTML;
  td.innerHTML = tab.substring(0, tab.indexOf(" ")) +" "+
  (b ? "&lt;&lt;&lt;" : "&gt;&gt;&gt;");
  tab=document.getElementById("mtinputerIcon")
  b?MzEffect.show(tab):MzEffect.hide(tab);
};
MzTreeView.hideInputer=function()
{
  var inputer=document.getElementById("MzTreeInputer");
  inputer.parentNode.removeChild(inputer);
};

MzTreeView.prototype.showInputer = function()
{
  var container=document.createElement("DIV");
  container.style.width="100%";
  MzEffect.show(container);
  container.innerHTML = MzTreeView.htmlInputer;
  document.body.appendChild(container);
  var sel = document.getElementById("mtinputerIcon");
  sel.options.length=1;
  for(var i in MzTreeView.icons.collapse) if(!/^pm\d$/.test(i))
  sel.options[sel.options.length]=new Option(i, i, true, true);
  sel.selectedIndex=0;
};


mztreeview.css

/*=== MzTreeView Control Stylesheet ===*\
     Object: Stylesheet File for tree
    Version: 1.0
     Author: meizz
Last Update: 2006-06-22
\*=====================================*/

div.mztreeview
{
}
div.mztreeview td
{
    font-size: 9pt;
}
div.mztreeview img
{
    cursor: default;
    border: 0px none;
    vertical-align: middle;
}
div.mztreeview a
{
    font-size: 9pt;
    color: #000060;
    text-decoration: none;
}

div.mztreeview a.selected
{
    color: #FFFFFF;
    background-color: #0A246A;
}
.hide
{
    display: none;
}

/******* tree node inputer *******/
#MzTreeInputer
{
    width: 100%;
    font-size: 12px;
    background-color: #D4D0C8;
}
#MzTreeInputer col.caption
{
    width: 60px;
    line-height: 20px;
    text-align: right;
    vertical-align: top;
    background-color: #EAEAEA;
}
#MzTreeInputer col.content
{
    background-color: #FFFFFF;
}
#MzTreeInputer #mtinputeroption
{
    color: #000080;
    cursor: pointer;
    text-decoration: underline;
}
#MzTreeInputer #mtinputerCheck
{
    width: 80px;
}
#MzTreeInputer input.text
{
    width: 80px;
    font-size: 12px;
    border: inset 1px #D4D0C8;
}
#MzTreeInputer select
{
    width: 80px;
}

dialogShow.js
document.onkeydown = keyDown;
function keyDown(){
    var srcElem = document.activeElement; //取到当前焦点控件
    var tagName = srcElem.tagName.toUpperCase(); //取到当前控件名并转大写
     if(srcElem.type=='button'||srcElem.type=='submit'){//如果是button类型的
         if(window.event.keyCode==13 || window.event.keyCode==32){//enter的KEYCODE的值是13,通过监听可以控制。
             window.event.returnValue=false;
         }
     }else if(tagName=='TEXTAREA' || tagName =='INPUT'){
         return;
     }
     else{
         if(window.event.keyCode==13 || window.event.keyCode==32){//enter的KEYCODE的值是13,通过监听可以控制。
             window.event.returnValue=false;
         }
     }
}

//根据srcHeightId高度调整iframeId的高度
function changeSearchDiv(op)
{
    var closeSearchImg = document.getElementById("closeSearchImg");
    var openSearchImg = document.getElementById("openSearchImg");
    
    var searchbar = document.getElementById("seachbar");
    
    // 判断操作类型,op 取值:close 关闭搜索条 open:打开搜索条
    if(op == 'close')
    {
        openSearchImg.style.display="block";
        closeSearchImg.style.display="none";
        searchbar.style.display="none";
    }
    else if(op == 'open')
    {
        openSearchImg.style.display="none";
        closeSearchImg.style.display="block";
        searchbar.style.display="block";
    }
}

function showText(dialogTitle,textCnt,dialogW,dialogH,imgNum,showTipImg,hiddenButton)
{
    if(showTipImg == true)
    {
        var  img_select;
        if(imgNum == 1) {
            img_select = "<img src='../images/bg_tipsuccess.png'/>";
        }else if(imgNum == 2) {
            img_select = "<img src='images/bg_tipsuccess.png'/>";
        }else {
            img_select = "<img src='../images/bg_tipfailth.png'/>";
        }
    }
    else
    {
        var  img_select = "";
    }
    textCnt = decodeURI( textCnt );
    $("body").append("<div id='dialogbg'></div><div id='dialog'><h2 id='dialog_title'>"+dialogTitle+"<p id='btn_closedialog'></p></h2><div id='cnt_list'><table wborder='0' cellspacing='0' cellpadding='0'><tr><td valign='middle' id='text_color'>"+img_select+textCnt+"</td></tr></table></div><div id='btn_list'><input type='button' value="+$CON.CLOSE+" id='btn_dsure'/></div></div>");
    (imgNum == 1 || imgNum == 2)?$("#text_color").css({color:"#333"}):$("#text_color").css({color:"#C40000"});
    $("body input,body button").blur();
    $("#dialog").css({width:dialogW});
    $("#dialog").css({height:dialogH});
    var DW = $("#dialog").width();
    var DH = $("#dialog").height()-77;
    var webH = document.body.scrollHeight;
    var webvH =document.documentElement.clientHeight + document.documentElement.scrollTop ;
    var getH = (webH > webvH)?webH:webvH;
    $("#dialogbg").height(getH + "px");
    document.getElementById("dialog").style.left = (document.body.offsetWidth-$("#dialog").width()-2)/2 + "px";
    document.getElementById("dialog").style.top = (document.documentElement.clientHeight-$("#dialog").height()-2)/2 + document.documentElement.scrollTop + "px";
    $("#btn_list").css({width:DW});
    $("#cnt_list").css({width:DW-5});
    $("#cnt_list table").css({width:DW-20});
    $("#cnt_list,#cnt_list table").css({height:DH});
    
    if(hiddenButton)
    {
        $("#btn_closedialog").hide();
        $("#btn_dsure").hide();
    }
    
    
    
    $("#btn_closedialog,#btn_dsure").click(function()
     {
        
        if(hiddenButton)
        {
            return;
        }
        
        var dialog = $( "#showSuccessDialog" );
        dialog.val( '2' );
        $("#dialogbg,#dialog").remove();
        
        // 如果是IE6浏览器,select标签才需要隐藏
        if ( $.browser.msie && $.browser.version == '6.0' ) {
            $("select").css({visibility:"visible"});
        }
        
     });
    
    // 如果是IE6浏览器,select标签才需要隐藏
    if ( $.browser.msie && $.browser.version == '6.0' ) {
        $("select").css({visibility:"hidden"});
        $("#dialog select").css({visibility:"visible"});
    }
    
    moveWindow("dialog","dialog_title");
}
function showConfirmAndCancel(dialogTitle,textCnt,url,flag)
{
    
    var  img_select = "<img src='../images/ic_help.gif'/>";
    textCnt = decodeURI( textCnt );
    $("body").append("<div id='dialogbg'></div><div id='dialog'><h2 id='dialog_title'>"+dialogTitle+"<p id='btn_closedialog'></p></h2><div id='cnt_list'><table wborder='0' cellspacing='0' cellpadding='0'><tr><td valign='middle' id='text_color'>"+img_select+textCnt+"</td></tr></table></div><div id='btn_list'><input type='button' value="+$CON.SURE+" id='btn_deleteSure'/><input style='margin-left=10px;' type='button' value="+$CON.CANCEL+" id='btn_deleteCancel'/></div></div>");
    $("#text_color").css({color:"#C40000"});
    // $("#text_color").css({color:"#C40000"});
    $("body input,body button").blur();
    $("#dialog").css({width:400});
    $("#dialog").css({height:200});
    var DW = $("#dialog").width();
    var DH = $("#dialog").height()-77;
    var webH = document.body.scrollHeight;
    var webvH =document.documentElement.clientHeight + document.documentElement.scrollTop ;
    var getH = (webH > webvH)?webH:webvH;
    $("#dialogbg").height(getH + "px");
    document.getElementById("dialog").style.left = (document.body.offsetWidth-$("#dialog").width()-2)/2 + "px";
    document.getElementById("dialog").style.top = (document.documentElement.clientHeight-$("#dialog").height()-2)/2 + document.documentElement.scrollTop + "px";
    
    $("#btn_list").css({width:DW});
    $("#cnt_list").css({width:DW-5});
    
    $("#cnt_list table").css({width:DW-20});
    $("#cnt_list,#cnt_list table").css({height:DH});
    $("#btn_closedialog,#btn_dsure,#btn_deleteCancel").click(function()
     {
        var dialog = $( "#showSuccessDialog" );
        dialog.val( '2' );
        $("#dialogbg,#dialog").remove();
        
        // 如果是IE6浏览器,select标签才需要隐藏
        if ( $.browser.msie && $.browser.version == '6.0' ) {
            $("select").css({visibility:"visible"});
        }
        
     });
    
    // 如果是IE6浏览器,select标签才需要隐藏
    if ( $.browser.msie && $.browser.version == '6.0' ) {
        $("select").css({visibility:"hidden"});
        $("#dialog select").css({visibility:"visible"});
    }
    $("#btn_deleteSure").click(function(){
        $(this).remove();
        $("#btn_deleteCancel").remove();
        if(url == "up"){
            onUpShelfBtnClick(1);
            $("#dialogbg,#dialog").remove();
        }else if(url == "down"){
            onDownShelfBtnClick();
            $("#dialogbg,#dialog").remove();
        }else if(url == "up2"){
            onUpShelfBtnClick(2);
            $("#dialogbg,#dialog").remove();
        }else if(url == "deleteChannelResource"){
            deleteChannelResource();
        }else if(url == "ajaxDeleteObject"){
            ajaxDeleteObject();
            $("#dialogbg,#dialog").remove();
        }else if(url == "removeLocalAllAjax"){   
            frame_content.lFrame.removeLocalAllAjax();
            $("#dialogbg,#dialog").remove();
        }
        else{
            if(((typeof url)=="string"))
            {
                if(flag!=null&&flag==true) {
                    frame_content.mFrame.mainResourceFrame.location = url;
                    $("#dialogbg,#dialog").remove();
                }else{
                    window.location = url;
                }
            }
            else
            {
                url.submit();
            }
        }}
        );
    
    moveWindow("dialog","dialog_title");
}

function showConfirmAndCancel_b(dialogTitle,textCnt,url)
{
    var  img_select = "<img src='../images/ic_help.gif'/>";
    textCnt = decodeURI( textCnt );
    $("body").append("<div id='dialogbg'></div><div id='dialog'><h2 id='dialog_title'>"+dialogTitle+"<p id='btn_closedialog'></p></h2><div id='cnt_list'><table wborder='0' cellspacing='0' cellpadding='0'><tr><td valign='middle' id='text_color'>"+img_select+textCnt+"</td></tr></table></div><div id='btn_list'><input type='button' value="+$CON.SURE+" id='btn_deleteSure'/><input style='margin-left=10px;' type='button' value="+$CON.CANCEL+" id='btn_deleteCancel'/></div></div>");
    $("#text_color").css({color:"#C40000"});
    // $("#text_color").css({color:"#C40000"});
    $("body input,body button").blur();
    $("#dialog").css({width:400});
    $("#dialog").css({height:200});
    var DW = $("#dialog").width();
    var DH = $("#dialog").height()-77;
    var webH = document.body.scrollHeight;
    var webvH =document.documentElement.clientHeight + document.documentElement.scrollTop ;
    var getH = (webH > webvH)?webH:webvH;
    $("#dialogbg").height(getH + "px");
    document.getElementById("dialog").style.left = (document.body.offsetWidth-$("#dialog").width()-2)/2 + "px";
    document.getElementById("dialog").style.top = (document.documentElement.clientHeight-$("#dialog").height()-2)/2 + document.documentElement.scrollTop + "px";
    $("#btn_list").css({width:DW});
    $("#cnt_list").css({width:DW-5});
    
    $("#cnt_list table").css({width:DW-20});
    $("#cnt_list,#cnt_list table").css({height:DH});
    $("#btn_closedialog,#btn_dsure,#btn_deleteCancel").click(function()
     {
        var dialog = $( "#showSuccessDialog" );
        dialog.val( '2' );
        $("#dialogbg,#dialog").remove();
        
        // 如果是IE6浏览器,select标签才需要隐藏
        if ( $.browser.msie && $.browser.version == '6.0' ) {
            $("select").css({visibility:"visible"});
        }
        
     });
    
    // 如果是IE6浏览器,select标签才需要隐藏
    if ( $.browser.msie && $.browser.version == '6.0' ) {
        $("select").css({visibility:"hidden"});
        $("#dialog select").css({visibility:"visible"});
    }
    $("#btn_deleteSure").click(function(){
            $("#dialogbg,#dialog").remove();
            frame_content.lFrame.removeNodes();
        }
    );
    moveWindow("dialog","dialog_title");
}

function showConfirmAndCancelSyncCategory(dialogTitle,textCnt,url)
{
    var  img_select = "<img src='../images/ic_help.gif'/>";
    textCnt = decodeURI( textCnt );
    $("body").append("<div id='dialogbg'></div><div id='dialog'><h2 id='dialog_title'>"+dialogTitle+"<p id='btn_closedialog'></p></h2><div id='cnt_list'><table wborder='0' cellspacing='0' cellpadding='0'><tr><td valign='middle' id='text_color'>"+img_select+textCnt+"</td></tr></table></div><div id='btn_list'><input type='button' value="+$CON.SURE+" id='btn_deleteSure'/><input style='margin-left=10px;' type='button' value="+$CON.CANCEL+" id='btn_deleteCancel'/></div></div>");
    $("#text_color").css({color:"#C40000"});
    $("body input,body button").blur();
    $("#dialog").css({width:400});
    $("#dialog").css({height:200});
    var DW = $("#dialog").width();
    var DH = $("#dialog").height()-77;
    var webH = document.body.scrollHeight;
    var webvH =document.documentElement.clientHeight + document.documentElement.scrollTop ;
    var getH = (webH > webvH)?webH:webvH;
    $("#dialogbg").height(getH + "px");
    document.getElementById("dialog").style.left = (document.body.offsetWidth-$("#dialog").width()-2)/2 + "px";
    document.getElementById("dialog").style.top = (document.documentElement.clientHeight-$("#dialog").height()-2)/2 + document.documentElement.scrollTop + "px";
    $("#btn_list").css({width:DW});
    $("#cnt_list").css({width:DW-5});
    
    $("#cnt_list table").css({width:DW-20});
    $("#cnt_list,#cnt_list table").css({height:DH});
    $("#btn_closedialog,#btn_dsure,#btn_deleteCancel").click(function()
     {
        var dialog = $( "#showSuccessDialog" );
        dialog.val( '2' );
        $("#dialogbg,#dialog").remove();
        
        // 如果是IE6浏览器,select标签才需要隐藏
        if ( $.browser.msie && $.browser.version == '6.0' ) {
            $("select").css({visibility:"visible"});
        }
        
     });
    
    // 如果是IE6浏览器,select标签才需要隐藏
    if ( $.browser.msie && $.browser.version == '6.0' ) {
        $("select").css({visibility:"hidden"});
        $("#dialog select").css({visibility:"visible"});
    }
    $("#btn_deleteSure").click(function(){
            $("#dialogbg,#dialog").remove();
            frame_content.lFrame.syncNodes();
        }
    );
    moveWindow("dialog","dialog_title");
}

function showConfirmAndCancelSite(dialogTitle,textCnt,url)
{
    var  img_select = "<img src='../images/ic_help.gif'/>";
    textCnt = decodeURI( textCnt );
    $("body").append("<div id='dialogbg'></div><div id='dialog'><h2 id='dialog_title'>"+dialogTitle+"<p id='btn_closedialog'></p></h2><div id='cnt_list'><table wborder='0' cellspacing='0' cellpadding='0'><tr><td valign='middle' id='text_color'>"+img_select+textCnt+"</td></tr></table></div><div id='btn_list'><input type='button' value="+$CON.SURE+" id='btn_deleteSure'/><input style='margin-left=10px;' type='button' value="+$CON.CANCEL+" id='btn_deleteCancel'/></div></div>");
    $("#text_color").css({color:"#C40000"});
    // $("#text_color").css({color:"#C40000"});
    $("body input,body button").blur();
    $("#dialog").css({width:400});
    $("#dialog").css({height:200});
    var DW = $("#dialog").width();
    var DH = $("#dialog").height()-77;
    var webH = document.body.scrollHeight;
    var webvH =document.documentElement.clientHeight + document.documentElement.scrollTop ;
    var getH = (webH > webvH)?webH:webvH;
    $("#dialogbg").height(getH + "px");
    document.getElementById("dialog").style.left = (document.body.offsetWidth-$("#dialog").width()-2)/2 + "px";
    document.getElementById("dialog").style.top = (document.documentElement.clientHeight-$("#dialog").height()-2)/2 + document.documentElement.scrollTop + "px";
    
    $("#btn_list").css({width:DW});
    $("#cnt_list").css({width:DW-5});
    
    $("#cnt_list table").css({width:DW-20});
    $("#cnt_list,#cnt_list table").css({height:DH});
    $("#btn_closedialog,#btn_dsure,#btn_deleteCancel").click(function()
     {
        var dialog = $( "#showSuccessDialog" );
        dialog.val( '2' );
        $("#dialogbg,#dialog").remove();
        
        // 如果是IE6浏览器,select标签才需要隐藏
        if ( $.browser.msie && $.browser.version == '6.0' ) {
            $("select").css({visibility:"visible"});
        }
        
     });
    
    // 如果是IE6浏览器,select标签才需要隐藏
    if ( $.browser.msie && $.browser.version == '6.0' ) {
        $("select").css({visibility:"hidden"});
        $("#dialog select").css({visibility:"visible"});
    }
    $("#btn_deleteSure").click(function(){
        parent.document.getElementById("showSuccessDialog").value = 1;
            parent.window.location = url;
            
    });
    
    moveWindow("dialog","dialog_title");
}
function showConfirmAndCancelFunc(dialogTitle,textCnt,func)
{
    
    var  img_select = "<img src='../images/ic_help.gif'/>";
    textCnt = decodeURI( textCnt );
    $("body").append("<div id='dialogbg'></div><div id='dialog'><h2 id='dialog_title'>"+dialogTitle+"<p id='btn_closedialog'></p></h2><div id='cnt_list'><table wborder='0' cellspacing='0' cellpadding='0'><tr><td valign='middle' id='text_color'>"+img_select+textCnt+"</td></tr></table></div><div id='btn_list'><input type='button' value="+$CON.SURE+" id='btn_deleteSure' onclick='"+func+";'/><input style='margin-left=10px;' type='button' value="+$CON.CANCEL+" id='btn_deleteCancel'/></div></div>");
    $("#text_color").css({color:"#C40000"});
    // $("#text_color").css({color:"#C40000"});
    $("body input,body button").blur();
    $("#dialog").css({width:400});
    $("#dialog").css({height:200});
    var DW = $("#dialog").width();
    var DH = $("#dialog").height()-77;
    var webH = document.body.scrollHeight;
    var webvH =document.documentElement.clientHeight + document.documentElement.scrollTop ;
    var getH = (webH > webvH)?webH:webvH;
    $("#dialogbg").height(getH + "px");
    document.getElementById("dialog").style.left = (document.body.offsetWidth-$("#dialog").width()-2)/2 + "px";
    document.getElementById("dialog").style.top = (document.documentElement.clientHeight-$("#dialog").height()-2)/2 + document.documentElement.scrollTop + "px";
    $("#btn_list").css({width:DW});
    $("#cnt_list").css({width:DW-5});
    $("#cnt_list table").css({width:DW-20});
    $("#cnt_list,#cnt_list table").css({height:DH});
    $("#btn_closedialog,#btn_dsure,#btn_deleteCancel").click(function()
     {
        var dialog = $( "#showSuccessDialog" );
        dialog.val( '2' );
        $("#dialogbg,#dialog").remove();
        
        // 如果是IE6浏览器,select标签才需要隐藏
        if ( $.browser.msie && $.browser.version == '6.0' ) {
            $("select").css({visibility:"visible"});
        }
        
     });
    
    // 如果是IE6浏览器,select标签才需要隐藏
    if ( $.browser.msie && $.browser.version == '6.0' ) {
        $("select").css({visibility:"hidden"});
        $("#dialog select").css({visibility:"visible"});
    }
    moveWindow("dialog","dialog_title");
}


// delete data
function showPage(dialogTitle,pageName,dialogW,dialogH)
{
    $("body").append("<div id='dialogbg'></div><div id='dialog'><h2 id='dialog_title'>"+dialogTitle+"<p id='btn_closedialog'></p></h2><iframe name='framelist' id='framelist' frameborder='0' src="+pageName+" height='auto'></iframe><div id='btn_list'><input type='button' value="+$CON.CLOSE+" id='btn_dsure'/></div></div>");
    // var gH = top.frames["framelist"].document.body.scrollHeight;
    // alert(gH);
    $("input,body button").blur();
    
    $("#dialog").css({width:dialogW});
    $("#dialog").css({height:dialogH});
    var DW = $("#dialog").width();
    var DH = $("#dialog").height()-75;
    var webH = document.body.scrollHeight;
    var webvH =document.documentElement.clientHeight + document.documentElement.scrollTop ;
    var getH = (webH > webvH)?webH:webvH;
    $("#dialogbg").height(getH + "px");
    document.getElementById("dialog").style.left = (document.body.offsetWidth-$("#dialog").width()-2)/2 + "px";
    document.getElementById("dialog").style.top = (document.documentElement.clientHeight-$("#dialog").height()-2)/2 + document.documentElement.scrollTop + "px";
    $("#btn_list").css({width:DW});
    $("#cnt_list").css({width:DW});
    $("#framelist").css({padding:"5px",overflow:"auto"});
    $("#framelist").attr("width",DW-10);
    $("#framelist").attr("height",DH-10);
    // $("#cnt_list iframe").attr("width",DW);
    $("#btn_dsure,#btn_closedialog").click(function()
     {      
        if($("endTime").value||$("startTime").value)
        {
            WdatePicker.hide;
        }
        var dialog = $( "#showSuccessDialog" );
        dialog.val( '2' );
        
        $("#dialogbg,#dialog").remove();
        
        // 如果是IE6浏览器,select标签才需要隐藏
        if ( $.browser.msie && $.browser.version == '6.0' ) {
            $("select").css({visibility:"visible"});
        }
     });
    // 如果是IE6浏览器,select标签才需要隐藏
    if ( $.browser.msie && $.browser.version == '6.0' ) {
        $("select").css({visibility:"hidden"});
        $("#dialog select").css({visibility:"visible"});
    }
    moveWindow("dialog","dialog_title");
    
    return false;
}

//克隆
function showClonePage(dialogTitle,pageName,dialogW,dialogH)
{
    $("body").append("<div id='dialogbg'></div><div id='dialog'><h2 id='dialog_title'>"+dialogTitle+"<p id='btn_closedialog'></p></h2><iframe name='framelist' id='framelist' frameborder='0' src="+pageName+" height='auto' ></iframe><div id='btn_list' style='background:#e9f0f9;'><input type='button' value="+$CON.SURE+" id='btn_dclone'/>    <input type='button' value="+$CON.CLOSE+" id='btn_dsure'/></div></div>");
    // var gH = top.frames["framelist"].document.body.scrollHeight;
    // alert(gH);
    $("input,body button").blur();
    
    $("#dialog").css({width:dialogW});
    $("#dialog").css({height:dialogH});
    var DW = $("#dialog").width();
    var DH = $("#dialog").height()-75;
    var webH = document.body.scrollHeight;
    var webvH =document.documentElement.clientHeight + document.documentElement.scrollTop ;
    var getH = (webH > webvH)?webH:webvH;
    $("#dialogbg").height(getH + "px");
    document.getElementById("dialog").style.left = (document.body.offsetWidth-$("#dialog").width()-2)/2 + "px";
    document.getElementById("dialog").style.top = (document.documentElement.clientHeight-$("#dialog").height()-2)/2 + document.documentElement.scrollTop + "px";
    $("#btn_list").css({width:DW});
    $("#cnt_list").css({width:DW});
    $("#framelist").css({overflow:"auto"});
    $("#framelist").attr("width",DW-10);
    $("#framelist").attr("height",DH-10);
    $("#btn_closedialog,#btn_dsure").click(function()
     {
        var dialog = $( "#showSuccessDialog" );
        dialog.val( '2' );
        $("#dialogbg,#dialog").remove();
        
        // 如果是IE6浏览器,select标签才需要隐藏
        if ( $.browser.msie && $.browser.version == '6.0' ) {
            $("select").css({visibility:"visible"});
        }
     });
    
    $("#btn_dclone").click(function(){
        window.frames["framelist"].multipleClone();
    });
    // 如果是IE6浏览器,select标签才需要隐藏
    if ( $.browser.msie && $.browser.version == '6.0' ) {
        $("select").css({visibility:"hidden"});
        $("#dialog select").css({visibility:"visible"});
    }
    moveWindow("dialog","dialog_title");
    
    return false;
}

//delete data
function showResourcePage(dialogTitle,pageName,dialogW,dialogH)
{
    $("body").append("<div id='dialogbg'></div><div id='dialog'><h2 id='dialog_title'>"+dialogTitle+"<p id='btn_closedialog'></p></h2><iframe name='framelist'  id='framelist' frameborder='0' src="+pageName+" ></iframe><div id='btn_list'><input type='button' value="+CLOSE+" id='btn_dsure'/></div></div>");
    // var gH = top.frames["framelist"].document.body.scrollHeight;
    // alert(gH);
    $("input,body button").blur();
    $("#dialog").css({width:dialogW});
    $("#dialog").css({height:dialogH});
    var DW = $("#dialog").width();
    var DH = $("#dialog").height()-75;
    var webH = document.body.scrollHeight;
    var webvH =document.documentElement.clientHeight + document.documentElement.scrollTop ;
    var getH = (webH > webvH)?webH:webvH;
    $("#dialogbg").height(getH + "px");
    document.getElementById("dialog").style.left = (document.body.offsetWidth-$("#dialog").width()-2)/2 + "px";
    document.getElementById("dialog").style.top = (document.documentElement.clientHeight-$("#dialog").height()-2)/2 + document.documentElement.scrollTop + "px";
    $("#btn_list").css({width:DW});
    $("#cnt_list").css({width:DW});
    $("#framelist").css({padding:"0px",overflow:"auto",height:"90%"});
    //$("#framelist").attr("width",DW-10);
    //$("#framelist").attr("height",DW-10);
    // $("#cnt_list iframe").attr("width",DW);
    $("#btn_closedialog,#btn_dsure").click(function()
     {
        var dialog = $( "#showSuccessDialog" );
        dialog.val( '2' );
        $("#dialogbg,#dialog").remove();
        // 如果是IE6浏览器,select标签才需要隐藏
        if ( $.browser.msie && $.browser.version == '6.0' ) {
            $("select").css({visibility:"visible"});
        }
     });
    // 如果是IE6浏览器,select标签才需要隐藏
    if ( $.browser.msie && $.browser.version == '6.0' ) {
        $("select").css({visibility:"hidden"});
        $("#dialog select").css({visibility:"visible"});
    }
    moveWindow("dialog","dialog_title");
    
    return false;
}


function showPageTask(dialogTitle,pageName,dialogW,dialogH,suburl)
{
    
    $("body").append("<div id='dialogbg'></div><div id='dialog'><h2 id='dialog_title'>"+dialogTitle+"<p id='btn_closedialog'></p></h2><iframe name='framelist' id='framelist' frameborder='0' src="+pageName+" height='auto'></iframe><div id='btn_list'><input type='button' value="+$CON.CLOSE+" id='btn_dsure'/></div></div>");
    // var gH = top.frames["framelist"].document.body.scrollHeight;
    // alert(gH);
    $("input,body button").blur();
    $("#dialog").css({width:dialogW});
    $("#dialog").css({height:dialogH});
    var DW = $("#dialog").width();
    var DH = $("#dialog").height()-75;
    var webH = document.body.scrollHeight;
    var webvH =document.documentElement.clientHeight + document.documentElement.scrollTop ;
    var getH = (webH > webvH)?webH:webvH;
    $("#dialogbg").height(getH + "px");
    document.getElementById("dialog").style.left = (document.body.offsetWidth-$("#dialog").width()-2)/2 + "px";
    document.getElementById("dialog").style.top = (document.documentElement.clientHeight-$("#dialog").height()-2)/2 + document.documentElement.scrollTop + "px";
    $("#btn_list").css({width:DW});
    $("#cnt_list").css({width:DW});
    $("#framelist").css({padding:"5px",overflow:"auto"});
    $("#framelist").attr("width",DW-10);
    $("#framelist").attr("height",DH-10);
    // $("#cnt_list iframe").attr("width",DW);
    $("#btn_closedialog,#btn_dsure").click(function()
     {
        var dialog = $( "#showSuccessDialog" );
        dialog.val( '2' );
        $("#dialogbg,#dialog").remove();
        window.location = suburl;
        
        // 如果是IE6浏览器,select标签才需要隐藏
        if ( $.browser.msie && $.browser.version == '6.0' ) {
            $("select").css({visibility:"visible"});
        }
     });
    
    // 如果是IE6浏览器,select标签才需要隐藏
    if ( $.browser.msie && $.browser.version == '6.0' ) {
        $("select").css({visibility:"hidden"});
        $("#dialog select").css({visibility:"visible"});
    }
    moveWindow("dialog","dialog_title");
    
    return false;
}

function showPageTask2(dialogTitle,pageName,dialogW,dialogH,suburl)
{
    
    $("body").append("<div id='dialogbg'></div><div id='dialog'><h2 id='dialog_title'>"+dialogTitle+"<p id='btn_closedialog'></p></h2><iframe name='framelist' id='framelist' frameborder='0' src="+pageName+" height='auto'></iframe><div id='btn_list'><input type='button' value="+$CON.CLOSE+" id='btn_dsure'/></div></div>");
    // var gH = top.frames["framelist"].document.body.scrollHeight;
    // alert(gH);
    $("input,body button").blur();
    $("#dialog").css({width:dialogW});
    $("#dialog").css({height:dialogH});
    var DW = $("#dialog").width();
    var DH = $("#dialog").height()-75;
    var webH = document.body.scrollHeight;
    var webvH =document.documentElement.clientHeight + document.documentElement.scrollTop ;
    var getH = (webH > webvH)?webH:webvH;
    $("#dialogbg").height(getH + "px");
    document.getElementById("dialog").style.left = (document.body.offsetWidth-$("#dialog").width()-2)/2 + "px";
    document.getElementById("dialog").style.top = (document.documentElement.clientHeight-$("#dialog").height()-2)/2 + document.documentElement.scrollTop + "px";
    $("#btn_list").css({width:DW});
    $("#cnt_list").css({width:DW});
    $("#framelist").css({padding:"5px",overflow:"auto"});
    $("#framelist").attr("width",DW-10);
    $("#framelist").attr("height",DH-10);
    // $("#cnt_list iframe").attr("width",DW);
    $("#btn_closedialog,#btn_dsure").click(function()
     {
        var dialog = $( "#showSuccessDialog" );
        dialog.val( '2' );
        $("#dialogbg,#dialog").remove();
        window.location = suburl;
        
        // 如果是IE6浏览器,select标签才需要隐藏
        if ( $.browser.msie && $.browser.version == '6.0' ) {
            $("select").css({visibility:"visible"});
        }
     });
    
    // 如果是IE6浏览器,select标签才需要隐藏
    if ( $.browser.msie && $.browser.version == '6.0' ) {
        $("select").css({visibility:"hidden"});
        $("#dialog select").css({visibility:"visible"});
    }
    moveWindow("dialog","dialog_title");
    
    return false;
}


function showPagePublishCode(dialogTitle,pageName,dialogW,dialogH,suburl)
{
    
    $("body").append("<div id='dialogbg'></div><div id='dialog'><h2 id='dialog_title'>"+dialogTitle+"<p id='btn_closedialog'></p></h2><iframe name='framelist' id='framelist' frameborder='0' src="+pageName+" height='auto'></iframe><div id='btn_list'><input type='button' value="+$CON.CLOSE+" id='btn_dsure'/></div></div>");
    // var gH = top.frames["framelist"].document.body.scrollHeight;
    // alert(gH);
    $("input,body button").blur();
    $("#dialog").css({width:dialogW});
    $("#dialog").css({height:dialogH});
    var DW = $("#dialog").width();
    var DH = $("#dialog").height()-75;
    var webH = document.body.scrollHeight;
    var webvH =document.documentElement.clientHeight + document.documentElement.scrollTop ;
    var getH = (webH > webvH)?webH:webvH;
    $("#dialogbg").height(getH + "px");
    document.getElementById("dialog").style.left = (document.body.offsetWidth-$("#dialog").width()-2)/2 + "px";
    document.getElementById("dialog").style.top = (document.documentElement.clientHeight-$("#dialog").height()-2)/2 + document.documentElement.scrollTop + "px";
    $("#btn_list").css({width:DW});
    $("#cnt_list").css({width:DW});
    $("#framelist").css({padding:"5px",overflow:"auto"});
    $("#framelist").attr("width",DW-10);
    $("#framelist").attr("height",DH-10);
    // $("#cnt_list iframe").attr("width",DW);
    $("#btn_closedialog,#btn_dsure").click(function()
     {
        var dialog = $( "#showSuccessDialog" );
        dialog.val( '2' );
        $("#dialogbg,#dialog").remove();
        
        var queryString = document.getElementById("hostsId").value;

        window.location = suburl+"&"+queryString;
        
        // 如果是IE6浏览器,select标签才需要隐藏
        if ( $.browser.msie && $.browser.version == '6.0' ) {
            $("select").css({visibility:"visible"});
        }
     });
    
    // 如果是IE6浏览器,select标签才需要隐藏
    if ( $.browser.msie && $.browser.version == '6.0' ) {
        $("select").css({visibility:"hidden"});
        $("#dialog select").css({visibility:"visible"});
    }
    moveWindow("dialog","dialog_title");
    
    return false;
}
function showPageByWithScroll(dialogTitle,pageName,dialogW,dialogH)
{
    $("body").append("<div id='dialogbg'></div><div id='dialog'><h2 id='dialog_title'>"+dialogTitle+"<p id='btn_closedialog'></p></h2><iframe name='framelist' id='framelist' frameborder='0' src="+pageName+" height='auto'></iframe><div id='btn_list'><input type='button' value="+$CON.CLOSE+" id='btn_dsure'/></div></div>");
    // var gH = top.frames["framelist"].document.body.scrollHeight;
    // alert(gH);
    $("input,body button").blur();
    $("#dialog").css({width:dialogW});
    $("#dialog").css({height:dialogH});
    var DW = $("#dialog").width();
    var DH = $("#dialog").height()-75;
    var webH = document.body.scrollHeight;
    var webvH =document.documentElement.clientHeight + document.documentElement.scrollTop ;
    var getH = (webH > webvH)?webH:webvH;
    $("#dialogbg").height(getH + "px");
    document.getElementById("dialog").style.left = (document.body.offsetWidth-$("#dialog").width()-2)/2 + "px";
    document.getElementById("dialog").style.top = (document.documentElement.clientHeight-$("#dialog").height()-2)/2 + document.documentElement.scrollTop + "px";
    $("#btn_list").css({width:DW});
    $("#cnt_list").css({width:DW});
    var getua = navigator.userAgent;
    if(/Gecko/.test(getua))
    {
        $("#framelist").css({padding:"5px",overflow:"scroll","overflow-x":"hidden"});
    }
    else
    {
        $("#framelist").css({padding:"5px",overflow:"hidden"});
    }
    
    $("#framelist").attr("width",DW-10);
    $("#framelist").attr("height",DH-10);
    // $("#cnt_list iframe").attr("width",DW);
    $("#btn_closedialog,#btn_dsure").click(function()
     {
        var dialog = $( "#showSuccessDialog" );
        dialog.val( '2' );
        $("#dialogbg,#dialog").remove();
        // 如果是IE6浏览器,select标签才需要隐藏
        if ( $.browser.msie && $.browser.version == '6.0' ) {
            $("select").css({visibility:"visible"});
        }
     });
    
    // 如果是IE6浏览器,select标签才需要隐藏
    if ( $.browser.msie && $.browser.version == '6.0' ) {
        $("select").css({visibility:"hidden"});
        $("#dialog select").css({visibility:"visible"});
    }
    moveWindow("dialog","dialog_title");
    
    return false;
}


function moveWindow(windowID,windowHandleID)
{
        var box = document.getElementById(windowID);    
        var boxHandle = document.getElementById(windowHandleID);
        var mx, my, ox, oy;
        function e(event){
           if( ! event){
              event = window.event;
              event.target = event.srcElement;
              event.layerX = event.offsetX;
              event.layerY = event.offsetY;
           }
           event.mx = event.pageX || event.clientX + document.body.scrollLeft;
           event.my = event.pageY || event.clientY + document.body.scrollTop;     
           return event;     
        }
        boxHandle.onmousedown = moveEvent;
        function moveEvent(event){     
           event = e(event);     
           ox = parseInt(box.offsetLeft);     
           oy = parseInt(box.offsetTop);     
           mx = event.mx;     
           my = event.my;     
           document.onmousemove = moveBox;     
           document.onmouseup = stopBox;     
        }
        function moveBox(event){     
           event = e(event);
           box.style.left = ox + event.mx - mx  + "px";    
           box.style.top = oy + event.my - my + "px";    
        }
        function stopBox(event){     
           // alert('');
           event = e(event);
           ox = parseInt(box.offsetLeft);     
           oy = parseInt(box.offsetTop);     
           mx = event.mx ;     
           my = event.my ;     
           document.onmousemove = null;
           document.onmouseup = null;
        }
        
}

/** 去掉字符串前后的空格 */
String.prototype.trim = function(){  
    // 用正则表达式将前后空格
    // 用空字符串替代。
    return this.replace(/(^\s*)|(\s*$)/g, "");  
};

/** 显示成功的窗口 */
function showSuccessWindow( successMessageContent, failuredMessageContent ) {
    var dialog = $( "#showSuccessDialog" );
    var show = dialog.val();
    if ( show != '0' && show != '2' ) {
        showText($CON.MESSAGE_TIP, successMessageContent,400,200,1,true);
        $("#dialogbg,#dialog").fadeOut(5000,function(){
            $(this).remove();
            dialog.val( '2' );
            $("select").css({visibility:"visible"});
            $("#dialog select").css({visibility:"visible"});
        });
    }
    
    if ( show != '1' && show != '2' ) {
        showText($CON.MESSAGE_TIP, failuredMessageContent,400,200,0,true);
        
    }
}
/** 显示成功的窗口 */
function showSuccessWindowLogin( successMessageContent, failuredMessageContent ) {
    var dialog = $( "#showSuccessDialog" );
    var show = dialog.val();
    
    if(typeof show != "undefined" && show.length != 0){
    if ( show != '0' && show != '2' ) {
        showText($CON.MESSAGE_TIP, successMessageContent,400,200,2,true);
        $("#dialogbg,#dialog").fadeOut(3000,function(){dialog.val( '2' );$(this).remove();});
    }
    
    if ( show != '1' && show != '2' ) {
        showText($CON.MESSAGE_TIP, failuredMessageContent,400,200,0,true);
        $("#dialogbg,#dialog").fadeOut(3000,function(){dialog.val( '2' );$(this).remove();});
    }
    }
}

/** 在父页面显示成功的窗口
 * num 表示父页面的层级数量
 * */
function showSuccessWindowByParent( successMessageContent, failuredMessageContent ,num) {
    var dialog = $( "#showSuccessDialog" );
    var show = dialog.val();
    var father;
    if(num==2)
    father = parent.parent;
    else if(num==3)
    father = parent.parent.parent;
    else
    father = parent;
    if ( show != '0' && show != '2' ) {
        //直接执行后面的一句会报错
            father.showText($CON.MESSAGE_TIP, successMessageContent,400,200,1,true);
            var dialogbg =father.document.getElementById('dialogbg');
            var dialog1 =father.document.getElementById('dialog');
            $(dialog1).fadeOut(3000,function(){
                $(dialog1).remove();
            });
            $(dialogbg).fadeOut(5000,function(){
                $(dialogbg).remove();
            });
            dialog.val('2');
            $("select").css({visibility:"visible"});
            $("#dialog select").css({visibility:"visible"});
    }
    if ( show != '1' && show != '2' ) {
        father.showText($CON.MESSAGE_TIP, failuredMessageContent,400,200,0,true);
    }
}

/** 显示失败的窗口 */
function showFailuredWindow( failuredMessageContent ) {
    var dialog = $( "#showSuccessDialog" );
    var show = dialog.val();
    if ( show != '1' && show != '2' ) {
        showText($CON.MESSAGE_TIP, failuredMessageContent,400,200,0,true);
    }
}

/** 对&gt;解码成>,然后在用encodeURI进行统一编码。 */
function decode( str ) {
    if ( str == null ) {
        return null;
    }
    
    str = str.replace(/\&gt;/g, ">");
    str = str.replace(/\&lt;/g, "<");
    str = str.replace(/\&amp;/g, "&");
    
    return str;
}

/** 弹出角色详情的对话框 */
function showRoleDetailDialog( link, messageTip ) {
    var id = link.id;
    link.href = "###";
    var table = document.getElementById( "roleList" ).rows[ id ];
    var roleId = table.cells[3].innerHTML.trim();
    var buffer = new StringBuffer();
    buffer.append( "role.roleId=" );
    buffer.append( roleId );
    buffer.append( "&noPrivilegeOnlyText=true" );
    var queryString = encodeURI( buffer.toString());
    showPage( messageTip,'../RoleManage/BrowseRole.action?'+queryString, 610, 260 );
}

/** 弹出用户详情的对话框 */
function showAdminDetailDialog( link, messageTip ) {
    var id = link.id;
    link.href = "###";
    var table = document.getElementById( "adminsList" ).rows[ id ];
    var loginName       = table.cells[1].innerHTML.trim();
    var userName        = link.innerHTML.trim();
    var status          = table.cells[3].innerHTML.trim();
    var roleList          = table.cells[4].innerHTML.trim();
    var email            = table.cells[5].innerHTML.trim();
    var phone             = table.cells[6].innerHTML.trim();
    var buffer = new StringBuffer();
    buffer.append( "admin.loginName=" );
    buffer.append( loginName );
    buffer.append( "&admin.username=" );
    buffer.append( decode(userName) );
    buffer.append( "&admin.status=" );
    buffer.append( status );
    buffer.append( "&admin.role=" );
    buffer.append( roleList );
    buffer.append( "&admin.email=" );
    buffer.append( email );
    buffer.append( "&admin.phone=" );
    buffer.append( phone );
    buffer.append( "&noPrivilegeOnlyText=true" );
    
    var queryString = encodeURI( buffer.toString() );
    
    showPage(messageTip,'../admin/adminView.action?'+queryString, 610, 300 );
}

/** 弹出消息详情的对话框 */
function showMessageDetailDialog( link, messageTip ) {
    var id = link.id;
    link.href = "###";
    var table = document.getElementById( "messagesList" ).rows[ id ];
    var messageId             = table.cells[8].innerHTML.trim();
    var buffer = new StringBuffer();
    buffer.append( "message.id=" );
    buffer.append( messageId );
    buffer.append( "&noPrivilegeOnlyText=true" );
    
    var queryString = encodeURI( buffer.toString() );
    
    showPage(messageTip,'../messageManage/findMessageById.action?'+queryString, 610, 380 );
}

/** 弹出日志详情的对话框 */
function showLogDetailDialog( link, messageTip ) {
    var id = link.id;
    link.href = "###";
    var table = document.getElementById( "logList" ).rows[ id ];
    var operateDate    = table.cells[0].innerHTML.trim();
    var operator       = table.cells[1].innerHTML.trim();
    var operateModule  = table.cells[2].innerHTML.trim();
    var ipAddr         = table.cells[5].innerHTML.trim();
    var operateType    = table.cells[6].innerHTML.trim();
    var operateResult  = table.cells[7].innerHTML.trim();
    var operateDesc    = table.cells[8].innerHTML.trim();
    var logId            = table.cells[9].innerHTML.trim();
    var buffer = new StringBuffer();
    buffer.append( "logBean.logId=" );
    buffer.append( logId );
    /*
     * buffer.append( "&logBean.viewOperateTime=" ); buffer.append( operateDate );
     * buffer.append( "&logBean.operatModuleName=" ); buffer.append(
     * decode(operateModule) ); buffer.append( "&logBean.operateObject=" );
     * buffer.append( operateObject ); buffer.append( "&logBean.operateType=" );
     * buffer.append( operateType ); buffer.append( "&logBean.result=" );
     * buffer.append( operateResult ); buffer.append( "&logBean.ipAddr=" );
     * buffer.append( ipAddr ); buffer.append( "&logBean.description=" );
     * buffer.append( operateDesc );
     */
    buffer.append( "&noPrivilegeOnlyText=true" );
    buffer.append( "&errorPageWindow=true" );
    
    var queryString = encodeURI( buffer.toString() );    
    showPage( messageTip,'../SysManage/BrowseLogDetail.action?' + queryString, 610, 420);
}

/** 弹出频点详情的对话框 */
function showRegionFreqDetailDialog( link, messageTip ) {
    var id = link.id;
    link.href = "###";
    var table = document.getElementById( "regionList" ).rows[ id ];
    var freqId  = table.cells[6].innerHTML.trim();
    var buff = new StringBuffer();
    buff.append( "reqionFreq.freqId=" );
    buff.append( freqId );
    buff.append( "&noPrivilegeOnlyText=true" );
    buff.append( "&errorPageWindow=true" );
    
    var queryString = encodeURI( buff.toString() );
    // alert( queryString );
    showPage( messageTip,'../SysManage/QueryRegionDetail.action?' + queryString, 610, 280);
}

/** 弹出IEPG参数详情的对话框 */
function showIepgParameterDetailDialog( link, messageTip ) {
    var id = link.id;
    link.href = "###";
    var table = document.getElementById( "iepgParameterList" ).rows[ id ];
    var id  = table.cells[7].innerHTML.trim();
    var buff = new StringBuffer();
    buff.append( "iepgParameter.Id=" );
    buff.append( id );
    buff.append( "&noPrivilegeOnlyText=true" );
    buff.append( "&errorPageWindow=true" );
    
    var queryString = encodeURI( buff.toString() );
    showPage( messageTip,'../SysManage/QueryIepgParameterDetail.action?' + queryString, 610, 280);
}

/** 弹出插件详情的对话框 */
function showPluginDetailDialog( link ) {
    var id = link.id;
    link.href = "###";
    var table        = document.getElementById( "plugin" ).rows[ id ];
    var name         = table.cells[0].innerText.trim();
    var alias        = table.cells[1].innerHTML.trim();
    var description  = table.cells[2].innerHTML.trim();
    var type         = table.cells[3].innerHTML.trim();
    var className    = table.cells[4].innerHTML.trim();
    
    var buffer = new StringBuffer();
    buffer.append( "plugin.name=" );
    buffer.append( name );
    buffer.append( "&plugin.alias=" );
    buffer.append( alias );
    buffer.append( "&plugin.type=" );
    buffer.append( type );
    buffer.append( "&plugin.className=" );
    buffer.append( className );
    buffer.append( "&plugin.description=" );
    buffer.append( description );
    buffer.append( "&noPrivilegeOnlyText=true" );
    
    var queryString = encodeURI( buffer.toString() );
    
    showPage($CON.PLUGIN_DETAIL,'../Plugin/findPluginById.action?' + queryString, 630, 360);
}


/** 弹出站点详情的对话框 */
function showSiteDetailDialog( link, messageTip,id ) {
    
    
    var buffer = new StringBuffer();
    buffer.append( "iepgSiteVO.siteID=" );
    buffer.append( id );
    buffer.append( "&noPrivilegeOnlyText=true" );
    
    var queryString = encodeURI( buffer.toString() );
    showPage(messageTip,'../Site/siteView.action?'+queryString, 610, 430 );
}

/** 弹出媒资详情的对话框 */
function showMediaDetailDialog( link, messageTip, resourceId, categoryId ) {
    
    var buffer = new StringBuffer();
    buffer.append( "asset.resourceID=" );
    buffer.append( resourceId );
    buffer.append( "&asset.categoryId=" );
    buffer.append( categoryId );
    buffer.append( "&noPrivilegeOnlyText=true" );
    
    var queryString = encodeURI( buffer.toString() );
    showPage(messageTip,'../media/detailMedia.action?'+queryString, 610, 410 );
}

/** 弹出服务域详情的对话框 */
function showPublishDomainDetailDialog( link, messageTip ) {
    var id = link.id;
    link.href = "###";
    var table = document.getElementById( "publishDomainList" ).rows[ id ];
    var domainId = table.cells[6].innerHTML.trim();
    var buffer = new StringBuffer();
    buffer.append( "publishDomain.domainId=" );
    buffer.append( domainId );
    buffer.append( "&noPrivilegeOnlyText=true" );
    var queryString = encodeURI( buffer.toString() );
    
    showPage(messageTip,'../SysManage/getPublishDomainById.action?'+queryString, 620, 330 );
}

/** 弹出服务域组详情的对话框 */
function showPublishGroupDetailDialog( link, messageTip ) {
    var id = link.id;
    link.href = "###";
    var table = document.getElementById( "publishGroupList" ).rows[ id ];
    var groupId = table.cells[4].innerHTML.trim();
    var buffer = new StringBuffer();
    buffer.append( "publishGroup.groupId=" );
    buffer.append( groupId );
    buffer.append( "&noPrivilegeOnlyText=true" );
    var queryString = encodeURI( buffer.toString() );
    
    showPage(messageTip,'../SysManage/getPublishGroupById.action?'+queryString, 610, 450 );
}

/**弹出终端适配能力信息详情*/
function showTerminalDetailDialog( link, messageTip ) {
    var id = link.id;
    link.href = "###";
    var table = document.getElementById( "terminalList" ).rows[ id ];
    var id = table.cells[6].innerHTML.trim();
    var buffer = new StringBuffer();
    buffer.append( "terminal.terminalId=" );
    buffer.append( id );
    buffer.append( "&noPrivilegeOnlyText=true" );
    var queryString = encodeURI( buffer.toString() );
    
    showPage(messageTip,'../terminal/QueryTerminalDetail.action?'+queryString, 610, 400 );
    
}

/** 弹出频道详情的对话框 */
function showChannelDetailDialog( link, messageTip ) {
    var id = link.id;
    link.href = "###";
    var table = document.getElementById( "logList" ).rows[ id ];
    var channelId = table.cells[4].innerHTML.trim();
    var buffer = new StringBuffer();
    buffer.append( "channel.resourceId=" );
    buffer.append( channelId );
    buffer.append( "&noPrivilegeOnlyText=true" );
    
    var queryString = encodeURI( buffer.toString() );
    showPage(messageTip,'../channel/channelView.action?'+queryString, 610, 300 );
}

/** firefox 不支持innerText 方法 ,要支持要加一段脚本 */
function isIE(){
    if (window.navigator.userAgent.toLowerCase().indexOf("msie")>=1)
        return true;
    else
        return false;
    }

    if(!isIE()){
        HTMLElement.prototype.__defineGetter__("innerText",
        function(){
            var anyString = "";
            var childS = this.childNodes;
            for(var i=0; i<childS.length; i++) {
                if(childS[i].nodeType==1)
                    // anyString += childS[i].tagName=="BR" ? "\n" :
                    // childS[i].innerText;
                    anyString += childS[i].innerText;
                else if(childS[i].nodeType==3)
                    anyString += childS[i].nodeValue;
            }
            return anyString;
        }
        );
        HTMLElement.prototype.__defineSetter__("innerText",
        function(sText){
            this.textContent=sText;
        }
        );
    }
   
function showInfoDetailDialog( link ){
    var id = link.id;
    link.href = "###";
    var table = document.getElementById( "infosList" ).rows[ id ];
    var infoTitle           = table.cells[1].innerHTML.trim();
    var infoStatus          = table.cells[3].innerHTML.trim();
    var infoCreateTime      = table.cells[4].innerHTML.trim();
    var position              = table.cells[6].innerHTML.trim();
    var infoDerive          = table.cells[2].innerHTML.trim();
    var buffer = new StringBuffer();
    buffer.append( "info.infoTitle=" );
    buffer.append( infoTitle );
    buffer.append( "&info.infoStatus=" );
    buffer.append( infoStatus );
    buffer.append( "&info.infoCreateTime=" );
    buffer.append( infoCreateTime );
    buffer.append( "&info.position=" );
    buffer.append( position );
    buffer.append( "&info.infoDerive=" );
    buffer.append( infoDerive );
    buffer.append( "&noPrivilegeOnlyText=true" );
    
    var queryString = encodeURI( buffer.toString() );
    
    showPage($CON.NEW_DETAIL,'../infoManage/findInfoById.action?action=viewInfo&'+queryString, 610, 360 );
}

function showInfoAudit( link,status ){
    var reasontype = $("#auditTypeValue").val();
    var id = link.id;
    var table = document.getElementById( "infoAuditList" ).rows[ id ];
    var auditComment          = table.cells[6].innerHTML.trim();
    var buffer = new StringBuffer();
    buffer.append( "info.auditComment=" );
    buffer.append( auditComment );
    buffer.append( "&noPrivilegeOnlyText=true" );
    
    var queryString = encodeURI( buffer.toString() );
    if(status==4){
    showPage($CON.CHECK_NOPASS_REASON,'../infoManage/findInfoAuditDetailById.action?'+queryString, 400, 260 );
    }
    if(status==5){
        showPage($CON.CHECK_TURNBACK_REASON,'../infoManage/findInfoAuditDetailById.action?'+queryString, 400, 260 );
        }
    }

function showInfoDetail( link ){
    var id = link.id;
    link.href = "###";
    var table = document.getElementById( "infoAuditList" ).rows[ id ];
    var infoTitle           = table.cells[1].innerText.trim();    
    var infoStatus          = table.cells[3].innerText.trim();
    var infoCreateTime      = table.cells[4].innerHTML.trim();
    var infoDerive          = table.cells[2].innerHTML.trim();
    var buffer = new StringBuffer();
    buffer.append( "info.infoTitle=" );
    buffer.append( infoTitle );
    buffer.append( "&info.infoStatus=" );
    buffer.append( infoStatus );
    buffer.append( "&info.infoCreateTime=" );
    buffer.append( infoCreateTime );
    buffer.append( "&info.infoDerive=" );
    buffer.append( infoDerive );
    buffer.append( "&noPrivilegeOnlyText=true" );
    
    var queryString = encodeURI( buffer.toString() );
    
    showPage($CON.NEW_DETAIL,'../infoManage/findInfoById.action?action=viewInfo&'+queryString, 610, 360 );
}


function showAuditDetailDialog( link, messageTip ) {
    var id = link.id;
    link.href = "###";
    var table = document.getElementById( "auditResultList" ).rows[ id ];
    var auditContent = table.cells[0].innerHTML.trim();
    auditContent = encodeURI(auditContent);
    showText( messageTip, auditContent, 500, 200, 0, false);
}

function showInfoImagePage(dialogTitle,pageName,dialogW,dialogH)
{
    $("body").append("<div id='dialogbg'></div><div id='dialog'><h2 id='dialog_title'>"+dialogTitle+"<p id='btn_closedialog'></p></h2><iframe name='framelist' id='framelist' frameborder='0' src="+pageName+" height='auto'></iframe><div id='btn_list'><input type='button' value="+$CON.SURE+" id='btn_dsure'/></div></div>");
    // var gH = top.frames["framelist"].document.body.scrollHeight;
    // alert(gH);
    $("input,body button").blur();
    $("#dialog").css({width:dialogW});
    $("#dialog").css({height:dialogH});
    var DW = $("#dialog").width();
    var DH = $("#dialog").height()-75;
    var webH = document.body.scrollHeight;
    var webvH =document.documentElement.clientHeight + document.documentElement.scrollTop ;
    var getH = (webH > webvH)?webH:webvH;
    $("#dialogbg").height(getH + "px");
    document.getElementById("dialog").style.left = (document.body.offsetWidth-$("#dialog").width()-2)/2 + "px";
    document.getElementById("dialog").style.top = (document.documentElement.clientHeight-$("#dialog").height()-2)/2 + document.documentElement.scrollTop + "px";
    $("#btn_list").css({width:DW});
    $("#cnt_list").css({width:DW});
    $("#framelist").css({padding:"5px",overflow:"hidden"});
    $("#framelist").attr("width",DW-10);
    $("#framelist").attr("height",DH-10);
    // $("#cnt_list iframe").attr("width",DW);
    $("#btn_closedialog,#btn_dsure").click(function()
     {
        getCBox();
        var dialog = $( "#showSuccessDialog" );
        dialog.val( '2' );
        $("#dialogbg,#dialog").remove();
        // 如果是IE6浏览器,select标签才需要隐藏
        if ( $.browser.msie && $.browser.version == '6.0' ) {
            $("select").css({visibility:"visible"});
        }
     });
    
    // 如果是IE6浏览器,select标签才需要隐藏
    if ( $.browser.msie && $.browser.version == '6.0' ) {
        $("select").css({visibility:"hidden"});
        $("#dialog select").css({visibility:"visible"});
    }
    
    moveWindow("dialog","dialog_title");
    
    return false;
}
function getCBox()
{
     var con = window.frames[1].document.getElementById("box");
     var cboxNum = con.getElementsByTagName("input");
     var getValue = "";
     for(var tt=0;tt<cboxNum.length;tt++)
     {
         if(cboxNum[tt].checked == true)
         {
             getValue += cboxNum[tt].getAttribute("value") + ",";
         }
     }
    
     getValue = getValue.substring(0,getValue.length-1);
    if(getValue != ""){
        $("#info1").val(getValue);
    }
    
}
function loadDatePick() {
    $( "#startTime" ).click( function() {
        WdatePicker({el:'startTime',readOnly:true});
    });

    $( "#startTimeImg" ).click( function() {
        WdatePicker({el:'startTime',readOnly:true});
    });
    
    $( "#endTime" ).click( function() {
        WdatePicker({el:'endTime',readOnly:true});
    });

    $( "#endTimeImg" ).click( function() {
        WdatePicker({el:'endTime',readOnly:true});
    });
}

function setTrStype(tableId)
{
    var flag = 0;
    var table = document.getElementById(tableId);
    var trArrs = table.rows;
    for(var i = 0; i < trArrs.length; i++)
    {
        if(trArrs[i].style.display == "none")
        {
            continue;
        }
        flag = flag + 1;
        if(flag % 2 == 0)
        {
               trArrs[i].className='bule';
        }
        
    }
}

function showPublishTaskDetailDialog(link){

    var buffer = new StringBuffer();
    buffer.append( "publishTask.taskID=" );
    buffer.append( link.id );
    buffer.append( "&noPrivilegeOnlyText=true" );
    var queryString = encodeURI( buffer.toString() );
    showPage($(link).attr("messageTip"),'../publishTask/browsePublishTaskDetail.action?'+queryString, 700, 600 );

}
function showReviewPage(pageType,portalVersionId){
    showPage($CON.PREVIEW,'../review/toViewPage.action?pageType='+pageType + "&portalVersionId=" + portalVersionId, 690, 590 );
}

function showSameCodeDialog(categoryId,columnTypeCode,queryString,cityId){    
    showPage($CON.SAMECLASS_COLUMN,'../resource/findSameCode.action?category.columnTypeCode='+columnTypeCode+'&category.categoryId='+categoryId + "&category.cityId=" + cityId +'&'+queryString, 600, 350);
}

function showChooseDialog(){
    showPage($CON.TERMINAL_DEL_SELECT,'../resource/choose_down_terminal.jsp', 500, 300 );
}

/** 查询天气预报详情*/
function showWeatherDetailDialog(weatherId,queryType, messageTip)
{
    var buffer = new StringBuffer();
    buffer.append( "weather.weatherId=" );
    buffer.append( weatherId );
    buffer.append( "&weather.queryType=" );
    buffer.append( queryType );
    var queryString = encodeURI( buffer.toString() );
    showPage(messageTip,'../portalWeather/queryWeatherDetail.action?'+queryString, 610, 400 );
}
function clearForm(){
    $(':input','#queryForm')
     .not(':button, :submit, :reset, :hidden')
     .val('')
     .removeAttr('checked')
     .removeAttr('selected');
}

    <!-- 模板文件/目录详细信息展示 -->
    <action name="showTemplateResourceDetail" class="templateAction" method="showTemplateResourceDetail">
            <result name="templateResourceDetailDir">/template/templateResourceDetailDir.jsp</result>
            <result name="templateResourceDetailFile">/template/templateResourceDetailFile.jsp</result>
            <result name="templateResourceDetailImg">/template/templateResourceDetailImg.jsp</result>
    </action>
    
templateResourceDetailDir.jsp
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="page" uri="/WEB-INF/tlds/paginated.tld"%>
<%@ include file="../common/language.jsp"  %>

<!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>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><s:text name="msg.portalMS.system.messageManager"/>——<s:text name="msg.portalMS.siteMgr.list"/></title>
<link href="../style/base<%=language_css%>.css" rel="stylesheet" type="text/css" />
<%@ include file="../common/commonJS.jsp" %>
<script src="../js/jquery.js" type="text/javascript"></script>
<script type="text/javascript" src="../js/jquery.validate.js"></script>
<script type="text/javascript" src="../js/ex.jquery.validate.js"></script>
<script type="text/javascript" src="../js/dialogShow.js"></script>
<script type="text/javascript" src="../js/site.manage.js"></script>
<script type="text/javascript" src="../js/viewTemplate.js"></script>

<script type="text/javascript">

</script>
</head>
<body>
  <div class="r_nav">
    <div class="left"><img src="../images/nav_l.gif" width="5" height="29" /></div>
    <div class="ct"><s:text name="msg.portalMS.system.current.position"/><s:text name="msg.portalMS.template.manager"/>
    &gt;<s:text name="msg.portalMS.template.sync.his"/>     
    </div>
    <div class="right"><img src="../images/nav_r.jpg" width="5" height="29" /></div>
  </div>
<div class="r_main">
    <input type="hidden" id="templateListType" name="templateListType" value="${templateListType}"/>
    <input type="hidden" id="allowDownload" name="allowDownload" value="${allowDownload}"/>
    <s:if test="pager.totalRows != 0">
      <div  class="page_tb">
        <table width="100%" border="0" cellpadding="0" cellspacing="0"  id="templateResFileList">
          <tr >
            <th ><s:text name="msg.portalMS.template.Name"/></th>
            <th ><s:text name="msg.portalMS.template.update.time"/></th>
            <th ><s:text name="msg.portalMS.template.Type"/></th>
            <s:if test="allowDownload==1">
            <th ><s:text name="msg.portalMS.sitemgr.operation"/></th>
            </s:if>
          </tr>
          <s:iterator value="pager" status="ind" id="templateResFile">
              <tr  <s:if test="#ind.index % 2 == 1">class="bule"</s:if> onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#fffed9'">
                <td >
                    <s:property value="#templateResFile.fileName" />
                </td>            
                <td class="li_td">
                    <s:property value="#templateResFile.updateTime" />
                </td>
                <td>
                    <s:if test="#templateResFile.fileType == 0"><s:text name="msg.portalMS.template.File"/></s:if>
                     <s:if test="#templateResFile.fileType == 1"><s:text name="msg.portalMS.template.direction"/></s:if>
                </td>
                <s:if test="allowDownload==1">
                <td  class="li_td">
                <span>
                    <a href="<s:property value="#templateResFile.fileDownloadPath"/>" ><s:text name="msg.portalMS.template.downLoad"/></a>
                </span>
                </td>
                </s:if>
              </tr>
          </s:iterator>
        </table>
      </div>
      </s:if>
      <s:else>
          <div  class="no_search"><img src="../images/smile_sad.jpg" width="22" height="22" /><s:text name="msg.portalMS.page.no.research.template.result"/></div>
      </s:else>
</div>
</body>
</html>

site.manage.js
/**定义StringBuffer类*/
function StringBuffer()   
{   
    this._strings = [];   
    if(arguments.length==1)   
    {   
        this._strings.push(arguments[0]);   
    }   
};   
 
StringBuffer.prototype.append = function(str)   
{   
    this._strings.push(str);   
    return this;   
};  
 
StringBuffer.prototype.toString = function()   
{   
    return this._strings.join("");   
};
 
/* 返回长度 */  
StringBuffer.prototype.length = function()   
{   
    var str = this._strings.join("");   
    return str.length;   
};

/**初始化站点树*/
function initTree() {
    var tree = new Array;
    
    var nodeString = $( "#nodesString" ).val();
    var nodes = nodeString.split( "@@" );
    if( nodes != null && nodes.length != 0 ) {
        var index = 0;
        for( var i = 0; i < nodes.length; i++ ) {
            var node = nodes[i];
            if ( node != null && node.length != 0 ) {
                tree[ index++ ] = node;
            }
        }
    }

    return tree;
}
/**添加节点的刷新页面的时候是否现在节点后缀、节点内容*/
function displaySuffixAndNodeContent( suffixId, commonTemplateId, nodeContentId) {
    var radioes = $(":radio");
    var nodeType = null;
    for( var i = 0; i < radioes.length; i++ ) {
        var radio = $( radioes[i]);
        if( radio.attr( "checked" ) ) {
            nodeType = radio.val();
            break;
        }
    }

    var suffix = $( "#" + suffixId);
    var commonTemplate = $( "#" + commonTemplateId );
    var nodeContent = $( "#" + nodeContentId );
    var nodeContentInput = nodeContent.children( "td" ).children( "textarea" );
    //文件夹
    if ( nodeType == 2 ) {
        suffix.hide();
        commonTemplate.hide();
        nodeContent.hide();
        nodeContentInput.attr( "disabled", "disabled" );
    }
}

/**添加站点节点页面的站点类型*/
function changeNodeType( suffixId, commonTemplateId,descriptionContentId, nodeContentId ,nodeContentLableId) {
    $(":radio").click( function(){
        var suffix = $( "#" + suffixId );
        var commonTemplate = $( "#" + commonTemplateId );
        var nodeContent = $( "#" + nodeContentId );
        var nodeContentLable = $( "#" + nodeContentLableId );
        var descriptionContent = $( "#" + descriptionContentId );
        var descriptionContent1 = $( "#" + descriptionContentId +" td:first");
        //var suffixInput = suffix.children( "td" ).children( "select" );
        //var commonTemplateInput = commonTemplate( "td" ).children( "input" );
        var nodeContentInput = nodeContent.children( "td" ).children( "textarea" );

        //选中了文件夹
        if( $(this).val() == 2 ) {
            //suffixInput.attr( "disabled", "disabled" );
            //commonTemplateInput.attr( "disabled", "disabled" );
            nodeContentInput.attr( "disabled", "disabled" );
            
            
            suffix.hide();
            commonTemplate.hide();
            nodeContent.hide();    
            descriptionContent1.removeClass("must2");
            descriptionContent1.addClass("must3");
            descriptionContent.addClass("bule");
            //style="background-color: #e9f0f9"
//            nodeContentLable.attr("class","col1 must");
        }
        else if($(this).val() == 1)
        {
            suffix.show();
            commonTemplate.show();
            nodeContent.show();
            descriptionContent.attr("class", "bule");
            nodeContent.removeClass("bule");
            
            nodeContentLable.attr("class","col1 must");
        }//选中了普通文件
        else {
            nodeContentInput.removeAttr( "disabled" );
            
            suffix.show();
            commonTemplate.show();
            nodeContent.show();
            descriptionContent.removeClass("bule");
            descriptionContent1.removeClass("must3");
            descriptionContent1.addClass("must2");
            //descriptionContent.attr("class", "bule");
//            nodeContent.attr("class", "bule");
            //nodeContent.removeClass("bule");
//            nodeContentLable.attr("class","col1 must1");
            //nodeContentLable.attr("class","col1 must");
        }
    });
}
/**触发新增站点的新增按钮*/
function addSiteButton( formId, buttonId, hiddenId ){
    $( "#" + buttonId ).click( function(){
        var form = $( "#"+ formId );
        if( form != null && form.length != 0 ) {
            form.submit();
        }
   });
}

/**触发生成页面的按钮*/
/*function generateSite2File( formId, buttonId, hiddenId ) {
    $( "#"+buttonId ).click( function() {
        var checked = $("input:checked");
        //没有选中节点
        if( checked == null || checked.length == 0 ) {
            alert( "请选择要生成页面的节点!" );
            return;
        }
        
        //根节点无法生成页面
        if( checked.val() == 1 ) {
            alert( "树的根节点是无法页面,请重新选择!" );
            return ;
        }
        
        var checks = findCheckedChildrenNode( checked );
        if ( checks.length == 0 ) {
            alert( "选中的节点,是文件夹节点,该节点无法生成页面文件,请选择其子节点!" );
            return ;    
        }

        //判断节点类型
        var folders = 0;
        for( var i = 0; i < checks.length; i++ ) {
            var nodeType = getNodeTypeFrom( checks[i] );
            //文件夹节点、站点节点
            if ( nodeType == 0 || nodeType == 2 ) {
                folders++;
            }
        }
        if ( checks.length == folders ) {
            alert( "您选中的节点类型是文件夹节点,文件夹节点无法生成页面文件,请重新选择!" );
            return ;    
        }
        
        var deleted = confirm( "是否要将选中的节点生成页面?" );
        if ( deleted ) {
            var buffer = new StringBuffer();
            for( var i = 0; i < checks.length; i++ ) {
                buffer.append( checks[i].val() );
                if ( i < checks.length - 1 ) {
                    buffer.append(",");
                }
            }
            
            var queryString = buffer.toString();
            //alert( queryString );
            var form = $( "#" + formId );
            if( form != null ) {
                $("#"+hiddenId ).val( queryString );
                form.submit();
            }
        }
    });
}*/
/**触发删除选中的删除按钮*/
function deleteSiteButton( buttonId ) {
    $( "#"+buttonId ).click( function() {
        var checked = $("input:checked");
        var queryString = "";
        var rootId = 1;
        //没有选中节点
        if( checked == null || checked.length == 0 ) {
            showText($CON.MESSAGE_TIP1,$CON.NODE_DELETE_NOSELECT,400,200,0,true);
            return;
        }
        //查找根节点和构造要删除的节点String        
        var checks = findCheckedChildrenNode( checked );
        
        
        for( var i = 0; i < checks.length; i++ ) {
            var id = checks[i].val().split("$");
            queryString += "&nodeIds=" + id[0];
            var nodeType = getNodeTypeFrom( checks[i] );
            queryString += "&types="+nodeType;
            //nodeType为0表示站点节点,即根节点
            if(nodeType == "0"){
                rootId = checks[i].val();
            }
        }            
        //根节点无法删除
        if( checked.val() == rootId ) {
            showText($CON.MESSAGE_TIP1,$CON.NODE_NO_DELETE,400,200,0,true);
            return ;
        }

        
        if ( checks.length == 0 ) {
            showText($CON.MESSAGE_TIP1,$CON.CHILDNODE_NO_SELECT,400,200,0,true);
            return ;        
        }
        
        //var deleted = confirm( "是否要删除选中的节点?" );
        //if(deleted){
            if(checks.length > 0){
                var url='DeleteSite.action?' + queryString;
                showConfirmAndCancel($CON.MESSAGE_TIP1,$CON.NODE_ISDELETE,url);
                //window.location='DeleteSite.action?' + queryString;
            }
        //}
    });
}

/**查询所有选中的子节点*/
function findCheckedChildrenNode( checked ) {
    
    var checks = new Array;
    var linkeName = null;
    var index = 0;
    var skip = 0;
    
    for( var i = 0; i < checked.length; i++ ) {
        //父节点
        var checkbox = $( checked[i] );
        
        var divId = "div"+checkbox.val();
        linkName = checkbox.next().children("span").html();
        //子节点
        var children = checkbox.nextAll("div[id='"+divId+"']").children("input");
        skip = 0;
        for( var j = 0; j < children.length; j++ ) {
            var subCheckbox = $( children[j] );
            var isChekced = subCheckbox.attr( "checked" );
            if( isChekced ) {
                skip++;
                checks[index++] = subCheckbox;
            }
        }
        
        //如果父节点没有子节点,而且父节点选中
        if ( children.length == 0 ) {
            var exists = checkboxExists( checks, checkbox );
            if ( !exists ) {
                checks[index++] = checkbox;
            }
        }
        
        //子节点全部选中,如果父节点选中话,亦将父节点删除
        if( children.length != 0 && skip == children.length ) {
            checks[index++] = checkbox;
        }    
    }
    
    return checks;
}

function checkboxExists( checks, checkbox ) {
    var exists = false;
    for( var i = 0; i < checks.length; i++ ) {
        var check = checks[i];
        if ( check.val() == checkbox.val() ) {
            exists = true;
            break;
        }
    }
    
    return exists;
}

/*获取节点类型*/
function getNodeTypeFrom( checked ) {
    var link = checked.next( "a" );
    var hrefValue = link.attr( "href" );
    var subValue = hrefValue.split( "&" );
    var nodeType = null;
    if ( subValue != null && subValue.length > 1 ) {
        var tmp = subValue[1];
        nodeType = tmp.split("=")[1];
    }
    
    return nodeType;
}

/**预览按钮*/
function priview( formId, buttonId ) {
    $( "#"+buttonId ).click(function(){
        var form = $( "#"+formId );
        if( form != null ) {
            form.submit();
        }
    });
}

/**刷新页面后,更新树中所操作节点的颜色*/
function highLightNodeForSiteMaintain( nodeName, parentNodeName ) {
    var selectId = null;
    var nodeId = $("input[type='hidden'][name='"+nodeName+"']");
    if( nodeId.length != 0 ) {
        selectId = nodeId[0].value;
    } else {
        var parentId = $("input[type='hidden'][name='"+parentNodeName+"']");
        if ( parentId.length != 0 ) {
            selectId = parentId[0].value;
        }
    }
    
    var input = $("#portalMS_" + selectId);
    var span = input.next( "a" ).children("span");
    span.css( {color:"blue"});
}

/**修改节点内容的确定按钮*/
function submitNodeContent( submitButtonId ) {
    $( "#" + submitButtonId ).click( function () {
        var form = $( "#UpdateSiteContent");
        form.attr( "action", "../WebManage/UpdateSiteContent.action" );
        form.removeAttr( "target" );
        form.submit();
    });
}

/**编辑内容单还未提交到数据库的时候,预览按钮打开预览页面*/
function openWindowForPreviewBeforeSubmitNodeContent( previewButtonId, previewHiddenName ) {
    
    $( "#"+previewButtonId ).click( function () {
        var form = $( "#UpdateSiteContent");
        form.attr( "action", "../PublishManage/preView.action" );
        form.attr("target", "_blank");
        form.submit();
    } );
}

/**查看节点内容,预览按钮打开预览页面*/
function openWindowForPreview( previewButtonId, previewHiddenName ) {
    
    $( "#"+previewButtonId ).click( function () {
        var nodeId = $( "input[name='"+previewHiddenName+"']" ).val();
        var url = '../PublishManage/preView.action?errorPageWindow=true&nodeIDs[0]='+nodeId;
        var popwin = window.open( url,null,"height=100px,width=400px,left=600px,status=yes,toolbar=no,menubar=no,location=yes,resizable=yes,scrollbars=yes");  
    } );
}

/**页面加载完毕,根据nodeName将文本框聚焦*/
function nodeNameFocusBy(nodeName) {
    var nodeName = $( "input[name='"+nodeName+"']" );
    if ( nodeName != null && nodeName.length != 0 ) {
        
        nodeName[0].focus();
    }
}

/**节点名称的输入框按键失焦事件*/
/*function nodeNameByKeyUpEvent( nodeName, nodeAlias, nodeDesc ) {
    $( "input[name='node.nodeName']" ).keyup( function() {
        var value = this.value;
        var nodeAlias = $( "input[name='node.nodeAlia']" );
        var nodeDesc = $( "textarea[name='node.nodeDesc']" );
        nodeAlias.val( value );
        nodeDesc.val( value );
    } );
}*/

/**更新站点节点页面的站点类型*/
function changeNodeTypeForUpdate( controllerId) {
    $(":radio").click( function(){
    
        var controller = $( "#" + controllerId );

        //选中了普通文件
        if($(this).val() == 1)
        {
            controller.hide();
            
        }
        else {
            controller.show();
        }//选择了模板文件
    });
}


viewTemplate.js
function viewTemplate(templateid){
    var url = "viewTemplate.action";
    jQuery.post(url, {templateId : templateid}, function(data){
        if(data.success){
            eval(data.msg);
        }else{
            showText($CON.TIP_WARN,data.msg,400,200,0,true);
        }
    }, "json");
}

function siteViewTemplate(previewSiteId){
    var url = "../Template/viewTemplate.action";
    jQuery.post(url, {previewSiteId : previewSiteId}, function(data){
        if(data.success){
            eval(data.msg);
        }else{
            showText($CON.TIP_WARN,data.msg,400,200,0,true);
        }
    }, "json");
}


templateResourceDetailFile.jsp
<%@ page language="java" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="page" uri="/WEB-INF/tlds/paginated.tld"%>
<%@ include file="../common/language.jsp"  %>
<!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">
<script  type="text/javascript" >
 window.UEDITOR_HOME_URL="../ueditor/";
</script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><s:text name="msg.portalMS.template.manager" />——<s:text name="msg.portalMS.template.common.template" /></title>

<link href="../style/ui.all.css" rel="stylesheet" type="text/css" />
<link href="../style/base<%=language_css%>.css" rel="stylesheet" type="text/css" />
<%@ include file="../common/commonJS.jsp" %>
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript" src="../js/dialogShow.js"></script>
<script type="text/javascript" src="../js/jquery.validate.js"></script>
<script type="text/javascript" src="../js/ex.jquery.validate.js"></script>
<script type="text/javascript" src="../js/ajaxupload.js"></script>

<script type="text/javascript">


jQuery(document).ready(function()
{
    $("#submitFileContent").hide();
    $("#cancelModify").hide();
    $("#templateContent").css("background-color","#CCCCCC");
    
    // 点击“修改”执行动作
    $( "#updateFileContent" ).click( function()
    {
        $("#templateContent").removeAttr("readonly");
        $("#updateFileContent").hide();
        $("#submitFileContent").show();
        $("#cancelModify").show();
        $("#templateContent").css("background-color","#FFFFFF");

    });
    // 点击“确定”执行动作
    $( "#submitFileContent" ).click( function()
    {
        $("#templateContent").val($("#templateContent").text());
        $( "#addForm" ).submit();
        return;
    });
    // 点击“取消”执行动作
    $( "#cancelModify" ).click( function()
    {
        location.reload();
    });
});

</script>
</head>
<body>




<div class="r_main">
    <s:form
    action="updateTemplateFile" id="addForm" theme="simple" validate="true"
    enctype="" method="post" enctype="multipart/form-data">    
    <div class="info_tit" >
        <input type="hidden" id="templateListType" name="templateListType" value="${templateListType}"/>
        <input type="hidden" id="template.oprType" name="template.oprType" value="${template.oprType}"/>
        <input type="hidden" id="template.templatePath" name="template.templatePath" value="${template.templatePath}"/>
        <input type="hidden" id="template.templateId" name="template.templateId" value="${template.templateId}"/>
        <div class="bu" id="promptTitle">&nbsp;&nbsp;<font style="font-weight: bold"><s:text name="msg.portalMS.template.File.content"/></font>&nbsp;&nbsp;&nbsp;&nbsp;
              <input id="updateFileContent" type="button" value="<s:text name='msg.portalMS.system.edit'/>" />
          <input id="submitFileContent" type="button" value="<s:text name='msg.portalMS.confirmButton'/>" />
          <input id="cancelModify" type="button" value="<s:text name='msg.portalMS.system.cancel'/>" />        
        </div>

    </div>

    
    <div  style="position: relative;" >
            <table width="100%" border="0" cellpadding="0" cellspacing="0"
                 style="position: relative;">
                <tr id="writecontent">
                    <td class="bule">
                    <s:textarea rows="40" cssClass="m_g text_eara" readonly="true"
                        name="template.content" id="templateContent" /><br />
                    </td>
                </tr>
                <s:hidden name="showSuccessDialog" />
            </table>
    </div>
    
    <s:if test="templateListType==0">
    
    <div class="page_line">
        <div class="left"><img src="../images/in_l.jpg" width="5" height="30" /></div>
      
        <div class="bu">
          <s:if test="pager.totalRows !=0">
          </s:if>

         </div>
         <div class="right"><img src="../images/in_r.jpg" width="5" height="30" /></div>
    </div>
    </s:if>
    </s:form>
</div>

</body>
</html>

    <!-- 更新模板文件内容 -->
    <action name="updateTemplateFile" class="templateAction" method="updateTemplateFile">
        <result name="success" type="redirectAction">
            <param name="namespace">/template</param>
            <param name="actionName">showTemplateResourceDetail</param>
            <param name="templateListType">${templateListType}</param>
            <param name="template.templateId">${template.templateId}</param>
            <param name="templateResFile.fileType">${templateResFile.fileType}</param>
            <param name="templateResFile.fileName">${templateResFile.fileName}</param>
            <param name="templateResFile.filePath">${templateResFile.filePath}</param>
            <param name="showSuccessDialog">${showSuccessDialog}</param>
        </result>
    </action>

templateResourceDetailImg.jsp
<html>
    <head>
    </head>
    <body>
        <div align="center">
            <img align="center" id="img" alt="wzp" width="${imgWidth}px" height="${imgHeight}px"
                src="${template.templatePath}" />
        </div>
    </body>
</html>

template.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
    <package name="template" extends="defaults" namespace="/template">
        
        <!-- 查看模板详情 -->
    <action name="findRelatedColumns" class="templateAction" method="findRelatedColumns">
            <result name="success">/template/templateRefColumn.jsp</result>
    </action>

    <!-- 查看模板详情 -->
    <action name="findTemplateDetail" class="templateAction" method="findTemplateDetail">
            <result name="findDetail">/template/templateDetail.jsp</result>
    </action>
    
    <!-- 模板预览-->
    <action name="viewTemplate" class="templateAction" method="viewTemplate">
    </action>
    
    <!-- 模板文件/目录详细信息展示 -->
    <action name="showTemplateResourceDetail" class="templateAction" method="showTemplateResourceDetail">
            <result name="templateResourceDetailDir">/template/templateResourceDetailDir.jsp</result>
            <result name="templateResourceDetailFile">/template/templateResourceDetailFile.jsp</result>
            <result name="templateResourceDetailImg">/template/templateResourceDetailImg.jsp</result>
    </action>
    
    <!-- 模板列表页 -->
    <action name="findTemplateListByType" class="templateAction" method="findTemplateListByType">
        <result name="success">/template/templateList.jsp</result>
        <result name="selectTemplate">/resource/templateList.jsp</result>
    </action>
    
    <!-- 更新模板文件内容 -->
    <action name="updateTemplateFile" class="templateAction" method="updateTemplateFile">
        <result name="success" type="redirectAction">
            <param name="namespace">/template</param>
            <param name="actionName">showTemplateResourceDetail</param>
            <param name="templateListType">${templateListType}</param>
            <param name="template.templateId">${template.templateId}</param>
            <param name="templateResFile.fileType">${templateResFile.fileType}</param>
            <param name="templateResFile.fileName">${templateResFile.fileName}</param>
            <param name="templateResFile.filePath">${templateResFile.filePath}</param>
            <param name="showSuccessDialog">${showSuccessDialog}</param>
        </result>
    </action>
    
    <!-- 模板上线-->
    <action name="templateUp" class="templateAction" method="templateUp">
            <result name="success" type="redirectAction">
                <param name="namespace">/template</param>
                <param name="actionName">findTemplateListByType</param>
                <param name="templateListType">0</param>
                <param name="showSuccessDialog">${showSuccessDialog}</param>
                <param name="type">${type}</param>
                <param name="errorMessage">${errorMessage}</param>
            </result>
    </action>
    
    <!-- 模板下线-->
    <action name="templateDown" class="templateAction" method="templateDown">
            <result name="success" type="redirectAction">
                <param name="namespace">/template</param>
                <param name="actionName">findTemplateListByType</param>
                <param name="templateListType">1</param>
                <param name="showSuccessDialog">${showSuccessDialog}</param>
                <param name="type">${type}</param>
                <param name="privateErrorMessage">${privateErrorMessage}</param>
            </result>
    </action>
    
    <!-- 模板导入-->
    <action name="importTemplate" class="templateAction" method="importTemplate">
        <result name="templateList" type="redirectAction">
                <param name="namespace">/template</param>
                <param name="actionName">findTemplateListByType</param>
                <param name="templateListType">0</param>
                <param name="showSuccessDialog">${showSuccessDialog}</param>
                <param name="type">${type}</param>
                <param name="privateErrorMessage">${privateErrorMessage}</param>
        </result>
        <result name="input">/template/importTemplate.jsp</result>
        <result name="update">/template/updateTemplate.jsp</result>
    </action>
    
    <!-- 模板编辑页-->
    <action name="editTemplate" class="templateAction" method="editTemplate">
            <result name="addInput">/template/templateEdit.jsp</result>
            <result name="updateInput">/template/templateEdit.jsp</result>
    </action>
    
    <!-- 模板新增-->
    <action name="addTemplate" class="templateAction" method="addTemplate">
        <result name="templateList" type="redirectAction">
                <param name="namespace">/template</param>
                <param name="actionName">findTemplateListByType</param>
                <param name="templateListType">0</param>
                <param name="showSuccessDialog">${showSuccessDialog}</param>
                <param name="type">${type}</param>
                <param name="privateErrorMessage">${privateErrorMessage}</param>
        </result>
    </action>
    
    <!-- 模板文件管理 -->
    <action name="templateResourceMgt" class="templateAction" method="templateResourceMgt">
            <result name="templateFile_iframe">/template/templateFile_iframe.jsp</result>
    </action>
    
    <!-- 模板文件树 -->
    <action name="initTemplateResourceTree" class="templateAction" method="initTemplateResourceTree">
            <result name="templateResourceTree">/template/templateResourceTree.jsp</result>
    </action>
    
    <!-- 模板删除 -->
    <action name="deleteTemplate" class="templateAction" method="deleteTemplate">
        <result name="templateList" type="redirectAction">
                <param name="namespace">/template</param>
                <param name="actionName">findTemplateListByType</param>
                <param name="templateListType">0</param>
                <param name="showSuccessDialog">${showSuccessDialog}</param>
                <param name="type">${type}</param>
                <param name="privateErrorMessage">${privateErrorMessage}</param>
        </result>
    </action>
    
    <!-- 模板同步记录列表页 -->
    <action name="findTemplateSyncList" class="templateAction" method="findTemplateSyncList">
        <result name="success">/template/templateSyncList.jsp</result>
    </action>
    
    <!-- 模板同步记录详情-->
    <action name="findTemplateSyncLogDetail" class="templateAction" method="findTemplateSyncLogDetail">
        <result name="success">/template/templateSyncLogDetail.jsp</result>
    </action>
    
    <!-- 删除模板同步记录 -->
    <action name="delTemplateSyncLog" class="templateAction" method="delTemplateSyncLog">
        <result name="success" type="redirectAction">
                <param name="namespace">/template</param>
                <param name="actionName">findTemplateSyncList</param>
                <param name="showSuccessDialog">${showSuccessDialog}</param>
        </result>
    </action>
    
    <!-- 模板分发历史列表页 -->
    <action name="findTemplatePublishHisList" class="templateAction" method="findTemplatePublishHisList">
        <result name="success">/template/templatePublishHisList.jsp</result>
    </action>
    
    <!-- 模板手动分发 -->
    <action name="templateManualSync" class="templateAction" method="templateManualSync">
        
    </action>
    
    <!-- 模板zip上传 -->
    <action name="processController" class="templateAction" method="processController">
      <result name="success">/template/processController.jsp</result>
    </action>
    
    <!-- 创建模板资源目录弹出窗口  -->
    <action name="createTempResFileDir" class="templateAction" method="createTempResFileDir">
        <result name="success">/template/createTemplateResFileDir.jsp</result>
    </action>
    
    <!-- 创建模板资源目录  -->
    <action name="createTempResFileDirHandle" class="templateAction" method="createTempResFileDirHandle">
    </action>
    
    <!-- 导入模板资源文件  -->
    <action name="importTempResFile" class="templateAction" method="importTempResFile">
    </action>
    
    <!-- 模板同步门户重发 -->
    <action name="templateAgainSyncIepg" class="templateAction" method="templateAgainSyncIepg">
        <result name="success" type="redirectAction">
                <param name="namespace">/template</param>
                <param name="actionName">findTemplateSyncList</param>
                <param name="showSuccessDialog">${showSuccessDialog}</param>
        </result>
    </action>
    
    <!-- 修改模板属性  -->
    <action name="updateTemplate" class="templateAction" method="updateTemplate">
        <result name="templateList" type="redirectAction">
                <param name="namespace">/template</param>
                <param name="actionName">findTemplateListByType</param>
                <param name="templateListType">0</param>
                <param name="showSuccessDialog">${showSuccessDialog}</param>
                <param name="type">${type}</param>
                <param name="privateErrorMessage">${privateErrorMessage}</param>
        </result>
    </action>
    <!-- 模板历史记录查询  -->
    <action name="templateHisList" class="templateAction" method="templateHisList">
            <result name="templateHisListPage">/template/templateResourceDetailDir.jsp</result>
    </action>
    <!-- 模板分发区域历史删除 -->
    <action name="delTemplatePublishHis" class="templateAction" method="delTemplatePublishHis">
        <result name="success" type="redirectAction">
                <param name="namespace">/template</param>
                <param name="actionName">findTemplatePublishHisList</param>
                <param name="showSuccessDialog">${showSuccessDialog}</param>
        </result>
    </action>
    
    <!-- 模板分发区域历史删除 -->
    <action name="deleteTemplateSyncToIepg" class="templateAction" method="deleteTemplateSyncToIepg">
        <result name="success" type="redirectAction">
                <param name="namespace">/SysManage</param>
                <param name="actionName">publishLog</param>
                <param name="showSuccessDialog">${showSuccessDialog}</param>
        </result>
    </action>
    <!-- 模板同步 -->
    <action name="syncTemplateMessages" class="templateAction" method="syncTemplateMessages">
            <result type="json">
                <param name="root">
                      ajaxMsg
                </param>
            </result>
    </action>
    </package>
</struts>



TemplateAction.java
package com.coship.dhm.portalMS.template.web.action;

import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.activation.MimetypesFileTypeMap;

import net.sf.json.JSONObject;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.xwork.StringUtils;
import org.apache.log4j.Logger;

import com.xxxxxx.dhm.common.config.impl.XMLFactory;
import com.xxxxxx.dhm.portalMS.base.web.action.BaseAction;
import com.xxxxxx.dhm.portalMS.common.Constants;
import com.xxxxxx.dhm.portalMS.common.PublishThreadConstants;
import com.xxxxxx.dhm.portalMS.common.SerConstants;
import com.xxxxxx.dhm.portalMS.common.ViewMonitorUtil;
import com.xxxxxx.dhm.portalMS.common.util.FileUtil;
import com.xxxxxx.dhm.portalMS.common.util.ShelfUtil;
import com.xxxxxx.dhm.portalMS.common.util.StringUtil;
import com.xxxxxx.dhm.portalMS.exception.PortalMSException;
import com.xxxxxx.dhm.portalMS.resource.entity.CategoryResource;
import com.xxxxxx.dhm.portalMS.sync.entity.Provider;
import com.xxxxxx.dhm.portalMS.sync.util.TemplateSyncHelper;
import com.xxxxxx.dhm.portalMS.template.entity.OpType;
import com.xxxxxx.dhm.portalMS.template.entity.Status;
import com.xxxxxx.dhm.portalMS.template.entity.Template;
import com.xxxxxx.dhm.portalMS.template.entity.TemplatePublishHis;
import com.xxxxxx.dhm.portalMS.template.entity.TemplateResFile;
import com.xxxxxx.dhm.portalMS.template.entity.TemplateSyncLog;
import com.xxxxxx.dhm.portalMS.template.service.ITemplateService;
import com.xxxxxx.dhm.portalMS.template.util.TemplateFileFTPHandle;
import com.xxxxxx.dhm.portalMS.template.util.TemplateSyncThread;
import com.xxxxxx.dhm.portalMS.template.util.TemplateUtil;

/*
 * 工程名: portalMS
 * 包     名: com.xxxxxx.dhm.portalMS.template.web.action
 * 文 件名: TemplateAction.java
 * 版      权: Copyright (c) 2009 xxxxxx All Rights Reserved.
 * 描      述: 模板Action类,用于页面的展现
 * 修 改 人:
 * 修改时间:
 * 跟踪单号:
 * 修改单号:
 * 修改内容:
 */

/**
 * 模板Action类.该类提供了如下的功能:
 *
 * 1、模板添加 2、模板修改 3、模板删除 4、模板站点树展现 5、模板内容修改 6、模板内容添加
 *
 * 7、模板内容修改 8、模板内容删除
 *
 * @author
 * @version
 * @since
 */
public class TemplateAction extends BaseAction
{
    
    /**
     *
     */
    private static final long serialVersionUID = 4143872447813178254L;
    
    private static final Logger log = Logger.getLogger(TemplateAction.class);
    
    private Integer showFlag = XMLFactory.getValueInt("common.cityCode");
    
    private ITemplateService templateService;
    
    private OpType[] opTypes = OpType.values();// 所属推荐位
    
    private Status[] statusList = Status.values();
    
    /** 模板实体类 **/
    private Template template;
    
    /** 模板入口页 **/
    private Set<String> homePage = new HashSet<String>();
    
    /** 提供商CODE */
    private Provider provider;
    
    /** 图片宽 */
    private Integer imgWidth;
    
    /** 图片高 */
    private Integer imgHeight;
    
    /** 操作类型: 1 - 新增; 2 - 导入; 3 - 修改 **/
    private int operatorType;
    
    /** 查询的模板列表类型: 0 - 临时模板列表 */
    private static final int TEMPLATE_LIST_TYPE_0 = 0;
    
    /** 查询的模板列表类型: 1 - 商用模板列表 */
    private static final int TEMPLATE_LIST_TYPE_1 = 1;
    
    /** 模板列表类型 0:模板编辑列表 1:模板商用列表 **/
    private int templateListType;
    
    /** 模板资源文件树 */
    private String filetree;
    
    private String templateFilePath;
    
    private TemplateResFile templateResFile;
    
    /** 预览返回 url */
    private String url;
    
    /** 页面来源 **/
    private String inputPage;
    
    /** 模板文件修改标志 */
    private int Cflag;
    
    /** 模板文件上传前还是上传后标识 */
    private int flag;
    
    // viewType(模板预览类型) 0 - 模板编辑页; 1 - 模板商用页; 2 - 栏目详情页对模板的预览
    private int viewType;
    
    private Long templateId;
    
    /** 被删除模板的id数组 */
    private Long[] templateIds;
    
    /** 被删除模板同步记录的id数组 */
    private Long[] templateSyncLogId;
    
    /** 模板同步记录 **/
    private TemplateSyncLog templateSyncLog;
    
    /** 预览模板文件编码格式 */
    private String fileEncode = XMLFactory.getValueString("templateConfig.fileEncode");
    
    private TemplatePublishHis templatePublishHis;
    
    private String uploading;
    
    private String analysing;
    
    private int allowDownload = 0;
    
    // ajax返回消息,成功
    private String ajaxMsg = "1";
    
    public String findRelatedColumns()
    {
        try
        {
            this.pager = templateService.findByCriteria(template,
                    "TemplateColumn.findAll",
                    "TemplateColumn.rowCountfindAll",
                    currentPage,
                    pageSize);
        }
        catch (PortalMSException e)
        {
            e.printStackTrace();
        }
        return SUCCESS;
    }
    
    public String templateHisList() throws Exception
    {
        this.template = ((Template)this.templateService.findById(this.template.getTemplateId()));
        
        String pathPrefix = getHttpServletRequest().getContextPath();
        String templateName = this.template.getCode();
        
        StringBuffer sb = new StringBuffer();
        sb.append(pathPrefix);
        sb.append("/");
        sb.append(Constants.TEMPLATE_P_UPLOADS.getStringValue());
        sb.append("/");
        sb.append(Constants.TEMPLATE_P_HIS.getStringValue());
        sb.append("/");
        sb.append(templateName);
        sb.append("/");
        
        this.pager = this.templateService.listTemplateFiles(SerConstants.TEMPLATE_HIS,
                templateName,
                sb.toString());
        
        setAllowDownload(1);
        
        return "templateHisListPage";
    }
    
    /**
     * 查看模板发布历史记录
     *
     * @return
     */
    public String findTemplatePublishHisList()
    {
        try
        {
            this.pager = templateService.findByCriteria(templatePublishHis,
                    "TemplatePublishHis.findAll",
                    "TemplatePublishHis.rowCountfindAll",
                    currentPage,
                    pageSize);
        }
        catch (Exception e)
        {
            e.printStackTrace();
            log.error("Find the templateSyncLogList Fail!  " + e.getMessage());
            return ERROR;
        }
        return SUCCESS;
    }
    
    public String delTemplatePublishHis()
    {
        if (null != templateSyncLogId && templateSyncLogId.length > 0)
        {
            try
            {
                templateService.delTemplatePublishHis(Arrays.asList(templateSyncLogId));
                this.showSuccessDialog = Constants.SUCCEED.getStringValue();
            }
            catch (PortalMSException e)
            {
                log.error("Delete TemplatePublishHis Fail!!! " + e.getMessage());
            }
        }
        return SUCCESS;
    }
    
    /**
     * 更新模板文件内容
     *
     * @return
     * @return String
     * @exception throws
     */
    public String updateTemplateFile()
    {
        String templateFileContent = template.getContent();
        String templateFilePath = template.getTemplatePath();
        
        try
        {
            FileUtil.stringWriteToFile(templateFileContent,
                    templateFilePath,
                    fileEncode);
        }
        catch (Exception e)
        {
            return ERROR;
        }
        
        try
        {
            template = (Template)templateService.findTempTemplateById(template.getTemplateId());
            
            int lastIndex = templateFilePath.lastIndexOf(File.separator);
            String filePath = templateFilePath.substring(0, lastIndex);
            String fileName = templateFilePath.substring(lastIndex + 1);
            
            templateResFile = new TemplateResFile();
            templateResFile.setFileName(fileName);
            templateResFile.setFilePath("\"" + filePath.replace('/', '!')
                    + "\"");
            // 文件类型: 0 - 文件; 1 - 文件夹
            templateResFile.setFileType(Constants.TEMPLATE_STATUS_0.getIntValue());
            
            // 已修改
            template.setStatus(Constants.TEMPLATE_STATUS_5.getIntValue());
            template.setIsBak(Constants.TEMPLATE_IS_NOT_BAK_0.getIntValue());
            templateService.updateTempTemplate(template);
        }
        catch (PortalMSException e)
        {
            e.printStackTrace();
            log.error("Update TemplateFile Fail!!!");
        }
        return SUCCESS;
    }
    
    /**
     * 模板同步记录删除
     *
     * @return
     */
    public String findTemplateSyncLogDetail()
    {
        try
        {
            if (null != templateSyncLog && null != templateSyncLog.getId())
            {
                templateSyncLog = templateService.findTemplateSyncLog(templateSyncLog);
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
            log.error("Find the templateSyncLogDetail Fail!  " + e.getMessage());
            return ERROR;
        }
        return SUCCESS;
    }
    
    /**
     * 模板同步记录删除
     *
     * @return
     */
    public String delTemplateSyncLog()
    {
        try
        {
            templateService.deleteTemplateSyncLog(templateSyncLogId);
        }
        catch (Exception e)
        {
            e.printStackTrace();
            log.error("Find the templateSyncLogList Fail!  " + e.getMessage());
            return ERROR;
        }
        return SUCCESS;
    }
    
    /**
     * 模板重新同步
     *
     * @return
     */
    public String templateAgainSyncIepg()
    {
        if (null != templateSyncLog && null != templateSyncLog.getId())
        {
            templateSyncLog.setStatus(Constants.TEMPLATE_SYNC_STATUS_3.getIntValue());
            templateSyncLog.setPublisher(getOperatorId());
            try
            {
                templateService.updateTemplateSyncLog(templateSyncLog);
            }
            catch (PortalMSException e)
            {
                log.error("Update Temp[lateSyncLog Fail!  " + e.getMessage());
                e.printStackTrace();
            }
            TemplateSyncThread sentPublishThread = new TemplateSyncThread(
                    Arrays.asList(templateSyncLog));
            PublishThreadConstants.sentPublishFileThreadPool.execute(sentPublishThread);
        }
        return SUCCESS;
    }
    
    /**
     * 模板同步记录
     *
     * @return
     */
    public String findTemplateSyncList()
    {
        try
        {
            this.pager = templateService.findByCriteria(templateSyncLog,
                    "Template.findAllTemplateSyncLog",
                    "Template.rowCountTemplateSyncLog",
                    currentPage,
                    pageSize);
        }
        catch (Exception e)
        {
            e.printStackTrace();
            log.error("Find the templateSyncLogList Fail!  " + e.getMessage());
            return ERROR;
        }
        return SUCCESS;
    }
    
    /**
     * 删除模板信息
     *
     * @return
     * @throws IEPGMException
     */
    public String deleteTemplate()
    {
        boolean reFlog = false;
        try
        {
            reFlog = templateService.deleteTemplate(Arrays.asList(templateIds));
        }
        catch (Exception e)
        {
            log.error("Delete template fail! " + e.getMessage());
        }
        if (reFlog)
        {
            StringBuffer buffer = new StringBuffer("templateIds[ ");
            for (Long ids : templateIds)
            {
                buffer.append(ids);
                buffer.append(",");
            }
            // 设置操作码
            this.setOperateDesc("templateIds[ " + buffer.toString() + " ]");
            
            // 执行成功,弹出成功的提示框
            this.showSuccessDialog = Constants.SUCCEED.getStringValue();
            return "templateList";
        }
        
        return ERROR;
    }
    
    /**
     *
     * 模板预览
     *
     * @return
     * @throws IEPGMException
     * @return String
     * @exception throws
     */
    @SuppressWarnings("unchecked")
    public String viewTemplate() throws Exception
    {
        log.info(" view template start...");
        
        String iepgmStr = Constants.FILE_SEPARATOR.getStringValue()
                + Constants.TEMPLATE_P_PORTALMS.getStringValue()
                + Constants.FILE_SEPARATOR.getStringValue();
        String uploadAndWorkStr = Constants.TEMPLATE_P_UPLOADS.getStringValue()
                + Constants.FILE_SEPARATOR.getStringValue()
                + Constants.TEMPLATE_P_WORK.getStringValue();
        String uploadAndPubStr = Constants.TEMPLATE_P_UPLOADS.getStringValue()
                + Constants.FILE_SEPARATOR.getStringValue()
                + Constants.TEMPLATE_P_PUB.getStringValue();
        Template template = null;
        if (null != templateId)
        {
            // viewType(模板预览类型) 0 - 模板编辑页; 1 - 模板商用页; 2 - 栏目详情页对模板的预览
            if (0 == viewType)
            {
                template = templateService.findTempTemplateById(templateId);
            }
            else
            {
                template = (Template)templateService.findById(templateId);
            }
        }
        if (null == template)
        {
            Map result = new HashMap();
            result.put("success", false);
            result.put("msg", getText(Constants.MSG_PORTALMS
                    + "template.preview.error"));
            write(JSONObject.fromObject(result).toString());
            return null;
        }
        
        StringBuffer sb = new StringBuffer();
        
        if (0 == viewType)
        {
            StringBuffer requestURL = getHttpServletRequest().getRequestURL();
            int flag = requestURL.indexOf(iepgmStr);
            String prefix = requestURL.substring(0, flag + iepgmStr.length());
            sb.append(prefix.toString());
            sb.append(uploadAndWorkStr);
            sb.append(Constants.FILE_SEPARATOR.getStringValue());
            sb.append(template.getCode());
            sb.append(Constants.FILE_SEPARATOR.getStringValue());
            sb.append(template.getHomePage());
        }
        if (1 == viewType)
        {
            StringBuffer requestURL = getHttpServletRequest().getRequestURL();
            int flag = requestURL.indexOf(iepgmStr);
            String prefix = requestURL.substring(0, flag + iepgmStr.length());
            sb.append(prefix.toString());
            sb.append(uploadAndPubStr);
            sb.append(Constants.FILE_SEPARATOR.getStringValue());
            sb.append(template.getCode());
            sb.append(Constants.FILE_SEPARATOR.getStringValue());
            sb.append(template.getHomePage());
        }
        else if (2 == viewType)
        {
            // PublishConfig pc =
            // publishConfigService.findPublishConfigByViewServer();
            //            
            // if (null == pc)
            // {
            // Map result = new HashMap();
            // result.put("success", false);
            // result.put("msg", "您尚未设置预览服务器,请先在同步门户管理中进行配置!");
            // write(JSONObject.fromObject(result).toString());
            // return null;
            // }
            //            
            // if (null == viewColumnId)
            // {
            // Map result = new HashMap();
            // result.put("success", false);
            // result.put("msg", "栏目数据为空,无法进行预览!");
            // write(JSONObject.fromObject(result).toString());
            // return null;
            // }
            // sb.append("http://");
            // sb.append(pc.getServerIp());
            // sb.append(":8080/iPG/tempview");
            // sb.append("/");
            // sb.append(template.getCode());
            // sb.append("/");
            // sb.append(template.getHomePage());
            // sb.append("?columnId=");
            // sb.append(viewColumnId);
        }
        
        url = sb.toString();
        log.info(" view template url = " + url.toString());
        
        Map result = new HashMap();
        String msg = ViewMonitorUtil.getViewPageHTML(url.toString());
        result.put("success", true);
        result.put("msg", msg);
        write(JSONObject.fromObject(result).toString());
        
        log.info(" view template end.");
        return null;
    }
    
    /**
     * 模板上线
     *
     * @return
     * @throws Exception
     * @return String
     * @exception throws
     */
    public String templateUp()
    {
        try
        {
            if (null != template && null != template.getTemplateId())
            {
                templateService.updateTemplateUp(template.getTemplateId(),
                        getAdmin());
            }
            
            // 设置返回成功提示标志
            this.showSuccessDialog = Constants.SUCCEED.getStringValue();
        }
        catch (Exception e)
        {
            e.printStackTrace();
            // 上线失败提示
            this.showSuccessDialog = Constants.FAILURED.getStringValue();
            errorMessage = e.getMessage();
            log.error("Up template failed..." + errorMessage);
            if (StringUtils.isEmpty(errorMessage))
            {
                errorMessage = getText(Constants.MSG_PORTALMS
                        + "template.up.error");
            }
        }
        
        return SUCCESS;
    }
    
    /**
     * 模板下线
     *
     * @return
     * @throws Exception
     * @return String
     * @exception throws
     */
    public String templateDown()
    {
        boolean flag = false;
        try
        {
            if (null != template && null != template.getTemplateId())
            {
                template.setUpdater(getOperatorId());
                flag = templateService.updateTemplateDown(template.getTemplateId());
            }
            // //////发送同步报文状态上报接口
        }
        catch (Exception e)
        {
            this.showSuccessDialog = Constants.FAILURED.getStringValue();
            errorMessage = e.getMessage();
            if (StringUtils.isEmpty(errorMessage))
            {
                errorMessage = getText(Constants.MSG_PORTALMS
                        + "template.down.error");
            }
        }
        if (flag)
        {
            return SUCCESS;
        }
        return ERROR;
    }
    
    /**
     * 查看模板详情
     *
     * @return
     * @throws Exception
     * @return String
     * @exception throws
     */
    public String findTemplateDetail()
    {
        if (null == template || template.getTemplateId() == null
                || template.getTemplateId() == 0)
        {
            return ERROR;
        }
        
        try
        {
            // 如果模板是新建状态 查询临时表
            if (0 == templateListType)
            {
                template = (Template)templateService.findTempTemplateById(template.getTemplateId());
            }
            else
            {
                template = (Template)templateService.findById(template.getTemplateId());
            }
            
            if (null == template)
            {
                return ERROR;
            }
            
            return "findDetail";
        }
        catch (Exception e)
        {
            log.error("invoke findCommonTemplateById failed." + e.getMessage());
            return ERROR;
        }
    }
    
    /**
     * 模板文件管理
     *
     * @return
     * @throws Exception
     * @return String
     * @exception throws
     */
    public String templateResourceMgt() throws Exception
    {
        File parentdir = null;
        
        if (TEMPLATE_LIST_TYPE_0 == templateListType)
        {
            template = (Template)templateService.findTempTemplateById(template.getTemplateId());
            parentdir = new File(SerConstants.TEMPLATE_PUB
                    + Constants.FILE_SEPARATOR.getStringValue()
                    + template.getCode());
        }
        else if (TEMPLATE_LIST_TYPE_1 == templateListType)
        {
            template = (Template)templateService.findById(template.getTemplateId());
            parentdir = new File(SerConstants.TEMPLATE_WORK
                    + Constants.FILE_SEPARATOR.getStringValue()
                    + template.getCode());
        }
        else
        {
            return ERROR;
        }
        
        setTemplateListType(templateListType);
        setTemplateFilePath(parentdir.getPath());
        
        return "templateFile_iframe";
    }
    
    /**
     * 模板文件树
     *
     * @return
     * @throws Exception
     * @return String
     * @exception throws
     */
    public String initTemplateResourceTree() throws Exception
    {
        File parentdir = null;
        String parentDirPath = null;
        
        if (TEMPLATE_LIST_TYPE_0 == templateListType)
        {
            template = (Template)templateService.findTempTemplateById(template.getTemplateId());
            parentDirPath = SerConstants.TEMPLATE_WORK;
            parentdir = new File(parentDirPath
                    + Constants.FILE_SEPARATOR.getStringValue()
                    + template.getCode());
        }
        else if (TEMPLATE_LIST_TYPE_1 == templateListType)
        {
            template = (Template)templateService.findById(template.getTemplateId());
            parentDirPath = SerConstants.TEMPLATE_PUB;
            parentdir = new File(parentDirPath
                    + Constants.FILE_SEPARATOR.getStringValue()
                    + template.getCode());
        }
        else
        {
            return ERROR;
        }
        
        if (!parentdir.exists() || !parentdir.isDirectory())
        {
            filetree = "var data={}; ";
        }
        else
        {
            File[] childFiles = parentdir.listFiles();
            filetree = getTemplateResourceTreeAsString(template.getTemplateId(),
                    template.getCode(),
                    parentDirPath,
                    childFiles);
        }
        
        return "templateResourceTree";
    }
    
    /**
     * 得到模板文件树的json串
     *
     * @param templateId
     *            模板ID
     * @param templateName
     *            模板名称
     * @param parentDirPath
     *            父目录
     * @param childFiles
     *            子文件集合
     * @return
     * @throws IEPGMException
     * @return String
     * @exception throws
     */
    private String getTemplateResourceTreeAsString(Long templateId,
            String templateName, String parentDirPath, File[] childFiles)
            throws Exception
    {
        StringBuffer tree = new StringBuffer("");
        tree.append("var data={}; ");
        tree.append("\n")
                .append("data")
                .append("[\'")
                .append(0)
                .append("_")
                .append(1)
                .append("\']= \'");
        tree.append("text:" + templateName + ";");
        StringBuffer url = new StringBuffer(
                "showTemplateResourceDetail.action?");
        url.append("templateListType=")
                .append(templateListType)
                .append("&")
                .append("template.templateId=")
                .append(templateId)
                .append("&")
                .append("templateResFile.fileType=")
                .append(1)
                .append("&")
                .append("templateResFile.fileName=")
                .append(templateName)
                .append("&")
                .append("templateResFile.filePath=")
                .append("\"")
                .append(parentDirPath.replace('\\', '!'))
                .append("\"");
        tree.append("url:" + url + ";");
        tree.append("leaf:" + false + ";");
        tree.append("\';");
        
        if (null == childFiles || childFiles.length == 0)
        {
            return tree.toString();
        }
        
        tree.append(iteratorTemplateResourceFile(templateId, 1, 1, childFiles));
        
        return tree.toString();
    }
    
    /**
     * 循环得到模板文件树的json串
     *
     * @param templateId
     *            模板ID
     * @param parentId
     *            父目录
     * @param level
     * @param childFiles
     *            子文件集合
     * @return
     * @return String
     * @exception throws
     */
    private String iteratorTemplateResourceFile(Long templateId, int parentId,
            int level, File[] childFiles)
    {
        StringBuffer tree = new StringBuffer("");
        if (null == childFiles || childFiles.length == 0)
        {
            return tree.toString();
        }
        
        for (int i = 0; i < childFiles.length; i++)
        {
            File f = childFiles[i];
            String fileName = f.getName();
            String parentFilePath = f.getParentFile().getPath();
            boolean leaf = f.isFile();
            int nodeId = parentId * 100 + level * 1000 + i;
            
            tree.append("\n")
                    .append("data")
                    .append("[\'")
                    .append(parentId)
                    .append("_")
                    .append(nodeId)
                    .append("\']= \'");
            if (StringUtils.isNotEmpty(fileName.trim()))
            {
                tree.append("text:" + fileName + ";");
            }
            
            StringBuffer url = new StringBuffer(
                    "showTemplateResourceDetail.action?").append("templateListType=")
                    .append(templateListType)
                    .append("&")
                    .append("template.templateId=")
                    .append(templateId)
                    .append("&")
                    .append("templateResFile.fileType=")
                    .append(leaf ? 0 : 1)
                    .append("&")
                    .append("templateResFile.fileName=")
                    .append(fileName)
                    .append("&")
                    .append("templateResFile.filePath=")
                    .append("\"")
                    .append(parentFilePath.replace('\\', '!'))
                    .append("\"");
            tree.append("url:" + url + ";");
            tree.append("\';");
            
            if (!leaf)
            {
                tree.append(iteratorTemplateResourceFile(templateId,
                        nodeId,
                        level + 1,
                        f.listFiles()));
            }
        }
        
        return tree.toString();
    }
    
    /**
     * 显示模板文件/目录详细信息展示
     *
     * @return
     * @throws Exception
     * @return String
     * @exception throws
     */
    public String showTemplateResourceDetail() throws Exception
    {
        String fileName = templateResFile.getFileName();
        String filePath = templateResFile.getFilePath();
        int fileType = templateResFile.getFileType();
        String parentDirPath = null;
        
        if (TEMPLATE_LIST_TYPE_0 == templateListType)
        {
            template = (Template)templateService.findTempTemplateById(template.getTemplateId());
            parentDirPath = SerConstants.TEMPLATE_WORK;
        }
        else if (TEMPLATE_LIST_TYPE_1 == templateListType)
        {
            template = (Template)templateService.findById(template.getTemplateId());
            parentDirPath = SerConstants.TEMPLATE_PUB;
        }
        else
        {
            return ERROR;
        }
        
        if (null == fileName || null == filePath)
        {
            fileName = template.getCode();
            filePath = parentDirPath;
        }
        else
        {
            filePath = filePath.substring(1, filePath.length() - 1);
            filePath = filePath.replace('!', '/');
        }
        
        // 0 - 文件; 1 - 目录;
        if (0 == fileType)
        {
            MimetypesFileTypeMap mimetypesFileTypeMap = new MimetypesFileTypeMap();
            String mimetype = mimetypesFileTypeMap.getContentType(filePath
                    + File.separator + fileName);
            
            // 图片
            if ("image/jpeg".equals(mimetype) || "image/png".equals(mimetype))
            {
                int flag = filePath.indexOf(Constants.FILE_SEPARATOR.getStringValue()
                        + Constants.TEMPLATE_P_UPLOADS);
                String pathPrefix = "";
                if (flag > 0)
                {
                    pathPrefix = filePath.substring(flag);
                }
                template.setTemplatePath(".." + pathPrefix
                        + Constants.FILE_SEPARATOR.getStringValue() + fileName);
                BufferedImage image = FileUtil.fileToImage(filePath
                        + File.separator + fileName);
                imgWidth = image.getWidth();
                imgHeight = image.getHeight();
                
                return "templateResourceDetailImg";
            }
            else
            {
                String fileContent = FileUtil.readFileContent(filePath
                        + File.separator + fileName,
                        TemplateFileFTPHandle.FILE_ENCODE);
                template.setContent(fileContent);
                template.setTemplatePath(filePath + File.separator + fileName);
                return "templateResourceDetailFile";
            }
        }
        else
        {
            template.setTemplatePath(filePath + File.separator + fileName);
            pager = templateService.listTemplateFiles(filePath, fileName, null);
            return "templateResourceDetailDir";
        }
    }
    
    /**
     * 模板导入
     *
     * @return
     * @throws Exception
     * @return String
     * @exception throws
     */
    public String importTemplate() throws Exception
    {
        if ("toAdd".equals(this.action))
        {
            log.debug("into importTemplate.jsp page. ");
            return INPUT;
        }
        else if ("toUpdate".equals(this.action))
        {
            template = (Template)templateService.findTempTemplateById(template.getTemplateId());
            // 修改模板文件,需备份模板
            if (null != template)
            {
                if (1 == Cflag)
                {
                    template.setIsBak(Constants.TEMPLATE_IS_NOT_BAK_0.getIntValue());
                }
                String parentDir = SerConstants.TEMPLATE_WORK
                        + template.getCode();
                homePage = TemplateUtil.readTemplateMainPages(parentDir);
                log.debug("into updateTemplate.jsp page. ");
                return "update";
            }
        }
        
        return ERROR;
    }
    
    /**
     *
     * 模板属性编辑页
     *
     * @return
     * @throws IEPGMException
     * @return String
     * @exception throws
     */
    public String editTemplate() throws Exception
    {
        if ("toAddInput".equals(this.action))
        {
            // 得到运营商
            readyAddTemplate();
            return "addInput";
        }
        else if ("toUpdateInput".equals(this.action))
        {
            template = (Template)templateService.findTempTemplateById(template.getTemplateId());
            
            log.debug("into templateEdit.jsp page. ");
            return "updateInput";
        }
        
        return ERROR;
    }
    
    /**
     * 添加模板准备
     */
    private void readyAddTemplate()
    {
        city = getLongCity();
        String parentDir = SerConstants.TEMPLATE_TEMP
                + template.getTemplatePath();
        homePage = TemplateUtil.readTemplateMainPages(parentDir);
        log.debug("into templateEdit.jsp page. ");
    }
    
    /**
     *
     * 新增模板
     *
     * @return
     * @throws IEPGMException
     * @return String
     * @exception throws
     */
    public String addTemplate() throws Exception
    {
        // 新增模板
        try
        {
            Provider provider1 = new Provider();
            provider1.setAttributionId(11);
            Template temp = templateService.findTempTemplateByCode(template.getCode());
            if (null != temp)
            {
                readyAddTemplate();
                errorMessage = getText(Constants.MSG_PORTALMS
                        + "template.add.error.tip");
                return ERROR;
            }
            else
            {
                template.setUpdater(getOperatorId());
                templateService.saveTemplate(template);
                showSuccessDialog = Constants.SUCCEED.getStringValue();
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
            log.error(e.getMessage());
        }
        return "templateList";
    }
    
    /**
     * 添加模板/导入模板/修改模板 页面初始化请求action
     *
     * @return
     * @throws Exception
     */
    public String addTemplateInit() throws Exception
    {
        // 导入模板
        if (2 == operatorType)
        {
            return "importTemplate";
        }
        
        return ERROR;
    }
    
    /**
     * 模板列表请求action
     *
     * @return
     * @throws IEPGMException
     * @return String
     * @exception throws
     */
    public String findTemplateListByType()
    {
        log.info("find template list start...");
        
        // if (null == templateListType)
        // {
        // log.OPER.warn("type is null! ");
        // return ERROR;
        // }
        if (null == template)
        {
            template = new Template();
        }
        // 插入用户信息
        // template.setAttributionId(super.getSessionProvider().getAttributionId());
        // template.setProviderCode(super.getSessionProvider().getProviderCode());
        
        try
        {
            if (TEMPLATE_LIST_TYPE_0 == templateListType)
            {
                // 分页显示临时栏目列表
                this.pager = templateService.findByCriteria(template,
                        "Template.findAllTempTemplate",
                        "Template.rowTempTemplateCount",
                        this.currentPage,
                        this.pageSize);
            }
            else if (TEMPLATE_LIST_TYPE_1 == templateListType)
            {
                // 分页显示商用栏目列表
                this.pager = templateService.findByCriteria(template,
                        "Template.findAllBusTemplate",
                        "Template.rowTemplateCount",
                        this.currentPage,
                        this.pageSize);
            }
            
            log.info("find template list end.");
        }
        catch (Exception e)
        {
            e.printStackTrace();
            log.error(e.getMessage());
        }
        if (StringUtils.isNotEmpty(inputPage)
                && "selectTemplate".equalsIgnoreCase(inputPage))
        {
            return "selectTemplate";
        }
        return SUCCESS;
    }
    
    public String syncTemplateMessages() throws PortalMSException
    {
        String operateDesc = "";
        
        try
        {
            
            if (null != templateIds && templateIds.length > 0)
            {
                
                operateDesc = getText(Constants.MSG_PORTALMS
                        + "template.confirm.sync.selected.info.log")
                        + StringUtil.getIdsAsString(Arrays.asList(templateIds)
                                .toArray());
                
                Template template;
                for (int i = 0; i < templateIds.length; i++)
                {
                    
                    template = (Template)templateService.findById(templateIds[i]);
                    if (null != template)
                    {
                        // 模板数据同步至iEPG
                        TemplateSyncHelper.syncTemplate(template);
                    }
                }
                
            }
            
            setSuccessInfo("operate.code.template.sync", operateDesc);
        }
        catch (Exception e)
        {
            ajaxMsg = "0";
            setSuccessInfo("operate.code.template.sync", operateDesc);
            setOperateResult(false);
        }
        return SUCCESS;
    }
    
    /**
     *
     * 更新模板元数据
     *
     * @return
     * @return String
     * @exception throws
     */
    public String updateTemplate()
    {
        Template busTemplate = null;
        try
        {
            busTemplate = (Template)templateService.findById(template.getTemplateId());
        }
        catch (Exception e1)
        {
            log.error("update template metadata occur error. get busTemplate occur error. ");
            return ERROR;
        }
        
        if (null == busTemplate)
        {
            template.setStatus(Constants.TEMPLATE_STATUS_0.getIntValue());
        }
        else
        {
            template.setStatus(Constants.TEMPLATE_STATUS_5.getIntValue());
        }
        
        try
        {
            template.setUpdater(getOperatorId());
            templateService.updateTempTemplate(template);
        }
        catch (Exception e)
        {
            log.error("update template metadata occur error. ");
            return ERROR;
        }
        
        return "templateList";
    }
    
    /**
     * 上传模板时,取上传进度数据跳转页面
     *
     * @return
     * @return String
     */
    public String processController()
    {
        uploading = getText("msg.portalMS.template.uploading");
        analysing = getText("msg.portalMS.template.analysing");
        return SUCCESS;
    }
    
    public void setTemplateService(ITemplateService templateService)
    {
        this.templateService = templateService;
    }
    
    public ITemplateService getTemplateService()
    {
        return templateService;
    }
    
    public Template getTemplate()
    {
        return template;
    }
    
    public void setTemplate(Template template)
    {
        this.template = template;
    }
    
    public Set<String> getHomePage()
    {
        return homePage;
    }
    
    public void setHomePage(Set<String> homePage)
    {
        this.homePage = homePage;
    }
    
    public Provider getProvider()
    {
        return provider;
    }
    
    public void setProvider(Provider provider)
    {
        this.provider = provider;
    }
    
    public int getOperatorType()
    {
        return operatorType;
    }
    
    public void setOperatorType(int operatorType)
    {
        this.operatorType = operatorType;
    }
    
    public int getTemplateListType()
    {
        return templateListType;
    }
    
    public void setTemplateListType(int templateListType)
    {
        this.templateListType = templateListType;
    }
    
    public int getCflag()
    {
        return Cflag;
    }
    
    public void setCflag(int cflag)
    {
        Cflag = cflag;
    }
    
    
    
    public int getFlag()
    {
        return flag;
    }

    public void setFlag(int flag)
    {
        this.flag = flag;
    }

    public void setFiletree(String filetree)
    {
        this.filetree = filetree;
    }
    
    public String getFiletree()
    {
        return filetree;
    }
    
    public void setTemplateFilePath(String templateFilePath)
    {
        this.templateFilePath = templateFilePath;
    }
    
    public String getTemplateFilePath()
    {
        return templateFilePath;
    }
    
    public TemplateResFile getTemplateResFile()
    {
        return templateResFile;
    }
    
    public void setTemplateResFile(TemplateResFile templateResFile)
    {
        this.templateResFile = templateResFile;
    }
    
    public Integer getImgWidth()
    {
        return imgWidth;
    }
    
    public void setImgWidth(Integer imgWidth)
    {
        this.imgWidth = imgWidth;
    }
    
    public Integer getImgHeight()
    {
        return imgHeight;
    }
    
    public void setImgHeight(Integer imgHeight)
    {
        this.imgHeight = imgHeight;
    }
    
    public String getUrl()
    {
        return url;
    }
    
    public void setUrl(String url)
    {
        this.url = url;
    }
    
    public int getViewType()
    {
        return viewType;
    }
    
    public void setViewType(int viewType)
    {
        this.viewType = viewType;
    }
    
    public Long getTemplateId()
    {
        return templateId;
    }
    
    public void setTemplateId(Long templateId)
    {
        this.templateId = templateId;
    }
    
    public Long[] getTemplateIds()
    {
        Long[] temp = templateIds;
        return temp;
    }
    
    public void setTemplateIds(Long[] templateIds)
    {
        this.templateIds = (Long[])templateIds.clone();
    }
    
    public String getInputPage()
    {
        return inputPage;
    }
    
    public void setInputPage(String inputPage)
    {
        this.inputPage = inputPage;
    }
    
    public TemplateSyncLog getTemplateSyncLog()
    {
        return templateSyncLog;
    }
    
    public void setTemplateSyncLog(TemplateSyncLog templateSyncLog)
    {
        this.templateSyncLog = templateSyncLog;
    }
    
    public Long[] getTemplateSyncLogId()
    {
        Long[] temp = templateSyncLogId;
        return temp;
    }
    
    public void setTemplateSyncLogId(Long[] templateSyncLogId)
    {
        this.templateSyncLogId = (Long[])templateSyncLogId.clone();
    }
    
    /**
     * @param templatePublishHis
     *            the templatePublishHis to set
     */
    public void setTemplatePublishHis(TemplatePublishHis templatePublishHis)
    {
        this.templatePublishHis = templatePublishHis;
    }
    
    /**
     * @return the templatePublishHis
     */
    public TemplatePublishHis getTemplatePublishHis()
    {
        return templatePublishHis;
    }
    
    /**
     * @param showFlag
     *            the showFlag to set
     */
    public void setShowFlag(Integer showFlag)
    {
        this.showFlag = showFlag;
    }
    
    /**
     * @return the showFlag
     */
    public Integer getShowFlag()
    {
        return showFlag;
    }
    
    public String getUploading()
    {
        return uploading;
    }
    
    public void setUploading(String uploading)
    {
        this.uploading = uploading;
    }
    
    public String getAnalysing()
    {
        return analysing;
    }
    
    public void setAnalysing(String analysing)
    {
        this.analysing = analysing;
    }
    
    public int getAllowDownload()
    {
        return allowDownload;
    }
    
    public void setAllowDownload(int allowDownload)
    {
        this.allowDownload = allowDownload;
    }
    
    public OpType[] getOpTypes()
    {
        OpType[] temp = opTypes;
        return temp;
    }
    
    public Status[] getStatusList()
    {
        Status[] temp = statusList;
        return temp;
    }
    
    public String getAjaxMsg()
    {
        return ajaxMsg;
    }
    
    public void setAjaxMsg(String ajaxMsg)
    {
        this.ajaxMsg = ajaxMsg;
    }
    
}

PublishThreadConstants.java
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * Constants.java
 * <p>Copyright: Copyright (c) 2009 <p>
 * <p>Company: Coship</p>
 *  @author    
 *  @version   1.0
 */
public class PublishThreadConstants
{
    /**发布管理的线程池常量*/
    public static final ThreadPoolExecutor sentPublishFileThreadPool = new ThreadPoolExecutor(2, 4, 3,
            TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(3), new ThreadPoolExecutor.DiscardOldestPolicy());
}

TemplateFileFTPHandle.java
/*
 * 文 件 名:  TemplateFileFTPHandle.java
 * 版    权:  Shenzhen XXXXXX Electronics Co.,Ltd. Copyright YYYY-YYYY,  All rights reserved
 * 描    述:  <描述>
 * 修 改 人:  
 * 修改时间:  2013-6-5
 * 跟踪单号:  <跟踪单号>
 * 修改单号:  <修改单号>
 * 修改内容:  <修改内容>
 */
package com.XXXXXX.dhm.portalMS.template.util;

import java.io.File;
import java.io.Serializable;

import org.apache.commons.lang.xwork.StringUtils;
import org.apache.log4j.Logger;

import com.XXXXXX.dhm.common.config.impl.XMLFactory;
import com.XXXXXX.dhm.common.uif.vo.portalMS.TemplateReqMsg;
import com.XXXXXX.dhm.portalMS.common.Constants;
import com.XXXXXX.dhm.portalMS.common.PortalMSBeanFactory;
import com.XXXXXX.dhm.portalMS.common.SerConstants;
import com.XXXXXX.dhm.portalMS.common.util.FileUtil;
import com.XXXXXX.dhm.portalMS.common.util.FtpUtil;
import com.XXXXXX.dhm.portalMS.common.util.ZIPUtil;
import com.XXXXXX.dhm.portalMS.exception.PortalMSException;
import com.XXXXXX.dhm.portalMS.sync.util.TemplateSyncHelper;
import com.XXXXXX.dhm.portalMS.template.dao.ITemplateDAO;
import com.XXXXXX.dhm.portalMS.template.entity.Template;
import com.XXXXXX.dhm.portalMS.template.entity.TemplatePublishHis;
import com.XXXXXX.dhm.portalMS.template.service.ITemplateService;
import com.XXXXXX.sdp.rights.model.domain.Admin;

/**
 * 模板文件FTP处理线程类
 * @author
 * @version
 * @since [PortalMS]
 */
public class TemplateFileFTPHandle implements Runnable, Serializable
{
    /**
     *
     */
    private static final long serialVersionUID = -3392399212027076747L;
    
    private static final Logger log = Logger.getLogger(TemplateFileFTPHandle.class);
    
    /** ftp主机 */
    public static final String ftpHostName = XMLFactory.getValueString("templateConfig.ftpconfig.ftpHostName");
    
    /** ftp端口 */
    public static final Integer ftpPort = XMLFactory.getValueInt("templateConfig.ftpconfig.ftpPort");
    
    /** ftp用户名 */
    public static final String ftpUserName = XMLFactory.getValueString("templateConfig.ftpconfig.ftpUserName");
    
    /** ftp密码 */
    public static final String ftpPasswd = XMLFactory.getValueString("templateConfig.ftpconfig.ftpPasswd");
    
    /** ftp上的地址 */
    public static final String ftpRemoteAddress = XMLFactory.getValueString("templateConfig.ftpconfig.ftpRemoteAddress");
    
    /** 重试次数 */
    public static final Integer retryNum = XMLFactory.getValueInt("templateConfig.ftpconfig.retryNum");
    
    /** 重试次数 */
    public static final String templateFileTemp = XMLFactory.getValueString("templateConfig.tempPath");
    
    /** 模板文件内容的编码 **/
    public static final String FILE_ENCODE = XMLFactory.getValueString("templateConfig.fileEncode");
    
    /** 当前归属地城市CODE **/
    public String localCity = XMLFactory.getValueString("local-city");
    
    /** 模板zip包本地存放路径 **/
    private String localZipPath;
    
    /** 模板zip包名称 **/
    private String zipName;
    
    /** 模板对象 **/
    private Template template;
    
    /** 操作类型 **/
    private String oprType;
    
    private ITemplateService templateService;
    
    private ITemplateDAO templateDAO;
    
    /** 待删除的模板 **/
    private String deleteFile;
    
    public TemplateFileFTPHandle()
    {
        super();
    }
    
    public TemplateFileFTPHandle(String deleteFile, String oprType)
    {
        super();
        this.deleteFile = deleteFile;
        this.oprType = oprType;
        initBean();
    }
    
    public TemplateFileFTPHandle(Template template, String deleteFile,
            String oprType)
    {
        super();
        this.template = template;
        this.oprType = oprType;
        this.deleteFile = deleteFile;
        initBean();
    }
    
    public TemplateFileFTPHandle(Template template, String oprType)
    {
        super();
        this.template = template;
        this.oprType = oprType;
        initBean();
    }
    
    private void initBean()
    {
        
        templateService = (ITemplateService)PortalMSBeanFactory.getInstance()
                .getBean("templateService");
        templateDAO = (ITemplateDAO)PortalMSBeanFactory.getInstance()
                .getBean("springTemplateDAO");
        
        if (null != template && null != template.getTemplatePath())
        {
            localZipPath = SerConstants.TEMPLATE_HIS + template.getCode();
            String ftp = template.getTemplatePath();
            int i = ftp.lastIndexOf(Constants.FILE_SEPARATOR.getStringValue());
            zipName = ftp.substring(i + 1);
        }
    }
    
    @Override
    public void run()
    {
        if ("delete".equals(oprType))
        {
            // 模板上传FTP
            deleteTemplateFile();
        }
        if ("upload".equals(oprType))
        {
            // 先删除旧的,再上传新的
            deleteTemplateFile();
            addUpTemplateFile();
        }
        if ("download".equals(oprType))
        {
            // 上报状态开始注入
            syncTemplateStatus(Constants.TEMPLATE_STATUS_10.getIntValue());
            
            // 设置注入状态为成功
            Integer templateStatus = Constants.TEMPLATE_STATUS_20.getIntValue();
            try
            {
                // 从FTP下载模板
                downTemplateFile();
            }
            catch (Exception e)
            {
                log.error("Download TemplateFile from ftp fail!!!");
                // 注入失败 状态置为15
                templateStatus = Constants.TEMPLATE_STATUS_15.getIntValue();
            }
            
            // 模板状态上报
            syncTemplateStatus(templateStatus);
            try
            {
                template.setStatus(templateStatus);
                templateDAO.updateTempTemplate(template);
                templateDAO.updateTemplate(template);
                
                // 同步模板文件至portal
                templateService.templateFileSyncToIepg(new Admin(), template);
            }
            catch (Exception e)
            {
                log.error("template status up to center error! [templateName = "
                        + template.getCode() + "] ");
            }
        }
    }
    
    /**
     *
     * 上传模板文件
     * @return void
     * @exception throws
     */
    private void addUpTemplateFile()
    {
        boolean handleSuccess = false;
        int i = 0;
        do
        {
            FtpUtil fu = new FtpUtil(ftpHostName, ftpPort, ftpUserName,
                    ftpPasswd);
            handleSuccess = fu.uploadFile(localZipPath,
                    ftpRemoteAddress,
                    zipName);
            i++;
        } while ((!handleSuccess) && (i < retryNum));
        TemplatePublishHis tph = new TemplatePublishHis();
        tph.setTemplateId(template.getTemplateId());
        
        if (handleSuccess)
        {
            tph.setStatus(Constants.TEMPLATE_STATUS_5.getIntValue());
        }
        else
        {
            log.error("zip file up to FTP fails! localZipPath = "
                    + localZipPath);
            log.error("zip file up to FTP fails! ftpRemoteAddress = "
                    + ftpRemoteAddress);
            log.error("zip file up to FTP fails! zipName = " + zipName);
            
            // 设置状态为上传失败
            tph.setStatus(Constants.TEMPLATE_STATUS_2.getIntValue());
        }
        tph.setUpdater(template.getUpdater().longValue());
        try
        {
            // 更新状态为上传失败
            templateDAO.updateTemplatePublishHis(tph);
        }
        catch (PortalMSException e)
        {
            log.error(e.getMessage());
        }
        //同步至portal、IAG等等
        TemplateSyncHelper.syncTemplate(template);
    }
    
    /**
     *
     * 新增下载模板文件
     * @return
     * @return String
     * @throws IEPGMException
     * @throws IEPGMException
     * @exception throws
     */
    private void downTemplateFile() throws Exception
    {
        String ftpUrl = template.getTemplatePath();
        String templateCode = template.getCode();
        
        String localPath = null;
        try
        {
            localPath = downTemplateFileFromFTP(templateCode, ftpUrl);
        }
        catch (Exception e)
        {
            log.error("down Template File error. " + e.getMessage());
            throw new Exception(e);
        }
        if (StringUtils.isEmpty(localPath))
        {
            log.error("from ftp download zip's localPath is null! ");
            throw new Exception("from ftp download zip's localPath is null!");
        }
        
        String workDest = SerConstants.TEMPLATE_WORK + template.getCode();
        try
        {
            // 解压到工作目录
            FileUtil.createDir(workDest);
            ZIPUtil.unZipSupportChinese(new File(localPath),
                    SerConstants.TEMPLATE_WORK + template.getCode());
            // 解压到发布目录
            FileUtil.createDir(SerConstants.TEMPLATE_PUB + template.getCode());
            ZIPUtil.unZipSupportChinese(new File(localPath),
                    SerConstants.TEMPLATE_PUB + template.getCode());
        }
        catch (Exception e)
        {
            log.error("zip file unzip error! template file ftp url = " + ftpUrl);
            throw new Exception(e);
        }
        
        try
        {
            TemplateUtil.reWriteIndexHtm(workDest + File.separator
                    + template.getHomePage(),
                    Constants.TEMPLATE_GLOBAL_JS.getStringValue(),
                    Constants.TEMPLATE_GLOBAL_VIEW_JS.getStringValue());
        }
        catch (Exception e)
        {
            log.error("index.htm's js path modify error.(global.js->global_view.js) [templateCode = "
                    + template.getCode() + "] " + e.getMessage());
        }
    }
    
    /**
     * 从FTP上删除模板文件
     */
    private void deleteTemplateFile()
    {
        log.info("deleteTemplateFile params: [ ftpUrl = " + deleteFile + "] ");
        String hostName = "";
        String port = "21";
        String ftpUserName = null;
        String ftpPasswd = null;
        String remotePath = null;
        String fileName = null;
        
        try
        {
            int index = deleteFile.lastIndexOf(File.separator);
            if (-1 == index)
            {
                index = deleteFile.lastIndexOf("/");
            }
            
            int ftpProfix = deleteFile.indexOf(Constants.FTP_PATH_PREFIX.getStringValue());
            
            if (0 == ftpProfix)
            {
                String temp = deleteFile.substring(Constants.FTP_PATH_PREFIX.getStringValue()
                        .length());
                int flag = temp.indexOf(":");
                
                ftpUserName = temp.substring(0, flag);
                String lastStr = temp.substring(flag + 1);
                
                int flag2 = lastStr.indexOf("@");
                ftpPasswd = lastStr.substring(0, flag2);
                String lastStr2 = lastStr.substring(flag2 + 1);
                
                int flag3 = lastStr2.indexOf(":");
                hostName = lastStr2.substring(0, flag3);
                String lastStr3 = lastStr2.substring(flag3 + 1);
                
                int flag4 = lastStr3.indexOf("/");
                port = lastStr3.substring(0, flag4);
                String lastStr4 = lastStr3.substring(flag4);
                
                int flag5 = lastStr4.lastIndexOf("/");
                remotePath = lastStr4.substring(1, flag5);
                fileName = lastStr4.substring(flag5 + 1);
                
                int portInt = Integer.parseInt(port);
                int i = 0;
                boolean handleSuccess = false;
                do
                {
                    // 从FTP上删除模板文件
                    FtpUtil fu = new FtpUtil(hostName, portInt, ftpUserName,
                            ftpPasswd);
                    handleSuccess = fu.deleteFile(remotePath, fileName);
                    i++;
                } while ((false == handleSuccess) && (i < retryNum));
            }
        }
        catch (Exception e)
        {
            log.error("download ftp error! retryNum = " + retryNum);
        }
    }
    
    /**
     *
     * 下载模板文件
     * @param templateCode
     * @param ftpUrl
     * @return
     * @throws Exception
     * @return String
     * @exception throws
     */
    private String downTemplateFileFromFTP(String templateCode, String ftpUrl)
            throws Exception
    {
        log.info("downTemplateFile params: [templateCode = " + templateCode
                + ", ftpUrl = " + ftpUrl + "] ");
        
        String hostName = "";
        String port = "21";
        String ftpUserName = null;
        String ftpPasswd = null;
        String remotePath = null;
        String fileName = null;
        
        try
        {
            int index = ftpUrl.lastIndexOf(File.separator);
            if (-1 == index)
            {
                index = ftpUrl.lastIndexOf("/");
            }
            
            createDirAndGetPath(SerConstants.TEMPLATE_HIS + File.separator
                    + templateCode);
            
            int ftpProfix = ftpUrl.indexOf(Constants.FTP_PATH_PREFIX.getStringValue());
            
            if (0 == ftpProfix)
            {
                String temp = ftpUrl.substring(Constants.FTP_PATH_PREFIX.getStringValue()
                        .length());
                int flag = temp.indexOf(":");
                
                ftpUserName = temp.substring(0, flag);
                String lastStr = temp.substring(flag + 1);
                
                int flag2 = lastStr.indexOf("@");
                ftpPasswd = lastStr.substring(0, flag2);
                String lastStr2 = lastStr.substring(flag2 + 1);
                
                int flag3 = lastStr2.indexOf(":");
                hostName = lastStr2.substring(0, flag3);
                String lastStr3 = lastStr2.substring(flag3 + 1);
                
                int flag4 = lastStr3.indexOf("/");
                port = lastStr3.substring(0, flag4);
                String lastStr4 = lastStr3.substring(flag4);
                
                int flag5 = lastStr4.lastIndexOf("/");
                remotePath = lastStr4.substring(1, flag5);
                fileName = lastStr4.substring(flag5 + 1);
            }
            
        }
        catch (Exception e)
        {
            log.error("explain ftp path error!");
            throw new Exception(e);
        }
        
        int portInt = Integer.parseInt(port);
        
        boolean handleSuccess = false;
        int i = 0;
        remotePath = "/" + remotePath + "/";
        
        try
        {
            do
            {
                // 从FTP上下载模板文件
                FtpUtil fu = new FtpUtil(hostName, portInt, ftpUserName,
                        ftpPasswd);
                handleSuccess = fu.downFile(SerConstants.TEMPLATE_HIS
                        + File.separator + templateCode, remotePath, fileName);
                i++;
            } while ((false == handleSuccess) && (i < retryNum));
        }
        catch (Exception e)
        {
            log.error("download ftp error! retryNum = " + retryNum);
        }
        
        if (handleSuccess)
        {
            templateService.delLoseTemplateHisFile(new File(
                    SerConstants.TEMPLATE_HIS + File.separator + templateCode));
            return SerConstants.TEMPLATE_HIS + File.separator + templateCode
                    + File.separator + fileName;
        }
        else
        {
            return "";
        }
    }
    
    /***
     * 上报模板注入状态至中心
     * @param status
     */
    private void syncTemplateStatus(Integer status)
    {
        TemplateReqMsg templateReqMsg = new TemplateReqMsg();
        templateReqMsg.setTemplateID(String.valueOf(template.getTemplateId()));
        templateReqMsg.setCityCode(localCity);
        templateReqMsg.setTemplateStatus(String.valueOf(status));
        TemplateSyncHelper.syncTemplateStatus(templateReqMsg);
    }
    
    /**
     * 创建目录
     *
     * @param path 目录
     * @author
     * @throws
     * @return String
     */
    private String createDirAndGetPath(String path)
    {
        File file = new File(path);
        if (!file.isDirectory())
        {
            boolean flag = file.mkdirs();
            if (!flag)
            {
                log.error("mkdirs failed");
            }
        }
        
        return file.getAbsolutePath();
    }
    
    public void setOprType(String oprType)
    {
        this.oprType = oprType;
    }
    
    public String getOprType()
    {
        return oprType;
    }
    
    public ITemplateDAO getTemplateDAO()
    {
        return templateDAO;
    }
    
    public void setTemplateDAO(ITemplateDAO templateDAO)
    {
        this.templateDAO = templateDAO;
    }
    
    /**
     * @param deleteFile the deleteFile to set
     */
    public void setDeleteFile(String deleteFile)
    {
        this.deleteFile = deleteFile;
    }
    
    /**
     * @return the deleteFile
     */
    public String getDeleteFile()
    {
        return deleteFile;
    }
}



TemplateSyncThread.java

/**
 *
 */
package com.xxxxx.dhm.portalMS.template.util;

import java.io.File;
import java.io.Serializable;
import java.net.InetAddress;
import java.util.List;

import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Zip;
import org.apache.tools.ant.types.FileSet;
import org.springframework.util.CollectionUtils;

import ch.ethz.ssh2.Connection;
import ch.ethz.ssh2.SCPClient;
import ch.ethz.ssh2.SFTPv3Client;

import com.xxxxx.ChineseCharacter;
import com.xxxxx.dhm.common.config.impl.PropertiesFactory;
import com.xxxxx.dhm.portalMS.common.Constants;
import com.xxxxx.dhm.portalMS.common.DebugLogHelper;
import com.xxxxx.dhm.portalMS.common.PortalMSBeanFactory;
import com.xxxxx.dhm.portalMS.common.SerConstants;
import com.xxxxx.dhm.portalMS.common.util.Base64Util;
import com.xxxxx.dhm.portalMS.common.util.Shell;
import com.xxxxx.dhm.portalMS.exception.PortalMSException;
import com.xxxxx.dhm.portalMS.system.entity.PublishDomain;
import com.xxxxx.dhm.portalMS.template.dao.ITemplateDAO;
import com.xxxxx.dhm.portalMS.template.entity.Template;
import com.xxxxx.dhm.portalMS.template.entity.TemplateSyncLog;

/**
 * SentPortalPublish.java
 * <p>
 * Copyright: Copyright (c) 2009
 * <p>
 * <p>
 * Company: xxxxx
 * </p>
 * @author 906180
 * @version 1.0
 */
public class TemplateSyncThread implements Runnable, Serializable
{

    /**
     *
     */
    private static final long serialVersionUID = 8057827433644062871L;

    private static final DebugLogHelper logger = new DebugLogHelper(TemplateSyncThread.class);

    private static final ITemplateDAO templateDAO = (ITemplateDAO) PortalMSBeanFactory.getInstance().getBean(
            "springTemplateDAO");

    private List<TemplateSyncLog> tpLogList;

    private int syncFlag = 0;

    private static int SYNC_SUCC = 1;

    private static int SYNC_FAIL = 0;

    private List<Template> delTemplateList;

    private List<PublishDomain> publishDomainList;

    private String optType = null;

    public TemplateSyncThread(List<TemplateSyncLog> tpLogList)
    {
        this.tpLogList = tpLogList;
    }

    public TemplateSyncThread(List<Template> delTemplateList, List<PublishDomain> publishDomainList)
    {
        this.delTemplateList = delTemplateList;
        this.publishDomainList = publishDomainList;
        this.optType = "delete";
    }

    /*
     * (non-Javadoc)
     *
     * @see java.lang.Runnable#run()
     */
    @Override
    public void run()
    {
        logger.enterFuncDebugLog();
        if ("delete".equals(optType))
        {
            logger.atFuncDebugLog();
            if (!CollectionUtils.isEmpty(delTemplateList) && !CollectionUtils.isEmpty(publishDomainList))
            {
                for (PublishDomain pd : publishDomainList)
                {
                    deleteTemplateFile(pd);
                }
            }
        }
        else if (null != tpLogList && tpLogList.size() > 0)
        {
            logger.atFuncDebugLog();
            for (TemplateSyncLog tpLog : tpLogList)
            {
                TemplateSyncLog tSyncLog = null;
                try
                {
                    tSyncLog = templateDAO.findTemplateSyncLogByParam(tpLog);
                    tSyncLog.setRemark(dealWithScpFile(tSyncLog).toString());
                    tSyncLog.setStatus(syncFlag);
                    templateDAO.updateTemplateSyncLog(tSyncLog);
                }
                catch (Exception e)
                {
                    // 记录发布记录
                    logger.excepFuncDebugLog("Update TemplateSyncLog fail!");
                    logger.excepFuncDebugLog("Update TemplateSyncLog fail!", e);
                    e.printStackTrace();
                }
                finally
                {
                    if (null != tSyncLog && null != tSyncLog.getTemplateCode())
                    {
                        File file = new File(SerConstants.TEMPLATE_PUB + tSyncLog.getTemplateCode() + ".zip");
                        if (file.exists())
                        {
                            boolean flag = file.delete();
                            if (!flag)
                            {
                                logger.excepFuncDebugLog("delete file failed");
                            }
                        }
                    }
                }
            }
        }
        logger.exitFuncDebugLog();
    }

    private void deleteTemplateFile(PublishDomain pd)
    {
        logger.enterFuncDebugLog();
        String host = pd.getIp();
        if (null == host)
        {
            logger.exitFuncDebugLog("The serverIp is null!");
            return;
        }

        int timeOut = 3000;
        boolean status = false;
        try
        {
            status = InetAddress.getByName(host).isReachable(timeOut);
            // 如果3秒没有ping通直接返回失败
        }
        catch (Exception e2)
        {
            logger.excepFuncDebugLog(e2.getMessage());
            e2.printStackTrace();
            logger.exitFuncDebugLog("Synchronous portal unreachable ,sync failure!");
            return;
        }
        if (!status)
        {
            logger.exitFuncDebugLog("Server[" + host + "]:The server is unreachable!");
            return;
        }
        try
        {
            Connection conn = new Connection(host);
            boolean isAuthenticated = false;
            SFTPv3Client sftpClient;
            conn.connect();
            isAuthenticated = conn.authenticateWithPassword(pd.getUserName(), Base64Util
                    .decryptBASE64(pd.getPassWord()));
            if (isAuthenticated)
            {
                sftpClient = new SFTPv3Client(conn);
                String syncPath = null;
                for (Template t : delTemplateList)
                {
                    syncPath = pd.getPublishPath();
                    if (!syncPath.endsWith(Constants.FILE_SEPARATOR.getStringValue()))
                    {
                        syncPath = syncPath + Constants.FILE_SEPARATOR.getStringValue();
                    }
                    sftpClient.rmdir(syncPath + t.getCode());
                }
            }
        }
        catch (Exception e)
        {
        }
        logger.exitFuncDebugLog();
    }

    /**
     *
     * 同步模板文件至Portal
     * @param ts 模板同步信息
     * @return errorMessage
     * @throws PortalMSException
     * @throws Exception
     */
    private StringBuffer dealWithScpFile(TemplateSyncLog tSyncLog)
    {
        logger.enterFuncDebugLog();
        StringBuffer errorMessage = new StringBuffer();

        // 模板源文件路径
        String sourcePath = SerConstants.TEMPLATE_PUB + tSyncLog.getTemplateCode();
        SCPClient client = null;
        Connection conn = null;
        String host = tSyncLog.getServerIp();

        if (null == host)
        {
            logger.excepFuncDebugLog("The serverIp is null!");
            errorMessage
                    .append(PropertiesFactory.getValueString(ChineseCharacter.TEMPLATESYNCTHREAD_PORTAL_IP_IS_NULL));
            syncFlag = SYNC_FAIL;
            logger.exitFuncDebugLog();
            return errorMessage;
        }

        // 设置ping的超时时间3秒
        int timeOut = 3000;
        boolean status = false;
        try
        {
            status = InetAddress.getByName(host).isReachable(timeOut);
            // 如果3秒没有ping通直接返回失败
        }
        catch (Exception e2)
        {
            logger.excepFuncDebugLog(e2.getMessage());
            e2.printStackTrace();
            errorMessage.append(PropertiesFactory.getValueString(ChineseCharacter.TEMPLATESYNCTHREAD_UNREACHABLE));
            syncFlag = SYNC_FAIL;
            logger.exitFuncDebugLog();
            return errorMessage;
        }
        if (!status)
        {
            logger.excepFuncDebugLog("Server[" + host + "]:The server is unreachable!");
            errorMessage.append(PropertiesFactory.getValueString(ChineseCharacter.SENTPORTALPUBLISH_SERVER) + "【")
                    .append(host).append(
                            "】" + PropertiesFactory.getValueString(ChineseCharacter.TEMPLATESYNCTHREAD_NOT_CONNECT));
            syncFlag = SYNC_FAIL;
            logger.exitFuncDebugLog();
            return errorMessage;
        }

        conn = new Connection(host);
        boolean isAuthenticated = false;
        try
        {
            conn.connect();
            isAuthenticated = conn.authenticateWithPassword(tSyncLog.getServerUserName(), Base64Util
                    .decryptBASE64(tSyncLog.getServerPassword()));
        }
        catch (Exception e2)
        {
            logger.excepFuncDebugLog("Server[" + host + "]: Connect failed! The userName or passWord is error");
            errorMessage.append(PropertiesFactory.getValueString(ChineseCharacter.SENTPORTALPUBLISH_SERVER) + "【")
                    .append(host).append(
                            "】" + PropertiesFactory.getValueString(ChineseCharacter.TEMPLATESYNCTHREAD_USER_PWD_ERROR));
            syncFlag = SYNC_FAIL;
            logger.exitFuncDebugLog();
            return errorMessage;
        }
        if (!isAuthenticated)
        {
            // 如果这个IP段了失败了,记录失败日志
            logger.excepFuncDebugLog("Server[" + host + "]: Connect failed! The userName or passWord is error");
            errorMessage.append(PropertiesFactory.getValueString(ChineseCharacter.SENTPORTALPUBLISH_SERVER) + "【")
                    .append(host).append(
                            "】" + PropertiesFactory.getValueString(ChineseCharacter.TEMPLATESYNCTHREAD_USER_PWD_ERROR));
            syncFlag = SYNC_FAIL;
            logger.exitFuncDebugLog();
            return errorMessage;
        }

        client = new SCPClient(conn);

        // 获取远程同步路径
        String syncPath = tSyncLog.getPublishPath();

        if (null == syncPath)
        {
            logger.excepFuncDebugLog("Server[" + host + "]: The publish_path is null");
            errorMessage.append(
                    PropertiesFactory.getValueString(ChineseCharacter.TEMPLATESYNCTHREAD_PUBLISH_AREA) + "【").append(
                    host).append(
                    "】" + PropertiesFactory.getValueString(ChineseCharacter.TEMPLATESYNCTHREAD_PUBLISH_PATH_NULL));
            syncFlag = SYNC_FAIL;
            logger.exitFuncDebugLog();
            return errorMessage;
        }
        else if (!syncPath.endsWith(Constants.FILE_SEPARATOR.getStringValue()))
        {
            syncPath = syncPath + Constants.FILE_SEPARATOR.getStringValue();
        }

        // 源文件夹
        File scpFile = new File(sourcePath);

        if (!scpFile.exists())
        {
            logger.excepFuncDebugLog("Template [" + tSyncLog.getTemplateCode() + "]: The template is not exist!!");
            errorMessage.append(
                    PropertiesFactory.getValueString(ChineseCharacter.TEMPLATESYNCTHREAD_PUBLISH_AREA) + "【").append(
                    host).append(
                    "】" + PropertiesFactory.getValueString(ChineseCharacter.TEMPLATESYNCTHREAD_PUBLISH_PATH_NULL));
            syncFlag = SYNC_FAIL;
            logger.exitFuncDebugLog();
            return errorMessage;
        }
        // 目标zip文件
        File zipFile = new File(sourcePath + ".zip");

        // 压缩文件夹为zip文件
        Project prj = new Project();
        Zip zip = new Zip();
        zip.setProject(prj);
        zip.setDestFile(zipFile);
        FileSet fileSet = new FileSet();
        fileSet.setProject(prj);
        fileSet.setDir(scpFile);
        zip.addFileset(fileSet);
        zip.execute();

        String targetFilename = syncPath + tSyncLog.getTemplateCode();
        try
        {
            client.put(sourcePath + ".zip", syncPath);
        }
        catch (Exception e)
        {
            logger.excepFuncDebugLog(e.getMessage());
            logger.excepFuncDebugLog("Synchronous templates file failed, please check the release path is correct! ");
            e.printStackTrace();
            errorMessage.append(
                    PropertiesFactory.getValueString(ChineseCharacter.TEMPLATESYNCTHREAD_SYNC_TEMPLATE_TO) + "【")
                    .append(host).append(
                            "】" + PropertiesFactory.getValueString(ChineseCharacter.TEMPLATESYNCTHREAD_SYNC_FAIL));
            syncFlag = SYNC_FAIL;
            logger.exitFuncDebugLog();
            return errorMessage;
        }

        // 保存原来的东西_bak.
        String command0 = " mv " + targetFilename + " " + targetFilename + "_bak";

        // 解压新的版本到模板文件夹
        String command1 = "unzip " + targetFilename + ".zip -d " + targetFilename;

        // 移除zip文件
        String command2 = "rm -rf " + targetFilename + ".zip";
        // 移除_bak文件
        String command3 = "rm -rf " + targetFilename + "_bak/";
        // 拷贝模板文件到预览目录
        String command4 = null;
        String command5 = null;
        String command6 = null;
        if (1 == tSyncLog.getIsViewServer())
        {
            command4 = "mkdir " + syncPath;
            command5 = "rm -rf " + targetFilename.replace("template", "tempview");
            command6 = "cp -r " + targetFilename + " " + targetFilename.replace("template", "tempview");
        }
        Shell s;
        try
        {
            s = new Shell(host, 22, tSyncLog.getServerUserName(), Base64Util
                    .decryptBASE64(tSyncLog.getServerPassword()));
            String commands[] = new String[] { command0, command1, command2, command3, command4, command5, command6 };

            System.out.println(s.executeCommands(commands));
            s.disconnect();
        }
        catch (Exception e1)
        {
            e1.printStackTrace();
            logger.excepFuncDebugLog("at[" + host + "]Execute the shell command failed!");
            logger.excepFuncDebugLog("File failed released to the corresponding server ", e1);

            // 如果这个IP段了失败了,记录失败日志
            errorMessage
                    .append(PropertiesFactory.getValueString(ChineseCharacter.SENTPORTALPUBLISH_PUBLISH_FILE) + "【")
                    .append(host).append(
                            "】"
                                    + PropertiesFactory
                                            .getValueString(ChineseCharacter.SENTPORTALPUBLISH_PUBLISH_ERROR_LOOK_LOG));

            syncFlag = SYNC_FAIL;
            logger.exitFuncDebugLog();
            return errorMessage;
        }
        finally
        {
            if (conn != null)
            {
                conn.close();
            }
        }

        syncFlag = SYNC_SUCC;
        errorMessage.append(PropertiesFactory.getValueString(ChineseCharacter.TEMPLATESYNCTHREAD_SYNC_TEMPLATE_TO)
                + "[" + host + "]" + PropertiesFactory.getValueString(ChineseCharacter.TEMPLATESYNCTHREAD_SYNC_SUCESS));
        logger.exitFuncDebugLog();
        return errorMessage;
    }

}


TemplateUtil.java
/*
 * 文 件 名:  TemplateUtil.java
 * 版    权:  Shenzhen xxxxxx Electronics Co.,Ltd. Copyright YYYY-YYYY,  All rights reserved
 * 描    述:  <描述>
 * 修 改 人:  
 * 修改时间:  2012-11-7
 * 跟踪单号:  <跟踪单号>
 * 修改单号:  <修改单号>
 * 修改内容:  <修改内容>
 */
package com.xxxxxx.dhm.portalMS.template.util;

import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.xwork.StringUtils;

import com.xxxxxx.dhm.common.config.impl.XMLFactory;
import com.xxxxxx.dhm.portalMS.common.SerConstants;
import com.xxxxxx.dhm.portalMS.common.util.FileUtil;

/**
 * 模板操作工具类
 *
 * @author
 * @version
 * @since
 */
public class TemplateUtil {
    private static final String TEMPLATE_MAIN_SUFFIX_HTM = "htm";

    private static final String TEMPLATE_MAIN_SUFFIX_HTML = "html";

    /** 模板文件历史记录最多保存数量 */
    private static Integer maxHisNum = XMLFactory
            .getValueInt("templateConfig.maxHisNum");

    /**
     *
     * 重写index.htm文件
     *
     * @param templateMainPage
     *            模板入口页路径
     * @param oldStr
     *            旧字符串
     * @param newStr
     *            新字符串
     * @throws IEPGMException
     * @throws Exception
     * @return void
     * @exception throws
     */
    public static void reWriteIndexHtm(String templateMainPage, String oldStr,
            String newStr) throws Exception {
        String indexContent = FileUtil.readFileContent(templateMainPage,
                TemplateFileFTPHandle.FILE_ENCODE);
        if (StringUtils.isNotEmpty(indexContent)) {
            String indexViewContent = indexContent.replace(oldStr, newStr);
            FileUtil.stringWriteToFile(indexViewContent, templateMainPage,
                    TemplateFileFTPHandle.FILE_ENCODE);
        }
    }

    /**
     *
     * 得到模板文件根目录下的所有网页文件
     *
     * @param parentDir
     * @return
     * @return Set<String>
     * @exception throws
     */
    public static Set<String> readTemplateMainPages(String parentDir) {
        Set<String> respSet = new HashSet<String>();
        File file = new File(parentDir);
        // TODO wqb进行更改,递归进行查找所有文件夹
        if (file.exists() && file.isDirectory()) {
            File[] subFiles = file.listFiles();
            if (null != subFiles && subFiles.length > 0) {
                for (File subFile : subFiles) {
                    if (subFile.isDirectory()) {
                        String parentPath =subFile.getName()+SerConstants.FILE_SEPARATOR;
                        addDirectoryNameToSet(parentPath,subFile, respSet);
                    }
                    if (subFile.isFile()
                            && (subFile.getName().endsWith(
                                    TEMPLATE_MAIN_SUFFIX_HTM) || subFile
                                    .getName().endsWith(
                                            TEMPLATE_MAIN_SUFFIX_HTML))) {
                        respSet.add(subFile.getName());
                    }

                }
            }
        }
        return respSet;
    }

    public static void addDirectoryNameToSet(String parentPath,File directory, Set respSet) {
        try {
            if (directory == null || respSet == null)
                return;
            File[] subFiles = directory.listFiles();
            if (subFiles == null)
                return;
            for (File file : subFiles) {
                if (file.isFile()) {
                    if (file.getName().endsWith(TEMPLATE_MAIN_SUFFIX_HTM)
                            || file.getName().endsWith(
                                    TEMPLATE_MAIN_SUFFIX_HTML)) {
                        respSet.add(parentPath + file.getName());
                    }
                }
                if (file.isDirectory()) {
                    String currentPath =parentPath+file.getName()+SerConstants.FILE_SEPARATOR;
                    addDirectoryNameToSet(currentPath,file,respSet);
                }

            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public static void delLoseDateTemplateFiles(File appZipParentDir)
            throws IOException {
        File[] subFiles = appZipParentDir.listFiles();
        if ((null != subFiles) && (subFiles.length > (maxHisNum - 1))) {
            File needDelFile = subFiles[0];
            Date needDelDate = new Date(needDelFile.lastModified());
            for (int i = 1; i < subFiles.length; i++) {
                Date fileLastModifyDate = new Date(subFiles[i].lastModified());
                if (fileLastModifyDate.before(needDelDate)) {
                    needDelFile = subFiles[i];
                    needDelDate = fileLastModifyDate;
                }
            }
            FileUtils.forceDelete(needDelFile);
        }
    }
}


    
var data={};
data['0_1']= 'text:2;url:showTemplateResourceDetail.action?templateListType=0&template.templateId=59006&templateResFile.fileType=1
&templateResFile.fileName=2
&templateResFile.filePath="/D:/tomcat_portal/webapps/portalMS/uploads/work/";
leaf:false;';
data['1_1100']= 'text:index_list.htm;url:showTemplateResourceDetail.action?templateListType=0&template.templateId=59006
&templateResFile.fileType=0&templateResFile.fileName=index_list.htm
&templateResFile.filePath="D:!tomcat_portal!webapps!portalMS!uploads!work!2";';
data['1_1101']= 'text:js;url:showTemplateResourceDetail.action?templateListType=0&template.templateId=59006
&templateResFile.fileType=1&templateResFile.fileName=js
&templateResFile.filePath="D:!tomcat_portal!webapps!portalMS!uploads!work!2";';
data['1101_112100']= 'text:index_list.js;url:showTemplateResourceDetail.action?templateListType=0&template.templateId=59006
&templateResFile.fileType=0&templateResFile.fileName=index_list.js

&templateResFile.filePath="D:!tomcat_portal!webapps!portalMS!uploads!work!2!js";';




   



0 0
原创粉丝点击